Repository navigation
Commit f16d229
committed
Restructure pysdl2 example and fix resize, dropdown and input bugs
Make the example easier to read: main() only does setup, the event
loop is in run_event_loop() and handle_event(), and there are no
nested functions. A single RenderHandler replaces MetaRenderHandler,
since popup browsers inherit the handlers of their opener.
BrowserWindow holds an SDL window and its textures, and
WindowManager tracks the main and popup windows. Paint buffers are
copied with SDL_UpdateTexture(), so Pillow is no longer needed.
Fixes:
- Opening a <select> dropdown crashed (OnPopupSize gets "rect_out").
- Typing non-ASCII text crashed in ord(), now sent as UTF-16.
- Resizing complex pages was slow, because the scale factor and the
screen rect changed on every resize. Round the scale factor to a
multiple of 1/120 and report the display size as the screen rect.
- The mouse wheel scrolled twice as fast on HiDPI displays. Scroll
100 pixels per step, like Chrome on Windows.
- Check for SDL_Init() and window/renderer creation errors.
- Shutdown CEF before SDL2. Remove code and comments that were not
needed or incorrect.1 parent 4840b35 commit f16d229
1 file changed
Lines changed: 499 additions & 715 deletions
0 commit comments