GNOME Bugzilla – Bug 455627
Keyboard input gets confused with modal windows
Last modified: 2008-02-05 17:12:09 UTC
Tor pointed out in bug #112404 that when you click the titlebar of a transient/modal owner window the keyboard focus will stay on the child window. This does not happen for non-modal transient windows.
I'm thinking about this some more, and I guess the real bug is that the modal parent shouldn't allow you to activate its titlebar. Because the focus -should- be on the child window, that's the entire point behind modal windows. I need to try to find an example of modal windows to see how they do it normally in the Win32 world, just for reference.
Created attachment 104456 [details] [review] Proposed patch This patch does a few things. It implements a modal window stack using GSList, and uses that from WM_MOUSEACTIVATE to determine if it should eat the activation and mouse click when window != current modal. It also handles the problem of alt-tabbing to a modally-blocked window. I tried using WM_SYSCOMMAND and listening for SC_NEXTWINDOW/SC_PREVWINDOW/SC_TASKLIST, but couldn't get that to work in a useful way. So instead I'm now watching WM_ACTIVATE to see when the window is activated by some means other than a mouse click (since we handle that with WM_MOUSEACTIVATE), and if the window is modally blocked then I activate the current modal window. This should also take care of other ways of activating the window, like if the app tries to call ActivateWindow() on a modally-blocked window. This seems to cover every angle I can think of. If anyone has any additional thoughts, let me know! Also, this patch fixes bug #511111 as well.
Some stylistic comments about the patch: the non-static functions you added should be prefixed with an underscore. And as they aren't intended to be called by libgtk like the ones suffixed with _libgtk_only, they shouldn't be declared in gdkwin32.h, but gdkprivate-win32.h. (Yeah, I notice there are a couple of old libgdk-local functions that aren't prefixed with underscore. That should be changed for consistency. Feel free...) As to the functionality of the patch, I trust you have investigate this well enough. Please fix the style issues and commit to trunk first and then after some week to the stable branch as well.
Created attachment 104490 [details] [review] Updated patch Updated patch with fixes for style.
2008-02-05 Cody Russell <bratsche@gnome.org> * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkevents-win32.c * gdk/win32/gdkwindow-win32.c * gdk/win32/gdkwindow-win32.h * gdk/win32/gdkwin32.h: Modal window rework. (#455627 and #511111)