Fixed focus problem (clicking on an X11 window that sits behind

an Aqua window would not always bring it to the top of the stack.
This commit is contained in:
Ben Byer 2007-11-07 02:22:39 -08:00 committed by Ben Byer
parent b34d2ffc38
commit 9a8abcfa6d
3 changed files with 36 additions and 0 deletions

View File

@ -201,6 +201,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
if (_x_active) [self activateX:NO];
} else if ([self modalWindow] == nil) {
/* Must be an X window. Tell appkit it doesn't have focus. */
WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
if (pWin) RootlessReorderWindow(pWin);
for_appkit = NO;
if ([self isActive]) {

View File

@ -38,6 +38,9 @@ void AppleDRIExtensionInit(void);
void xprAppleWMInit(void);
Bool xprInit(ScreenPtr pScreen);
Bool xprIsX11Window(void *nsWindow, int windowNumber);
WindowPtr xprGetX11Window(xp_window_id wid);
WindowPtr xprGetXWindowFromAppKit(int windowNumber);
void xprHideWindows(Bool hide);
Bool QuartzInitCursor(ScreenPtr pScreen);

View File

@ -424,6 +424,37 @@ xprGetXWindow(xp_window_id wid)
return winRec != NULL ? winRec->win : NULL;
}
/*
* Given the id of a physical window, try to find the top-level (or root)
* X window that it represents.
*/
WindowPtr
xprGetXWindowFromAppKit(int windowNumber)
{
RootlessWindowRec *winRec;
Bool ret;
xp_window_id wid;
if (window_hash == NULL)
return FALSE;
/* need to lock, since this function can be called by any thread */
pthread_mutex_lock(&window_hash_mutex);
if (xp_lookup_native_window(windowNumber, &wid))
ret = xprGetXWindow(wid) != NULL;
else
ret = FALSE;
pthread_mutex_unlock(&window_hash_mutex);
if (!ret) return NULL;
winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
return winRec != NULL ? winRec->win : NULL;
}
/*
* The windowNumber is an AppKit window number. Returns TRUE if xpr is