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 5314 - UnmapNotify does not mean that window has been iconified
Summary: UnmapNotify does not mean that window has been iconified
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.12
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-10 14:32 UTC by Alberts Muktupāvels
Modified: 2020-10-20 00:27 UTC (History)
2 users (show)

See Also:


Attachments
x11events: ignore UnmapNotify events from XReparentWindow (2.46 KB, patch)
2020-10-17 20:11 UTC, Alberts Muktupāvels
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alberts Muktupāvels 2020-10-10 14:32:46 UTC
https://github.com/SDL-mirror/SDL/blob/master/src/video/x11/SDL_x11events.c#L949-L956

SDL receiving UnmapNotify event assumes that window has been iconified. This assumption seems wrong... For example UnmapNotify event is also sent when window is reparented, see https://tronche.com/gui/x/xlib/window-and-session-manager/XReparentWindow.html.

This causes problems when using SDL applications with Metacity 3.36+. Metacity now removes decorations when windows are fullscreen.

Perhaps SDL could check if next event is ReparentNotify and not dispatch UnmapNotify in that case? Something like this:

XEvent ev;
if (X11_XCheckIfEvent(display, &ev, &isReparentNotify, (XPointer)&xevent.xunmap))
  X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&xevent.xunmap);
else
  X11_DispatchUnmapNotify(data);


static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer unmap)
{
    XUnmapEvent *event;

    event = (XUnmapEvent*) unmap;

    return ev->type == MapNotify &&
        ev->xmap.window == event->window &&
        ev->xmap.serial == event->serial;
}

static Bool isReparentNotify(Display *dpy, XEvent *ev, XPointer unmap)
{
    XUnmapEvent *event;

    event = (XUnmapEvent*) unmap;

    return ev->type == ReparentNotify &&
        ev->xreparent.window == event->window &&
        ev->xreparent.serial == event->serial;
}
Comment 1 Sam Lantinga 2020-10-12 16:27:58 UTC
That seems reasonable, can you provide a tested and working patch? Can you also make sure that iconification is still detected correctly?
Comment 2 Alberts Muktupāvels 2020-10-17 20:11:44 UTC
Created attachment 4480 [details]
x11events: ignore UnmapNotify events from XReparentWindow
Comment 3 Alberts Muktupāvels 2020-10-17 20:16:32 UTC
(In reply to Sam Lantinga from comment #1)
> That seems reasonable, can you provide a tested and working patch? Can you
> also make sure that iconification is still detected correctly?

Patch attached. Iconification seems to work as expected.
Comment 4 Sam Lantinga 2020-10-20 00:27:20 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/204628027601