From 3f51f493b6daf2464e6c2ba5a924219b88a9e57e Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Tue, 8 Apr 2008 17:02:56 -0700 Subject: [PATCH] XQuartz: Fix issue where clicking on an X11 window might send that event to an X11 window in another space. (cherry picked from commit df21312c8b0e9ef0c809bfc57cdf64f27db0d8a7) (cherry picked from commit 2d4194a8d124e7a9c7cd1b83635ba6957aa4ae1c) --- configure.ac | 3 ++- dix/events.c | 7 +++++++ dix/window.c | 3 +++ hw/xquartz/darwinEvents.c | 6 +++++- hw/xquartz/quartz.c | 1 - include/windowstr.h | 3 +++ miext/rootless/rootlessWindow.c | 14 ++++++++------ miext/rootless/rootlessWindow.h | 4 +--- 8 files changed, 29 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index c2109633d9..94151ded1a 100644 --- a/configure.ac +++ b/configure.ac @@ -1732,7 +1732,8 @@ if test "X$XQUARTZ" = Xauto; then fi if test "x$XQUARTZ" = xyes; then - AC_DEFINE([XQUARTZ],[1],[Have Quartz]) + AC_DEFINE(XQUARTZ,1,[Have Quartz]) + AC_DEFINE(ROOTLESS,1,[Build Rootless code]) #glxAGL / glxCGL don't work yet # AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[ diff --git a/dix/events.c b/dix/events.c index 4a8e480c8e..aef333edea 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2170,6 +2170,13 @@ XYToWindow(int x, int y) wInputShape(pWin), x - pWin->drawable.x, y - pWin->drawable.y, &box)) +#endif +#ifdef ROOTLESS + /* In rootless mode windows may be offscreen, even when + * they're in X's stack. (E.g. if the native window system + * implements some form of virtual desktop system). + */ + && !pWin->rootlessUnhittable #endif ) { diff --git a/dix/window.c b/dix/window.c index 9975b5eec5..499f58e7ac 100644 --- a/dix/window.c +++ b/dix/window.c @@ -292,6 +292,9 @@ SetWindowToDefaults(WindowPtr pWin) pWin->forcedBS = FALSE; pWin->redirectDraw = RedirectDrawNone; pWin->forcedBG = FALSE; +#ifdef ROOTLESS + pWin->rootlessUnhittable = FALSE; +#endif } static void diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 3afbaf890c..410acdd76d 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -56,6 +56,10 @@ in this Software without prior written authorization from The Open Group. #include "applewmExt.h" #include +/* FIXME: Abstract this away into xpr */ +#include +#include "rootlessWindow.h" +WindowPtr xprGetXWindow(xp_window_id wid); /* Fake button press/release for scroll wheel move. */ #define SCROLLWHEELUPFAKE 4 @@ -228,7 +232,7 @@ void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int neven case kXquartzWindowState: DEBUG_LOG("kXquartzWindowState\n"); - RootlessNativeWindowStateChanged(xe[i].u.clientMessage.u.l.longs0, + RootlessNativeWindowStateChanged(xprGetXWindow(xe[i].u.clientMessage.u.l.longs0), xe[i].u.clientMessage.u.l.longs1); break; diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c index 96dc021a63..6a8cf7c124 100644 --- a/hw/xquartz/quartz.c +++ b/hw/xquartz/quartz.c @@ -52,7 +52,6 @@ #include "windowstr.h" #include "colormapst.h" #include "globals.h" -#include "rootlessWindow.h" // System headers #include diff --git a/include/windowstr.h b/include/windowstr.h index e06a2f1bdc..99bd640cc4 100644 --- a/include/windowstr.h +++ b/include/windowstr.h @@ -160,6 +160,9 @@ typedef struct _Window { unsigned forcedBS:1; /* system-supplied backingStore */ unsigned redirectDraw:2; /* COMPOSITE rendering redirect */ unsigned forcedBG:1; /* must have an opaque background */ +#ifdef ROOTLESS + unsigned rootlessUnhittable:1; /* doesn't hit-test */ +#endif } WindowRec; /* diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index 0dad44a99f..17fe690850 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -117,12 +117,10 @@ rootlessHasRoot (ScreenPtr pScreen) } void -RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state) +RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state) { - WindowPtr pWin; RootlessWindowRec *winRec; - pWin = xprGetXWindow (id); if (pWin == NULL) return; winRec = WINREC (pWin); @@ -130,7 +128,7 @@ RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state) winRec->is_offscreen = ((state & XP_WINDOW_STATE_OFFSCREEN) != 0); winRec->is_obscured = ((state & XP_WINDOW_STATE_OBSCURED) != 0); - // pWin->rootlessUnhittable = winRec->is_offscreen; + pWin->rootlessUnhittable = winRec->is_offscreen; } void @@ -143,7 +141,7 @@ RootlessNativeWindowMoved (WindowPtr pWin) ClientPtr client; RootlessWindowRec *winRec = WINREC(pWin); - if (xp_get_window_bounds (winRec->wid, &bounds) != Success) return; + if (xp_get_window_bounds ((xp_window_id)winRec->wid, &bounds) != Success) return; sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX; sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY; @@ -1426,6 +1424,10 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent) pTopWin = TopLevelParent(pWin); assert(pTopWin != pWin); + + pWin->rootlessUnhittable = FALSE; + + DeleteProperty (pWin, xa_native_window_id ()); if (WINREC(pTopWin) != NULL) { /* We're screwed. */ @@ -1482,7 +1484,7 @@ RootlessFlushWindowColormap (WindowPtr pWin) wc.colormap = RootlessColormapCallback; wc.colormap_data = pWin->drawable.pScreen; - configure_window (winRec->wid, XP_COLORMAP, &wc); + configure_window ((xp_window_id)winRec->wid, XP_COLORMAP, &wc); } /* diff --git a/miext/rootless/rootlessWindow.h b/miext/rootless/rootlessWindow.h index 055589e79a..45bc4c202c 100644 --- a/miext/rootless/rootlessWindow.h +++ b/miext/rootless/rootlessWindow.h @@ -36,8 +36,6 @@ #include "rootlessCommon.h" -#include - Bool RootlessCreateWindow(WindowPtr pWin); Bool RootlessDestroyWindow(WindowPtr pWin); @@ -57,6 +55,6 @@ void RootlessResizeWindow(WindowPtr pWin, int x, int y, void RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent); void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width); void RootlessNativeWindowMoved (WindowPtr pWin); -void RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state); +void RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state); #endif