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 3410 - SDL_WINDOW_HIDDEN flag is inaccurate.
Summary: SDL_WINDOW_HIDDEN flag is inaccurate.
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.4
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
: 2818 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-08-17 15:15 UTC by Jason Wyatt
Modified: 2017-11-14 14:46 UTC (History)
3 users (show)

See Also:


Attachments
Demo for incorrect hidden/shown state (961 bytes, text/x-c++src)
2016-08-17 15:15 UTC, Jason Wyatt
Details
Quick patch. (2.41 KB, patch)
2016-08-17 17:04 UTC, Jason Wyatt
Details | Diff
Alternate patch for this bug, the original proposed patch did not work for me (916 bytes, patch)
2017-07-20 13:07 UTC, Dan Ginsburg
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Wyatt 2016-08-17 15:15:04 UTC
Created attachment 2550 [details]
Demo for incorrect hidden/shown state

After hiding the window, SDL_WINDOW_HIDDEN/SDL_WINDOW_SHOWN flags on a window are correctly updated. However on the next SDL_PumpEvents, they are set incorrectly.

This appears to be because X11_GetNetWMState does not check whether the _NET_WM_STATE property exists (it shouldn't on unmapped windows, see https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#idm140130317598336). This results in an empty list of atoms for the state, which would imply that the window is not hidden.

(Seen on Fedora 24, Gnome)
Comment 1 Jason Wyatt 2016-08-17 17:04:10 UTC
Created attachment 2551 [details]
Quick patch.

Checking that the property exists, and if it doesn't, setting the SDL_WINDOW_HIDDEN flag, fixes the issue for me.
Comment 2 Dan Ginsburg 2017-07-20 13:07:25 UTC
Created attachment 2802 [details]
Alternate patch for this bug, the original proposed patch did not work for me
Comment 3 Dan Ginsburg 2017-07-20 13:10:33 UTC
More details on my proposed patch: I am on Kubuntu 16.04.2.  I ran into this same bug, but with Jason's patch I found that actualType != None was true so the SDL_WINDOW_HIDDEN would still not be set.  My fix instead is to explicitly check for whether the window is unmapped rather than relying on the returned values in XGetWindowProperty.
Comment 4 Sam Lantinga 2017-07-20 17:53:19 UTC
Thanks Dan, I accepted your patch.
https://hg.libsdl.org/SDL/rev/7cfe088fafba

Jason, can you check the latest build and see if that fixes your issue?
Comment 5 Jason Wyatt 2017-07-21 08:36:23 UTC
Yes, this fixes the issue for me too. Thanks.

(In reply to Sam Lantinga from comment #4)
> Thanks Dan, I accepted your patch.
> https://hg.libsdl.org/SDL/rev/7cfe088fafba
> 
> Jason, can you check the latest build and see if that fixes your issue?
Comment 6 Sam Lantinga 2017-07-21 16:50:23 UTC
Great, thanks!
Comment 7 Max Reitz 2017-11-14 14:46:15 UTC
*** Bug 2818 has been marked as a duplicate of this bug. ***