[RFC][PATCH 3/3] Rough attempt at abstracting some of the Xplugin specific stuff which has crept into rootlessWindow.c

Jon TURNEY jon.turney at dronecode.org.uk
Tue Jun 23 10:54:51 PDT 2009


This has been done in a pretty mindless fashion, without much thought
as to if the additions to the generic rootless interface are the
correct ones

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 hw/xquartz/xpr/xprFrame.c       |   40 +++++++++++++++++++++++++++++++
 hw/xwin/winscrinit.c            |    6 +++-
 miext/rootless/rootless.h       |    9 +++++++
 miext/rootless/rootlessWindow.c |   49 +++++++-------------------------------
 4 files changed, 62 insertions(+), 42 deletions(-)

diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 6635f08..329bf92 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -83,6 +83,8 @@ static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
                int shift_x, int shift_y);
 static void xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
 static Bool xprDoReorderWindow(RootlessWindowPtr pFrame);
+static void xprHideWindow(RootlessFrameID wid);
+static void xprUpdateColormap(RootlessFrameID wid);
 static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
               int dx, int dy);
 
@@ -447,6 +449,8 @@ static RootlessFrameProcsRec xprRootlessProcs = {
     xprDamageRects,
     xprSwitchWindow,
     xprDoReorderWindow,
+    xprHideWindow,
+    xprUpdateColormap,
     xp_copy_bytes,
     xp_fill_bytes,
     xp_composite_pixels,
@@ -593,3 +597,39 @@ xprHideWindows(Bool hide)
         }
     }
 }
+
+// XXX: identical to x_cvt_vptr_to_uint ?
+#define MAKE_WINDOW_ID(x)		((xp_window_id)((size_t)(x)))
+
+Bool no_configure_window;
+
+static inline int
+configure_window (xp_window_id id, unsigned int mask,
+                  const xp_window_changes *values)
+{
+  if (!no_configure_window)
+    return xp_configure_window (id, mask, values);
+  else
+    return XP_Success;
+}
+
+
+static
+void xprUpdateColormap(RootlessFrameID wid)
+{
+  /* This is how we tell xp that the colormap may have changed. */
+  xp_window_changes wc;
+  wc.colormap = RootlessColormapCallback;
+  wc.colormap_data = pWin->drawable.pScreen; // XXX: add this to function signature
+
+  configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc);
+}
+
+static
+void xprHideWindow(RootlessFrameID wid)
+{
+  xp_window_changes wc;
+  wc.stack_mode = XP_UNMAPPED;
+  wc.sibling = 0;
+  configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc);
+}
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index eab0c6c..99d5a46 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -58,8 +58,10 @@ winMWExtWMProcs = {
   winMWExtWMDamageRects,
 #endif
   winMWExtWMRootlessSwitchWindow,
-  NULL,//winWMExtWMDoReorderWindow,
-  
+  NULL,//winMWExtWMDoReorderWindow,
+  NULL,//winMWExtWMHideWindow,
+  NULL,//winMWExtWMUpdateColorMap,
+
   NULL,//winMWExtWMCopyBytes,
   NULL,//winMWExtWMFillBytes,
   NULL,//winMWExtWMCompositePixels,
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index bde4cff..0b0b08b 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -351,6 +351,13 @@ typedef void (*RootlessCopyWindowProc)
     (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
      int dx, int dy);
 
+
+typedef void (*RootlessHideWindowProc)
+     (RootlessFrameID wid);
+
+typedef void (*RootlessUpdateColormapProc)
+     (RootlessFrameID wid);
+
 /*
  * Rootless implementation function list
  */
@@ -374,6 +381,8 @@ typedef struct _RootlessFrameProcs {
     /* Optional frame functions */
     RootlessSwitchWindowProc SwitchWindow;
     RootlessDoReorderWindowProc DoReorderWindow;
+    RootlessHideWindowProc HideWindow;
+    RootlessUpdateColormapProc UpdateColormap;
 
     /* Optional acceleration functions */
     RootlessCopyBytesProc CopyBytes;
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index f3bbd21..217178e 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -37,14 +37,14 @@
 #include <limits.h> /* For CHAR_BIT */
 #include <assert.h>
 #include <X11/Xatom.h>
-#include <Xplugin.h>
 #ifdef __APPLE__
-//#include <X11/Xlib.h>
+#include <Xplugin.h>
 #include "mi.h"
 #include "pixmapstr.h"
 #include "windowstr.h"
 //#include <X11/extensions/applewm.h>
 extern int darwinMainScreenX, darwinMainScreenY;
+extern Bool no_configure_window;
 #endif
 #include "fb.h"
 
@@ -61,8 +61,6 @@ extern int darwinMainScreenX, darwinMainScreenY;
 #define SCREEN_TO_GLOBAL_Y 0
 #endif
 
-#define MAKE_WINDOW_ID(x)		((xp_window_id)((size_t)(x)))
-
 #define DEFINE_ATOM_HELPER(func,atom_name)                      \
   static Atom func (void) {                                       \
     static unsigned int generation = 0;                             \
@@ -78,33 +76,9 @@ DEFINE_ATOM_HELPER (xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
 DEFINE_ATOM_HELPER (xa_native_window_id, "_NATIVE_WINDOW_ID")
 DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
 
-static Bool no_configure_window;
 static Bool windows_hidden;
 // TODO - abstract xp functions
 
-static inline int
-configure_window (xp_window_id id, unsigned int mask,
-                  const xp_window_changes *values)
-{
-#ifdef __APPLE__
-  if (!no_configure_window)
-    return xp_configure_window (id, mask, values);
-  else
-#endif
-    return XP_Success;
-}
-
-/*static inline unsigned long
-current_time_in_seconds (void)
-{
-  unsigned long t = 0;
-
-  t += currentTime.milliseconds / 1000;
-  t += currentTime.months * 4294967;
-
-  return t;
-  } */
-
 #ifdef __APPLE__
 void
 RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state)
@@ -445,7 +419,8 @@ RootlessInitializeFrame(WindowPtr pWin, RootlessWindowRec *winRec)
 Bool
 RootlessColormapCallback (void *data, int first_color, int n_colors, uint32_t *colors)
 {
-    return (RootlessResolveColormap (data, first_color, n_colors, colors) ? XP_Success : XP_BadMatch);
+    return RootlessResolveColormap (data, first_color, n_colors, colors);
+    // does anything use the return code from this... it looks like it was inverted :-)
 }
 
 /*
@@ -1486,19 +1461,15 @@ void
 RootlessFlushWindowColormap (WindowPtr pWin)
 {
   RootlessWindowRec *winRec = WINREC (pWin);
-  xp_window_changes wc;
+  ScreenPtr pScreen = pWin->drawable.pScreen;
 
   if (winRec == NULL)
     return;
 
   RootlessStopDrawing (pWin, FALSE);
 
-  /* This is how we tell xp that the colormap may have changed. */
-
-  wc.colormap = RootlessColormapCallback;
-  wc.colormap_data = pWin->drawable.pScreen;
-
-  configure_window (MAKE_WINDOW_ID(winRec->wid), XP_COLORMAP, &wc);
+  if (SCREENREC(pScreen)->imp->UpdateColormap)
+    SCREENREC(pScreen)->imp->UpdateColormap(winRec->wid);
 }
 
 /*
@@ -1621,7 +1592,6 @@ RootlessHideAllWindows (void)
     ScreenPtr pScreen;
     WindowPtr pWin;
     RootlessWindowRec *winRec;
-    xp_window_changes wc;
     
     if (windows_hidden)
         return;
@@ -1645,9 +1615,8 @@ RootlessHideAllWindows (void)
             winRec = WINREC (pWin);
             if (winRec != NULL)
             {
-                wc.stack_mode = XP_UNMAPPED;
-                wc.sibling = 0;
-                configure_window (MAKE_WINDOW_ID(winRec->wid), XP_STACKING, &wc);
+              if (SCREENREC(pScreen)->imp->HideWindow)
+                SCREENREC(pScreen)->imp->HideWindow(winRec->wid);
             }
         }
     }
-- 
1.6.1.2



More information about the xorg-devel mailing list