[PATCH 4/6] Add a DDX specific hook into miPaintWindow for DDXen which support the rootless extension

Jon TURNEY jon.turney at dronecode.org.uk
Mon Jan 17 06:20:39 PST 2011


Add a DDX specific hook into miPaintWindow, so DDXs which have the
rootless extension can install the the neccesary checking which
rootless needs to do

DDXs which don't support rootless won't install the hook, but the
DIX remains compatible with them, so they can be built at the same
time.

XXX: Xquartz changes aren't tested and are just an example

See [1] for admission that code as it stands is a horrible hack :-)

[1] http://lists.macosforge.org/pipermail/xquartz-dev/2009-September/002551.html

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 hw/xquartz/quartzStartup.c      |    7 +++++--
 hw/xwin/InitOutput.c            |    6 ++++++
 include/dixmain.h               |    1 +
 mi/miexpose.c                   |   31 +++++++++----------------------
 miext/rootless/rootless.h       |    6 ++++++
 miext/rootless/rootlessWindow.c |   24 ++++++++++++++++++++++++
 6 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 36c8182..3b65707 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -47,8 +47,8 @@
 #include <assert.h>
 
 #include <pthread.h>
-
-int dix_main(int argc, char **argv, char **envp);
+#include "dixmain.h"
+#include "rootless.h"
 
 struct arg {
     int argc;
@@ -59,6 +59,9 @@ struct arg {
 static void server_thread (void *arg) {
     struct arg args = *((struct arg *)arg);
     free(arg);
+
+    ddxHooks.ddxRootlessPaintWindow = RootlessPaintWindow;
+
     exit (dix_main(args.argc, args.argv, args.envp));
 }
 
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index a8ce86e..1cab5dd 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -58,6 +58,7 @@ typedef HRESULT (*SHGETFOLDERPATHPROC)(
 );
 #endif
 #include "dixmain.h"
+#include "rootless.h"
 
 /*
  * References to external symbols
@@ -193,6 +194,11 @@ int main(int argc, char *argv[], char *envp[])
   ddxHooks.ddxBeforeReset = ddxBeforeReset;
   ddxHooks.ddxPushProviders = ddxPushProviders;
 
+#ifdef ROOTLESS
+  // XXX: we actually could only install this hook if we are in rootless mode as an optimisation...
+  ddxHooks.ddxRootlessPaintWindow = RootlessPaintWindow;
+#endif
+
   return dix_main(argc, argv, envp);
 }
 
diff --git a/include/dixmain.h b/include/dixmain.h
index 20f5919..59fe689 100644
--- a/include/dixmain.h
+++ b/include/dixmain.h
@@ -30,6 +30,7 @@ struct _DdxHooks
 {
   void (*ddxBeforeReset)(void);
   void (*ddxPushProviders)(void);
+  Bool (*ddxRootlessPaintWindow)(WindowPtr pWin, RegionPtr prgn, int what);
 };
 
 typedef struct _DdxHooks DdxHooks;
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 94258b8..84ca05e 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -88,6 +88,7 @@ Equipment Corporation.
 #include "windowstr.h"
 #include "pixmap.h"
 #include "input.h"
+#include "dixmain.h"
 
 #include "dixstruct.h"
 #include "mi.h"
@@ -515,14 +516,6 @@ miWindowExposures( WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
 	RegionDestroy(exposures);
 }
 
-#ifdef ROOTLESS
-/* Ugly, ugly, but we lost our hooks into miPaintWindow... =/ */
-void RootlessSetPixmapOfAncestors(WindowPtr pWin);
-void RootlessStartDrawing(WindowPtr pWin);
-void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
-Bool IsFramedWindow(WindowPtr pWin);
-#endif 
-
 void
 miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 {
@@ -549,21 +542,15 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     DrawablePtr	drawable = &pWin->drawable;
 
 #ifdef ROOTLESS
-    if(!drawable || drawable->type == UNDRAWABLE_WINDOW)
-	return;
-
-    if(IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-    
-        if(pWin->backgroundState == ParentRelative) {
-            if((what == PW_BACKGROUND) || 
-               (what == PW_BORDER && !pWin->borderIsPixel))
-                RootlessSetPixmapOfAncestors(pWin);
-        }
-    }
+    /*
+       If the DDX is linked with the rootless extension, do the
+       work that rootless needs done here
+    */
+    if (ddxHooks.ddxRootlessPaintWindow)
+      if (!ddxHooks.ddxRootlessPaintWindow(pWin, prgn, what))
+        return;
 #endif
-    
+
     if (what == PW_BACKGROUND)
     {
 	while (pWin->backgroundState == ParentRelative)
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index 3d4a1b0..cefb505 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -365,4 +365,10 @@ void RootlessRepositionWindows(ScreenPtr pScreen);
  * Bring all windows to the front of the native stack
  */
 void RootlessOrderAllWindows (Bool include_unhitable);
+
+/*
+ * Paint window hook
+ */
+Bool RootlessPaintWindow(WindowPtr pWin, RegionPtr prgn, int what);
+
 #endif /* _ROOTLESS_H */
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index c4a32aa..5c7e6f6 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -1635,3 +1635,27 @@ RootlessSetPixmapOfAncestors(WindowPtr pWin)
     }
 }
 
+/*
+  This is called by a hook in miPaintWindow() if we are rootless,
+  to do the work that rootless needs done there
+*/
+Bool RootlessPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
+{
+  DrawablePtr drawable = &pWin->drawable;
+
+  if(!drawable || drawable->type == UNDRAWABLE_WINDOW)
+        return FALSE;
+
+  if(IsFramedWindow(pWin)) {
+        RootlessStartDrawing(pWin);
+        RootlessDamageRegion(pWin, prgn);
+
+        if(pWin->backgroundState == ParentRelative) {
+            if((what == PW_BACKGROUND) ||
+               (what == PW_BORDER && !pWin->borderIsPixel))
+                RootlessSetPixmapOfAncestors(pWin);
+        }
+    }
+
+  return TRUE;
+}
-- 
1.7.3.3



More information about the xorg-devel mailing list