title: Window focusing issues lastupdated: 2008-07-30 This is a possibly long-term task, aimed at fixing various window focusing issues present in GNUstep GUI.
Ensure that GNUstep application windows (and menus) will obtain and retain focus correctly in EWMH-compliant window managers and especially WindowMaker.
Implementation is in:
- (void) _lossOfKeyOrMainWindow
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
when ordering out
- (void) miniaturize: (id)sender
- (void) sendEvent: (NSEvent*)theEvent
on GSAppKitWindowFocusIn
when focus goes to the main menu window
- (id) initWithContentRect: (NSRect)contentRect styleMask: (unsigned int)aStyle backing: (NSBackingStoreType)bufferingType defer: (BOOL)flag screen: (NSScreen*)aScreen
, - (void) _initBackendWindow
, - (void) _startBackendWindow
, - (void) _terminateBackendWindow
_initBackendWindow
calls XGServerWindow
's window::::
and
setwindowlevel
methods
- (id) initWithWindowRef: (void *)windowRef
- (void) becomeKeyWindow
, - (void) becomeMainWindow
,
- (void) makeKeyAndOrderFront: (id)sender
, - (void) makeKeyWindow
, - (void) makeMainWindow
, - (void) resignKeyWindow
, - (void) resignMainWindow
- (void) orderBack: (id)sender
, - (void) orderFront: (id)sender
, - (void) orderFrontRegardless
, - (void) orderOut: (id)sender
, - (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
- (void) setLevel: (int)newLevel
- (void) _didDeminiaturize: sender
, - (void) deminiaturize: sender
, - (void) miniaturize: (id)sender
- (void) sendEvent: (NSEvent*)theEvent
- (BOOL) hidesOnDeactivate
, - (void) setHidesOnDeactivate: (BOOL)flag
- (void) finishLaunching
(where windows are first ordered)
- (void) hide: (id)sender
- (void) unhide: (id)sender
, - (void) unhideWithoutActivation
- (void) unhideWithoutActivation
- (void) arrangeInFront: (id)sender
- (NSWindow*) keyWindow
, - (NSWindow*) mainWindow
- (void) miniaturizeAll: sender
- (void) preventWindowOrdering
(not implemented)
- (void) activateIgnoringOtherApps: (BOOL)flag
, - (void) deactivate
- (void) mouseDown: (NSEvent*)theEvent
- (void) orderwindow: (int)op : (int)otherWin : (int)winNum
- (void) setwindowlevel: (int)level : (int)win
?
- (void) setinputfocus: (int)win
XSetInputFocus
to claim focus
- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style : (int)screen
-orderwindow::
is called
- (void) processEvent: (XEvent *) event
ClientMessage
: may call -_handleTakeFocusAtom:forContext:
FocusOut
: calls [NSApp deactivate]
if focus goes do another
application; may cancel previous focus request
- (NSEvent *)_handleTakeFocusAtom: (XEvent)xEvent forContext: (NSGraphicsContext *)gcontext
-setinputfocus:
for the appropriate window
NSApplication
's -sendEvent
have different cases? Why don't
we check if theEvent
is nil
at the beginning?
generic
, and some in
function-local static variables?
generic
eventually.
from_configure
NO)
WM_STATE
set
_NET_WM_STATE
set
_WIN_STATE
set
WM_STATE
set
_NET_WM_STATE
set
_WIN_STATE
set
same_screen
YES,
focus YES, state 6)
same_screen
YES, focus YES, state 0)
_NET_WM_USER_TIME
_NET_WM_ACTIVE_WINDOW
GSX11HandlesWindowDecorations
set to NO
, clicking miniaturize button doesn't unmap windowPropertyNotify
XEvents shouldn't be too
bad. (A bunch of events are generated, but no noticeable impact.)
PropertyNotify
under EWMH window managers
"If you close or iconify a window and the one to gain focus is not owned by the same application, the app menu gets stuck. That is, at first the menu disappears because another app got focus, but if you bring it up again, it won't go away as easily. In the iconify case, the menu gets stuck right away, without first disappearing, probably because GNUstep does not take any notice at all of the action done by the window manager.
"The menu just sits there and does not receive keybord actions. Even if you interact with the menu by opening and closing sub-menus it does not get in a state where it reacts to menu shortcuts.
"It seems that opening a sub-menu and then clicking back and forth between the appicon and a window belonging to some other app fixes the problem. Also notice that when in the problematic state, double clicking the appicon does not unfocus other windows like is normally the case. Opening or focusing one of the application's own windows is another way to fix the situation."
"When an application is hidden, you can still access its menu by right-clicking the app icon. If you bring to front an existing window from the Window menu or open a new one using Document->New or similar, the app stays hidden when the window appears, which means the app menu does not show. The application as a whole gets restored if you click anywhere inside the window, though."
-[NSWindow makeKeyAndOrderFront:]
or
-[NSWindow makeKeyWindow]
When you hide an application that has miniaturized windows, strange things happen to those windows.
-[NSApplication hide:]
skips windows that are not visible
-[NSApplication unhide]
should order in miniaturized windows, but don't
try to make them key (make sure they are still iconified)
FocusOut
saying that
window 0 got focus. I guess other WMs send FocusOut
saying that the
application's other window got focus.
FocusIn
event, check the current desktop. If the desktop is
different, move menu (and other similar windows) to the desktop.
-[NSWindow makeKeyAndOrderFront:]
or
-[NSWindow makeKeyWindow]
(same as "Open window from hidden app")