summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Byer <bbyer@bbyer.local>2007-11-07 02:22:39 -0800
committerBen Byer <bbyer@bbyer.apple.com>2007-11-08 20:37:18 -0800
commit9a8abcfa6d6d0cdc17be02a3443a7e116eb07d07 (patch)
tree2073efa644d81686fb4ab8b1d687726ad7c7a727
parentb34d2ffc38002f7c4980c138f57e9a828cd79c37 (diff)
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.
-rw-r--r--hw/darwin/apple/X11Application.m2
-rw-r--r--hw/darwin/quartz/xpr/xpr.h3
-rw-r--r--hw/darwin/quartz/xpr/xprFrame.c31
3 files changed, 36 insertions, 0 deletions
diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 0a080db40..84e295b4a 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -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]) {
diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
index 73a88c03d..46baac78f 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -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);
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index aa38845f6..ddb6d2dda 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -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