[PATCH] Wayland: Resize windows with 0x0 requested size to screen size

Hi,

With the Wayland video driver, requesting a 0x0 window with SDL_WINDOW_FULLSCREEN will make the window fullscreen, but the EGL surface that?s being created has a size of 1x1. This patch fixes this by making the EGL surface the size of the screen if one or both of the sides are 1 (or 0; 0 gets turned into 1 by SDL_CreateWindow()).

It doesn?t check the flags, because for some reason, SDL_WINDOW_FULLSCREEN isn?t in the flags of the window in the Wayland create window function, even when it is passed to SDL_CreateWindow(). This means that the width/height will also be changed for a SDL_CreateWindow() call /without/ SDL_WINDOW_FULLSCREEN set, but that?s usually okay, because if you create a window of a certain size, you don?t pass in 0x0 as its size.

Patch against yesterday?s Hg default branch attached, successfully tested under QtWayland on Sailfish OS.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdl2_wayland-fullscreen-size.patch
Type: application/octet-stream
Size: 1264 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140406/998c03ab/attachment.obj
-------------- next part --------------

To test, simply build SDL2 with the patch applied, then create a window like this:

SDL_CreateWindow(??, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 0, 0,
SDL_WINDOW_FULLSCREEN);

Without the patch, the EGL surface will have a size of 1x1, with the patch, the EGL surface will have the size of the screen, which is what also happens with most (all?) other platforms.

Thanks,
Thomas

PS: Bugzilla registration seems to be broken, I didn?t get a confirmation e-mail; otherwise I?d have posted this patch directly in Bugzilla.

This seems like an odd behavior. A 0 input should not be silently
updated to 1 but an error should be generated and SDL_CreateWindow
should fail.

–AndreasOn 4/6/2014 5:34 AM, Thomas Perl wrote:

0 gets turned into 1 by SDL_CreateWindow()).

The comment there just says “Some platforms can’t create zero-sized
windows” [1], I didn’t look more into that. I would be okay with
removing that and just checking for == 0 in the patch, but I don’t know
about all the different platforms where this might be needed.

The change where this was added is here; maybe Sam knows what “some
platforms” are in that case:

http://lists.libsdl.org/pipermail/commits-libsdl.org/2012-January/005353.html

Btw, in the meantime I’ve got a Bugzilla account, so I also pushed the
patch here:

 https://bugzilla.libsdl.org/show_bug.cgi?id=2481

Thanks,
Thomas

[1] https://hg.libsdl.org/SDL/file/0eed6a72e3c1/src/video/SDL_video.c#l1226On 2014-04-06 21:29, Andreas Schiffler wrote:

On 4/6/2014 5:34 AM, Thomas Perl wrote:

0 gets turned into 1 by SDL_CreateWindow()).

This seems like an odd behavior. A 0 input should not be silently
updated to 1 but an error should be generated and SDL_CreateWindow
should fail.