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 2793

Summary: No SDL_WINDOWEVENT_MAXIMIZED events under Linux/LXDE
Product: SDL Reporter: Rainer Deyke <rainerd>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED DUPLICATE QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: icculus
Version: HG 2.0   
Hardware: x86_64   
OS: Linux   
Attachments: patch to testwm2.c to illustrate the problem
Patch to fix the bug.
Latest patch that supersedes both previous patches.

Description Rainer Deyke 2014-11-28 09:14:14 UTC
Created attachment 1943 [details]
patch to testwm2.c to illustrate the problem

I'm running Linux Mint 17, using the LXDE desktop environment.  I've noticed that I'm not receiving the SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_MINIMIZED, and SDL_WINDOWEVENT_RESTORED events at all.  Also, SDL_GetWindowFlags does not reflect the maximized/minimized state of the window if this was changed through the window manager (e.g. by clicking the maximize or minimize button on the title bar).  The attached patch to testwm2.c illustrates the problem, but does not attempt to diagnose or fix it.  I propose that the patch be incorporated into SDL immediately, on the basis that more tests are always good.
Comment 1 Rainer Deyke 2014-11-28 13:46:42 UTC
Created attachment 1944 [details]
Patch to fix the bug.
Comment 2 Rainer Deyke 2014-11-28 13:48:30 UTC
It turns out that SDL_WINDOWEVENT_MAXIMIZED support was completely missing from the x11 video driver.  Fixed in the patch.
Comment 3 Sam Lantinga 2014-11-29 22:28:54 UTC
A few comments...

The window early return could be done at the top of SDL_SendWindowFlagChangeEvents()

Have you tested how this code interacts with programmatic maximizing/minimizing?

The shown state handling worries me. If the window system doesn't support NETWM (eg twm or bare X server), does SDL think windows are always hidden?
Comment 4 Rainer Deyke 2014-11-30 07:21:18 UTC
Created attachment 1947 [details]
Latest patch that supersedes both previous patches.

(In reply to Sam Lantinga from comment #3)
> A few comments...
> 
> The window early return could be done at the top of
> SDL_SendWindowFlagChangeEvents()

Yes, that's an error in my code.  I also discovered a more serious error that causes SDL_WINDOWEVENT_MAXIMIZED events to be followed by spurious SDL_WINDOWEVENT_RESTORED events, rendering my patch moot.  Fixed in the latest patch.

> Have you tested how this code interacts with programmatic
> maximizing/minimizing?

SDL_Maximize does not result in a SDL_WINDOWEVENT_MAXIMIZED event; this seems to be intentional, but I am not sure what the correct behavior should be.  SDL_Restore from maximized was flat-out broken before the patch and is still broken with the patch.  That is a separate bug that should be fixed in a separate patch, IMO.

> The shown state handling worries me. If the window system doesn't support
> NETWM (eg twm or bare X server), does SDL think windows are always hidden?

If the window system does not support NETWM, then the new code should never be called.  Even if it were to be called, it would default to thinking that the window is always shown.
Comment 5 Ryan C. Gordon 2015-02-02 06:26:13 UTC
I believe this is fixed properly by the patch I just applied for Bug #1447.

    https://hg.libsdl.org/SDL/rev/bb0b744fd1a6

Marking this as a duplicate, but feel free to reopen if this was a different concern.

--ryan.

*** This bug has been marked as a duplicate of bug 1447 ***