xserver: Branch 'orib-soc-2006'

Ori Bernstein orib at kemper.freedesktop.org
Fri Jun 30 06:41:10 EEST 2006


 hw/xnest/Args.c     |    4 ++
 hw/xnest/Color.c    |   37 +++---------------
 hw/xnest/Cursor.c   |   26 ++++++++-----
 hw/xnest/Events.c   |   94 ++++++++++++++++++++++++++++-------------------
 hw/xnest/GCOps.c    |    1 
 hw/xnest/Keyboard.c |  102 +++++++++++-----------------------------------------
 hw/xnest/Keyboard.h |    2 -
 hw/xnest/Pointer.c  |    9 +++-
 hw/xnest/Screen.c   |   40 ++++++++++----------
 hw/xnest/Window.c   |   32 +++++++++++-----
 hw/xnest/XNWindow.h |    2 +
 11 files changed, 158 insertions(+), 191 deletions(-)

New commits:
diff-tree 130d2c58308b1ccc8dd600887379dba96ab938b0 (from 9d20580082874eea87a13b641a8b76fdea0b6729)
Author: Ori Bernstein <rand.chars at gmail.com>
Date:   Thu Jun 29 23:45:18 2006 -0500

    Broken Rootless implementation

diff --git a/hw/xnest/Args.c b/hw/xnest/Args.c
index bfe7cd1..a79072f 100644
--- a/hw/xnest/Args.c
+++ b/hw/xnest/Args.c
@@ -32,6 +32,9 @@ is" without express or implied warranty.
 #include "Display.h"
 #include "Args.h"
 
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBsrv.h>
+#include <X11/extensions/XKBconfig.h>
 char *xnestDisplayName = NULL;        
 Bool xnestSynchronize = False;
 Bool xnestFullGeneration = False;
@@ -55,6 +58,7 @@ XCBWINDOW xnestParentWindow = {0};
 /* ddxInitGlobals - called by |InitGlobals| from os/util.c */
 void ddxInitGlobals(void)
 {
+    noXkbExtension=TRUE;
 }
 
 int
diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c
index 8af75d2..40b6b45 100644
--- a/hw/xnest/Color.c
+++ b/hw/xnest/Color.c
@@ -61,9 +61,9 @@ Bool xnestCreateColormap(ColormapPtr pCm
     screen = XCBSetupRootsIter (XCBGetSetup (xnestConnection)).data;
 
     xnestColormapPriv(pCmap)->colormap = XCBCOLORMAPNew(xnestConnection);
-    vid = screen->root_visual;//pCmap->pScreen->rootVisual.id;    
+    vid = screen->root_visual;   
     XCBCreateColormap(xnestConnection,
-            (pVisual->class & DynamicClass) ?  AllocAll : AllocNone,
+            (pVisual->class & DynamicClass) ?  XCBColormapAllocAll : XCBColormapAllocNone,
             xnestColormapPriv(pCmap)->colormap,
             xnestDefaultWindows[pCmap->pScreen->myNum],
             vid);
@@ -213,8 +213,7 @@ void xnestSetInstalledColormapWindows(Sc
     XCBParamsCW params;
     int numWindows;
 
-    icws.cmapIDs = (XCBCOLORMAP *)xalloc(pScreen->maxInstalledCmaps *
-            sizeof(XCBCOLORMAP));
+    icws.cmapIDs = (XCBCOLORMAP *)xalloc(pScreen->maxInstalledCmaps*sizeof(XCBCOLORMAP));
     icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs);
     icws.numWindows = 0;
     WalkTree(pScreen, xnestCountInstalledColormapWindows, (pointer)&icws);
@@ -235,21 +234,8 @@ void xnestSetInstalledColormapWindows(Sc
     if (!xnestSameInstalledColormapWindows(icws.windows, icws.numWindows)) {
         if (xnestOldInstalledColormapWindows)
             xfree(xnestOldInstalledColormapWindows);
-/* Hm, how do I deal with _XSERVER64 in XCB?
-#ifdef _XSERVER64
-        {
-            int i;
-            Window64 *windows = (Window64 *)xalloc(numWindows * sizeof(Window64));
 
-            for(i = 0; i < numWindows; ++i)
-                windows[i] = icws.windows[i];
-            xnestSetWmColormapWindows(xnestDisplay, xnestDefaultWindows[pScreen->myNum],
-                    windows, numWindows);
-            xfree(windows);
-        }
-#else*/
         xnestSetWmColormapWindows(xnestConnection, xnestDefaultWindows[pScreen->myNum], icws.windows, numWindows);
-/*#endif*/
 
         xnestOldInstalledColormapWindows = icws.windows;
         xnestNumOldInstalledColormapWindows = icws.numWindows;
@@ -277,10 +263,10 @@ void xnestSetInstalledColormapWindows(Sc
                         RT_COLORMAP);
 
             params.colormap = xnestColormap(pCmap).xid;
-            XCBAuxChangeWindowAttributes(xnestConnection, 
-                                         xnestDefaultWindows[pScreen->myNum],
+            /*XCBAuxChangeWindowAttributes(xnestConnection, 
+                                         xnestDefaultRoots[pScreen->myNum],
                                          XCBCWColormap,
-                                         &params);
+                                         &params);*/
            /* XSetWindowColormap(xnestDisplay, 
                     xnestDefaultWindows[pScreen->myNum],
                     xnestColormap(pCmap));*/
@@ -296,19 +282,8 @@ void xnestSetScreenSaverColormapWindow(S
     if (xnestOldInstalledColormapWindows)
         xfree(xnestOldInstalledColormapWindows);
 
-/*#ifdef _XSERVER64
-    {
-        Window64 window;
-
-        window = xnestScreenSaverWindows[pScreen->myNum];
-        xnestSetWMColormapWindows(xnestConnection, xnestDefaultWindows[pScreen->myNum],
-                &window, 1);
-        xnestScreenSaverWindows[pScreen->myNum] = window;
-    }
-#else*/
     xnestSetWmColormapWindows(xnestConnection, xnestDefaultWindows[pScreen->myNum],
             &xnestScreenSaverWindows[pScreen->myNum], 1);
-//#endif /* _XSERVER64 */
 
     xnestOldInstalledColormapWindows = NULL;
     xnestNumOldInstalledColormapWindows = 0;
diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c
index b169797..92cf9eb 100644
--- a/hw/xnest/Cursor.c
+++ b/hw/xnest/Cursor.c
@@ -42,10 +42,12 @@
 
 Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
 {
+    /*do we really want to realize the pointer here?*/
     XCBPIXMAP source, mask;
-    XCBDRAWABLE d;
     int pad;
     int size;
+    int bpp;
+    int i;
     XCBCURSOR c;
     unsigned long valuemask;
     XCBParamsGC values;
@@ -66,28 +68,33 @@ Bool xnestRealizeCursor(ScreenPtr pScree
     source = XCBPIXMAPNew(xnestConnection);
     mask = XCBPIXMAPNew(xnestConnection);
 
-    d.window = xnestDefaultWindows[pScreen->myNum];
     XCBCreatePixmap(xnestConnection,
                     xnestDefaultDepth,
                     source,
-                    d,
+                    (XCBDRAWABLE)xnestDefaultWindows[pScreen->myNum],
                     pCursor->bits->width,
                     pCursor->bits->height);
 
     XCBCreatePixmap(xnestConnection, 
                     xnestDefaultDepth,
                     mask,
-                    d,
+                    (XCBDRAWABLE)xnestDefaultWindows[pScreen->myNum],
                     pCursor->bits->width,
                     pCursor->bits->height);
 
-    pad =  XCBGetSetup(xnestConnection)->bitmap_format_scanline_pad;
+    for (i=0; i<xnestNumPixmapFormats; i++) {
+        if (xnestPixmapFormats[i].depth == 1) {
+            pad = xnestPixmapFormats[i].scanline_pad;
+            bpp = xnestPixmapFormats[i].bits_per_pixel;
+            break;
+        }
+    }
+
     /*not sure if this is right*/
-    size = (((pCursor->bits->width + pad - 1) & -pad) >> 3) * pCursor->bits->height;
-    d.pixmap = source;
+    size = (((bpp * pCursor->bits->width + pad - 1) & -pad) >> 3) * pCursor->bits->height;
     XCBPutImage(xnestConnection,
                 XCBImageFormatXYBitmap,
-                d,
+                (XCBDRAWABLE)source,
                 xnestBitmapGC,
                 pCursor->bits->width,
                 pCursor->bits->height,
@@ -96,10 +103,9 @@ Bool xnestRealizeCursor(ScreenPtr pScree
                 1,                      /*depth*/
                 size,      /*length..correct??*/
                 pCursor->bits->source);             /*bits*/
-    d.pixmap = mask;
     XCBPutImage(xnestConnection,
                 XCBImageFormatXYBitmap,
-                d,
+                (XCBDRAWABLE)mask,
                 xnestBitmapGC,
                 pCursor->bits->width,
                 pCursor->bits->height,
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index f550fdb..2e0bd3b 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -30,6 +30,7 @@
 #include "servermd.h"
 
 #include "mi.h"
+#include "dix.h"
 
 #include "Xnest.h"
 
@@ -72,33 +73,6 @@ static Bool xnestNotExposurePredicate(Di
     return !xnestExposurePredicate(display, event, args);
 }
 
-/*void xnestCollectExposures()
-{
-    XCBGenericEvent *e;
-    XCBExposeEvent *evt;
-    WindowPtr pWin;
-    RegionRec Rgn;
-    BoxRec Box;
-
-    e = XCBPeekNextEvent(xnestConnection);
-    while ((e->response_type & ~0x80) == XCBExpose) {
-        evt = (XCBExposeEvent *)XCBWaitForEvent(xnestConnection);
-        pWin = xnestWindowPtr(evt->window);
-
-        if (pWin) {
-            Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + evt->x;
-            Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + evt->y;
-            Box.x2 = Box.x1 + evt->width;
-            Box.y2 = Box.y1 + evt->height;
-
-            REGION_INIT(pWin->drawable.pScreen, &Rgn, &Box, 1);
-
-            miWindowExposures(pWin, &Rgn, NullRegion); 
-        }
-        e = XCBPeekNextEvent(xnestConnection);
-    }
-}*/
-
 void xnestQueueKeyEvent(int type, unsigned int keycode)
 {
     xEvent x;
@@ -110,26 +84,37 @@ void xnestQueueKeyEvent(int type, unsign
 
 void xnestHandleEvent(XCBGenericEvent *e)
 {
-    XCBMotionNotifyEvent *pev;
-    XCBEnterNotifyEvent  *eev;
-    XCBLeaveNotifyEvent  *lev;    
-    XCBExposeEvent       *xev;
-    XCBGenericEvent ev;
+    XCBMotionNotifyEvent    *pev;
+    XCBEnterNotifyEvent     *eev;
+    XCBLeaveNotifyEvent     *lev;    
+    XCBExposeEvent          *xev;
+    XCBResizeRequestEvent   *rev;
+    XCBConfigureNotifyEvent *cev;
+    xEvent ev;
     ScreenPtr pScreen;
     WindowPtr pWin;
+    WindowPtr pSib;
     RegionRec Rgn;
     BoxRec Box;
 
 
     switch (e->response_type & ~0x80) {
         case XCBKeyPress:
+            ErrorF("Key Pressed\n");
             xnestUpdateModifierState(((XCBKeyPressEvent *)e)->state);
-            xnestQueueKeyEvent(XCBKeyPress, ((XCBKeyPressEvent *)e)->detail.id);
+            ((XCBKeyPressEvent *)e)->time.id = lastEventTime = GetTimeInMillis();
+            memcpy(&ev, e, sizeof(XCBGenericEvent));
+            mieqEnqueue(&ev);
+
+            //xnestQueueKeyEvent(XCBKeyPress, ((XCBKeyPressEvent *)e)->detail.id);
             break;
 
         case XCBKeyRelease:
             xnestUpdateModifierState(((XCBKeyReleaseEvent *)e)->state);
-            xnestQueueKeyEvent(KeyRelease, ((XCBKeyReleaseEvent *)e)->detail.id);
+            ((XCBKeyReleaseEvent *)e)->time.id = lastEventTime = GetTimeInMillis();
+            memcpy(&ev, e, sizeof(XCBGenericEvent));
+            mieqEnqueue(&ev);
+            //xnestQueueKeyEvent(KeyRelease, ((XCBKeyReleaseEvent *)e)->detail.id);
             break;
 
         case XCBButtonPress:
@@ -191,6 +176,9 @@ void xnestHandleEvent(XCBGenericEvent *e
                     x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
                     mieqEnqueue(&x);
 #endif
+                    ErrorF("Entry Notify\n");
+                    XCBTIMESTAMP t = { XCBCurrentTime };
+                    XCBSetInputFocus(xnestConnection, RevertToNone, eev->child, t);
                     miPointerAbsoluteCursor (eev->event_x, eev->event_y, 
                             lastEventTime = GetTimeInMillis());
                     xnestDirectInstallColormaps(pScreen);
@@ -227,10 +215,40 @@ void xnestHandleEvent(XCBGenericEvent *e
                 miWindowExposures(pWin, &Rgn, NullRegion); 
             }
             break;
+        case XCBResizeRequest:
+            rev = (XCBResizeRequestEvent *)e;
+            pWin = xnestWindowPtr(rev->window);     
+            rev->window = xnestWindow(xnestWindowPtr(rev->window));
+            memcpy(&ev, cev, sizeof(XCBGenericEvent));            
+            if (pWin) {
+                DeliverEvents(pWin, &ev, 1, NULL);
+            } 
+            break;
+
+        case XCBConfigureNotify:
+            cev = (XCBConfigureNotifyEvent *)e;
+            pWin = xnestWindowPtr(cev->event);
+            cev->event = xnestWindow(xnestWindowPtr(cev->event));
+            cev->window = xnestWindow(xnestWindowPtr(cev->window));
+            pSib = xnestWindowPtr(cev->above_sibling);
+            if (pSib)
+                cev->above_sibling = xnestWindow(pSib);
+            memcpy(&ev, cev, sizeof(XCBGenericEvent));
+            if (pWin) {
+                DeliverEvents(pWin, &ev, 1, NULL);
+            }
+            break;
+            /*
+            pWin = xnestWindowPtr(cev->event);
+            pSib = xnestWindowPtr(cev->above_sibling);
+            if (pWin)
+                miSlideAndSizeWindow(pWin, cev->x, cev->y, cev->width, cev->height, pSib);
+            break;
+            */
         case XCBNoExposure:
         case XCBGraphicsExposure:
         case XCBCirculateNotify:
-        case XCBConfigureNotify:
+
         case XCBGravityNotify:
         case XCBMapNotify:
         case XCBReparentNotify:
@@ -238,8 +256,8 @@ void xnestHandleEvent(XCBGenericEvent *e
             break;
 
         default:
-            ErrorF("xnest warning: unhandled event %d\n", e->response_type & ~0x80);
-            ErrorF("Sequence number: %d\n", e->sequence);
+            ErrorF("****xnest warning: unhandled event %d\n", e->response_type & ~0x80);
+            ErrorF("****Sequence number: %d\n", e->sequence);
             break;
     }
 }
@@ -256,7 +274,7 @@ void xnestCollectEvents()
     while ((e = XCBPollForEvent(xnestConnection, NULL)) != NULL) {
         if (!e->response_type) {
             err = (XCBGenericError *)e;
-            ErrorF("File: %s Error: %d, Sequence %d\n", __FILE__, err->error_code, err->sequence);
+            ErrorF("****** File: %s Error: %d, Sequence %d\n", __FILE__, err->error_code, err->sequence);
             switch(err->error_code){
                 case XCBMatch:
                     re = (XCBRequestError *)err;
diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c
index 5e744ae..dbb3116 100644
--- a/hw/xnest/GCOps.c
+++ b/hw/xnest/GCOps.c
@@ -83,6 +83,7 @@ void xnestPutImage(DrawablePtr pDrawable
         if (xnestPixmapFormats[i].depth == depth) {
             pad = xnestPixmapFormats[i].scanline_pad;
             bpp = xnestPixmapFormats[i].bits_per_pixel;
+            break;
         }
     }
     size = (((bpp * w + pad - 1) & -pad) >> 3)*h;
diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
index 8700728..67528c2 100644
--- a/hw/xnest/Keyboard.c
+++ b/hw/xnest/Keyboard.c
@@ -133,8 +133,10 @@ void xnestChangeKeyboardControl(DeviceIn
 #endif
 }
 
+/*FIXME: XCB Doesn't currently support XKB. */
 int xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
 {
+
     const XCBSetup *setup;
     XCBGetModifierMappingCookie modmapcook;
     XCBGetModifierMappingRep   *modmaprep;
@@ -151,9 +153,10 @@ int xnestKeyboardProc(DeviceIntPtr pDev,
     CARD8 modmap[MAP_LENGTH];
     int i, j;
 
+    noXkbExtension=TRUE;
     switch (onoff)
     {
-        case DEVICE_INIT: 
+        case DEVICE_INIT:
             modmapcook = XCBGetModifierMapping(xnestConnection);
             modmaprep = XCBGetModifierMappingReply(xnestConnection, modmapcook, NULL);
             modifier_keymap = XCBGetModifierMappingKeycodes(modmaprep);
@@ -161,115 +164,54 @@ int xnestKeyboardProc(DeviceIntPtr pDev,
             setup = XCBGetSetup(xnestConnection);
             min_keycode = setup->min_keycode;
             max_keycode = setup->max_keycode;
-#if 0
-//#ifdef _XSERVER64
-            {
-                KeySym64 *keymap64;
-                int i, len;
-                keymap64 = XGetKeyboardMapping(xnestDisplay,
-                        min_keycode,
-                        max_keycode - min_keycode + 1,
-                        &mapWidth);
-                len = (max_keycode - min_keycode + 1) * mapWidth;
-                keymap = (KeySym *)xalloc(len * sizeof(KeySym));
-                for(i = 0; i < len; ++i)
-                    keymap[i] = keymap64[i];
-                XFree(keymap64);
-            }
-//#else
-#endif
+
             keymapcook = XCBGetKeyboardMapping(xnestConnection, 
                     min_keycode,
                     min_keycode.id-max_keycode.id+1);
             keymaprep = XCBGetKeyboardMappingReply(xnestConnection, keymapcook, NULL);
             keymap = XCBGetKeyboardMappingKeysyms(keymaprep);
             mapWidth = keymaprep->length;
-            //XFree(keymap); Do we leak? X doesn't like freeing this...
-            /*#endif*/
 
             for (i = 0; i < MAP_LENGTH; i++)
                 modmap[i] = 0;
-            for (j = 0; j < 8; j++)
+            for (j = 0; j < 8; j++) {
                 for(i = 0; i < keycodes_per_mod; i++) {
                     CARD8 keycode;
                     if ((keycode = modifier_keymap[j * keycodes_per_mod + i].id))
                         modmap[keycode] |= 1<<j;
                 }
-            //XFree(modifier_keymap); Freeing this also doesn't want to work..
+            }
 
             keySyms.minKeyCode = min_keycode.id;
             keySyms.maxKeyCode = max_keycode.id;
             keySyms.mapWidth = mapWidth;
             keySyms.map = (KeySym *)keymap;
-/*
-#ifdef XKB
-            if (noXkbExtension) {
-XkbError:
-#endif*/
-                ctlcook = XCBGetKeyboardControl(xnestConnection);
-                ctlvals = XCBGetKeyboardControlReply(xnestConnection, ctlcook, NULL);
-                memmove(defaultKeyboardControl.autoRepeats, 
-                        ctlvals->auto_repeats, 
-                        sizeof(ctlvals->auto_repeats));
-                InitKeyboardDeviceStruct(&pDev->public, 
-                                         &keySyms, 
-                                         modmap, 
-                                         xnestBell, 
-                                         xnestChangeKeyboardControl);
-/*
-#ifdef XKB
-            } else {
-                FILE *file;
-                XkbConfigRtrnRec config;
-
-                XkbComponentNamesRec names;
-                char *rules, *model, *layout, *variants, *options;
-
-                XkbDescPtr xkb;
-                int op, event, error, major, minor;
-
-                if (XkbQueryExtension(xnestConnection, &op, &event, &error, &major, &minor) == 0) {
-                    ErrorF("Unable to initialize XKEYBOARD extension.\n");
-                    goto XkbError;
-                }
-                xkb = XkbGetKeyboard(xnestDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
-                if (xkb == NULL || xkb->geom == NULL) {
-                    ErrorF("Couldn't get keyboard.\n");
-                    goto XkbError;
-                }
-                XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb);
 
-                memset(&names, 0, sizeof(XkbComponentNamesRec));
-                rules = XKB_DFLT_RULES_FILE;
-                model = XKB_DFLT_KB_MODEL;
-                layout = XKB_DFLT_KB_LAYOUT;
-                variants = XKB_DFLT_KB_VARIANT;
-                options = XKB_DFLT_KB_OPTIONS;
-
-                XkbSetRulesDflts(rules, model, layout, variants, options);
-                XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, modmap,
-                        xnestBell, xnestChangeKeyboardControl);
-                XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls);
-                XkbFreeKeyboard(xkb, 0, False);
-            }
-#endif
-#ifdef _XSERVER64
-              xfree(keymap);
-#else*/
-            //XFree(keymap); or this...
-/*#endif*/
+            ctlcook = XCBGetKeyboardControl(xnestConnection);
+            ctlvals = XCBGetKeyboardControlReply(xnestConnection, ctlcook, NULL);
+            memmove(defaultKeyboardControl.autoRepeats, ctlvals->auto_repeats, sizeof(ctlvals->auto_repeats));
+            InitKeyboardDeviceStruct(&pDev->public, 
+                    &keySyms, 
+                    modmap, 
+                    xnestBell, 
+                    xnestChangeKeyboardControl);
+
             break;
         case DEVICE_ON:
+            /*
             xnestEventMask |= XNEST_KEYBOARD_EVENT_MASK;
             for (i = 0; i < xnestNumScreens; i++)
-                XCBChangeWindowAttributes(xnestConnection, xnestDefaultWindows[i], 
+                XCBChangeWindowAttributes(xnestConnection, xnestDefaultRoots[i], 
                         XCBCWEventMask, &xnestEventMask);
+                        */
             break;
         case DEVICE_OFF: 
+            /*
             xnestEventMask &= ~XNEST_KEYBOARD_EVENT_MASK;
             for (i = 0; i < xnestNumScreens; i++)
-                XCBChangeWindowAttributes(xnestConnection, xnestDefaultWindows[i], 
+                XCBChangeWindowAttributes(xnestConnection, xnestDefaultRoots[i], 
                         XCBCWEventMask, &xnestEventMask);
+            */
             break;
         case DEVICE_CLOSE: 
             break;
diff --git a/hw/xnest/Keyboard.h b/hw/xnest/Keyboard.h
index 8237dac..7b63e37 100644
--- a/hw/xnest/Keyboard.h
+++ b/hw/xnest/Keyboard.h
@@ -18,7 +18,7 @@ is" without express or implied warranty.
 #define XNESTKEYBOARD_H
 
 #define XNEST_KEYBOARD_EVENT_MASK \
-        (KeyPressMask | KeyReleaseMask | FocusChangeMask | KeymapStateMask)
+        (XCBEventMaskKeyPress | XCBEventMaskKeyRelease | XCBEventMaskFocusChange | XCBEventMaskKeymapState)
 
 extern DeviceIntPtr xnestKeyboardDevice;
 
diff --git a/hw/xnest/Pointer.c b/hw/xnest/Pointer.c
index 4837ce2..6641254 100644
--- a/hw/xnest/Pointer.c
+++ b/hw/xnest/Pointer.c
@@ -69,16 +69,19 @@ int xnestPointerProc(DeviceIntPtr pDev, 
                     miPointerGetMotionBufferSize());
             break;
         case DEVICE_ON: 
-            xnestEventMask |= XNEST_POINTER_EVENT_MASK;
+/*            xnestEventMask |= XNEST_POINTER_EVENT_MASK;
             for (i = 0; i < xnestNumScreens; i++)
-                XCBChangeWindowAttributes(xnestConnection, xnestDefaultWindows[i], 
+                XCBChangeWindowAttributes(xnestConnection, xnestDefaultRoots[i], 
                                           XCBCWEventMask, &xnestEventMask);
+                                          */
             break;
         case DEVICE_OFF: 
             xnestEventMask &= ~XNEST_POINTER_EVENT_MASK;
+/*
             for (i = 0; i < xnestNumScreens; i++)
-                XCBChangeWindowAttributes(xnestConnection, xnestDefaultWindows[i], 
+                XCBChangeWindowAttributes(xnestConnection, xnestDefaultRoots[i], 
                                           XCBCWEventMask, &xnestEventMask);
+*/
             break;
         case DEVICE_CLOSE: 
             break;
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index 56af6d9..d60fa72 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -340,8 +340,8 @@ Bool xnestOpenScreen(int index, ScreenPt
     pScreen->DestroyColormap = xnestDestroyColormap;
     pScreen->InstallColormap = xnestInstallColormap;
     pScreen->UninstallColormap = xnestUninstallColormap;
-    pScreen->ListInstalledColormaps = xnestListInstalledColormaps;
-    pScreen->StoreColors = xnestStoreColors;
+    pScreen->ListInstalledColormaps = (ListInstalledColormapsProcPtr) xnestListInstalledColormaps;
+    pScreen->StoreColors = (StoreColorsProcPtr) xnestStoreColors;
     pScreen->ResolveColor = xnestResolveColor;
 
     pScreen->BitmapToRegion = xnestPixmapToRegion;
@@ -388,13 +388,28 @@ Bool xnestOpenScreen(int index, ScreenPt
                                       xnestDefaultWindows[pScreen->myNum],
                                       XCBCWEventMask,
                                       &xnestEventMask);
+            sizeHints = AllocSizeHints();
+            SizeHintsSetFlagPPosition(sizeHints);
+            SizeHintsSetFlagPSize(sizeHints);
+            SizeHintsSetFlagPMaxSize(sizeHints);
+            SizeHintsSetPosition(sizeHints, False, xnestX + POSITION_OFFSET, xnestY + POSITION_OFFSET);
+            SizeHintsSetSize(sizeHints, 0, xnestWidth, xnestHeight);
+            SizeHintsSetMaxSize(sizeHints, xnestWidth, xnestHeight);        
+            if (xnestUserGeometry & XValue || xnestUserGeometry & YValue)
+                SizeHintsSetFlagUSPosition(sizeHints);
+            if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue)
+                SizeHintsSetFlagUSSize(sizeHints);
+            /*FIXME: set name and the like properly!*/
+            SetWMNormalHints(xnestConnection, xnestDefaultWindows[pScreen->myNum], sizeHints);
+            XCBMapWindow(xnestConnection, xnestDefaultWindows[pScreen->myNum]);
         } else {
             //vid.id = pScreen->rootVisual;
             vid = screen->root_visual;
-            xnestDefaultWindows[pScreen->myNum] = XCBWINDOWNew(xnestConnection);
+            xnestDefaultWindows[pScreen->myNum] = screen->root;
+            /*xnestDefaultRoots[pScreen->myNum] = XCBWINDOWNew(xnestConnection);
             XCBAuxCreateWindow(xnestConnection, 
                                xnestDefaultDepth,
-                               xnestDefaultWindows[pScreen->myNum],
+                               xnestDefaultRoots[pScreen->myNum],
                                screen->root,
                                xnestX + POSITION_OFFSET,
                                xnestY + POSITION_OFFSET,
@@ -403,26 +418,13 @@ Bool xnestOpenScreen(int index, ScreenPt
                                XCBWindowClassInputOutput,
                                vid,
                                valuemask, 
-                               &param);
+                               &param);*/
         }
 
         if (!xnestWindowName)
             xnestWindowName = argv[0];
 
-        sizeHints = AllocSizeHints();
-        SizeHintsSetFlagPPosition(sizeHints);
-        SizeHintsSetFlagPSize(sizeHints);
-        SizeHintsSetFlagPMaxSize(sizeHints);
-        SizeHintsSetPosition(sizeHints, False, xnestX + POSITION_OFFSET, xnestY + POSITION_OFFSET);
-        SizeHintsSetSize(sizeHints, 0, xnestWidth, xnestHeight);
-        SizeHintsSetMaxSize(sizeHints, xnestWidth, xnestHeight);        
-        if (xnestUserGeometry & XValue || xnestUserGeometry & YValue)
-            SizeHintsSetFlagUSPosition(sizeHints);
-        if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue)
-            SizeHintsSetFlagUSSize(sizeHints);
-        /*FIXME: set name and the like properly!*/
-        SetWMNormalHints(xnestConnection, xnestDefaultWindows[pScreen->myNum], sizeHints);
-        XCBMapWindow(xnestConnection, xnestDefaultWindows[pScreen->myNum]);
+
 
         valuemask = CWBackPixmap | CWColormap;
         param.back_pixmap = xnestScreenSaverPixmap.xid;
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index 6a5e6ec..307dee0 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -76,11 +76,20 @@ WindowPtr xnestWindowPtr(XCBWINDOW windo
 
 Bool xnestCreateWindow(WindowPtr pWin)
 {
-    unsigned long mask;
-    XCBParamsCW param;
+    unsigned long  mask;
+    XCBParamsCW    param;
     XCBVISUALTYPE *visual;
     XCBVISUALID    vid;
-    ColormapPtr pCmap;
+    XCBSCREEN     *screen;
+    ColormapPtr    pCmap;
+
+    /* special case creating the root window. We don't want to actually create it, so
+     * we just set it's XID to the backing server's root.*/
+    screen = XCBSetupRootsIter (XCBGetSetup (xnestConnection)).data;    
+    if (xnestIsRoot(pWin)) {
+        xnestWindowPriv(pWin)->window = screen->root;
+        return True;
+    }
 
     if (pWin->drawable.class == XCBWindowClassInputOnly) {
         mask = 0L;
@@ -88,7 +97,10 @@ Bool xnestCreateWindow(WindowPtr pWin)
     }
     else {
         mask = XCBCWEventMask | XCBCWBackingStore;
-        param.event_mask = XCBEventMaskExposure;
+        param.event_mask = (1<<25)-1;
+            /*XCBEventMaskExposure|XCBEventMaskKeyPress|XCBEventMaskKeyRelease|XCBEventMaskButtonPress
+            |XCBEventMaskButtonRelease|XCBEventMaskEnterWindow|XCBEventMaskLeaveWindow|XCBEventMaskPointerMotion
+            |XCBEventMaskFocusChange|XCBEventMaskStructureNotify;*/
         param.backing_store = XCBBackingStoreNotUseful;
 
         if (pWin->parent) {
@@ -115,6 +127,8 @@ Bool xnestCreateWindow(WindowPtr pWin)
             vid = visual->visual_id;
         }
     }
+    if (xnestWindowParent(pWin).xid == screen->root.xid)
+        ErrorF("****Root Window Is Parent***");
 
     xnestWindowPriv(pWin)->window = XCBWINDOWNew(xnestConnection);
     XCBAuxCreateWindow(xnestConnection,
@@ -140,10 +154,8 @@ Bool xnestCreateWindow(WindowPtr pWin)
     if (pWin->nextSib)
         xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindow(pWin);
 #ifdef SHAPE
-    xnestWindowPriv(pWin)->bounding_shape = 
-        REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
-    xnestWindowPriv(pWin)->clip_shape = 
-        REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+    xnestWindowPriv(pWin)->bounding_shape = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+    xnestWindowPriv(pWin)->clip_shape = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
 #endif /* SHAPE */
 
     if (!pWin->parent) /* only the root window will have the right colormap */
@@ -345,6 +357,8 @@ Bool xnestChangeWindowAttributes(WindowP
 
 Bool xnestRealizeWindow(WindowPtr pWin)
 {
+    if (xnestIsRoot(pWin))
+        return True;
     xnestConfigureWindow(pWin, XCBConfigWindowStackMode);
 #ifdef SHAPE
     xnestShapeWindow(pWin);
@@ -406,7 +420,7 @@ void xnestWindowExposures(WindowPtr pWin
     XCBWINDOW window;
     BoxRec Box;
 
-    XCBSync(xnestConnection, NULL);
+    XCBFlush(xnestConnection);
 
     window = xnestWindow(pWin);
     /* Commenting this will probably lead to excessive expose events, but since XCB doesn't give the
diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h
index 2d80547..d7adb20 100644
--- a/hw/xnest/XNWindow.h
+++ b/hw/xnest/XNWindow.h
@@ -55,6 +55,8 @@ extern int xnestWindowPrivateIndex;
 #define xnestWindowSiblingBelow(pWin) \
   ((pWin)->nextSib ? xnestWindow((pWin)->nextSib) : None)
 
+#define xnestIsRoot(pWin) \
+    ((pWin) == WindowTable[(pWin)->drawable.pScreen->myNum])
 
 WindowPtr xnestWindowPtr(XCBWINDOW window);
 Bool xnestCreateWindow(WindowPtr pWin);



More information about the xorg-commit mailing list