Skip to content
Verified Commit 3db07faf authored by Alberts Muktupāvels's avatar Alberts Muktupāvels
Browse files

display: remove extra unmap events with same window and serial

Single XUnmapWindow call can result in multiple UnmapNotify events.

Linked issue has attached python code intended to reproduce original
bug and can be used to reproduce multiple UnmapNotify events for the
same window.

Steps to reproduce problem:
1. Run python3 Untitled.py;
2. Undock one of the application's child windows;
3. Minimize main window;
4. Unminimize main window.

On drag start metacity gets map event - new MetaWindow is created.
This window has override_redirect set to true, metacity selects
StructureNotifyMask events. When child window is dropped outside
main window we get 3 unmap events!

One event was sent because we asked X server to do that by selecting
StructureNotifyMask events. Second event was sent because child
window parent was root window. We have asked for such events on root
window by selecting SubstructureNotifyMask events. Third event seems
to come from XSendEvent.

At this point these multiple events are not problem. MetaWindow is
destroyed when we get first event and rest are ignored.

After that application sends map request and we create new
MetaWindow. This time override_redirect is not set and we choose to
not select StructureNotifyMask events. Unfortunately this mask is
already in your_event_mask as we are not unselecting events when
window is unmanaged.

Now when we minimize main window (step 3) also dock window is
minimized. We are just hiding window so we are adding pending unmap
event so we can ignore it when it will arrive. On first event we
correctly detect that it should be ignored but once second event
arrives we are unmanaging this window.

And here is our problem - trying to unminimize main window only
main window gets restored! Main window does not find child window
because it is destroyed.

Use XCheckIfEvent to remove extra UnmapNotify events that has same
window and serial preventing unnecessary window destruction.

https://gitlab.gnome.org/GNOME/metacity/-/issues/31
parent 77f1d554
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment