Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4272 closed defect (fixed)

[PATCH] Sending Alt+F4 to a foreground window also closes 0 A.D. in the background

Reported by: elexis Owned by: elexis
Priority: Must Have Milestone: Alpha 21
Component: Core engine Keywords: patch
Cc: Patch:

Description

If 0 A.D. is running in one window and another application is running in another window on top of the 0 A. D. window, then sending an Alt+F4 signal to the foreground window closes that window, the keydown event is still sent to 0 A.D. and that application closes too (at least on ffm and my linux machine).

Every application tested other from 0 A.D. accepts the Alt+F4 only if there was a keypress for Alt+F4 (not only keydown), i.e. 0 A.D. (or SDL2?) must test whether there was a keyup (release of the key) before.

Bug reported by ffm who uses dwm on some gnu/linux machine (I'm using ubuntu 16 with i3wm, likely doesn't matter).

Attachments (1)

fix_altf4_bug.patch (927 bytes ) - added by elexis 8 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by elexis, 8 years ago

Keywords: patch review added
Milestone: BacklogAlpha 21
Summary: Sending Alt+F4 to a foreground window also closes 0 A.D. in the background[PATCH] Sending Alt+F4 to a foreground window also closes 0 A.D. in the background
  • r7933 introduced the hotkey combination Alt+F4.
  • Removing that hotkey fixes the issue. Alt+F4 closes the app unless it was sent to the app that had the focus previously.
  • Since the user is actually pressing (multiple HOTKEYDOWN events) and releasing (one HOTKEYUP event), triggering these events is actually correct.

by elexis, 8 years ago

Attachment: fix_altf4_bug.patch added

comment:2 by Itms, 8 years ago

The patch doesn't introduce any problems for me on Windows (the bug reported here does not happen on Windows), and I agree with the principle, so it looks good to me.

As elexis said on IRC, if the operating system does not consider that Alt+F4 should quit the application, I don't think we should try to enforce that.

comment:3 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 18830:

Remove the unneeded hardcoding of the Alt+F4 hotkey which causes 0AD on linux to exit unintentionally after receiving the window focus from another window which was closed with that hotkey (with multiple tiling window managers). Reviewed by Philip, tested by Imarok and Itms, fixes #4272.
The hotkey introduced in r7933 was likely a workaround for the custom windows SDL (wsdl) implementation which is no longer in use.

comment:4 by elexis, 8 years ago

Keywords: review removed
  • Discussed the patch with Philip in IRC on 2016-10-09
  • Super+Q is the hardcoded OSX equivalent of Alt+F4 and should be removed if it is unneeded as well. That should be verified by someone with OSX though.
Note: See TracTickets for help on using tickets.