We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1859 - No SDL_VIDEORESIZE event generated when the window manager sets the window size.
Summary: No SDL_VIDEORESIZE event generated when the window manager sets the window size.
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-21 08:35 UTC by Niriel
Modified: 2017-04-03 20:34 UTC (History)
5 users (show)

See Also:


Attachments
[sdl-2.0] Do not drop events queue (639 bytes, patch)
2013-06-13 05:54 UTC, Peter Wu
Details | Diff
[sdl-1.2.15] Do not drop events queue (439 bytes, patch)
2013-06-13 05:55 UTC, Peter Wu
Details | Diff
[sdl-2.0.3] Do not drop events queue (546 bytes, patch)
2014-06-27 15:51 UTC, Andreas Eriksson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Niriel 2013-05-21 08:35:05 UTC
xmonad is a window manager that tiles the resizable windows to avoid overlap.

Shortly after SetVideoMode, xmonad resizes the window.  SDL does not notice it and no RESIZE_EVENT is generated.  GetVideoInfo and GetVideoSurface().w/h still think that my window is the way I created it, even after xmonad resized it.

As a result, I do not (cannot?) know the size of my window.

A user on StackOverflow found a workaround
http://stackoverflow.com/questions/16442573/check-for-window-dimensions-in-pygame-sdl
but it is far from ideal.
Comment 1 Peter Wu 2013-06-13 04:54:05 UTC
Confirmed with two other WMs:

- Openbox: set <maximized>True</maximized> in rc.xml to make a QEMU window full-screen.
- KWin: set a window rule to maximize the window by default.

Sometimes, the SDL_VIDEORESIZE event is generated and the window contents gets scaled correctly. At other times, there is no SDL_VIDEORESIZE event.

I identified that the X ConfigureNotify event is somehow dropped as can seen in log14 [1]. (for comparison, log13 is correct). After some debugging, I can finally conclude that this issue happens because of the use of XSync(SDL_Display, True) in src/video/x11/SDL_x11modes.c (src/video/x11/SDL_x11framebuffer.c in tip).

Changing that True to False causes a lot more events to be initially launched, but at least events are not dropped which result in more predictable behavior. Could this code be copied from x11vnc[2]?

 [1]: http://lekensteyn.nl/files/qemu-sdl-debug/
 [2]: http://cgit.freedesktop.org/xorg/app/x11perf/tree/do_blt.c#n421
Comment 2 Peter Wu 2013-06-13 05:54:07 UTC
Created attachment 1188 [details]
[sdl-2.0] Do not drop events queue

It seems very likely that this SDL code is based on x11perf's code. After some talk on #xorg-devel and reading about the MIT-SHM extension[1], it becomes apparent that the "True" parameter to XSync is not justified.

- The XSync manual page warns against it use.
- x11perf does not care about events, but SDL does. Events should not be dropped, it causes bugs like this one. Furthermore, the dropped events are non-deterministic.
- A possible event from MIT-SHM is Completion, but that is only sent when a certain parameter to XShmPutImage is True which is not the case.

After this patch, events are not dropped anymore. Programs behave more predictable.

 [1]: http://www.x.org/releases/current/doc/xextproto/shm.html
Comment 3 Peter Wu 2013-06-13 05:55:21 UTC
Created attachment 1189 [details]
[sdl-1.2.15] Do not drop events queue
Comment 4 Andreas Eriksson 2014-06-27 15:51:59 UTC
Created attachment 1715 [details]
[sdl-2.0.3] Do not drop events queue

This bug still exists in 2.0.3. I tried the above patch and it fixed the problem for me. It didn't apply cleanly anymore so I'm attaching a modified version that does.
Comment 5 Ryan C. Gordon 2015-08-25 09:38:21 UTC
Hello, and sorry if you're getting several copies of this message by email, since we are closing many bugs at once here.

We have decided to mark all SDL 1.2-related bugs as RESOLVED ENDOFLIFE, as we don't intend to work on SDL 1.2 any further, but didn't want to mark a large quantity of bugs as RESOLVED WONTFIX, to clearly show what was left unattended to and make it easily searchable.

Our current focus is on SDL 2.0.

If you are still having problems with an ENDOFLIFE bug, your absolute best option is to move your program to SDL2, as it will likely fix the problem by default, and give you access to modern platforms and tons of super-cool new features.

Failing that, we _will_ accept small patches to fix these issues, and put them in revision control, although we do not intend to do any further official 1.2 releases.

Failing that, please feel free to contact me directly by email (icculus@icculus.org) and we'll try to find some way to help you out of your situation.

Thank you,
--ryan.
Comment 6 Ryan C. Gordon 2015-08-25 18:12:15 UTC
I haven't looked at this yet, but apparently this still affects SDL2, so I've reopened the bug.

--ryan.
Comment 7 Samuel Hopkins 2015-09-11 09:05:02 UTC
(In reply to Ryan C. Gordon from comment #6)
> I haven't looked at this yet, but apparently this still affects SDL2, so
> I've reopened the bug.
> 
> --ryan.

Just confirming that the patch from Andreas (attachment 1715 [details]) works for me under SDL 2.0.3 with xmonad.
Comment 8 Stas Sergeev 2017-04-03 12:58:48 UTC
/me too

Confirming that the patch in this ticket
fixes the full-screen switching for dosemu2
on ubuntu-16.04. Note that I am not using
xmonad, so this bug appears to be generic.

I wish someone to take care of that patch,
as it is already 3 years old and it seems
vital for full-screen to work reliably.
Comment 9 Sam Lantinga 2017-04-03 20:34:36 UTC
Patched applied, thanks!
https://hg.libsdl.org/SDL/rev/f931db466859
https://hg.libsdl.org/SDL/rev/f318f6a4882f