[Xquartz-changes] xserver: Branch 'master' - 73 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Tue Dec 18 01:37:57 PST 2012


 Xext/saver.c                           |    2 
 Xi/exevents.c                          |   75 ++++----
 Xi/xipassivegrab.c                     |    8 
 Xi/xiquerypointer.c                    |   17 -
 Xi/xiselectev.c                        |   80 ++++++--
 dix/dispatch.c                         |    4 
 dix/enterleave.c                       |    5 
 dix/eventconvert.c                     |    4 
 dix/events.c                           |   24 ++
 dix/getevents.c                        |  132 ++++++--------
 dix/inpututils.c                       |   51 ++---
 dix/touch.c                            |   65 +++----
 dix/window.c                           |    2 
 glx/glxdri2.c                          |    2 
 hw/dmx/dmx.h                           |    2 
 hw/dmx/dmxcursor.c                     |    2 
 hw/dmx/dmxinit.c                       |   22 ++
 hw/kdrive/ephyr/hostx.c                |    4 
 hw/vfb/InitOutput.c                    |   19 ++
 hw/xfree86/common/xf86Events.c         |    1 
 hw/xfree86/common/xf86Extensions.c     |    2 
 hw/xfree86/dixmods/glxmodule.c         |    2 
 hw/xfree86/dri/dri.c                   |    7 
 hw/xfree86/modes/xf86Crtc.c            |    4 
 hw/xfree86/os-support/linux/lnx_init.c |   33 ++-
 hw/xquartz/GL/visualConfigs.c          |  214 ++++++++---------------
 hw/xquartz/darwin.c                    |   16 -
 hw/xquartz/quartz.c                    |    2 
 hw/xquartz/xpr/xprScreen.c             |    5 
 hw/xwin/InitOutput.c                   |   11 -
 hw/xwin/Makefile.am                    |    8 
 hw/xwin/ddraw.h                        |    4 
 hw/xwin/glx/indirect.c                 |   22 +-
 hw/xwin/man/XWin.man                   |   12 -
 hw/xwin/propertystore.h                |   83 +++++++++
 hw/xwin/win.h                          |    5 
 hw/xwin/winSetAppUserModelID.c         |  109 +++++++++++
 hw/xwin/winblock.c                     |    9 
 hw/xwin/winclipboardthread.c           |    3 
 hw/xwin/winclipboardxevents.c          |   36 +--
 hw/xwin/winengine.c                    |    6 
 hw/xwin/winerror.c                     |   32 ++-
 hw/xwin/winglobals.c                   |    2 
 hw/xwin/winkeybd.c                     |   47 +++--
 hw/xwin/winms.h                        |    1 
 hw/xwin/winmultiwindowwm.c             |   55 +++++-
 hw/xwin/winmultiwindowwndproc.c        |    2 
 hw/xwin/winprocarg.c                   |    6 
 hw/xwin/winshaddd.c                    |   14 -
 hw/xwin/winshadddnl.c                  |   14 -
 hw/xwin/winshadgdi.c                   |   15 -
 hw/xwin/wintaskbar.c                   |   92 ++++++++++
 hw/xwin/winwin32rootless.c             |    2 
 hw/xwin/winwindow.h                    |   12 +
 hw/xwin/winwndproc.c                   |    9 
 include/eventconvert.h                 |    2 
 include/extension.h                    |    2 
 include/extinit.h                      |    4 
 include/input.h                        |    7 
 include/inputstr.h                     |    2 
 include/inpututils.h                   |    1 
 include/xkbsrv.h                       |   18 -
 mi/miinitext.c                         |    2 
 os/osinit.c                            |    7 
 os/utils.c                             |   17 +
 randr/randr.c                          |    2 
 test/xi2/protocol-eventconvert.c       |    4 
 test/xi2/xi2.c                         |    6 
 xfixes/cursor.c                        |   16 +
 xfixes/xfixes.c                        |    2 
 xkb/Makefile.am                        |    3 
 xkb/ddxList.c                          |  302 ---------------------------------
 xkb/xkb.c                              |   50 ++---
 xkb/xkbAccessX.c                       |   36 ++-
 74 files changed, 1030 insertions(+), 870 deletions(-)

New commits:
commit ba4bb3bc1b87eb57cc34d2ad1f302c9d2a15c847
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Tue Dec 18 01:29:12 2012 -0800

    XQuartz: Don't add the 15bit visual any more
    
    Mountain Lion only supports 32bit backing stores, so don't use 15bit visuals until libXplugin adapts
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index bf51180..e0983d6 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -230,13 +230,15 @@ DarwinScreenInit(ScreenPtr pScreen, int argc, char **argv)
     }
 
     // TODO: Make PseudoColor visuals not suck in TrueColor mode
-    //    if(dfb->depth > 8)
-    //        miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
-    if (dfb->depth > 15)
-        miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor,
-                                 RM_ARGB(0, 5, 5, 5), GM_ARGB(0, 5, 5,
-                                                              5),
-                                 BM_ARGB(0, 5, 5, 5));
+    // if(dfb->depth > 8)
+    //    miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
+    //
+    // TODO: Re-add support for 15bit
+    // if (dfb->depth > 15)
+    //    miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor,
+    //                             RM_ARGB(0, 5, 5, 5), GM_ARGB(0, 5, 5,
+    //                                                          5),
+    //                             BM_ARGB(0, 5, 5, 5));
     if (dfb->depth > 24)
         miSetVisualTypesAndMasks(24, TrueColorMask, 8, TrueColor,
                                  RM_ARGB(0, 8, 8, 8), GM_ARGB(0, 8, 8,
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index efe2aa8..e376019 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -359,6 +359,10 @@ have_depth:
         dfb->blueMask = 0;
         break;
 
+#if 0
+    // Removed because Mountain Lion removed support for
+    // 15bit backing stores.  We can possibly re-add
+    // this once libXplugin is updated to work around it.
     case 15:
         dfb->visuals = TrueColorMask;     //LARGE_VISUALS;
         dfb->preferredCVC = TrueColor;
@@ -369,6 +373,7 @@ have_depth:
         dfb->greenMask = GM_ARGB(0, 5, 5, 5);
         dfb->blueMask = BM_ARGB(0, 5, 5, 5);
         break;
+#endif
 
     //        case 24:
     default:
commit c298f9c42ec05486ac88fc91a84739d7c3e3ea9e
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Tue Dec 18 01:28:02 2012 -0800

    XQuartz: Revert some unfortunate auto-indenting mishaps with our super-nested for-loops
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/GL/visualConfigs.c b/hw/xquartz/GL/visualConfigs.c
index e37eefb..03486cd 100644
--- a/hw/xquartz/GL/visualConfigs.c
+++ b/hw/xquartz/GL/visualConfigs.c
@@ -58,40 +58,38 @@
 #include "darwinfb.h"
 
 /* Based originally on code from indirect.c which was based on code from i830_dri.c. */
-__GLXconfig *
-__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
-{
+__GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) {
     int numConfigs = 0;
     __GLXconfig *visualConfigs, *c;
     struct glCapabilities caps;
     struct glCapabilitiesConfig *conf;
     int stereo, depth, aux, buffers, stencil, accum, color, msample;
 
-    if (getGlCapabilities(&caps)) {
+    if(getGlCapabilities(&caps)) {
         ErrorF("error from getGlCapabilities()!\n");
         return NULL;
     }
 
     /*
-       conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
-       so we treat a true conf->stereo as 2.
+     conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
+     so we treat a true conf->stereo as 2.
 
-       The depth size is 0 or 24.  Thus we do 2 iterations for that.
+     The depth size is 0 or 24.  Thus we do 2 iterations for that.
 
-       conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
+     conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
 
-       conf->buffers indicates whether we have single or double buffering.
+     conf->buffers indicates whether we have single or double buffering.
 
-       conf->total_stencil_bit_depths
+     conf->total_stencil_bit_depths
 
-       conf->total_color_buffers indicates the RGB/RGBA color depths.
+     conf->total_color_buffers indicates the RGB/RGBA color depths.
 
-       conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
+     conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
 
-       conf->total_depth_buffer_depths
+     conf->total_depth_buffer_depths
 
-       conf->multisample_buffers iterations (with at least 1 if equal to 0).  We add 1
-       for the 0 multisampling config.
+     conf->multisample_buffers iterations (with at least 1 if equal to 0).  We add 1
+     for the 0 multisampling config.
 
      */
 
@@ -99,57 +97,43 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
 
     numConfigs = 0;
 
-    for (conf = caps.configurations; conf; conf = conf->next) {
-        if (conf->total_color_buffers <= 0)
+    for(conf = caps.configurations; conf; conf = conf->next) {
+        if(conf->total_color_buffers <= 0)
             continue;
 
         numConfigs += (conf->stereo ? 2 : 1)
-                      * (conf->aux_buffers ? 2 : 1)
-                      * conf->buffers
-                      * ((conf->total_stencil_bit_depths >
-                          0) ? conf->total_stencil_bit_depths : 1)
-                      * conf->total_color_buffers
-                      * ((conf->total_accum_buffers >
-                          0) ? conf->total_accum_buffers : 1)
-                      * conf->total_depth_buffer_depths
-                      * (conf->multisample_buffers + 1);
+	    * (conf->aux_buffers ? 2 : 1)
+	    * conf->buffers
+	    * ((conf->total_stencil_bit_depths > 0) ? conf->total_stencil_bit_depths : 1)
+	    * conf->total_color_buffers
+	    * ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1)
+	    * conf->total_depth_buffer_depths
+	    * (conf->multisample_buffers + 1);
     }
 
-    if (numConfigsPtr)
+    if(numConfigsPtr)
         *numConfigsPtr = numConfigs;
 
     visualConfigs = calloc(sizeof(*visualConfigs), numConfigs);
 
-    if (NULL == visualConfigs) {
+    if(NULL == visualConfigs) {
         ErrorF("xcalloc failure when allocating visualConfigs\n");
         freeGlCapabilities(&caps);
         return NULL;
     }
 
     c = visualConfigs; /* current buffer */
-    for (conf = caps.configurations; conf; conf = conf->next) {
-        for (stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
-            for (aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
-                for (buffers = 0; buffers < conf->buffers; ++buffers) {
-                    for (stencil = 0;
-                         stencil < ((conf->total_stencil_bit_depths > 0) ?
-                                    conf->
-                                    total_stencil_bit_depths : 1);
-                         ++stencil) {
-                        for (color = 0; color < conf->total_color_buffers;
-                             ++color) {
-                            for (accum = 0;
-                                 accum < ((conf->total_accum_buffers > 0) ?
-                                          conf->
-                                          total_accum_buffers : 1);
-                                 ++accum) {
-                                for (depth = 0;
-                                     depth < conf->total_depth_buffer_depths;
-                                     ++depth) {
-                                    for (msample = 0;
-                                         msample <
-                                         (conf->multisample_buffers + 1);
-                                         ++msample) {
+    for(conf = caps.configurations; conf; conf = conf->next) {
+        for(stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
+            for(aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
+                for(buffers = 0; buffers < conf->buffers; ++buffers) {
+                    for(stencil = 0; stencil < ((conf->total_stencil_bit_depths > 0) ?
+                                                conf->total_stencil_bit_depths : 1); ++stencil) {
+                        for(color = 0; color < conf->total_color_buffers; ++color) {
+                            for(accum = 0; accum < ((conf->total_accum_buffers > 0) ?
+                                                    conf->total_accum_buffers : 1); ++accum) {
+                                for(depth = 0; depth < conf->total_depth_buffer_depths; ++depth) {
+                                    for(msample = 0; msample < (conf->multisample_buffers + 1); ++msample) {
 
                                         // Global
                                         c->visualID = -1;
@@ -162,12 +146,10 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
                                         c->indexBits = 0;
                                         c->pixmapMode = 0; // TODO: What should this be?
 
-                                        if (conf->accelerated) {
+                                        if(conf->accelerated) {
                                             c->visualRating = GLX_NONE;
-                                        }
-                                        else {
-                                            c->visualRating =
-                                                GLX_SLOW_VISUAL_EXT;
+                                        } else {
+                                            c->visualRating = GLX_SLOW_VISUAL_EXT;
                                         }
 
                                         c->transparentPixel = GLX_NONE;
@@ -179,91 +161,52 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
 
                                         c->visualSelectGroup = 0;
 
-                                        c->swapMethod =
-                                            GLX_SWAP_UNDEFINED_OML;
+                                        c->swapMethod = GLX_SWAP_UNDEFINED_OML;
 
                                         // Stereo
                                         c->stereoMode = stereo ? TRUE : FALSE;
 
                                         // Aux buffers
-                                        c->numAuxBuffers =
-                                            aux ? conf->aux_buffers : 0;
+                                        c->numAuxBuffers = aux ? conf->aux_buffers : 0;
 
                                         // Double Buffered
-                                        c->doubleBufferMode =
-                                            buffers ? TRUE : FALSE;
+                                        c->doubleBufferMode = buffers ? TRUE : FALSE;
 
                                         // Stencil Buffer
-                                        if (conf->total_stencil_bit_depths >
-                                            0) {
-                                            c->stencilBits =
-                                                conf->stencil_bit_depths[
-                                                    stencil];
-                                        }
-                                        else {
+                                        if(conf->total_stencil_bit_depths > 0) {
+                                            c->stencilBits = conf->stencil_bit_depths[stencil];
+                                        } else {
                                             c->stencilBits = 0;
                                         }
 
                                         // Color
-                                        if (GLCAPS_COLOR_BUF_INVALID_VALUE !=
-                                            conf->color_buffers[color].a) {
-                                            c->alphaBits =
-                                                conf->color_buffers[color].a;
-                                        }
-                                        else {
+                                        if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->color_buffers[color].a) {
+                                            c->alphaBits = conf->color_buffers[color].a;
+                                        } else {
                                             c->alphaBits = 0;
                                         }
-                                        c->redBits =
-                                            conf->color_buffers[color].r;
-                                        c->greenBits =
-                                            conf->color_buffers[color].g;
-                                        c->blueBits =
-                                            conf->color_buffers[color].b;
-
-                                        c->rgbBits = c->alphaBits +
-                                                     c->redBits +
-                                                     c->greenBits +
-                                                     c->blueBits;
-
-                                        c->alphaMask =
-                                            AM_ARGB(c->alphaBits, c->redBits,
-                                                    c->greenBits,
-                                                    c->blueBits);
-                                        c->redMask =
-                                            RM_ARGB(c->alphaBits, c->redBits,
-                                                    c->greenBits,
-                                                    c->blueBits);
-                                        c->greenMask =
-                                            GM_ARGB(c->alphaBits, c->redBits,
-                                                    c->greenBits,
-                                                    c->blueBits);
-                                        c->blueMask =
-                                            BM_ARGB(c->alphaBits, c->redBits,
-                                                    c->greenBits,
-                                                    c->blueBits);
+                                        c->redBits   = conf->color_buffers[color].r;
+                                        c->greenBits = conf->color_buffers[color].g;
+                                        c->blueBits  = conf->color_buffers[color].b;
+
+                                        c->rgbBits = c->alphaBits + c->redBits + c->greenBits + c->blueBits;
+
+                                        c->alphaMask = AM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
+                                        c->redMask   = RM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
+                                        c->greenMask = GM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
+                                        c->blueMask  = BM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
 
                                         // Accumulation Buffers
-                                        if (conf->total_accum_buffers > 0) {
-                                            c->accumRedBits =
-                                                conf->accum_buffers[accum].r;
-                                            c->accumGreenBits =
-                                                conf->accum_buffers[accum].g;
-                                            c->accumBlueBits =
-                                                conf->accum_buffers[accum].b;
-                                            if (
-                                                GLCAPS_COLOR_BUF_INVALID_VALUE
-                                                !=
-                                                conf->accum_buffers[accum].a)
-                                            {
-                                                c->accumAlphaBits =
-                                                    conf->accum_buffers[accum
-                                                    ].a;
-                                            }
-                                            else {
+                                        if(conf->total_accum_buffers > 0) {
+                                            c->accumRedBits = conf->accum_buffers[accum].r;
+                                            c->accumGreenBits = conf->accum_buffers[accum].g;
+                                            c->accumBlueBits = conf->accum_buffers[accum].b;
+                                            if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) {
+                                                c->accumAlphaBits = conf->accum_buffers[accum].a;
+                                            } else {
                                                 c->accumAlphaBits = 0;
                                             }
-                                        }
-                                        else {
+                                        } else {
                                             c->accumRedBits = 0;
                                             c->accumGreenBits = 0;
                                             c->accumBlueBits = 0;
@@ -271,17 +214,13 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
                                         }
 
                                         // Depth
-                                        c->depthBits =
-                                            conf->depth_buffers[depth];
+                                        c->depthBits = conf->depth_buffers[depth];
 
                                         // MultiSample
-                                        if (msample > 0) {
-                                            c->samples =
-                                                conf->multisample_samples;
-                                            c->sampleBuffers =
-                                                conf->multisample_buffers;
-                                        }
-                                        else {
+                                        if(msample > 0) {
+                                            c->samples = conf->multisample_samples;
+                                            c->sampleBuffers = conf->multisample_buffers;
+                                        } else {
                                             c->samples = 0;
                                             c->sampleBuffers = 0;
                                         }
@@ -291,9 +230,7 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
                                          * GLXPbuffers in direct mode.
                                          */
                                         /* SGIX_fbconfig / GLX 1.3 */
-                                        c->drawableType = GLX_WINDOW_BIT |
-                                                          GLX_PIXMAP_BIT |
-                                                          GLX_PBUFFER_BIT;
+                                        c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
                                         c->renderType = GLX_RGBA_BIT;
                                         c->xRenderable = GL_TRUE;
                                         c->fbconfigID = -1;
@@ -310,8 +247,7 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
                                          */
                                         c->maxPbufferWidth = 8192;
                                         c->maxPbufferHeight = 8192;
-                                        c->maxPbufferPixels =
-                                            /*Do we need this?*/ 0;
+                                        c->maxPbufferPixels = /*Do we need this?*/ 0;
                                         /*
                                          * There is no introspection for this sort of thing
                                          * with CGL.  What should we do realistically?
@@ -337,12 +273,10 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
         }
     }
 
-    (c - 1)->next = NULL;
+    (c-1)->next = NULL;
 
     if (c - visualConfigs != numConfigs) {
-        FatalError(
-            "numConfigs calculation error in setVisualConfigs!  numConfigs is %d  i is %d\n",
-            numConfigs, (int)(c - visualConfigs));
+        FatalError("numConfigs calculation error in setVisualConfigs!  numConfigs is %d  i is %d\n", numConfigs, (int)(c - visualConfigs));
     }
 
     freeGlCapabilities(&caps);
commit 3420a7778c7d5eaa638327f31dd460554c257bb1
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Dec 12 11:02:19 2012 +1000

    xfree86: print message to the log when zapping the server
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 9dabf10..d8d4fad 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -180,6 +180,7 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
     switch (action) {
     case ACTION_TERMINATE:
         if (!xf86Info.dontZap) {
+            xf86Msg(X_INFO, "Server zapped. Shutting down.\n");
 #ifdef XFreeXDGA
             DGAShutdown();
 #endif
commit 6d508b81857edaed03c7ee06410434ea56d9b701
Merge: d982d87 bb6f351
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Dec 17 11:45:45 2012 -0800

    Merge remote-tracking branch 'whot/for-keith'
    
    I've looked at these patches, but I can't say I've actually
    reviewed them...

commit d982d877436377597b8ed04bca1438d2edaf53ee
Merge: da3eaf6 6b4aa8a
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Dec 17 10:56:12 2012 -0800

    Merge remote-tracking branch 'airlied/for-keithp'

commit da3eaf6bdbd7ce3bebf2c490cbe2448b4c402dba
Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Dec 17 15:40:17 2012 +1000

    glx/dri2: initialise api to avoid indirect rendering failing randomly
    
    Running glxinfo under indirect rendering would randomly fail against the
    intel driver, as it would create a context with no attribs, and then the
    api value would be passed to the driver uninitialised.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index bce1bfa..b26e501 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -514,7 +514,7 @@ create_driver_context(__GLXDRIcontext * context,
         unsigned minor_ver;
         uint32_t flags;
         int reset;
-        int api;
+        int api = __DRI_API_OPENGL;
 
         if (num_attribs != 0) {
             if (!dri2_convert_glx_attribs(screen, num_attribs, attribs,
commit bb6f3514ca17d993c1af380e8d4480d61e5bbcae
Merge: f961c3a 08da994
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Dec 12 17:25:28 2012 +1000

    Merge branch 'stack-smash-on-touchpoint' into for-keith

commit f961c3a3b9dfbe1201da317c24797ba7f979731e
Merge: 36740d0 39f19b3
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Dec 12 17:25:23 2012 +1000

    Merge branch 'touch-selection-conflict-fixes' into for-keith

commit 39f19b3f3b8c9b714e70e339dfb0083ff629ab2a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Nov 20 11:48:31 2012 +1000

    Xi: fix touch event selction conflicts (#57301)
    
    There are limits on which client may select for touch events on a given
    window, with restrictions being that no two clients can select on the same
    device, but narrower selections are allowed, i.e. if one client has
    XIAllDevices, a second client may still select for device X.
    
    The current code had a dependency on which client selected first and which
    device, resulting in inconsistencies when selecting for events. Fix that,
    responding with the right errors regardless of who selected what first.
    
    X.Org Bug 57301 <http://bugs.freedesktop.org/show_bug.cgi?id=57301>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index ab1b624..45a996e 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -37,6 +37,57 @@
 #include "xiselectev.h"
 
 /**
+ * Ruleset:
+ * - if A has XIAllDevices, B may select on device X
+ * - If A has XIAllDevices, B may select on XIAllMasterDevices
+ * - If A has XIAllMasterDevices, B may select on device X
+ * - If A has XIAllMasterDevices, B may select on XIAllDevices
+ * - if A has device X, B may select on XIAllDevices/XIAllMasterDevices
+ */
+static int check_for_touch_selection_conflicts(ClientPtr B, WindowPtr win, int deviceid)
+{
+    OtherInputMasks *inputMasks = wOtherInputMasks(win);
+    InputClients *A = NULL;
+
+    if (inputMasks)
+        A = inputMasks->inputClients;
+    for (; A; A = A->next) {
+        DeviceIntPtr tmp;
+
+        if (CLIENT_ID(A->resource) == B->index)
+            continue;
+
+        if (deviceid == XIAllDevices)
+            tmp = inputInfo.all_devices;
+        else if (deviceid == XIAllMasterDevices)
+            tmp = inputInfo.all_master_devices;
+        else
+            dixLookupDevice(&tmp, deviceid, serverClient, DixReadAccess);
+        if (!tmp)
+            return BadImplementation;       /* this shouldn't happen */
+
+        /* A has XIAllDevices */
+        if (xi2mask_isset_for_device(A->xi2mask, inputInfo.all_devices, XI_TouchBegin)) {
+            if (deviceid == XIAllDevices)
+                return BadAccess;
+        }
+
+        /* A has XIAllMasterDevices */
+        if (xi2mask_isset_for_device(A->xi2mask, inputInfo.all_master_devices, XI_TouchBegin)) {
+            if (deviceid == XIAllMasterDevices)
+                return BadAccess;
+        }
+
+        /* A has this device */
+        if (xi2mask_isset_for_device(A->xi2mask, tmp, XI_TouchBegin))
+            return BadAccess;
+    }
+
+    return Success;
+}
+
+
+/**
  * Check the given mask (in len bytes) for invalid mask bits.
  * Invalid mask bits are any bits above XI2LastEvent.
  *
@@ -169,30 +220,11 @@ ProcXISelectEvents(ClientPtr client)
              * same devices, including master devices.
              * XXX: This breaks if a device goes from floating to attached. */
             if (BitIsOn(bits, XI_TouchBegin)) {
-                OtherInputMasks *inputMasks = wOtherInputMasks(win);
-                InputClients *iclient = NULL;
-
-                if (inputMasks)
-                    iclient = inputMasks->inputClients;
-                for (; iclient; iclient = iclient->next) {
-                    DeviceIntPtr tmp;
-
-                    if (CLIENT_ID(iclient->resource) == client->index)
-                        continue;
-
-                    if (evmask->deviceid == XIAllDevices)
-                        tmp = inputInfo.all_devices;
-                    else if (evmask->deviceid == XIAllMasterDevices)
-                        tmp = inputInfo.all_master_devices;
-                    else
-                        dixLookupDevice(&tmp, evmask->deviceid, serverClient,
-                                        DixReadAccess);
-                    if (!tmp)
-                        return BadImplementation;       /* this shouldn't happen */
-
-                    if (xi2mask_isset(iclient->xi2mask, tmp, XI_TouchBegin))
-                        return BadAccess;
-                }
+                rc = check_for_touch_selection_conflicts(client,
+                                                         win,
+                                                         evmask->deviceid);
+                if (rc != Success)
+                    return rc;
             }
         }
 
commit a7c97d737ef0d14ec97869082decd049637cfe7a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Nov 20 11:38:39 2012 +1000

    dix: split xi2_mask_isset into a per-device function
    
    For touch selection conflicts, we need to check not only if the mask is set
    for the device, but if it is set for only that specific device (regardless
    of XIAll*Devices)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index eb2222a..9e38e17 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -1016,6 +1016,21 @@ xi2mask_free(XI2Mask **mask)
 }
 
 /**
+ * Test if the bit for event type is set for this device only.
+ *
+ * @return TRUE if the bit is set, FALSE otherwise
+ */
+Bool
+xi2mask_isset_for_device(XI2Mask *mask, const DeviceIntPtr dev, int event_type)
+{
+    BUG_WARN(dev->id < 0);
+    BUG_WARN(dev->id >= mask->nmasks);
+    BUG_WARN(bits_to_bytes(event_type + 1) > mask->mask_size);
+
+    return BitIsOn(mask->masks[dev->id], event_type);
+}
+
+/**
  * Test if the bit for event type is set for this device, or the
  * XIAllDevices/XIAllMasterDevices (if applicable) is set.
  *
@@ -1026,15 +1041,12 @@ xi2mask_isset(XI2Mask *mask, const DeviceIntPtr dev, int event_type)
 {
     int set = 0;
 
-    BUG_WARN(dev->id < 0);
-    BUG_WARN(dev->id >= mask->nmasks);
-    BUG_WARN(bits_to_bytes(event_type + 1) > mask->mask_size);
-
-    set = ! !BitIsOn(mask->masks[XIAllDevices], event_type);
-    if (!set)
-        set = ! !BitIsOn(mask->masks[dev->id], event_type);
-    if (!set && IsMaster(dev))
-        set = ! !BitIsOn(mask->masks[XIAllMasterDevices], event_type);
+    if (xi2mask_isset_for_device(mask, inputInfo.all_devices, event_type))
+        set = 1;
+    else if (xi2mask_isset_for_device(mask, dev, event_type))
+        set = 1;
+    else if (IsMaster(dev) && xi2mask_isset_for_device(mask, inputInfo.all_master_devices, event_type))
+        set = 1;
 
     return set;
 }
diff --git a/include/inpututils.h b/include/inpututils.h
index cd9a4de..53c96ba 100644
--- a/include/inpututils.h
+++ b/include/inpututils.h
@@ -57,6 +57,7 @@ XI2Mask *xi2mask_new(void);
 XI2Mask *xi2mask_new_with_size(size_t, size_t); /* don't use it */
 void xi2mask_free(XI2Mask **mask);
 Bool xi2mask_isset(XI2Mask *mask, const DeviceIntPtr dev, int event_type);
+Bool xi2mask_isset_for_device(XI2Mask *mask, const DeviceIntPtr dev, int event_type);
 void xi2mask_set(XI2Mask *mask, int deviceid, int event_type);
 void xi2mask_zero(XI2Mask *mask, int deviceid);
 void xi2mask_merge(XI2Mask *dest, const XI2Mask *source);
diff --git a/test/xi2/xi2.c b/test/xi2/xi2.c
index 6ee7052..1cdad1d 100644
--- a/test/xi2/xi2.c
+++ b/test/xi2/xi2.c
@@ -36,8 +36,14 @@ xi2mask_test(void)
     XI2Mask *xi2mask = NULL, *mergemask = NULL;
     unsigned char *mask;
     DeviceIntRec dev;
+    DeviceIntRec all_devices, all_master_devices;
     int i;
 
+    all_devices.id = XIAllDevices;
+    inputInfo.all_devices = &all_devices;
+    all_master_devices.id = XIAllMasterDevices;
+    inputInfo.all_master_devices = &all_master_devices;
+
     /* size >= nmasks * 2 for the test cases below */
     xi2mask = xi2mask_new_with_size(MAXDEVICES + 2, (MAXDEVICES + 2) * 2);
     assert(xi2mask);
commit 08da994a08bb74afae81176c56fb525d0439274b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Nov 26 12:33:29 2012 +1000

    dix: add FIXME, TouchRemovePointerGrab does nothing
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/touch.c b/dix/touch.c
index f4a93c6..d890b62 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -915,6 +915,8 @@ TouchRemovePointerGrab(DeviceIntPtr dev)
     ti = TouchFindByClientID(dev, ev->touchid);
     if (!ti)
         return;
+
+    /* FIXME: missing a bit of code here... */
 }
 
 /* As touch grabs don't turn into active grabs with their own resources, we
commit 00def5144557cfe8bf535f926212a8e084dc7cf6
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Nov 26 14:55:13 2012 +1000

    Xi: if a TouchEnd appears on a actively grabbing client, always accept
    
    Once the TouchEnd appears on the device, the touch is done. If the client
    still has a pointer grab, accept it to avoid clients with TouchOwnership
    selections to wait indefinitely for the actual touch event.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index ae126df..4c1aeb4 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1566,32 +1566,41 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
     else
         ti = TouchFindByClientID(dev, touchid);
 
-    /* Under the following circumstances we create a new touch record for an
-     * existing touch:
-     *
-     * - The touch may be pointer emulated
-     * - An explicit grab is active on the device
-     * - The grab is a pointer grab
-     *
-     * This allows for an explicit grab to receive pointer events for an already
-     * active touch.
-     */
-    if (!ti && type != ET_TouchBegin && emulate_pointer &&
-        dev->deviceGrab.grab && !dev->deviceGrab.fromPassiveGrab &&
+    /* Active pointer grab */
+    if (emulate_pointer && dev->deviceGrab.grab && !dev->deviceGrab.fromPassiveGrab &&
         (dev->deviceGrab.grab->grabtype == CORE ||
          dev->deviceGrab.grab->grabtype == XI ||
-         !xi2mask_isset(dev->deviceGrab.grab->xi2mask, dev, XI_TouchBegin))) {
-        ti = TouchBeginTouch(dev, ev->device_event.sourceid, touchid,
-                             emulate_pointer);
-        if (!ti) {
-            DebugF("[Xi] %s: Failed to create new dix record for explicitly "
-                   "grabbed touchpoint %d\n",
-                   dev->name, touchid);
-            return;
-        }
+         !xi2mask_isset(dev->deviceGrab.grab->xi2mask, dev, XI_TouchBegin)))
+    {
+        /* Active pointer grab on touch point and we get a TouchEnd - claim this
+         * touchpoint accepted, otherwise clients waiting for ownership will
+         * wait on this touchpoint until this client ungrabs, or the cows come
+         * home, whichever is earlier */
+        if (ti && type == ET_TouchEnd)
+            TouchListenerAcceptReject(dev, ti, 0, XIAcceptTouch);
+        else if (!ti && type != ET_TouchBegin) {
+            /* Under the following circumstances we create a new touch record for an
+             * existing touch:
+             *
+             * - The touch may be pointer emulated
+             * - An explicit grab is active on the device
+             * - The grab is a pointer grab
+             *
+             * This allows for an explicit grab to receive pointer events for an already
+             * active touch.
+             */
+            ti = TouchBeginTouch(dev, ev->device_event.sourceid, touchid,
+                                 emulate_pointer);
+            if (!ti) {
+                DebugF("[Xi] %s: Failed to create new dix record for explicitly "
+                       "grabbed touchpoint %d\n",
+                       dev->name, touchid);
+                return;
+            }
 
-        TouchBuildSprite(dev, ti, ev);
-        TouchSetupListeners(dev, ti, ev);
+            TouchBuildSprite(dev, ti, ev);
+            TouchSetupListeners(dev, ti, ev);
+        }
     }
 
     if (!ti) {
commit ece8157a59751b3ed492fb2e1eb8d5f20221e195
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Nov 26 15:14:19 2012 +1000

    dix: when deactivating pointer-only grabs, don't emulate TouchEnd events
    
    A client with a pointer grab on a touch device must reject the touch when
    detactivating the grab while the touch is active. However, such a rejecting
    must not trigger a ButtonRelease event to be emulated and sent to the
    client.
    Set the grabbing listener's state to HAS_END, so we simply skip delivery to
    that client.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 03ed106..31f8d87 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1513,8 +1513,15 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
      * all the touches' listener lists. */
     for (i = 0; !wasPassive && mouse->touch && i < mouse->touch->num_touches; i++) {
         TouchPointInfoPtr ti = mouse->touch->touches + i;
-        if (ti->active && TouchResourceIsOwner(ti, grab_resource))
+        if (ti->active && TouchResourceIsOwner(ti, grab_resource)) {
+            /* Rejecting will generate a TouchEnd, but we must not
+               emulate a ButtonRelease here. So pretend the listener
+               already has the end event */
+            if (grab->grabtype == CORE || grab->grabtype == XI ||
+                    !xi2mask_isset(dev->deviceGrab.grab->xi2mask, dev, XI_TouchBegin))
+                ti->listeners[0].state = LISTENER_HAS_END;
             TouchListenerAcceptReject(mouse, ti, 0, XIRejectTouch);
+        }
     }
 
     TouchRemovePointerGrab(mouse);
commit bc1f90a615018c05994fae3e678dd2341256cd82
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Nov 26 12:23:54 2012 +1000

    dix: only reject active grabs on ungrab and do it before actually ungrabbing
    
    An active grab ungrabbing is the same as rejecting the grab, since the
    client is no longer interested in those events. So reject any touch grab,
    but do so before actually deactivating since we're interested in the
    TouchEnd for the current grabbing client.
    
    A passive grab otoh is _not_ like rejecting a grab, since it deactivates
    automatically when the touch ends.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 3282ef8..03ed106 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1503,11 +1503,20 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
 {
     GrabPtr grab = mouse->deviceGrab.grab;
     DeviceIntPtr dev;
+    Bool wasPassive = mouse->deviceGrab.fromPassiveGrab;
     Bool wasImplicit = (mouse->deviceGrab.fromPassiveGrab &&
                         mouse->deviceGrab.implicitGrab);
     XID grab_resource = grab->resource;
     int i;
 
+    /* If an explicit grab was deactivated, we must remove it from the head of
+     * all the touches' listener lists. */
+    for (i = 0; !wasPassive && mouse->touch && i < mouse->touch->num_touches; i++) {
+        TouchPointInfoPtr ti = mouse->touch->touches + i;
+        if (ti->active && TouchResourceIsOwner(ti, grab_resource))
+            TouchListenerAcceptReject(mouse, ti, 0, XIRejectTouch);
+    }
+
     TouchRemovePointerGrab(mouse);
 
     mouse->valuator->motionHintWindow = NullWindow;
commit 146f48c2934fc85ec095496da5c8f0102bc7f5b5
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Nov 22 13:49:34 2012 +1000

    dix: don't call ProcessInputEvents() when accepting/rejecting touches
    
    TouchListenerAcceptReject may be called during normal event processing, but
    ProcessInputEvents is not reentrant and calling it here smashes the event
    queue.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/touch.c b/dix/touch.c
index 29ba171..f4a93c6 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -987,8 +987,6 @@ TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener,
     for (i = 0; i < nev; i++)
         mieqProcessDeviceEvent(dev, events + i, NULL);
 
-    ProcessInputEvents();
-
     FreeEventList(events, GetMaximumEventsNum());
 
     return nev ? Success : BadMatch;
commit ead21f9426122536adfb4787ac181008ae83cd4b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Nov 19 16:16:10 2012 +1000

    Xi: fix typo "mechansims" → "mechanisms"
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 2caf98c..ae126df 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1409,7 +1409,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
     ptrev->device_event.corestate = event_get_corestate(dev, kbd);
 
     if (grab) {
-        /* this side-steps the usual activation mechansims, but... */
+        /* this side-steps the usual activation mechanisms, but... */
         if (ev->any.type == ET_TouchBegin && !dev->deviceGrab.grab)
             ActivatePassiveGrab(dev, grab, ptrev, ev);  /* also delivers the event */
         else {
commit 6b4aa8a359822cc70666de3b18744f05dd9b5f45
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Dec 12 12:56:46 2012 +1000

    Revert "xf86: Fix non-PCI configuration-less setups"
    
    This reverts commit 76d9c62eb2be2010a19bf36285012d086cdd180b.
    
    This breaks multi-GPU setups here, so lets drop it for now.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 599d84a..0525e39 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -377,14 +377,6 @@ xf86platformProbeDev(DriverPtr drvp)
             continue;
     }
 
-    /*
-     * If all of the above fails, which can happen if X was started without
-     * configuration or if BusID wasn't set for non-PCI devices, use the first
-     * device by default.
-     */
-    if (!foundScreen && xf86_num_platform_devices > 0 && numDevs > 0)
-        foundScreen = probeSingleDevice(&xf86_platform_devices[0], drvp, devList[0], 0);
-
     /* if autoaddgpu devices is enabled then go find a few more and add them as GPU screens */
     if (xf86Info.autoAddGPU && numDevs) {
         for (j = 0; j < xf86_num_platform_devices; j++) {
commit 785af88ab0120036e0ce3d0139f3c560ff71e10b
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Sep 26 16:16:40 2012 +1000

    dri1: fix dri1 startup since 459c6da0f907ba33d733c7e62a116184ba2f14e5
    
    This commit regresses dri1 since it moves the drmSetServerInfo from being
    called at module load time to extension init time. However DRIScreenInit
    relies on this being called before it gets control.
    
    This patches moves the call into DRIScreenInit and seems to work here.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 398178e..6292e87 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -320,6 +320,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     DRIContextFlags flags = 0;
     DRIContextPrivPtr pDRIContextPriv;
+    static Bool drm_server_inited;
 
     /* If the DRI extension is disabled, do not initialize the DRI */
     if (noXFree86DRIExtension) {
@@ -345,6 +346,10 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
         return FALSE;
     }
 #endif
+    if (drm_server_inited == FALSE) {
+        drmSetServerInfo(&DRIDRMServerInfo);
+        drm_server_inited = TRUE;
+    }
 
     if (!DRIOpenDRMMaster(pScrn, pDRIInfo->SAREASize,
                           pDRIInfo->busIdString, pDRIInfo->drmDriverName))
@@ -791,8 +796,6 @@ DRIExtensionInit(void)
 
     RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
 
-    drmSetServerInfo(&DRIDRMServerInfo);
-
     return TRUE;
 }
 
commit 36740d02b9ca117f1404e077367fbbbe271a17d6
Author: Daniel Martin <consume.noise at gmail.com>
Date:   Fri Dec 7 19:38:55 2012 +0100

    xfixes: Fix minor number in QueryVersion
    
    Due to a typo the major version number was passed as minor version to
    version_compare().
    
    Regression-from: ffd4874798ba54f86acac75779a15b4babeaa5f3
    
    Signed-off-by: Daniel Martin <consume.noise at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index 52c57df..48af9ea 100644
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -74,7 +74,7 @@ ProcXFixesQueryVersion(ClientPtr client)
 
     if (version_compare(stuff->majorVersion, stuff->minorVersion,
                         SERVER_XFIXES_MAJOR_VERSION,
-                        SERVER_XFIXES_MAJOR_VERSION) < 0) {
+                        SERVER_XFIXES_MINOR_VERSION) < 0) {
         rep.majorVersion = stuff->majorVersion;
         rep.minorVersion = stuff->minorVersion;
     }
commit 5daa442fe15d9a87112a2def673c99a5f2506dcf
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Dec 4 15:28:14 2012 +1000

    xkb: only post a XTest release if the XTest device has the button down
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 9631502..13051e0 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -732,8 +732,13 @@ ProcessPointerEvent(InternalEvent *ev, DeviceIntPtr mouse)
             if (rc != Success)
                 ErrorF("[xkb] bad sourceid '%d' on button release event.\n",
                         event->sourceid);
-            else if (!IsXTestDevice(source, GetMaster(dev, MASTER_POINTER)))
-                XkbFakeDeviceButton(dev, FALSE, event->detail.key);
+            else if (!IsXTestDevice(source, GetMaster(dev, MASTER_POINTER))) {
+                DeviceIntPtr xtest_device;
+
+                xtest_device = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
+                if (button_is_down(xtest_device, ev->device_event.detail.button, BUTTON_PROCESSED))
+                    XkbFakeDeviceButton(dev, FALSE, event->detail.key);
+            }
         }
 
         if (xkbi)
commit c4fee9d2ecd6fdd4c05b04c9f02b23f10f2938b8
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Dec 4 15:03:37 2012 +1000

    xkb: always post XTest button up when the physical button released (#28808)
    
    Regression introduced by commit 2decff6393a44b56d80d53570718f95354fde454
      xkb: ProcesssPointerEvent must work on the VCP if it gets the VCP
    
    XTest buttons must be released when a physical button is released. This was
    fixed in 14327858391ebe929b806efb53ad79e789361883, but
    2decff6393a44b56d80d53570718f95354fde454 changed a condition that this code
    didn't get triggered anymore.
    
    "dev" for pointer events is now always the VCP which doesn't have a xkbi
    struct. So move this condition out and always trigger the XTest released for
    button events.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Tested-by: Frank Roscher <Frank-Roscher at gmx.net>

diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 21df85d..9631502 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -723,23 +723,22 @@ ProcessPointerEvent(InternalEvent *ev, DeviceIntPtr mouse)
         changed |= XkbPointerButtonMask;
     }
     else if (event->type == ET_ButtonRelease) {
-        if (xkbi) {
-            xkbi->lockedPtrButtons &= ~(1 << (event->detail.key & 0x7));
-
-            if (IsMaster(dev)) {
-                DeviceIntPtr source;
-                int rc;
-
-                rc = dixLookupDevice(&source, event->sourceid, serverClient,
-                                     DixWriteAccess);
-                if (rc != Success)
-                    ErrorF("[xkb] bad sourceid '%d' on button release event.\n",
-                           event->sourceid);
-                else if (!IsXTestDevice(source, GetMaster(dev, MASTER_POINTER)))
-                    XkbFakeDeviceButton(dev, FALSE, event->detail.key);
-            }
+        if (IsMaster(dev)) {
+            DeviceIntPtr source;
+            int rc;
+
+            rc = dixLookupDevice(&source, event->sourceid, serverClient,
+                    DixWriteAccess);
+            if (rc != Success)
+                ErrorF("[xkb] bad sourceid '%d' on button release event.\n",
+                        event->sourceid);
+            else if (!IsXTestDevice(source, GetMaster(dev, MASTER_POINTER)))
+                XkbFakeDeviceButton(dev, FALSE, event->detail.key);
         }
 
+        if (xkbi)
+            xkbi->lockedPtrButtons &= ~(1 << (event->detail.key & 0x7));
+
         changed |= XkbPointerButtonMask;
     }
 
commit b51a1bd2766e7dc975ca8f1cacc3f8bd0e1a68a3
Merge: e9ea96d ce6b652
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Nov 30 09:31:46 2012 -0800

    Merge remote-tracking branch 'whot/for-keith'

commit e9ea96d6a88f197928c82b008953f1810de6f792
Author: Dave Airlie <airlied at gmail.com>
Date:   Fri Nov 30 20:54:38 2012 +1000

    randr: call RRProviderInit in the proper place.
    
    No idea where this got lost across development cycles, but its
    definitely missing.
    
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=57448
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/randr/randr.c b/randr/randr.c
index da48c3f..f0decfc 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -264,6 +264,8 @@ RRInit(void)
             return FALSE;
         if (!RROutputInit())
             return FALSE;
+        if (!RRProviderInit())
+            return FALSE;
         RRGeneration = serverGeneration;
     }
     if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0))
commit ce6b6529290f7d42717aad3fd8a83aaaaf8962de
Merge: 6e18599 3b9f1c7
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Nov 29 14:49:22 2012 +1000

    Merge branch 'high-resolution-touch-devices' into for-keith

commit 6e18599d691036eca6ff082c17727d9ffb926984
Author: Sybren van Elderen <sowmestno at msn.com>
Date:   Tue Nov 27 19:27:10 2012 +0100

    hw/dmx: add update_desktop_dimensions() call
    
    The Xdmx server did not update the desktop dimensions when computing screen
    origins.
    
    Signed-off-by: Sybren van Elderen <sowmestno at msn.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index 1a77c7d..35aca81 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -346,6 +346,8 @@ dmxComputeScreenOrigins(void)
             screenInfo.screens[i]->y -= minY;
         }
     }
+
+    update_desktop_dimensions();
 }
 
 /** Recompute origin information in the #dmxScreens list.  This is
commit 59d70b30e93f8be93db9e873423353f7e4419811
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Nov 23 10:05:02 2012 +1000

    dix: use pixman for fp1616 conversions
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Søren Sandmann <ssp at redhat.com>>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index f01e9a7..eb2222a 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -910,11 +910,7 @@ input_option_set_value(InputOption *opt, const char *value)
 double
 fp1616_to_double(FP1616 in)
 {
-    double ret;
-
-    ret = (double) (in >> 16);
-    ret += (double) (in & 0xffff) * (1.0 / (1UL << 16));        /* Optimized: ldexp((double)(in & 0xffff), -16); */
-    return ret;
+    return pixman_fixed_to_double(in);
 }
 
 double
@@ -930,20 +926,7 @@ fp3232_to_double(FP3232 in)
 FP1616
 double_to_fp1616(double in)
 {
-    FP1616 ret;
-    int32_t integral;
-    double tmp;
-    uint32_t frac_d;
-
-    tmp = floor(in);
-    integral = (int32_t) tmp;
-
-    tmp = (in - integral) * (1UL << 16);        /* Optimized: ldexp(in - integral, 16) */
-    frac_d = (uint16_t) tmp;
-
-    ret = integral << 16;
-    ret |= frac_d & 0xffff;
-    return ret;
+    return pixman_double_to_fixed(in);
 }
 
 FP3232
commit 2c4388a00ec308bc2d48ba751ff510cd5c1b2384
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Jun 26 10:30:35 2012 +1000

    xkb: fill in keycode and event type for slow keys enablement
    
    eventType is set for the type that triggered a XkbControlsNotify event.
    Technically, SlowKeys is triggered by a timer which doesn't have a matching
    core event type. So we used to use 0 here.
    
    Practically, the timer is triggered by a key press + hold and cancelled when
    the key is released before the timeout expires. So we might as well set
    KeyPress (keycode) in the ControlsNotify to give clients a chance to differ
    between timer-triggered SlowKeys and client-triggered ones.
    
    This is a chance in behaviour, though I suspect with little impact.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 2b926a9..45e2e8c 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -171,6 +171,7 @@ typedef struct _XkbSrvInfo {
     KeyCode mouseKey;
     KeyCode inactiveKey;
     KeyCode slowKey;
+    KeyCode slowKeyEnableKey;
     KeyCode repeatKey;
     CARD8 krgTimerActive;
     CARD8 beepType;
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index c1af32e..21df85d 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -291,8 +291,8 @@ AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg)
         return 4000;
     }
     xkbi->krgTimerActive = _OFF_TIMER;
-    cn.keycode = 0;
-    cn.eventType = 0;
+    cn.keycode = xkbi->slowKeyEnableKey;
+    cn.eventType = KeyPress;
     cn.requestMajor = 0;
     cn.requestMinor = 0;
     if (xkbi->desc->ctrls->enabled_ctrls & XkbSlowKeysMask) {
@@ -304,6 +304,7 @@ AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg)
         LogMessage(X_INFO, "XKB SlowKeys are now enabled. Hold shift to disable.\n");
     }
 
+    xkbi->slowKeyEnableKey = 0;
     return 0;
 }
 
@@ -462,6 +463,7 @@ AccessXFilterPressEvent(DeviceEvent *event, DeviceIntPtr keybd)
     if (ctrls->enabled_ctrls & XkbAccessXKeysMask) {
         /* check for magic sequences */
         if ((sym[0] == XK_Shift_R) || (sym[0] == XK_Shift_L)) {
+            xkbi->slowKeyEnableKey = key;
             if (XkbAX_NeedFeedback(ctrls, XkbAX_SlowWarnFBMask)) {
                 xkbi->krgTimerActive = _KRG_WARN_TIMER;
                 xkbi->krgTimer = TimerSet(xkbi->krgTimer, 0, 4000,
commit 2dc6d9228456cbc274a1fcea478258e5ae4dc629
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Nov 15 14:00:57 2012 +1000

    When resetting device idle time, reset XIAll(Master)Devices too (#56649)
    
    When the screen saver is forcibly deactivated, the idle time counter is
    reset for all devices but not for the fake XIAllDevices and
    XIAllMasterDevices. XScreenSaverQueryInfo uses XIAlldevices to fill the
    "idle" field, thus returning the wrong value.
    
    Regression introduced in
    commit 6aef209ebc2e54f5465da505a780f7b4cc273ee0
    Author: Peter Hutterer <peter.hutterer at who-t.net>
    Date:   Mon Mar 12 13:51:02 2012 +1000
    
        Change lastDeviceIdleTime to be per-device
    
    X.Org Bug 56649 <http://bugs.freedesktop.org/show_bug.cgi?id=56649>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Tested-by: Giacomo Perale <ghepeu at virgilio.it>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/saver.c b/Xext/saver.c
index ac4a633..f73e2a2 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -393,6 +393,8 @@ ScreenSaverFreeSuspend(pointer value, XID id)
             UpdateCurrentTimeIf();
             nt_list_for_each_entry(dev, inputInfo.devices, next)
                 lastDeviceEventTime[dev->id] = currentTime;
+            lastDeviceEventTime[XIAllDevices] = currentTime;
+            lastDeviceEventTime[XIAllMasterDevices] = currentTime;
             SetScreenSaverTimer();
         }
     }
diff --git a/dix/window.c b/dix/window.c
index e70531a..99b3e0a 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3095,6 +3095,8 @@ dixSaveScreens(ClientPtr client, int on, int mode)
             UpdateCurrentTimeIf();
             nt_list_for_each_entry(dev, inputInfo.devices, next)
                 lastDeviceEventTime[dev->id] = currentTime;
+            lastDeviceEventTime[XIAllDevices] = currentTime;
+            lastDeviceEventTime[XIAllMasterDevices] = currentTime;
         }
         SetScreenSaverTimer();
     }
commit a51b2c3913fc8556f6bd1c76805d045fc424c4bb
Author: Jasper St. Pierre <jstpierre at mecheye.net>
Date:   Tue Nov 20 14:50:41 2012 -0500

    cursor: Revise edge cases for the pointer moving towards barriers
    
    Since barriers block the invisible line between pixels, that means
    that we need to explicitly check the boundaries, or else we'll have
    a potential off-by-one error. This fixes issues when trying to move
    down or right across a barrier and having the pointer visibly bounce.
    
    Signed-off-by: Jasper St. Pierre <jstpierre at mecheye.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index bd175b4..ffee4d6 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -1093,7 +1093,11 @@ barrier_is_blocking(const struct PointerBarrier * barrier,
         if (dir & BarrierNegativeX && x1 == (barrier->x1 - 1))
             return FALSE;
         /* startpoint adjacent to barrier, moving towards -> block */
-        if (x1 == barrier->x1 && y1 >= barrier->y1 && y1 <= barrier->y2) {
+        if (dir & BarrierPositiveX && x1 == (barrier->x1 - 1) && y1 >= barrier->y1 && y1 <= barrier->y2) {
+            *distance = 0;
+            return TRUE;
+        }
+        if (dir & BarrierNegativeX && x1 == barrier->x1 && y1 >= barrier->y1 && y1 <= barrier->y2) {
             *distance = 0;
             return TRUE;
         }
@@ -1105,7 +1109,11 @@ barrier_is_blocking(const struct PointerBarrier * barrier,
         if (dir & BarrierNegativeY && y1 == (barrier->y1 - 1))
             return FALSE;
         /* startpoint adjacent to barrier, moving towards -> block */
-        if (y1 == barrier->y1 && x1 >= barrier->x1 && x1 <= barrier->x2) {
+        if (dir & BarrierPositiveY && y1 == (barrier->y1 - 1) && x1 >= barrier->x1 && x1 <= barrier->x2) {
+            *distance = 0;
+            return TRUE;
+        }
+        if (dir & BarrierNegativeY && y1 == barrier->y1 && x1 >= barrier->x1 && x1 <= barrier->x2) {
             *distance = 0;
             return TRUE;
         }
commit 1712a45422a63f11b2146541279616fcfda09ec6
Merge: e54f71a 338bec3
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Nov 28 07:54:13 2012 -0800

    Merge remote-tracking branch 'jturney/mingw-patches'

commit 338bec30054bb5d41cb6fdb5d37439f3c8124cad
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Fri Nov 9 12:19:31 2012 -0600

    hw/xwin: Fix for MinGW-w64 DirectDraw headers
    
    mingw-w64 headers handle NONAMELESSUNION earlier than mingw.org's, so it must be
    defined before including any headers.  It also provides a ddraw.h, so use it.
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xwin/ddraw.h b/hw/xwin/ddraw.h
index 9463049..1871d95 100644
--- a/hw/xwin/ddraw.h
+++ b/hw/xwin/ddraw.h
@@ -1,3 +1,7 @@
+#ifdef __MINGW64_VERSION_MAJOR
+#include_next <ddraw.h>
+#define __XWIN_DDRAW_H
+#endif
 #ifndef __XWIN_DDRAW_H
 #define __XWIN_DDRAW_H
 
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 7b34e84..6c524f9 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -133,6 +133,8 @@
 
 #define WIN_MAX_KEYS_PER_KEY	4
 
+#define NONAMELESSUNION
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
diff --git a/hw/xwin/winms.h b/hw/xwin/winms.h
index 5282fc9..32923e5 100644
--- a/hw/xwin/winms.h
+++ b/hw/xwin/winms.h
@@ -30,7 +30,6 @@
  * Authors:	Harold L Hunt II
  */
 
-#define NONAMELESSUNION
 #define DIRECTDRAW_VERSION	0x0300
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
commit fb170498abc746a850864b59db2ddcba7ee29215
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Tue Nov 13 13:22:44 2012 +0000

    dix/dispatch.c, os/utils.c: Disable smart scheduler on WIN32
    
    setitimer() and SIGALRM aren't available on WIN32, so smart scheduler
    code cannot be built.  Provide only stubs for smart scheduler timer
    code, and disable smart scheduler by default.
    
    Signed-off-by: Ryan Pavlik <rpavlik at iastate.edu>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Tested-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 2df1a6e..99ba277 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -223,7 +223,11 @@ UpdateCurrentTimeIf(void)
 #define SMART_SCHEDULE_DEFAULT_INTERVAL	20      /* ms */
 #define SMART_SCHEDULE_MAX_SLICE	200     /* ms */
 
+#if defined(WIN32) && !defined(__CYGWIN__)
+Bool SmartScheduleDisable = TRUE;
+#else
 Bool SmartScheduleDisable = FALSE;
+#endif
 long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
 long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
 long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
diff --git a/os/utils.c b/os/utils.c
index 411daa0..6f75c17 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -71,6 +71,7 @@ __stdcall unsigned long GetTickCount(void);
 #if !defined(WIN32) || !defined(__MINGW32__)
 #include <sys/time.h>
 #include <sys/resource.h>
+# define SMART_SCHEDULE_POSSIBLE
 #endif
 #include "misc.h"
 #include <X11/X.h>
@@ -898,6 +899,7 @@ ProcessCommandLine(int argc, char *argv[])
             i = skip - 1;
         }
 #endif
+#ifdef SMART_SCHEDULE_POSSIBLE
         else if (strcmp(argv[i], "-dumbSched") == 0) {
             SmartScheduleDisable = TRUE;
         }
@@ -916,6 +918,7 @@ ProcessCommandLine(int argc, char *argv[])
             else
                 UseMsg();
         }
+#endif
         else if (strcmp(argv[i], "-render") == 0) {
             if (++i < argc) {
                 int policy = PictureParseCmapPolicy(argv[i]);
@@ -1127,6 +1130,7 @@ XNFstrdup(const char *s)
 void
 SmartScheduleStopTimer(void)
 {
+#ifdef SMART_SCHEDULE_POSSIBLE
     struct itimerval timer;
 
     if (SmartScheduleDisable)
@@ -1136,11 +1140,13 @@ SmartScheduleStopTimer(void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = 0;
     (void) setitimer(ITIMER_REAL, &timer, 0);
+#endif
 }
 
 void
 SmartScheduleStartTimer(void)
 {
+#ifdef SMART_SCHEDULE_POSSIBLE
     struct itimerval timer;
 
     if (SmartScheduleDisable)
@@ -1150,6 +1156,7 @@ SmartScheduleStartTimer(void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = SmartScheduleInterval * 1000;
     setitimer(ITIMER_REAL, &timer, 0);
+#endif
 }
 
 static void
@@ -1161,6 +1168,7 @@ SmartScheduleTimer(int sig)
 void
 SmartScheduleInit(void)
 {
+#ifdef SMART_SCHEDULE_POSSIBLE
     struct sigaction act;
 
     if (SmartScheduleDisable)
@@ -1176,6 +1184,7 @@ SmartScheduleInit(void)
         perror("sigaction for smart scheduler");
         SmartScheduleDisable = TRUE;
     }
+#endif
 }
 
 #ifdef SIG_BLOCK
commit b20d2998cd9a1320ef0e45ab6b741c7e25f646e0
Author: Ryan Pavlik <rpavlik at iastate.edu>
Date:   Thu Nov 3 19:25:57 2011 -0500

    os/osinit.c: no getpgrp() and setpgrp() on WIN32
    
    Signed-off-by: Ryan Pavlik <rpavlik at iastate.edu>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Tested-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/os/osinit.c b/os/osinit.c
index 2a946a4..6c66f9c 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -246,8 +246,10 @@ OsInit(void)
 #endif
         }
 
+#if !defined(WIN32) || defined(__CYGWIN__)
         if (getpgrp() == 0)
             setpgid(0, 0);
+#endif
 
 #ifdef RLIMIT_DATA
         if (limitDataSpace >= 0) {
commit 2c712d094a49de0b96e2e9f5bcc1043b54ad0f61
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Sun Oct 14 23:05:30 2012 -0500

    hw/xwin: use raise() instead of kill()
    
    MinGW doesn't have kill(), so use raise() instead
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c
index 8912782..c8508a9 100644
--- a/hw/xwin/winclipboardthread.c
+++ b/hw/xwin/winclipboardthread.c
@@ -36,6 +36,7 @@
 #define HAS_WINSOCK 1
 #endif
 #include <sys/types.h>
+#include <signal.h>
 #include "winclipboard.h"
 #ifdef __CYGWIN__
 #include <errno.h>
@@ -431,7 +432,7 @@ winClipboardProc(void *pvNotUsed)
     else {
         ErrorF("winClipboardProc - Clipboard disabled  - Exit from server \n");
         /* clipboard thread has exited, stop server as well */
-        kill(getpid(), SIGTERM);
+        raise(SIGTERM);
     }
 
     return NULL;
commit 98d5acc1213b2ec71c2a7bd3a3b77a1b5536e963
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Aug 17 13:43:29 2012 +0100

    os/utils.c: Fix compilation of OsBlockSIGIO when SIGIO isn't defined
    
    Fix compilation of OsBlockSIGIO with -Werror=return-type when SIGIO isn't
    defined.
    
    /jhbuild/checkout/xorg/xserver/os/utils.c: In function 'OsBlockSIGIO':
    /jhbuild/checkout/xorg/xserver/os/utils.c:1248:1: error: control reaches end of non-void function [-Wreturn-type]
    
    v2: Shuffle around to avoid writing unreachable code
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Tested-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/os/utils.c b/os/utils.c
index 58df709..411daa0 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1231,10 +1231,10 @@ OsBlockSIGIO(void)
         sigprocmask(SIG_BLOCK, &set, &PreviousSigIOMask);
         ret = sigismember(&PreviousSigIOMask, SIGIO);
         return ret;
-    } else
-        return 1;
+    }
 #endif
 #endif
+    return 1;
 }
 
 void
commit 8e2bac0a69173b51e17a39d70e1d154b47fd0139
Author: Ryan Pavlik <rpavlik at iastate.edu>
Date:   Fri Apr 20 13:46:21 2012 +0100

    os/osinit.c, os/utils.c: Exclude sigaction code when building for MinGW
    
    MinGW doesn't have sigaction, so this patch is needed for building.
    
    No attempt is made to actually install the fatal error signal handler, as MinGW
    will simply terminate the process rather than deliver a fatal signal.
    
    Also avoid using strsignal
    
    Signed-off-by: Ryan Pavlik <rpavlik at iastate.edu>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Tested-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/os/osinit.c b/os/osinit.c
index 45ab527..2a946a4 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -102,6 +102,7 @@ OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper)
  * OsSigHandler --
  *    Catch unexpected signals and exit or continue cleanly.
  */
+#if !defined(WIN32) || defined(__CYGWIN__)
 static void
 #ifdef SA_SIGINFO
 OsSigHandler(int signo, siginfo_t * sip, void *unused)
@@ -146,6 +147,7 @@ OsSigHandler(int signo)
     FatalError("Caught signal %d (%s). Server aborting\n",
                signo, strsignal(signo));
 }
+#endif /* !WIN32 || __CYGWIN__ */
 
 void
 OsInit(void)
@@ -155,6 +157,7 @@ OsInit(void)
     char fname[PATH_MAX];
 
     if (!been_here) {
+#if !defined(WIN32) || defined(__CYGWIN__)
         struct sigaction act, oact;
         int i;
 
@@ -181,6 +184,8 @@ OsInit(void)
                        siglist[i], strerror(errno));
             }
         }
+#endif /* !WIN32 || __CYGWIN__ */
+
 #ifdef HAVE_BACKTRACE
         /*
          * initialize the backtracer, since the ctor calls dlopen(), which
diff --git a/os/utils.c b/os/utils.c
index 3c520ad..58df709 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -212,6 +212,9 @@ sig_atomic_t inSignalContext = FALSE;
 OsSigHandlerPtr
 OsSignal(int sig, OsSigHandlerPtr handler)
 {
+#if defined(WIN32) && !defined(__CYGWIN__)
+    return signal(sig, handler);
+#else
     struct sigaction act, oact;
 
     sigemptyset(&act.sa_mask);
@@ -222,6 +225,7 @@ OsSignal(int sig, OsSigHandlerPtr handler)
     if (sigaction(sig, &act, &oact))
         perror("sigaction");
     return oact.sa_handler;
+#endif
 }
 
 /*
commit e54f71a2c7a1677a5c5032d1e7dc099d5204144b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Nov 10 10:26:08 2012 +0000

    xf86: select a fake output for headless servers
    
    Following commit 37d956e3ac9513b74078882dff489f9b0a7a5a28
    Author: Keith Packard <keithp at keithp.com>
    Date:   Mon Sep 10 11:14:20 2012 +1000
    
        xf86: fix compat output selection for no output GPUs
    
    headless servers can no longer startup as we no longer select a compat
    output for the fake framebuffer.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56343
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 177f7ac..13251cf 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1847,6 +1847,10 @@ SetCompatOutput(xf86CrtcConfigPtr config)
         output = config->output[config->compat_output];
     }
 
+    /* All outputs are disconnected, select one to fake */
+    if (!output && config->num_output)
+        output = config->output[0];
+
     return output;
 }
 
commit 76d9c62eb2be2010a19bf36285012d086cdd180b
Author: Thierry Reding <thierry.reding at avionic-design.de>
Date:   Wed Oct 17 12:06:47 2012 +0200

    xf86: Fix non-PCI configuration-less setups
    
    For non-PCI video devices, such as those found on many ARM embedded
    systems, the X server currently requires the BusID option to specify the
    full path to the DRM device's sysfs node in order to properly match it
    against the probed platform devices.
    
    In order to allow X to start up properly if either the BusID option was
    omitted or no configuration is present at all, the first video device is
    used by default.
    
    Signed-off-by: Thierry Reding <thierry.reding at avionic-design.de>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 0525e39..599d84a 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -377,6 +377,14 @@ xf86platformProbeDev(DriverPtr drvp)
             continue;
     }
 
+    /*
+     * If all of the above fails, which can happen if X was started without
+     * configuration or if BusID wasn't set for non-PCI devices, use the first
+     * device by default.
+     */
+    if (!foundScreen && xf86_num_platform_devices > 0 && numDevs > 0)
+        foundScreen = probeSingleDevice(&xf86_platform_devices[0], drvp, devList[0], 0);
+
     /* if autoaddgpu devices is enabled then go find a few more and add them as GPU screens */
     if (xf86Info.autoAddGPU && numDevs) {
         for (j = 0; j < xf86_num_platform_devices; j++) {
commit d50a94568e06a06df682a0028579d37a7b209d15
Merge: 87b60ef cf05db8
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Nov 27 15:14:26 2012 -0800

    Merge remote-tracking branch 'daniels/master'

commit 87b60efb859d86fd9e96306112bc5453a549fa69
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Sun Sep 2 22:39:32 2012 +0100

    hw/xwin: Don't spam MotionNotify events when the mouse hasn't moved
    
    Don't spam MotionNotify events when the mouse hasn't moved, when polling the
    mouse position outside any X window
    
    (Test with 'xev -root' after mouse polling has started.)
    
    Signed-off-by: Colin Harrison <colin.harrison at virgin.net>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index fe662b9..7ba0280 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -930,6 +930,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
         case WIN_POLLING_MOUSE_TIMER_ID:
         {
+            static POINT last_point;
             POINT point;
             WPARAM wL, wM, wR, wShift, wCtrl;
             LPARAM lPos;
@@ -941,8 +942,12 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
             point.x -= GetSystemMetrics(SM_XVIRTUALSCREEN);
             point.y -= GetSystemMetrics(SM_YVIRTUALSCREEN);
 
-            /* Deliver absolute cursor position to X Server */
-            winEnqueueMotion(point.x, point.y);
+            /* If the mouse pointer has moved, deliver absolute cursor position to X Server */
+            if (last_point.x != point.x || last_point.y != point.y) {
+                winEnqueueMotion(point.x, point.y);
+                last_point.x = point.x;
+                last_point.y = point.y;
+            }
 
             /* Check if a button was released but we didn't see it */
             GetCursorPos(&point);
commit 886f4c389266bf759414f15a5e25e50b5935dc9d
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Mon Jun 25 15:58:21 2012 +0100

    hw/xwin: Don't log all fbConfigs and GL/WGL extensions
    
    Don't log all fbConfigs and GL/WGL extensions, unless verbose logging
    is requested
    Log the number of pixelFormats which gave rise to the fbConfigs
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index c0069a2..22c5abc 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -86,6 +86,7 @@
 
 #include <winpriv.h>
 #include <wgl_ext_api.h>
+#include <winglobals.h>
 
 #define NUM_ELEMENTS(x) (sizeof(x)/ sizeof(x[1]))
 
@@ -341,6 +342,10 @@ swap_method_name(int mthd)
 static void
 fbConfigsDump(unsigned int n, __GLXconfig * c)
 {
+    LogMessage(X_INFO, "%d fbConfigs\n", n);
+
+    if (g_iLogVerbose < 3)
+        return;
     ErrorF("%d fbConfigs\n", n);
     ErrorF
         ("pxf vis  fb                      render         Ste                     aux    accum        MS    drawable             Group/\n");
@@ -595,11 +600,14 @@ glxWinScreenProbe(ScreenPtr pScreen)
     gl_renderer = (const char *) glGetStringWrapperNonstatic(GL_RENDERER);
     ErrorF("GL_RENDERER:    %s\n", gl_renderer);
     gl_extensions = (const char *) glGetStringWrapperNonstatic(GL_EXTENSIONS);
-    glxLogExtensions("GL_EXTENSIONS:  ", gl_extensions);
     wgl_extensions = wglGetExtensionsStringARBWrapper(hdc);
     if (!wgl_extensions)
         wgl_extensions = "";
-    glxLogExtensions("WGL_EXTENSIONS: ", wgl_extensions);
+
+    if (g_iLogVerbose >= 3) {
+        glxLogExtensions("GL_EXTENSIONS:  ", gl_extensions);
+        glxLogExtensions("WGL_EXTENSIONS: ", wgl_extensions);
+    }
 
     if (strcasecmp(gl_renderer, "GDI Generic") == 0) {
         free(screen);
@@ -1835,8 +1843,8 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
     // get the number of pixelformats
     numConfigs =
         DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
-    GLWIN_DEBUG_MSG("DescribePixelFormat says %d possible pixel formats",
-                    numConfigs);
+    LogMessage(X_INFO, "%d pixel formats reported by DescribePixelFormat\n",
+               numConfigs);
 
     /* alloc */
     result = malloc(sizeof(GLXWinConfig) * numConfigs);
@@ -2083,9 +2091,9 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
         return;
     }
 
-    GLWIN_DEBUG_MSG
-        ("wglGetPixelFormatAttribivARB says %d possible pixel formats",
-         numConfigs);
+    LogMessage(X_INFO,
+               "%d pixel formats reported by wglGetPixelFormatAttribivARB\n",
+               numConfigs);
 
     /* alloc */
     result = malloc(sizeof(GLXWinConfig) * numConfigs);
commit 9b10f20f472e6b0d6114fb61c88906e349e47f2b
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Feb 10 13:36:46 2012 +0000

    hw/xwin: Use pre-computed extent of damage for creating GDI region
    
    When -clipupdates option is specified, use the pre-computed extent of damage,
    rather than computing a GDI region which combines all the individual boxes in
    the damage.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winshaddd.c b/hw/xwin/winshaddd.c
index 3afc57c..aad3a02 100644
--- a/hw/xwin/winshaddd.c
+++ b/hw/xwin/winshaddd.c
@@ -489,7 +489,7 @@ winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf)
     POINT ptOrigin;
     DWORD dwBox = RegionNumRects(damage);
     BoxPtr pBox = RegionRects(damage);
-    HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+    HRGN hrgnCombined = NULL;
 
     /*
      * Return immediately if the app is not active
@@ -551,15 +551,9 @@ winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf)
         BoxPtr pBoxExtents = RegionExtents(damage);
 
         /* Compute a GDI region from the damaged region */
-        hrgnCombined = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
-        dwBox--;
-        pBox++;
-        while (dwBox--) {
-            hrgnTemp = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
-            CombineRgn(hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
-            DeleteObject(hrgnTemp);
-            pBox++;
-        }
+        hrgnCombined =
+            CreateRectRgn(pBoxExtents->x1, pBoxExtents->y1, pBoxExtents->x2,
+                          pBoxExtents->y2);
 
         /* Install the GDI region as a clipping region */
         SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined);
diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c
index e730615..7668bd1 100644
--- a/hw/xwin/winshadddnl.c
+++ b/hw/xwin/winshadddnl.c
@@ -523,7 +523,7 @@ winShadowUpdateDDNL(ScreenPtr pScreen, shadowBufPtr pBuf)
     POINT ptOrigin;
     DWORD dwBox = RegionNumRects(damage);
     BoxPtr pBox = RegionRects(damage);
-    HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+    HRGN hrgnCombined = NULL;
 
     /*
      * Return immediately if the app is not active
@@ -595,15 +595,9 @@ winShadowUpdateDDNL(ScreenPtr pScreen, shadowBufPtr pBuf)
         BoxPtr pBoxExtents = RegionExtents(damage);
 
         /* Compute a GDI region from the damaged region */
-        hrgnCombined = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
-        dwBox--;
-        pBox++;
-        while (dwBox--) {
-            hrgnTemp = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
-            CombineRgn(hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
-            DeleteObject(hrgnTemp);
-            pBox++;
-        }
+        hrgnCombined =
+            CreateRectRgn(pBoxExtents->x1, pBoxExtents->y1, pBoxExtents->x2,
+                          pBoxExtents->y2);
 
         /* Install the GDI region as a clipping region */
         SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined);
diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c
index cdbb46b..912f7e4 100644
--- a/hw/xwin/winshadgdi.c
+++ b/hw/xwin/winshadgdi.c
@@ -439,7 +439,7 @@ winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf)
     DWORD dwBox = RegionNumRects(damage);
     BoxPtr pBox = RegionRects(damage);
     int x, y, w, h;
-    HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+    HRGN hrgnCombined = NULL;
 
 #ifdef XWIN_UPDATESTATS
     static DWORD s_dwNonUnitRegions = 0;
@@ -500,16 +500,11 @@ winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf)
         }
     }
     else if (!pScreenInfo->fMultiWindow) {
+
         /* Compute a GDI region from the damaged region */
-        hrgnCombined = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
-        dwBox--;
-        pBox++;
-        while (dwBox--) {
-            hrgnTemp = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
-            CombineRgn(hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
-            DeleteObject(hrgnTemp);
-            pBox++;
-        }
+        hrgnCombined =
+            CreateRectRgn(pBoxExtents->x1, pBoxExtents->y1, pBoxExtents->x2,
+                          pBoxExtents->y2);
 
         /* Install the GDI region as a clipping region */
         SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined);
commit 3ab95a2a5c848e8ce4c39be243fd5e2ac6bb1c1a
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Feb 24 15:32:26 2012 +0000

    hw/xwin: Ensure we own the clipboard before checking the format of it's contents
    
    Ensure we own the clipboard before checking the format of it's contents, this
    prevents the contents from changing underneath us.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c
index ce533c5..5cae98c 100644
--- a/hw/xwin/winclipboardxevents.c
+++ b/hw/xwin/winclipboardxevents.c
@@ -165,6 +165,24 @@ winClipboardFlushXEvents(HWND hwnd,
                 break;
             }
 
+            /* Close clipboard if we have it open already */
+            if (GetOpenClipboardWindow() == hwnd) {
+                CloseClipboard();
+            }
+
+            /* Access the clipboard */
+            if (!OpenClipboard(hwnd)) {
+                ErrorF("winClipboardFlushXEvents - SelectionRequest - "
+                       "OpenClipboard () failed: %08lx\n", GetLastError());
+
+                /* Abort */
+                fAbort = TRUE;
+                goto winClipboardFlushXEvents_SelectionRequest_Done;
+            }
+
+            /* Indicate that clipboard was opened */
+            fCloseClipboard = TRUE;
+
             /* Check that clipboard format is available */
             if (fUseUnicode && !IsClipboardFormatAvailable(CF_UNICODETEXT)) {
                 static int count;       /* Hack to stop acroread spamming the log */
@@ -192,24 +210,6 @@ winClipboardFlushXEvents(HWND hwnd,
                 goto winClipboardFlushXEvents_SelectionRequest_Done;
             }
 
-            /* Close clipboard if we have it open already */
-            if (GetOpenClipboardWindow() == hwnd) {
-                CloseClipboard();
-            }
-
-            /* Access the clipboard */
-            if (!OpenClipboard(hwnd)) {
-                ErrorF("winClipboardFlushXEvents - SelectionRequest - "
-                       "OpenClipboard () failed: %08lx\n", GetLastError());
-
-                /* Abort */
-                fAbort = TRUE;
-                goto winClipboardFlushXEvents_SelectionRequest_Done;
-            }
-
-            /* Indicate that clipboard was opened */
-            fCloseClipboard = TRUE;
-
             /* Setup the string style */
             if (event.xselectionrequest.target == XA_STRING)
                 xiccesStyle = XStringStyle;
commit a4f357c620ae9e2270316197a61fb8e1d5183a51
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Mon Apr 9 15:48:08 2012 +0100

    hw/xwin: Disable minimize button on window with skip-taskbar state
    
    If a window has had its taskbar button removed, disable its minimize
    button to prevent it becoming lost
    
    Signed-off-by: Colin Harrison <colin.harrison at virgin.net>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 7f7745f..773fc97 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1731,6 +1731,9 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
     if (hint & HINT_NOSYSMENU)
         style = style & ~WS_SYSMENU;
 
+    if (hint & HINT_SKIPTASKBAR)
+        style = style & ~WS_MINIMIZEBOX;        /* window will become lost if minimized */
+
     SetWindowLongPtr(hWnd, GWL_STYLE, style);
 
     exStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
commit a2983452ee1e2051ab54cded7a3a7735be020db6
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Jul 8 17:48:03 2009 +0100

    hw/xwin: Process _NET_WM_STATE_SKIP_TASKBAR hint in multiwindow mode.
    
    Set WS_EX_TOOLWINDOW style to hide window from Alt-Tab switcher
    
    Use ITaskBarList interface to ensure that the taskbar notices if the window has
    changed it's style in a way which affects if the taskbar shows it or not
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index fbf984d..7f7745f 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1503,6 +1503,7 @@ winDeinitMultiWindowWM(void)
 #define HINT_NOMAXIMIZE (1L<<4)
 #define HINT_NOMINIMIZE (1L<<5)
 #define HINT_NOSYSMENU  (1L<<6)
+#define HINT_SKIPTASKBAR (1L<<7)
 /* These two are used on their own */
 #define HINT_MAX	(1L<<0)
 #define HINT_MIN	(1L<<1)
@@ -1511,12 +1512,14 @@ static void
 winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
 {
     static Atom windowState, motif_wm_hints, windowType;
-    static Atom hiddenState, fullscreenState, belowState, aboveState;
+    static Atom hiddenState, fullscreenState, belowState, aboveState,
+        skiptaskbarState;
     static Atom dockWindow;
     static int generation;
     Atom type, *pAtom = NULL;
     int format;
-    unsigned long hint = 0, maxmin = 0, style, nitems = 0, left = 0;
+    unsigned long hint = 0, maxmin = 0, nitems = 0, left = 0;
+    unsigned long style, exStyle;
     MwmHints *mwm_hint = NULL;
 
     if (!hWnd)
@@ -1535,6 +1538,8 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
         belowState = XInternAtom(pDisplay, "_NET_WM_STATE_BELOW", False);
         aboveState = XInternAtom(pDisplay, "_NET_WM_STATE_ABOVE", False);
         dockWindow = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE_DOCK", False);
+        skiptaskbarState =
+            XInternAtom(pDisplay, "_NET_WM_STATE_SKIP_TASKBAR", False);
     }
 
     if (XGetWindowProperty(pDisplay, iWindow, windowState, 0L,
@@ -1542,6 +1547,8 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
                            &nitems, &left,
                            (unsigned char **) &pAtom) == Success) {
         if (pAtom && nitems == 1) {
+            if (*pAtom == skiptaskbarState)
+                hint |= HINT_SKIPTASKBAR;
             if (*pAtom == hiddenState)
                 maxmin |= HINT_MIN;
             else if (*pAtom == fullscreenState)
@@ -1700,13 +1707,15 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
             HINT_NOFRAME;
 
     /* Now apply styles to window */
-    style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX;      /* Just in case */
+    style = GetWindowLongPtr(hWnd, GWL_STYLE);
     if (!style)
-        return;
+        return;                 /* GetWindowLongPointer returns 0 on failure, we hope this isn't a valid style */
+
+    style &= ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
 
-    if (!hint)                  /* All on */
+    if (!(hint & ~HINT_SKIPTASKBAR))    /* No hints, default */
         style = style | WS_CAPTION | WS_SIZEBOX;
-    else if (hint & HINT_NOFRAME)       /* All off */
+    else if (hint & HINT_NOFRAME)       /* No frame, no decorations */
         style = style & ~WS_CAPTION & ~WS_SIZEBOX;
     else
         style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
@@ -1723,6 +1732,17 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
         style = style & ~WS_SYSMENU;
 
     SetWindowLongPtr(hWnd, GWL_STYLE, style);
+
+    exStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
+    if (hint & HINT_SKIPTASKBAR)
+        exStyle = (exStyle & ~WS_EX_APPWINDOW) | WS_EX_TOOLWINDOW;
+    else
+        exStyle = (exStyle & ~WS_EX_TOOLWINDOW) | WS_EX_APPWINDOW;
+    SetWindowLongPtr(hWnd, GWL_EXSTYLE, exStyle);
+
+    winDebug
+        ("winApplyHints: iWindow 0x%08x hints 0x%08x style 0x%08x exstyle 0x%08x\n",
+         iWindow, hint, style, exStyle);
 }
 
 void
commit de759cc38ccc8a7811923eb9620f01301aedc10e
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sun Feb 5 17:57:04 2012 +0000

    hw/xwin: Add a simple interface to the ITaskbarList COM interface
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 2df1dbe..93ce570 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -102,6 +102,7 @@ SRCS =	InitInput.c \
 	winshaddd.c \
 	winshadddnl.c \
 	winshadgdi.c \
+	wintaskbar.c \
 	wintrayicon.c \
 	winvalargs.c \
 	winwakeup.c \
diff --git a/hw/xwin/wintaskbar.c b/hw/xwin/wintaskbar.c
new file mode 100644
index 0000000..7dd4ec3
--- /dev/null
+++ b/hw/xwin/wintaskbar.c
@@ -0,0 +1,92 @@
+/*
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice (including the next
+  paragraph) shall be included in all copies or substantial portions of the
+  Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+
+#include "win.h"
+#include "winwindow.h"
+
+const GUID CLSID_TaskbarList = {0x56fdf344,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}};
+const GUID IID_ITaskbarList =  {0x56fdf342,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}};
+
+#ifdef INTERFACE
+#undef INTERFACE
+#endif
+
+#define INTERFACE ITaskbarList
+DECLARE_INTERFACE_(ITaskbarList, IUnknown)
+{
+  /* IUnknown methods */
+  STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
+  STDMETHOD_(ULONG, AddRef) (THIS) PURE;
+  STDMETHOD_(ULONG, Release) (THIS) PURE;
+
+  /* ITaskbarList methods */
+  STDMETHOD(HrInit) (THIS) PURE;
+  STDMETHOD(AddTab) (THIS_ HWND hWnd) PURE;
+  STDMETHOD(DeleteTab) (THIS_ HWND hWnd) PURE;
+  STDMETHOD(ActivateTab) (THIS_ HWND hWnd) PURE;
+  STDMETHOD(SetActiveAlt) (THIS_ HWND hWnd) PURE;
+};
+#undef INTERFACE
+
+/*
+   The stuff above needs to be in win32api headers, not defined here,
+   or at least generated from the MIDL :-)
+*/
+
+/*
+  This is unnecessarily heavyweight, we could just call CoInitialize() once at
+   startup and CoUninitialize() once at shutdown
+*/
+
+/*
+  The documentation for ITaskbarList::AddTab says that we are responsible for
+   deleting the tab ourselves when the window is deleted, but that doesn't actually
+   seem to be the case
+*/
+
+void winShowWindowOnTaskbar(HWND hWnd, BOOL show)
+{
+  ITaskbarList* pTaskbarList = NULL;
+
+  if (SUCCEEDED(CoInitialize(NULL)))
+    {
+      if (SUCCEEDED(CoCreateInstance((const CLSID *)&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, (const IID *)&IID_ITaskbarList, (void**)&pTaskbarList)))
+        {
+          if (SUCCEEDED(pTaskbarList->lpVtbl->HrInit(pTaskbarList)))
+            {
+              if (show)
+                {
+                  pTaskbarList->lpVtbl->AddTab(pTaskbarList,hWnd);
+                }
+              else
+                {
+                  pTaskbarList->lpVtbl->DeleteTab(pTaskbarList,hWnd);
+                }
+            }
+          pTaskbarList->lpVtbl->Release(pTaskbarList);
+        }
+      CoUninitialize();
+    }
+}
diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index 4540dd0..37b9752 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -157,5 +157,8 @@ void
 void
  winSetAppUserModelID(HWND hWnd, const char *AppID);
 
+void
+ winShowWindowOnTaskbar(HWND hWnd, BOOL show);
+
 #endif                          /* XWIN_MULTIWINDOW */
 #endif
commit 19d875187a113ca7772a770767ea2ceb2ade5a43
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Jan 4 17:40:14 2012 +0000

    hw/xwin: Enable RANDR resize by default
    
    Also fix erroneous use of '--resize' not '-resize', and document '-noresize' in man page
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index b345107..78ff74f 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -807,7 +807,7 @@ winUseMsg(void)
     ErrorF("-resize=none|scrollbars|randr"
            "\tIn windowed mode, [don't] allow resizing of the window. 'scrollbars'\n"
            "\tmode gives the window scrollbars as needed, 'randr' mode uses the RANR\n"
-           "\textension to resize the X screen.\n");
+           "\textension to resize the X screen.  'randr' is the default.\n");
 
     ErrorF("-rootless\n" "\tRun the server in rootless mode.\n");
 
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index fe173b1..18ee667 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -121,14 +121,16 @@ Alternative name for \fB\-resize=scrollbars\fP.
 .SH OPTIONS CONTROLLING RESIZE BEHAVIOUR
 .TP 8
 .B \-resize[=none|scrollbars|randr]
-Select the resize mode of an X screen.
+Select the resize mode of an X screen. The default is randr.
 
 .RS
 .IP \fB\-resize=none\fP 8
-(default). The screen is not resizable.
+The screen is not resizable.
 
 In windowed mode, if the window has decorations, a fixed frame is used.
 
+Alternative name is \fB\-noresize\fP.
+
 .IP \fB\-resize=scrollbars\fP 8
 The screen window is resizeable, but the screen is not resizable.
 
@@ -159,8 +161,8 @@ of the X screen using the RANDR extension is not permitted.
 
 The maximum dimensions of the screen are the dimensions of the \fIWindows\fP virtual desktop.
 
-.IP \fB\--resize\fP 8
-on its own is equivalent to \fB\--resize=randr\fP
+.IP \fB\-resize\fP 8
+on its own is equivalent to \fB\-resize=randr\fP
 .RE
 
 .SH OPTIONS CONTROLLING WINDOWS INTEGRATION
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 80d0937..858be4a 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -142,7 +142,7 @@ winInitializeScreenDefaults(void)
 #endif
     defaultScreenInfo.fMultipleMonitors = FALSE;
     defaultScreenInfo.fLessPointer = FALSE;
-    defaultScreenInfo.iResizeMode = notAllowed;
+    defaultScreenInfo.iResizeMode = resizeWithRandr;
     defaultScreenInfo.fNoTrayIcon = FALSE;
     defaultScreenInfo.iE3BTimeout = WIN_E3B_DEFAULT;
     defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
commit 444580673221bf3f89dfa3cbc518b5ed4ecabc23
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Sat Dec 31 22:11:18 2011 -0600

    hw/xwin: Enable AIGLX by default
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index f4d4e90..b345107 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -840,7 +840,7 @@ winUseMsg(void)
 
 #ifdef XWIN_GLX_WINDOWS
     ErrorF("-[no]wgl\n"
-           "\tEnable the GLX extension to use the native Windows WGL interface for accelerated OpenGL\n");
+           "\tEnable the GLX extension to use the native Windows WGL interface for hardware-accelerated OpenGL\n");
 #endif
 
     ErrorF("-[no]winkill\n" "\tAlt+F4 exits the X Server.\n");
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index dbadad6..fe173b1 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -211,7 +211,7 @@ is disabled by default.
 .TP 8
 .B \-[no]wgl
 Enable [disable] the GLX extension to use the native Windows WGL interface
-for hardware accelerated OpenGL (AIGLX). (Experimental)
+for hardware accelerated OpenGL (AIGLX). The default is enabled.
 .TP 8
 .B \-[no]winkill
 Enable or disable the \fIAlt-F4\fP key combination as a signal to exit the
diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c
index 4953bd0..b34d1a7 100644
--- a/hw/xwin/winglobals.c
+++ b/hw/xwin/winglobals.c
@@ -77,7 +77,7 @@ Bool g_fKeyboardHookLL = FALSE;
 Bool g_fNoHelpMessageBox = FALSE;
 Bool g_fSoftwareCursor = FALSE;
 Bool g_fSilentDupError = FALSE;
-Bool g_fNativeGl = FALSE;
+Bool g_fNativeGl = TRUE;
 
 #ifdef XWIN_CLIPBOARD
 /*
commit 11bb32e561b3f1c657a99b3902f9beea786babbb
Author: Oliver Schmidt <oschmidt-mailinglists at gmx.de>
Date:   Sun Jan 8 20:30:02 2012 +0000

    hw/xwin: Restore non-latching modifier key state when an X window gains focus
    
    In multiwindow mode, the state of the modifier keys was lost when a window is
    created (or raised) and focus moved to that window.
    
    For example: In window A Ctrl + some key opens a window B, then in window B Ctrl
    + some other key triggers the next action. However after the opening of window B
    the Ctrl key has to be released and pressed again. If the user keeps the Ctrl
    key held down when the window B is opened, the next key press X will be
    interpreted as X and not as Ctrl+X.
    
    Extended the function winRestoreModeKeyStates in winkeybd.c to consider not only
    the latching modifier keys but also the modifiers Ctrl, Shift, Alt/AltGr by
    using the Windows function GetAsyncKeyState.
    
    A combined Ctrl+AltGr modifier state cannot be restored correctly, as Windows
    always fakes a Ctrl-L when AltGr is pressed.
    
    Signed-off-by: Oliver Schmidt <oschmidt-mailinglists at gmx.de>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index 104ca58..a70cdcd 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -262,6 +262,28 @@ winRestoreModeKeyStates(void)
         XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
     winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
 
+    /* Check if modifier keys are pressed, and if so, fake a press */
+    {
+        BOOL ctrl = (GetAsyncKeyState(VK_CONTROL) < 0);
+        BOOL shift = (GetAsyncKeyState(VK_SHIFT) < 0);
+        BOOL alt = (GetAsyncKeyState(VK_LMENU) < 0);
+        BOOL altgr = (GetAsyncKeyState(VK_RMENU) < 0);
+
+        if (ctrl && altgr)
+            ctrl = FALSE;
+
+        if (LOGICAL_XOR(internalKeyStates & ControlMask, ctrl))
+            winSendKeyEvent(KEY_LCtrl, ctrl);
+
+        if (LOGICAL_XOR(internalKeyStates & ShiftMask, shift))
+            winSendKeyEvent(KEY_ShiftL, shift);
+
+        if (LOGICAL_XOR(internalKeyStates & Mod1Mask, alt))
+            winSendKeyEvent(KEY_Alt, alt);
+
+        if (LOGICAL_XOR(internalKeyStates & Mod5Mask, altgr))
+            winSendKeyEvent(KEY_AltLang, altgr);
+    }
 
     /*
        Check if latching modifier key states have changed, and if so,
commit 47291d0b7d7bfee74156f83badae15a0818c68ad
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Mon Nov 5 14:54:51 2012 +0000

    hw/xwin: Give our logical xor operator a more logical name
    
    Also, rather than a comment about why we need a logical operator, let's have a
    comment about what we are doing to the keyboard state...
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 7b34e84..180695e 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -248,9 +248,6 @@ if (++PROFPT##point % thresh == 0)\
 ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\
 }
 
-/* We use xor this macro for detecting toggle key state changes */
-#define WIN_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
-
 #define DEFINE_ATOM_HELPER(func,atom_name)			\
 static Atom func (void) {					\
     static int generation;					\
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index 2ffb9a9..104ca58 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -41,6 +41,9 @@
 
 #include "xkbsrv.h"
 
+/* C does not have a logical XOR operator, so we use a macro instead */
+#define LOGICAL_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
+
 static Bool g_winKeyState[NUM_KEYCODES];
 
 /*
@@ -259,36 +262,32 @@ winRestoreModeKeyStates(void)
         XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
     winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
 
-    /* 
-     * NOTE: The C XOR operator, ^, will not work here because it is
-     * a bitwise operator, not a logical operator.  C does not
-     * have a logical XOR operator, so we use a macro instead.
-     */
 
-    /* Has the key state changed? */
+    /*
+       Check if latching modifier key states have changed, and if so,
+       fake a press and a release to toggle the modifier to the correct
+       state
+    */
     dwKeyState = GetKeyState(VK_NUMLOCK) & 0x0001;
-    if (WIN_XOR(internalKeyStates & NumLockMask, dwKeyState)) {
+    if (LOGICAL_XOR(internalKeyStates & NumLockMask, dwKeyState)) {
         winSendKeyEvent(KEY_NumLock, TRUE);
         winSendKeyEvent(KEY_NumLock, FALSE);
     }
 
-    /* Has the key state changed? */
     dwKeyState = GetKeyState(VK_CAPITAL) & 0x0001;
-    if (WIN_XOR(internalKeyStates & LockMask, dwKeyState)) {
+    if (LOGICAL_XOR(internalKeyStates & LockMask, dwKeyState)) {
         winSendKeyEvent(KEY_CapsLock, TRUE);
         winSendKeyEvent(KEY_CapsLock, FALSE);
     }
 
-    /* Has the key state changed? */
     dwKeyState = GetKeyState(VK_SCROLL) & 0x0001;
-    if (WIN_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) {
+    if (LOGICAL_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) {
         winSendKeyEvent(KEY_ScrollLock, TRUE);
         winSendKeyEvent(KEY_ScrollLock, FALSE);
     }
 
-    /* Has the key state changed? */
     dwKeyState = GetKeyState(VK_KANA) & 0x0001;
-    if (WIN_XOR(internalKeyStates & KanaMask, dwKeyState)) {
+    if (LOGICAL_XOR(internalKeyStates & KanaMask, dwKeyState)) {
         winSendKeyEvent(KEY_HKTG, TRUE);
         winSendKeyEvent(KEY_HKTG, FALSE);
     }
commit 8aa27ae82109e4fab0ff3ed86ad1d152438a2585
Author: Tobias Häußler <tobias.haeussler at gmx.de>
Date:   Mon Jul 18 14:48:23 2011 +0100

    hw/xwin: Add correct taskbar grouping of X windows on Windows 7
    
    I created a small patch for XWin that adds correct grouping of taskbar icons
    when 'Always combine, hide labels' is set in the taskbar properties. It uses the
    new taskbar APIs introduced in Windows 7 to set an application id for each
    window. The id is based on the X11 class hints.
    
    v2: Add file to _SOURCES to fix distcheck
    
    v3 : Fix compilation with mingw-w64 w32api headers
    Include propkey.h, propsys.h rather than defining necessary stuff ourselves
    
    v4: Fix up names taskbar->propertystore, AppID->AppUserModelID, etc.
    Link directly with ole32 for PropVariantClear(), prototyping it if neccessary.
    
    v5: Put winSetAppUserModelID()-related code in a separate file.
    Drop a superfluous assign to hr of ignored HRESULT of SetValue()
    
    Signed-off-by: Tobias Häußler <tobias.haeussler at gmx.de>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 4bcd3a0..f4d4e90 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -204,6 +204,9 @@ ddxGiveUp(enum ExitCode error)
     }
 
 #ifdef XWIN_MULTIWINDOW
+    /* Unload libraries for taskbar grouping */
+    winPropertyStoreDestroy();
+
     /* Notify the worker threads we're exiting */
     winDeinitMultiWindowWM();
 #endif
@@ -951,6 +954,10 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
 
     /* Detect supported engines */
     winDetectSupportedEngines();
+#ifdef XWIN_MULTIWINDOW
+    /* Load libraries for taskbar grouping */
+    winPropertyStoreInit();
+#endif
 
     /* Store the instance handle */
     g_hInstance = GetModuleHandle(NULL);
diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 3fcaf9d..2df1dbe 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -23,8 +23,11 @@ SRCS_MULTIWINDOW = \
 	winmultiwindowshape.c \
 	winmultiwindowwindow.c \
 	winmultiwindowwm.c \
-	winmultiwindowwndproc.c
+	winmultiwindowwndproc.c \
+	propertystore.h \
+	winSetAppUserModelID.c
 DEFS_MULTIWINDOW = -DXWIN_MULTIWINDOW
+MULTIWINDOW_LIBS = -lshlwapi -lole32
 endif
 
 if XWIN_MULTIWINDOWEXTWM
@@ -150,7 +153,7 @@ INCLUDES = -I$(top_srcdir)/miext/rootless
 XWIN_SYS_LIBS += -ldxguid
 
 XWin_DEPENDENCIES = $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS)
-XWin_LDADD = $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_GLX_LINK_FLAGS) $(XWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS)
+XWin_LDADD = $(MULTIWINDOW_LIBS) $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_GLX_LINK_FLAGS) $(XWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS)
 XWin_LDFLAGS = -mwindows -static
 
 .rc.o:
diff --git a/hw/xwin/propertystore.h b/hw/xwin/propertystore.h
new file mode 100644
index 0000000..6afc6c9
--- /dev/null
+++ b/hw/xwin/propertystore.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 Tobias Häußler
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef PROPERTYSTORE_H
+#define PROPERTYSTORE_H
+
+#include <windows.h>
+
+#ifdef __MINGW64_VERSION_MAJOR
+/* If we are using headers from mingw-w64 project, it provides the PSDK headers this needs ... */
+#include <propkey.h>
+#include <propsys.h>
+#else /*  !__MINGW64_VERSION_MAJOR */
+/* ... otherwise, we need to define all this stuff ourselves */
+
+typedef struct _tagpropertykey {
+    GUID fmtid;
+    DWORD pid;
+} PROPERTYKEY;
+
+#define REFPROPERTYKEY const PROPERTYKEY *
+#define REFPROPVARIANT const PROPVARIANT *
+
+WINOLEAPI PropVariantClear(PROPVARIANT *pvar);
+
+#ifdef INTERFACE
+#undef INTERFACE
+#endif
+
+#define INTERFACE IPropertyStore
+DECLARE_INTERFACE_(IPropertyStore, IUnknown)
+{
+    STDMETHOD(QueryInterface) (THIS_ REFIID, PVOID *) PURE;
+    STDMETHOD_(ULONG, AddRef) (THIS) PURE;
+    STDMETHOD_(ULONG, Release) (THIS) PURE;
+    STDMETHOD(GetCount) (THIS_ DWORD) PURE;
+    STDMETHOD(GetAt) (THIS_ DWORD, PROPERTYKEY) PURE;
+    STDMETHOD(GetValue) (THIS_ REFPROPERTYKEY, PROPVARIANT) PURE;
+    STDMETHOD(SetValue) (THIS_ REFPROPERTYKEY, REFPROPVARIANT) PURE;
+    STDMETHOD(Commit) (THIS) PURE;
+};
+
+#undef INTERFACE
+typedef IPropertyStore *LPPROPERTYSTORE;
+
+DEFINE_GUID(IID_IPropertyStore, 0x886d8eeb, 0x8cf2, 0x4446, 0x8d, 0x02, 0xcd,
+            0xba, 0x1d, 0xbd, 0xcf, 0x99);
+
+#ifdef INITGUID
+#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) GUID_EXT const PROPERTYKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }, pid }
+#else
+#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) GUID_EXT const PROPERTYKEY name
+#endif
+
+DEFINE_PROPERTYKEY(PKEY_AppUserModel_ID, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0,
+                   0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 5);
+
+#endif /* !__MINGW64_VERSION_MAJOR */
+
+typedef HRESULT(__stdcall * SHGETPROPERTYSTOREFORWINDOWPROC) (HWND, REFIID,
+                                                              void **);
+
+#endif
diff --git a/hw/xwin/winSetAppUserModelID.c b/hw/xwin/winSetAppUserModelID.c
new file mode 100644
index 0000000..ce9da5e
--- /dev/null
+++ b/hw/xwin/winSetAppUserModelID.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2011 Tobias Häußler
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/Xproto.h>
+#include <X11/Xwindows.h>
+#include "winwindow.h"
+#include "os.h"
+#include "winmsg.h"
+
+#include <shlwapi.h>
+
+#define INITGUID
+#include "initguid.h"
+#include "propertystore.h"
+#undef INITGUID
+
+static HMODULE g_hmodShell32Dll = NULL;
+static SHGETPROPERTYSTOREFORWINDOWPROC g_pSHGetPropertyStoreForWindow = NULL;
+
+void
+winPropertyStoreInit(void)
+{
+    /*
+       Load library and get function pointer to SHGetPropertyStoreForWindow()
+
+       SHGetPropertyStoreForWindow is only supported since Windows 7. On previous
+       versions the pointer will be NULL and taskbar grouping is not supported.
+       winSetAppUserModelID() will do nothing in this case.
+     */
+    g_hmodShell32Dll = LoadLibrary("shell32.dll");
+    if (g_hmodShell32Dll == NULL) {
+        ErrorF("winPropertyStoreInit - Could not load shell32.dll\n");
+        return;
+    }
+
+    g_pSHGetPropertyStoreForWindow =
+        (SHGETPROPERTYSTOREFORWINDOWPROC) GetProcAddress(g_hmodShell32Dll,
+                                                         "SHGetPropertyStoreForWindow");
+    if (g_pSHGetPropertyStoreForWindow == NULL) {
+        ErrorF
+            ("winPropertyStoreInit - Could not get SHGetPropertyStoreForWindow address\n");
+        return;
+    }
+}
+
+void
+winPropertyStoreDestroy(void)
+{
+    if (g_hmodShell32Dll != NULL) {
+        FreeLibrary(g_hmodShell32Dll);
+        g_hmodShell32Dll = NULL;
+        g_pSHGetPropertyStoreForWindow = NULL;
+    }
+}
+
+void
+winSetAppUserModelID(HWND hWnd, const char *AppID)
+{
+    PROPVARIANT pv;
+    IPropertyStore *pps = NULL;
+    HRESULT hr;
+
+    if (g_pSHGetPropertyStoreForWindow == NULL) {
+        return;
+    }
+
+    winDebug("winSetAppUserMOdelID - hwnd 0x%08x appid '%s'\n", hWnd, AppID);
+
+    hr = g_pSHGetPropertyStoreForWindow(hWnd, &IID_IPropertyStore,
+                                        (void **) &pps);
+    if (SUCCEEDED(hr) && pps) {
+        memset(&pv, 0, sizeof(PROPVARIANT));
+        if (AppID) {
+            pv.vt = VT_LPWSTR;
+            hr = SHStrDupA(AppID, &pv.pwszVal);
+        }
+
+        if (SUCCEEDED(hr)) {
+            pps->lpVtbl->SetValue(pps, &PKEY_AppUserModel_ID, &pv);
+            PropVariantClear(&pv);
+        }
+        pps->lpVtbl->Release(pps);
+    }
+}
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 42925e3..fbf984d 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1630,10 +1630,14 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
         XFree(normal_hint);
     }
 
-    /* Override hint settings from above with settings from config file */
+    /*
+       Override hint settings from above with settings from config file and set
+       application id for grouping.
+     */
     {
         XClassHint class_hint = { 0, 0 };
         char *window_name = 0;
+        char *application_id = 0;
 
         if (XGetClassHint(pDisplay, iWindow, &class_hint)) {
             XFetchName(pDisplay, iWindow, &window_name);
@@ -1642,10 +1646,24 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
                 winOverrideStyle(class_hint.res_name, class_hint.res_class,
                                  window_name);
 
+#define APPLICATION_ID_FORMAT	"%s.xwin.%s"
+#define APPLICATION_ID_UNKNOWN "unknown"
+            if (class_hint.res_class) {
+                asprintf(&application_id, APPLICATION_ID_FORMAT, XVENDORNAME,
+                         class_hint.res_class);
+            }
+            else {
+                asprintf(&application_id, APPLICATION_ID_FORMAT, XVENDORNAME,
+                         APPLICATION_ID_UNKNOWN);
+            }
+            winSetAppUserModelID(hWnd, application_id);
+
             if (class_hint.res_name)
                 XFree(class_hint.res_name);
             if (class_hint.res_class)
                 XFree(class_hint.res_class);
+            if (application_id)
+                free(application_id);
             if (window_name)
                 XFree(window_name);
         }
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index af917d6..4180a3a 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -825,6 +825,8 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
         break;
 
     case WM_CLOSE:
+        /* Removep AppUserModelID property */
+        winSetAppUserModelID(hwnd, NULL);
         /* Branch on if the window was killed in X already */
         if (pWinPriv->fXKilled) {
             /* Window was killed, go ahead and destroy the window */
diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index 49a720a..4540dd0 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -148,5 +148,14 @@ void
 void
  winMinimizeWindow(Window id);
 
+void
+ winPropertyStoreInit(void);
+
+void
+ winPropertyStoreDestroy(void);
+
+void
+ winSetAppUserModelID(HWND hWnd, const char *AppID);
+
 #endif                          /* XWIN_MULTIWINDOW */
 #endif
commit f3aef7f9561d2723da0d1438a8b276b77a1e672e
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sun Sep 2 16:04:25 2012 +0100

    hw/xwin: Fix function name in log message
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index 5bf7102..9743092 100644
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -263,7 +263,7 @@ winMWExtWMCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
     strcat(pszClass, pszWindowID);
 
 #if CYGMULTIWINDOW_DEBUG
-    winDebug("winCreateWindowsWindow - Creating class: %s\n", pszClass);
+    winDebug("winMWExtWMCreateFrame - Creating class: %s\n", pszClass);
 #endif
 
     /* Setup our window class */
commit 127a7068b75258d396776cc101aba0bef10a5cef
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Apr 14 23:10:23 2011 +0100

    hw/xwin: Allow XScreenSaverSuspend() to effect Windows screen saver or monitor power off
    
    Reset the idle timer in the block handler if screenSaverSuspended is set.
    
    This isn't quite a complete solution.  We should also set the block timeout to
    something less than the idle timer timeout to ensure we will reset the idle
    timer before it times out if we are blocking.
    
    The idle timer timeout is presumably the first one to expire of the screen saver
    activation or monitor low power or power down timeout, depending on
    configuration.
    
    Unfortunately this is probably not straightforward to do. Whilst
    SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT) is portable, apparently
    SPI_GETLOWPOWERTIMEOUT and SPI_GETPOWEROFFTIMEOUT are not supported by Windows
    versions 6.0 or later, and the interface for discovering equivalent value is
    complex.
    
    This doesn't matter in the case where a media player or similar application is
    the one making the XScreenSaverSuspend() requests, as it will be continuously
    drawing, causing the X server to become unblocked often.
    
    In the case where slide show presentation application or similar is the one
    making the XScreenSaverSuspend() request, this might be a problem.
    
    Since "Powerpoint is Evil" [1], I think we'll leave it like this till someone
    complains :-)
    
    [1] http://www.edwardtufte.com/tufte/books_pp
    
    v2: conditionalize on SCREENSAVER
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winblock.c b/hw/xwin/winblock.c
index 480e3bd..a4ae866 100644
--- a/hw/xwin/winblock.c
+++ b/hw/xwin/winblock.c
@@ -86,4 +86,13 @@ winBlockHandler(ScreenPtr pScreen,
             DispatchMessage(&msg);
         }
     }
+
+  /*
+    At least one X client has asked to suspend the screensaver, so
+    reset Windows' display idle timer
+  */
+#ifdef SCREENSAVER
+  if (screenSaverSuspended)
+    SetThreadExecutionState(ES_DISPLAY_REQUIRED);
+#endif
 }
commit 190f165317c4a58adf38e3e32acfe7cf04850e91
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Mon Nov 5 13:02:46 2012 +0000

    hw/xwin: Avoid logging an extra blank line if BUILDERSTRING is empty
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 14056fa..80d0937 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -1161,6 +1161,8 @@ winLogVersionInfo(void)
     ErrorF("Vendor: %s\n", XVENDORNAME);
     ErrorF("Release: %d.%d.%d.%d\n", XORG_VERSION_MAJOR,
            XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP);
-    ErrorF("%s\n\n", BUILDERSTRING);
+    if (strlen(BUILDERSTRING))
+        ErrorF("%s\n", BUILDERSTRING);
     ErrorF("Contact: %s\n", BUILDERADDR);
+    ErrorF("\n");
 }
commit ef9dbea24f5ce7e1e400463ab2a333076d98a28e
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Aug 31 20:57:05 2011 +0100

    hw/xwin: Report which drawing engines are being enabled when checking for support
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winengine.c b/hw/xwin/winengine.c
index 6748959..b2007d7 100644
--- a/hw/xwin/winengine.c
+++ b/hw/xwin/winengine.c
@@ -92,7 +92,7 @@ winDetectSupportedEngines(void)
         else {
             /* We have DirectDraw */
             winErrorFVerb(2,
-                          "winDetectSupportedEngines - DirectDraw installed\n");
+                          "winDetectSupportedEngines - DirectDraw installed, allowing ShadowDD\n");
             g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
 
 #ifdef XWIN_PRIMARYFB
@@ -100,7 +100,7 @@ winDetectSupportedEngines(void)
             if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
                 g_dwEnginesSupported |= WIN_SERVER_PRIMARY_DD;
                 winErrorFVerb(2,
-                              "winDetectSupportedEngines - Allowing PrimaryDD\n");
+                              "winDetectSupportedEngines - Windows NT, allowing PrimaryDD\n");
             }
 #endif
         }
@@ -112,7 +112,7 @@ winDetectSupportedEngines(void)
         if (SUCCEEDED(ddrval)) {
             /* We have DirectDraw4 */
             winErrorFVerb(2,
-                          "winDetectSupportedEngines - DirectDraw4 installed\n");
+                          "winDetectSupportedEngines - DirectDraw4 installed, allowing ShadowDDNL\n");
             g_dwEnginesSupported |= WIN_SERVER_SHADOW_DDNL;
         }
 
commit 5824166256c8e96c91e225f4ccb2b094b8fb045b
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Mar 12 14:38:51 2010 +0000

    hw/xwin: Show any fatal error message
    
    Report the fatal error message in the dialog we pop up, rather than just
    referring the user to the logfile.
    
    v2: Do this a better way since the "Pass the FatalError message to
    OsVendorFatalError" patch has landed, and OsVendorFatalError() now gets passed
    the fatal error message
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c
index 6645469..1318b0f 100644
--- a/hw/xwin/winerror.c
+++ b/hw/xwin/winerror.c
@@ -59,15 +59,16 @@ OsVendorVErrorF(const char *pszFormat, va_list va_args)
 #endif
 
 /*
- * os/util.c/FatalError () calls our vendor ErrorF, so the message
- * from a FatalError will be logged.  Thus, the message for the
- * fatal error is not passed to this function.
+ * os/log.c:FatalError () calls our vendor ErrorF, so the message
+ * from a FatalError will be logged.
  *
  * Attempt to do last-ditch, safe, important cleanup here.
  */
 void
 OsVendorFatalError(const char *f, va_list args)
 {
+    char errormsg[1024] = "";
+
     /* Don't give duplicate warning if UseMsg was called */
     if (g_fSilentFatalError)
         return;
@@ -78,9 +79,28 @@ OsVendorFatalError(const char *f, va_list args)
     }
     LogClose(EXIT_ERR_ABORT);
 
-    winMessageBoxF("A fatal error has occurred and " PROJECT_NAME
-                   " will now exit.\n" "Please open %s for more information.\n",
-                   MB_ICONERROR, (g_pszLogFile ? g_pszLogFile : "the logfile"));
+    /* Format the error message */
+    vsnprintf(errormsg, sizeof(errormsg), f, args);
+
+    /*
+       Sometimes the error message needs a bit of cosmetic cleaning
+       up for use in a dialog box...
+     */
+    {
+        char *s;
+
+        while ((s = strstr(errormsg, "\n\t")) != NULL) {
+            s[0] = ' ';
+            s[1] = '\n';
+        }
+    }
+
+    winMessageBoxF("A fatal error has occurred and " PROJECT_NAME " will now exit.\n\n"
+                   "%s\n\n"
+                   "Please open %s for more information.\n",
+                   MB_ICONERROR,
+                   errormsg,
+                   (g_pszLogFile ? g_pszLogFile : "the logfile"));
 }
 
 /*
commit cf05db8ddec948d907915e1c9569d743e8771def
Author: Sjoerd Simons <sjoerd.simons at collabora.co.uk>
Date:   Tue Oct 30 17:02:58 2012 +0100

    Ephyr: Find the right host screen when embedded
    
    When Xephyr is embedded into another application (e.g. in xoo), the
    input events may come from the parent Window instead of our own. So make
    sure we find the host screen in that case as well instead of crashing.
    
    Signed-off-by: Sjoerd Simons <sjoerd.simons at collabora.co.uk>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 02729d6..157ac36 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -881,7 +881,9 @@ host_screen_from_window(Window w)
     struct EphyrHostScreen *result = NULL;
 
     for (index = 0; index < HostX.n_screens; index++) {
-        if (HostX.screens[index].win == w || HostX.screens[index].peer_win == w) {
+        if (HostX.screens[index].win == w
+            || HostX.screens[index].peer_win == w
+            || HostX.screens[index].win_pre_existing == w) {
             result = &HostX.screens[index];
             goto out;
         }
commit ac1a60e7b6f06fd075cc5bf55d6bc67206a01d29
Author: Raphael Kubo da Costa <raphael.kubo.da.costa at intel.com>
Date:   Fri Nov 16 19:51:58 2012 +0200

    vfb: Initialize the GLX extension again.
    
    This should fix a regression in the 1.13.0 release: commit
    5f5bbbe543f65c48ecbb5cce80116a86ca3fbe86 removed a code path used by Xvfb
    and made it use the default one when initializing extensions. However, this
    meant the GLX extension was not initialized anymore since it is not part of
    the `staticExtensions' array.
    
    Since it is not possible to just add it to that array after commit
    aad428b8e21c77397c623b78706eb64b1fea77c9, adopt an approach similar to
    xwin's and xquartz's and initialize the extension from vfb's `InitOutput'.
    
    Signed-off-by: Raphael Kubo da Costa <raphael.kubo.da.costa at intel.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 07ea8ea..97eccfd 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -65,6 +65,7 @@ from The Open Group.
 #endif                          /* HAS_SHM */
 #include "dix.h"
 #include "miline.h"
+#include "glx_extinit.h"
 
 #define VFB_DEFAULT_WIDTH      1280
 #define VFB_DEFAULT_HEIGHT     1024
@@ -884,12 +885,30 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv)
 
 }                               /* end vfbScreenInit */
 
+static const ExtensionModule vfbExtensions[] = {
+#ifdef GLXEXT
+    { GlxExtensionInit, "GLX", &noGlxExtension },
+#endif
+};
+
+static
+void vfbExtensionInit(void)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(vfbExtensions); i++)
+        LoadExtension(&vfbExtensions[i], TRUE);
+}
+
 void
 InitOutput(ScreenInfo * screenInfo, int argc, char **argv)
 {
     int i;
     int NumFormats = 0;
 
+    if (serverGeneration == 1)
+        vfbExtensionInit();
+
     /* initialize pixmap formats */
 
     /* must have a pixmap depth to match every screen depth */
commit 353b14ea77324b3f7b3ea29d6f03618fd9916d5f
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Nov 19 15:00:22 2012 +1100

    DMX: Add DMX and GLX extensions
    
    Unfortunately this also got lost in the extmod fallout, leaving the DMX
    server not exposing the DMX or GLX extensions.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h
index d7c6204..f0cb044 100644
--- a/hw/dmx/dmx.h
+++ b/hw/dmx/dmx.h
@@ -407,4 +407,6 @@ extern DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
 
 #define dmxGlyphSetPrivateKey (&dmxGlyphSetPrivateKeyRec) /**< Private index for GlyphSets */
 
+void DMXExtensionInit(void);
+
 #endif                          /* DMX_H */
diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
index 5804353..7a50aeb 100644
--- a/hw/dmx/dmxinit.c
+++ b/hw/dmx/dmxinit.c
@@ -68,10 +68,13 @@
 #include <GL/glx.h>
 #include <GL/glxint.h>
 #include "dmx_glxvisuals.h"
+#include "glx_extinit.h"
 #include <X11/extensions/Xext.h>
 #include <X11/extensions/extutil.h>
 #endif                          /* GLXEXT */
 
+#include <X11/extensions/dmxproto.h>
+
 /* Global variables available to all Xserver/hw/dmx routines. */
 int dmxNumScreens;
 DMXScreenInfo *dmxScreens;
@@ -586,6 +589,20 @@ dmxExecHost(void)
     return buffer;
 }
 
+static void dmxAddExtensions(Bool glxSupported)
+{
+    const ExtensionModule dmxExtensions[] = {
+        { DMXExtensionInit, DMX_EXTENSION_NAME, NULL },
+#ifdef GLXEXT
+        { GlxExtensionInit, "GLX", &glxSupported },
+#endif
+    };
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(dmxExtensions); i++)
+        LoadExtension(&dmxExtensions[i], TRUE);
+}
+
 /** This routine is called in Xserver/dix/main.c from \a main(). */
 void
 InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
@@ -594,7 +611,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
     static unsigned long dmxGeneration = 0;
 
 #ifdef GLXEXT
-    Bool glxSupported = TRUE;
+    static Bool glxSupported = TRUE;
 #endif
 
     if (dmxGeneration != serverGeneration) {
@@ -725,6 +742,9 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
         glxSupported &= (dmxScreens[i].glxMajorOpcode > 0);
 #endif
 
+    if (serverGeneration == 1)
+        dmxAddExtensions(glxSupported);
+
     /* Tell dix layer about the backend displays */
     for (i = 0; i < dmxNumScreens; i++) {
 
diff --git a/include/extinit.h b/include/extinit.h
index 7f4718f..5690d7b 100644
--- a/include/extinit.h
+++ b/include/extinit.h
@@ -68,10 +68,6 @@ extern _X_EXPORT Bool noDbeExtension;
 extern void DbeExtensionInit(void);
 #endif
 
-#ifdef DMXEXT
-extern void DMXExtensionInit(void);
-#endif
-
 #if defined(DPMSExtension)
 #include <X11/extensions/dpmsconst.h>
 extern _X_EXPORT Bool noDPMSExtension;
commit 3556d43010f0a37bf30aa2e0ceee9a8bbcad311d
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Nov 19 15:29:34 2012 +1100

    Constify extensions in LoadExtension users
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Extensions.c b/hw/xfree86/common/xf86Extensions.c
index d5309d5..f9e7916 100644
--- a/hw/xfree86/common/xf86Extensions.c
+++ b/hw/xfree86/common/xf86Extensions.c
@@ -53,7 +53,7 @@
 /*
  * DDX-specific extensions.
  */
-static ExtensionModule extensionModules[] = {
+static const ExtensionModule extensionModules[] = {
 #ifdef XF86VIDMODE
     {
 	XFree86VidModeExtensionInit,
diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c
index c0c6114..e6bb736 100644
--- a/hw/xfree86/dixmods/glxmodule.c
+++ b/hw/xfree86/dixmods/glxmodule.c
@@ -47,7 +47,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 static MODULESETUPPROTO(glxSetup);
 
-static ExtensionModule GLXExt = {
+static const ExtensionModule GLXExt = {
     GlxExtensionInit,
     "GLX",
     &noGlxExtension
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 31b0e61..5b977c7 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -145,7 +145,7 @@ QuartzSetupScreen(int index,
     return TRUE;
 }
 
-static ExtensionModule quartzExtensions[] = {
+static const ExtensionModule quartzExtensions[] = {
     /* PseudoramiX needs to be done before RandR, so
      * it is in miinitext.c until it can be reordered.
      * { PseudoramiXExtensionInit, "PseudoramiX", &noPseudoramiXExtension },
commit db83830eef38a86a471378121213162da180537d
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Nov 19 15:28:07 2012 +1100

    Constify argument to LoadExtension
    
    Since we never modify it.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/include/extension.h b/include/extension.h
index 0f55d90..acc6add 100644
--- a/include/extension.h
+++ b/include/extension.h
@@ -97,6 +97,6 @@ extern _X_EXPORT void InitExtensions(int argc, char **argv);
 
 extern _X_EXPORT void CloseDownExtensions(void);
 
-extern _X_EXPORT void LoadExtension(ExtensionModule *ext, Bool external);
+extern _X_EXPORT void LoadExtension(const ExtensionModule *ext, Bool external);
 
 #endif                          /* EXTENSION_H */
diff --git a/mi/miinitext.c b/mi/miinitext.c
index d175440..369da5e 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -365,7 +365,7 @@ NewExtensionModule(void)
 }
 
 void
-LoadExtension(ExtensionModule * e, Bool builtin)
+LoadExtension(const ExtensionModule * e, Bool builtin)
 {
     ExtensionModule *newext;
 
commit 3b9f1c701787965246638c1a6fd99fb2b6078114
Author: Yuly Novikov <ynovikov at chromium.org>
Date:   Mon Nov 19 21:04:57 2012 -0500

    dix: Save touchpoint last coordinates before transform. #49347
    
    DDXTouchPointInfoRec.valuators used to store axis values after transform.
    This resulted in Coordinate Transformation Matrix
    being applied multiple times to the last coordinates,
    in the case when only pressure changes in the last touch event.
    
    Changed DDXTouchPointInfoRec.valuators to store values before transform.
    
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=49347
    
    Signed-off-by: Yuly Novikov <ynovikov at chromium.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index 9fc8047..fa538d9 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1910,30 +1910,24 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
         return 0;
     }
 
-    if (t->mode == XIDirectTouch) {
-        if (!valuator_mask_isset(&mask, 0))
-            valuator_mask_set_double(&mask, 0,
-                                     valuator_mask_get_double(ti->
-                                                              valuators, 0));
-        if (!valuator_mask_isset(&mask, 1))
-            valuator_mask_set_double(&mask, 1,
-                                     valuator_mask_get_double(ti->
-                                                              valuators, 1));
-    }
-
     /* Get our screen event co-ordinates (root_x/root_y/event_x/event_y):
      * these come from the touchpoint in Absolute mode, or the sprite in
      * Relative. */
     if (t->mode == XIDirectTouch) {
-        transformAbsolute(dev, &mask);
-
-        for (i = 0; i < valuator_mask_size(&mask); i++) {
+        for (i = 0; i < max(valuator_mask_size(&mask), 2); i++) {
             double val;
 
             if (valuator_mask_fetch_double(&mask, i, &val))
                 valuator_mask_set_double(ti->valuators, i, val);
+            /* If the device doesn't post new X and Y axis values,
+             * use the last values posted.
+             */
+            else if (i < 2 &&
+                valuator_mask_fetch_double(ti->valuators, i, &val))
+                valuator_mask_set_double(&mask, i, val);
         }
 
+        transformAbsolute(dev, &mask);
         clipAbsolute(dev, &mask);
     }
     else {
diff --git a/include/inputstr.h b/include/inputstr.h
index 5a38924..bb0a779 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -331,7 +331,7 @@ typedef struct _DDXTouchPointInfo {
     uint32_t ddx_id;            /* touch ID given by the DDX */
     Bool emulate_pointer;
 
-    ValuatorMask *valuators;    /* last recorded axis values */
+    ValuatorMask *valuators;    /* last axis values as posted, pre-transform */
 } DDXTouchPointInfoRec;
 
 typedef struct _TouchClassRec {
commit d0fd592fc7be1706084923f43fa057e50122562c
Author: Thomas Jaeger <ThJaeger at gmail.com>
Date:   Sat Oct 13 23:18:50 2012 -0400

    Simplify GetTouchEvents
    
    With only one callee left, we are free to assume that
    !(flags & TOUCH_CLIENT_ID)
    
    Signed-off-by: Thomas Jaeger <ThJaeger at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index 39b0821..9fc8047 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1833,10 +1833,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
     int i;
     int num_events = 0;
     RawDeviceEvent *raw;
-    union touch {
-        TouchPointInfoPtr dix_ti;
-        DDXTouchPointInfoPtr ti;
-    } touchpoint;
+    DDXTouchPointInfoPtr ti;
     int need_rawevent = TRUE;
     Bool emulate_pointer = FALSE;
     int client_id = 0;
@@ -1855,37 +1852,15 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
 
     /* Find and/or create the DDX touch info */
 
-    if (flags & TOUCH_CLIENT_ID) {      /* A DIX-submitted TouchEnd */
-        touchpoint.dix_ti = TouchFindByClientID(dev, ddx_touchid);
-        BUG_RETURN_VAL(!touchpoint.dix_ti, 0);
-
-        if (!mask_in ||
-            !valuator_mask_isset(mask_in, 0) ||
-            !valuator_mask_isset(mask_in, 1)) {
-            ErrorF
-                ("[dix] dix-submitted events must have x/y valuator information.\n");
-            return 0;
-        }
-
-        need_rawevent = FALSE;
-        client_id = touchpoint.dix_ti->client_id;
-    }
-    else {                      /* a DDX-submitted touch */
-
-        touchpoint.ti =
-            TouchFindByDDXID(dev, ddx_touchid, (type == XI_TouchBegin));
-        if (!touchpoint.ti) {
-            ErrorFSigSafe("[dix] %s: unable to %s touch point %u\n", dev->name,
-                          type == XI_TouchBegin ? "begin" : "find", ddx_touchid);
-            return 0;
-        }
-        client_id = touchpoint.ti->client_id;
+    ti = TouchFindByDDXID(dev, ddx_touchid, (type == XI_TouchBegin));
+    if (!ti) {
+        ErrorFSigSafe("[dix] %s: unable to %s touch point %u\n", dev->name,
+                      type == XI_TouchBegin ? "begin" : "find", ddx_touchid);
+        return 0;
     }
+    client_id = ti->client_id;
 
-    if (!(flags & TOUCH_CLIENT_ID))
-        emulate_pointer = touchpoint.ti->emulate_pointer;
-    else
-        emulate_pointer = ! !(flags & TOUCH_POINTER_EMULATED);
+    emulate_pointer = ti->emulate_pointer;
 
     if (!IsMaster(dev))
         events =
@@ -1905,11 +1880,6 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
     num_events++;
 
     init_device_event(event, dev, ms);
-    /* if submitted for master device, get the sourceid from there */
-    if (flags & TOUCH_CLIENT_ID) {
-        event->sourceid = touchpoint.dix_ti->sourceid;
-        /* TOUCH_CLIENT_ID implies norawevent */
-    }
 
     switch (type) {
     case XI_TouchBegin:
@@ -1934,20 +1904,20 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
         event->type = ET_TouchEnd;
         /* We can end the DDX touch here, since we don't use the active
          * field below */
-        if (!(flags & TOUCH_CLIENT_ID))
-            TouchEndDDXTouch(dev, touchpoint.ti);
+        TouchEndDDXTouch(dev, ti);
         break;
     default:
         return 0;
     }
-    if (t->mode == XIDirectTouch && !(flags & TOUCH_CLIENT_ID)) {
+
+    if (t->mode == XIDirectTouch) {
         if (!valuator_mask_isset(&mask, 0))
             valuator_mask_set_double(&mask, 0,
-                                     valuator_mask_get_double(touchpoint.ti->
+                                     valuator_mask_get_double(ti->
                                                               valuators, 0));
         if (!valuator_mask_isset(&mask, 1))
             valuator_mask_set_double(&mask, 1,
-                                     valuator_mask_get_double(touchpoint.ti->
+                                     valuator_mask_get_double(ti->
                                                               valuators, 1));
     }
 
@@ -1957,13 +1927,11 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
     if (t->mode == XIDirectTouch) {
         transformAbsolute(dev, &mask);
 
-        if (!(flags & TOUCH_CLIENT_ID)) {
-            for (i = 0; i < valuator_mask_size(&mask); i++) {
-                double val;
+        for (i = 0; i < valuator_mask_size(&mask); i++) {
+            double val;
 
-                if (valuator_mask_fetch_double(&mask, i, &val))
-                    valuator_mask_set_double(touchpoint.ti->valuators, i, val);
-            }
+            if (valuator_mask_fetch_double(&mask, i, &val))
+                valuator_mask_set_double(ti->valuators, i, val);
         }
 
         clipAbsolute(dev, &mask);
commit fe59774c55e5d423633405e0869c22f4ce382548
Author: Thomas Jaeger <ThJaeger at gmail.com>
Date:   Sat Oct 13 23:08:27 2012 -0400

    Don't use GetTouchEvents in EmitTouchEnd
    
    As before GetTouchEvents causes unwanted side effects.  Add a new
    function GetDixTouchEnd, which generates a touch event from the touch
    point.  We fill in the event's screen coordinates from the MD's current
    sprite position.
    
    Signed-off-by: Thomas Jaeger <ThJaeger at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 4248b9a..2caf98c 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1066,24 +1066,14 @@ ActivateEarlyAccept(DeviceIntPtr dev, TouchPointInfoPtr ti)
 static void
 EmitTouchEnd(DeviceIntPtr dev, TouchPointInfoPtr ti, int flags, XID resource)
 {
-    InternalEvent *tel = InitEventList(GetMaximumEventsNum());
-    ValuatorMask *mask = valuator_mask_new(2);
-    int i, nev;
-
-    valuator_mask_set_double(mask, 0,
-                             valuator_mask_get_double(ti->valuators, 0));
-    valuator_mask_set_double(mask, 1,
-                             valuator_mask_get_double(ti->valuators, 1));
+    InternalEvent event;
 
     flags |= TOUCH_CLIENT_ID;
     if (ti->emulate_pointer)
         flags |= TOUCH_POINTER_EMULATED;
-    nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchEnd, flags, mask);
-    for (i = 0; i < nev; i++)
-        DeliverTouchEvents(dev, ti, tel + i, resource);
-
-    valuator_mask_free(&mask);
-    FreeEventList(tel, GetMaximumEventsNum());
+    TouchDeliverDeviceClassesChangedEvent(ti, GetTimeInMillis(), resource);
+    GetDixTouchEnd(&event, dev, ti, flags);
+    DeliverTouchEvents(dev, ti, &event, resource);
 }
 
 /**
diff --git a/dix/getevents.c b/dix/getevents.c
index 5c1e97e..39b0821 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -2022,6 +2022,37 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
     return num_events;
 }
 
+void
+GetDixTouchEnd(InternalEvent *ievent, DeviceIntPtr dev, TouchPointInfoPtr ti,
+               uint32_t flags)
+{
+    ScreenPtr scr = dev->spriteInfo->sprite->hotPhys.pScreen;
+    DeviceEvent *event = &ievent->device_event;
+    CARD32 ms = GetTimeInMillis();
+
+    BUG_WARN(!dev->enabled);
+
+    init_device_event(event, dev, ms);
+
+    event->sourceid = ti->sourceid;
+    event->type = ET_TouchEnd;
+
+    event->root = scr->root->drawable.id;
+
+    /* Get screen event coordinates from the sprite.  Is this really the best
+     * we can do? */
+    event_set_root_coordinates(event,
+                               dev->last.valuators[0],
+                               dev->last.valuators[1]);
+    event->touchid = ti->client_id;
+    event->flags = flags;
+
+    if (flags & TOUCH_POINTER_EMULATED) {
+        event->flags |= TOUCH_POINTER_EMULATED;
+        event->detail.button = 1;
+    }
+}
+
 /**
  * Synthesize a single motion event for the core pointer.
  *
diff --git a/include/input.h b/include/input.h
index 9522d00..2387dbf 100644
--- a/include/input.h
+++ b/include/input.h
@@ -465,6 +465,11 @@ extern int GetTouchOwnershipEvents(InternalEvent *events,
                                    TouchPointInfoPtr ti,
                                    uint8_t mode, XID resource, uint32_t flags);
 
+extern void GetDixTouchEnd(InternalEvent *ievent,
+                           DeviceIntPtr dev,
+                           TouchPointInfoPtr ti,
+                           uint32_t flags);
+
 extern _X_EXPORT int GetProximityEvents(InternalEvent *events,
                                         DeviceIntPtr pDev,
                                         int type, const ValuatorMask *mask);
commit cc79107a5b60d2926e16ddbee04149e8d5acc969
Author: Thomas Jaeger <ThJaeger at gmail.com>
Date:   Sat Oct 13 22:51:24 2012 -0400

    Don't use GetTouchEvents when replaying events
    
    GetTouchEvents has plenty of side effects such as moving the pointer or
    updating the master device, which we don't want to happen when
    replaying.  The only reason for calling it was to generate a DCCE event,
    but GetTouchEvents doesn't even do that right (we might need a DCCE
    event even when replaying a master event, or clients could interpret
    valuator data incorrectly).
    
    This discussion is moot at the moment anyway, since DeliverTouchEvents
    doesn't appear to deliver DCCE events.
    
    Signed-off-by: Thomas Jaeger <ThJaeger at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    
    [Added call to processInputProc instead of direct call to DeliverTouchEvents]
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/touch.c b/dix/touch.c
index 5f77be5..29ba171 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -463,45 +463,14 @@ TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev)
 void
 TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource)
 {
-    InternalEvent *tel;
-    ValuatorMask *mask;
-    int i, nev;
-    int flags;
+    int i;
 
     if (!ti->history)
         return;
 
-    tel = InitEventList(GetMaximumEventsNum());
-    mask = valuator_mask_new(0);
-
-    valuator_mask_set_double(mask, 0, ti->history[0].valuators.data[0]);
-    valuator_mask_set_double(mask, 1, ti->history[0].valuators.data[1]);
-
-    flags = TOUCH_CLIENT_ID | TOUCH_REPLAYING;
-    if (ti->emulate_pointer)
-        flags |= TOUCH_POINTER_EMULATED;
-    /* Generate events based on a fake touch begin event to get DCCE events if
-     * needed */
-    /* FIXME: This needs to be cleaned up */
-    nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchBegin, flags, mask);
-    for (i = 0; i < nev; i++) {
-        /* Send saved touch begin event */
-        if (tel[i].any.type == ET_TouchBegin) {
-            DeviceEvent *ev = &ti->history[0];
-            ev->flags |= TOUCH_REPLAYING;
-            DeliverTouchEvents(dev, ti, (InternalEvent*)ev, resource);
-        }
-        else {/* Send DCCE event */
-            tel[i].any.time = ti->history[0].time;
-            DeliverTouchEvents(dev, ti, tel + i, resource);
-        }
-    }
-
-    valuator_mask_free(&mask);
-    FreeEventList(tel, GetMaximumEventsNum());
+    TouchDeliverDeviceClassesChangedEvent(ti, ti->history[0].time, resource);
 
-    /* First event was TouchBegin, already replayed that one */
-    for (i = 1; i < ti->history_elements; i++) {
+    for (i = 0; i < ti->history_elements; i++) {
         DeviceEvent *ev = &ti->history[i];
 
         ev->flags |= TOUCH_REPLAYING;
@@ -509,6 +478,30 @@ TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource)
     }
 }
 
+void
+TouchDeliverDeviceClassesChangedEvent(TouchPointInfoPtr ti, Time time,
+                                      XID resource)
+{
+    DeviceIntPtr dev;
+    int num_events = 0;
+    InternalEvent dcce;
+
+    dixLookupDevice(&dev, ti->sourceid, serverClient, DixWriteAccess);
+
+    if (!dev)
+        return;
+
+    /* UpdateFromMaster generates at most one event */
+    UpdateFromMaster(&dcce, dev, DEVCHANGE_POINTER_EVENT, &num_events);
+    BUG_WARN(num_events > 1);
+
+    if (num_events) {
+        dcce.any.time = time;
+        /* FIXME: This doesn't do anything */
+        dev->public.processInputProc(&dcce, dev);
+    }
+}
+
 Bool
 TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite)
 {
diff --git a/include/input.h b/include/input.h
index f8459b8..9522d00 100644
--- a/include/input.h
+++ b/include/input.h
@@ -580,6 +580,8 @@ extern int TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti,
 extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
                              uint32_t touchid, Window grab_window, XID *error);
 extern void TouchEndPhysicallyActiveTouches(DeviceIntPtr dev);
+extern void TouchDeliverDeviceClassesChangedEvent(TouchPointInfoPtr ti,
+                                                  Time time, XID resource);
 
 /* misc event helpers */
 extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients);
commit 90b177e5cbb9047453af426d2abfe9c0514fe866
Author: Thomas Jaeger <ThJaeger at gmail.com>
Date:   Sat Oct 13 22:43:26 2012 -0400

    Update the MD's position when a touch event is received
    
    Signed-off-by: Thomas Jaeger <ThJaeger at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index 2a686e8..5c1e97e 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1994,6 +1994,14 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
     if (emulate_pointer)
         storeLastValuators(dev, &mask, 0, 1, devx, devy);
 
+    /* Update the MD's co-ordinates, which are always in desktop space. */
+    if (emulate_pointer && !IsMaster(dev) && !IsFloating(dev)) {
+	    DeviceIntPtr master = GetMaster(dev, MASTER_POINTER);
+
+	    master->last.valuators[0] = screenx;
+	    master->last.valuators[1] = screeny;
+    }
+
     event->root = scr->root->drawable.id;
 
     event_set_root_coordinates(event, screenx, screeny);
commit 6a6c3afe71ac82a93d9fd0034dd5bbdcf0eae1ea
Merge: 14c9e24 6f14508
Author: Keith Packard <keithp at keithp.com>
Date:   Sun Nov 18 21:50:20 2012 -0800

    Merge remote-tracking branch 'whot/for-keith'

commit 6f145084d5b9ca4a023dfc538a69bbf30edeac4a
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Nov 16 13:46:32 2012 -0500

    linux: Prefer ioctl(KDSKBMUTE, 1) over ioctl(KDSKBMODE, K_OFF)
    
    K_OFF is a slightly broken interface, since if some other process
    (cough, systemd) sets the console state to K_UNICODE then it undoes
    K_OFF, and now Alt-F2 will switch terminals instead of summoning the
    Gnome "run command" dialog.
    
    KDSKBMUTE separates the "don't enqueue events" logic from the keymap, so
    doesn't have this problem.  Try it first, then continue falling back to
    older methods.
    
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=859485
    Tested-by: Josh Boyer <jwboyer at redhat.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 68c296b..bcb039f 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -38,6 +38,14 @@
 
 #include <sys/stat.h>
 
+#ifndef K_OFF
+#define K_OFF 0x4
+#endif
+
+#ifndef KDSKBMUTE
+#define KDSKBMUTE 0x4B51
+#endif
+
 static Bool KeepTty = FALSE;
 static int activeVT = -1;
 
@@ -213,19 +221,23 @@ xf86OpenConsole(void)
             tcgetattr(xf86Info.consoleFd, &tty_attr);
             SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
 
-#ifdef K_OFF
-            /* disable kernel special keys and buffering */
-            SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
+            /* disable kernel special keys and buffering, new style */
+            SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMUTE, 1));
             if (ret < 0)
-#endif
             {
-                SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
+                /* disable kernel special keys and buffering, old style */
+                SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
                 if (ret < 0)
-                    FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
-                               strerror(errno));
-
-                /* need to keep the buffer clean, else the kernel gets angry */
-                xf86SetConsoleHandler(drain_console, NULL);
+                {
+                    /* fine, just disable special keys */
+                    SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
+                    if (ret < 0)
+                        FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
+                                   strerror(errno));
+
+                    /* ... and drain events, else the kernel gets angry */
+                    xf86SetConsoleHandler(drain_console, NULL);
+                }
             }
 
             nTty = tty_attr;
@@ -271,6 +283,7 @@ xf86CloseConsole(void)
         xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
                 strerror(errno));
 
+    SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMUTE, 0));
     SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode));
     tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
 
commit 0ff1c77b17062a3a3ff520709ef719316bc1d8bb
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Nov 16 14:21:47 2012 +1000

    xfixes: let PointerBarrierClient->device_ids point to allocated memory
    
    "Fixed" up Jasper's original patch [1] to use pointers instead of
    zero-length arrays but didn't actually set the pointer to anywhere.
    
    [1] 9a536820f6174befb22431bab375ef1af0a1ec29
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-By: Jasper St. Pierre <jstpierre at mecheye.net>

diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 7c223dd..bd175b4 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -1300,6 +1300,10 @@ CreatePointerBarrierClient(ScreenPtr screen, ClientPtr client,
 
     ret->screen = screen;
     ret->num_devices = stuff->num_devices;
+    if (ret->num_devices > 0)
+        ret->device_ids = (int*)&ret[1];
+    else
+        ret->device_ids = NULL;
 
     in_devices = (CARD16 *) &stuff[1];
     for (i = 0; i < stuff->num_devices; i++) {
commit aa9a9ad08b8a6e7e95de7c2bf45d93dd50f9ca87
Author: Daniel Martin <consume.noise at gmail.com>
Date:   Wed Nov 7 11:31:01 2012 +0100

    Xi: Fix modifier swapping in XIPassiveGrabDevice
    
    XIPassiveGrabDevice uses a list of uint32_t as modifier sets.
    
    The ModifierInfo struct represents the current modifier states and is
    therefor used in XIQueryPointer and various events.
    
    Signed-off-by: Daniel Martin <consume.noise at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index ddab53d..62a3a46 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -50,7 +50,7 @@ int
 SProcXIPassiveGrabDevice(ClientPtr client)
 {
     int i;
-    xXIModifierInfo *mods;
+    uint32_t *mods;
 
     REQUEST(xXIPassiveGrabDeviceReq);
 
@@ -63,12 +63,10 @@ SProcXIPassiveGrabDevice(ClientPtr client)
     swaps(&stuff->mask_len);
     swaps(&stuff->num_modifiers);
 
-    mods = (xXIModifierInfo *) &stuff[1];
+    mods = (uint32_t *) &stuff[1];
 
     for (i = 0; i < stuff->num_modifiers; i++, mods++) {
-        swapl(&mods->base_mods);
-        swapl(&mods->latched_mods);
-        swapl(&mods->locked_mods);
+        swapl(mods);
     }
 
     return ProcXIPassiveGrabDevice(client);
commit aa9da5eae109154edf740a5c1eee4bf98e8fbd4f
Author: Thomas Jaeger <ThJaeger at gmail.com>
Date:   Sat Oct 13 22:39:27 2012 -0400

    remove init_event
    
    The function is identical to init_device_event from inpututils.c with
    the first two arguments swapped.
    
    Signed-off-by: Thomas Jaeger <ThJaeger at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index 8b4379d..2a686e8 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -164,17 +164,6 @@ key_autorepeats(DeviceIntPtr pDev, int key_code)
 }
 
 static void
-init_event(DeviceIntPtr dev, DeviceEvent *event, Time ms)
-{
-    memset(event, 0, sizeof(DeviceEvent));
-    event->header = ET_Internal;
-    event->length = sizeof(DeviceEvent);
-    event->time = ms;
-    event->deviceid = dev->id;
-    event->sourceid = dev->id;
-}
-
-static void
 init_touch_ownership(DeviceIntPtr dev, TouchOwnershipEvent *event, Time ms)
 {
     memset(event, 0, sizeof(TouchOwnershipEvent));
@@ -1915,7 +1904,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
     event = &events->device_event;
     num_events++;
 
-    init_event(dev, event, ms);
+    init_device_event(event, dev, ms);
     /* if submitted for master device, get the sourceid from there */
     if (flags & TOUCH_CLIENT_ID) {
         event->sourceid = touchpoint.dix_ti->sourceid;
commit 710065da37b68a9ec7a0c9dc995247f39e3d01e9
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Nov 5 15:58:25 2012 +1100

    XKB: Remove component listing support
    
    No-one uses this - not xkbcomp, not GNOME, not KDE.  The preferred way
    to deal with component listing (which gives you RMLVO rather than
    KcCGST) is to use the XML files on the client side.
    
    Indeed, a couple of hours after making this commit, it emerged that all
    *.dir files built with xkbcomp 1.1.1 (released two years ago) and later
    have been catastrophically broken and nearly empty.  So I think that's
    reasonable proof that no-one uses them.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index d584785..2b926a9 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -835,23 +835,6 @@ extern void XkbFakeDeviceButton(DeviceIntPtr /* dev */ ,
 #define	_XkbListGeometry	4
 #define	_XkbListNumComponents	5
 
-typedef struct _XkbSrvListInfo {
-    int szPool;
-    int nPool;
-    char *pool;
-
-    int maxRtrn;
-    int nTotal;
-
-    char *pattern[_XkbListNumComponents];
-    int nFound[_XkbListNumComponents];
-} XkbSrvListInfoRec, *XkbSrvListInfoPtr;
-
-extern _X_EXPORT Status XkbDDXList(DeviceIntPtr /* dev */ ,
-                                   XkbSrvListInfoPtr /* listing */ ,
-                                   ClientPtr    /* client */
-    );
-
 extern _X_EXPORT unsigned int XkbDDXLoadKeymapByNames(DeviceIntPtr /* keybd */ ,
                                                       XkbComponentNamesPtr
                                                       /* names */ ,
diff --git a/xkb/Makefile.am b/xkb/Makefile.am
index fb3ccbf..e386ce5 100644
--- a/xkb/Makefile.am
+++ b/xkb/Makefile.am
@@ -6,8 +6,7 @@ DDX_SRCS = \
         ddxBeep.c \
         ddxCtrls.c \
         ddxLEDs.c \
-        ddxLoad.c \
-        ddxList.c
+        ddxLoad.c
 
 DIX_SRCS = \
         xkb.c \
diff --git a/xkb/ddxList.c b/xkb/ddxList.c
deleted file mode 100644
index 729c5ae..0000000
--- a/xkb/ddxList.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/************************************************************
-Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
-
-Permission to use, copy, modify, and distribute this
-software and its documentation for any purpose and without
-fee is hereby granted, provided that the above copyright
-notice appear in all copies and that both that copyright
-notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
-of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
-of this software for any purpose. It is provided "as is"
-without any express or implied warranty.
-
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
-AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
-THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-********************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <X11/X.h>
-#include <X11/Xos.h>
-#include <X11/Xproto.h>
-#include <X11/keysym.h>
-#include <X11/extensions/XKM.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#define	XKBSRV_NEED_FILE_FUNCS
-#include <xkbsrv.h>
-#include <X11/extensions/XI.h>
-
-#ifdef WIN32
-/* from ddxLoad.c */
-#define W32_tmparg " '%s'"
-#define W32_tmpfile ,tmpname
-#define W32_tmplen strlen(tmpname)+3
-#else
-#define W32_tmparg
-#define W32_tmpfile
-#define W32_tmplen 0
-#endif
-
-/***====================================================================***/
-
-static const char *componentDirs[_XkbListNumComponents] = {
-    "keycodes", "types", "compat", "symbols", "geometry"
-};
-
-/***====================================================================***/
-
-static Status
-_AddListComponent(XkbSrvListInfoPtr list,
-                  int what, unsigned flags, char *str, ClientPtr client)
-{
-    int slen, wlen;
-    unsigned char *wire8;
-    unsigned short *wire16;
-    char *tmp;
-
-    if (list->nTotal >= list->maxRtrn) {
-        list->nTotal++;
-        return Success;
-    }
-    tmp = strchr(str, ')');
-    if ((tmp == NULL) && ((tmp = strchr(str, '(')) == NULL)) {
-        slen = strlen(str);
-        while ((slen > 0) && isspace(str[slen - 1])) {
-            slen--;
-        }
-    }
-    else {
-        slen = (tmp - str + 1);
-    }
-    wlen = (((slen + 1) / 2) * 2) + 4;  /* four bytes for flags and length, pad to */
-    /* 2-byte boundary */
-    if ((list->szPool - list->nPool) < wlen) {
-        if (wlen > 1024)
-            list->szPool += XkbPaddedSize(wlen * 2);
-        else
-            list->szPool += 1024;
-        list->pool = realloc(list->pool, list->szPool * sizeof(char));
-        if (!list->pool)
-            return BadAlloc;
-    }
-    wire16 = (unsigned short *) &list->pool[list->nPool];
-    wire8 = (unsigned char *) &wire16[2];
-    wire16[0] = flags;
-    wire16[1] = slen;
-    memcpy(wire8, str, slen);
-    if (client->swapped) {
-        swaps(&wire16[0]);
-        swaps(&wire16[1]);
-    }
-    list->nPool += wlen;
-    list->nFound[what]++;
-    list->nTotal++;
-    return Success;
-}
-
-/***====================================================================***/
-static Status
-XkbDDXListComponent(DeviceIntPtr dev,
-                    int what, XkbSrvListInfoPtr list, ClientPtr client)
-{
-    char *file, *map, *tmp, *buf = NULL;
-    FILE *in;
-    Status status;
-    Bool haveDir;
-
-#ifdef WIN32
-    char tmpname[PATH_MAX];
-#else
-    int rval;
-#endif
-
-    if ((list->pattern[what] == NULL) || (list->pattern[what][0] == '\0'))
-        return Success;
-    file = list->pattern[what];
-    map = strrchr(file, '(');
-    if (map != NULL) {
-        map++;
-        tmp = strrchr(map, ')');
-        if ((tmp == NULL) || (tmp[1] != '\0')) {
-            /* illegal pattern.  No error, but no match */
-            return Success;
-        }
-    }
-
-    in = NULL;
-    haveDir = TRUE;
-#ifdef WIN32
-    strcpy(tmpname, Win32TempDir());
-    strcat(tmpname, "\\xkb_XXXXXX");
-    (void) mktemp(tmpname);
-#endif
-    if (XkbBaseDirectory != NULL) {
-        if ((list->pattern[what][0] == '*') && (list->pattern[what][1] == '\0')) {
-            if (asprintf(&buf, "%s/%s.dir", XkbBaseDirectory,
-                         componentDirs[what]) == -1)
-                buf = NULL;
-            else
-                in = fopen(buf, "r");
-        }
-        if (!in) {
-            haveDir = FALSE;
-            free(buf);
-            if (asprintf
-                (&buf,
-                 "'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg,
-                 XkbBinDirectory, XkbBaseDirectory, componentDirs[what],
-                 (long) ((xkbDebugFlags < 2) ? 1 :
-                         ((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),
-                 file W32_tmpfile) == -1)
-                buf = NULL;
-        }
-    }
-    else {
-        if ((list->pattern[what][0] == '*') && (list->pattern[what][1] == '\0')) {
-            if (asprintf(&buf, "%s.dir", componentDirs[what]) == -1)
-                buf = NULL;
-            else
-                in = fopen(buf, "r");
-        }
-        if (!in) {
-            haveDir = FALSE;
-            free(buf);
-            if (asprintf
-                (&buf,
-                 "xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg,
-                 componentDirs[what],
-                 (long) ((xkbDebugFlags < 2) ? 1 :
-                         ((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),
-                 file W32_tmpfile) == -1)
-                buf = NULL;
-        }
-    }
-    status = Success;
-    if (!haveDir) {
-#ifndef WIN32
-        in = Popen(buf, "r");
-#else
-        if (xkbDebugFlags)
-            DebugF("[xkb] xkbList executes: %s\n", buf);
-        if (System(buf) < 0)
-            ErrorF("[xkb] Could not invoke keymap compiler\n");
-        else
-            in = fopen(tmpname, "r");
-#endif
-    }
-    if (!in) {
-        free(buf);
-#ifdef WIN32
-        unlink(tmpname);
-#endif
-        return BadImplementation;
-    }
-    list->nFound[what] = 0;
-    free(buf);
-    buf = malloc(PATH_MAX * sizeof(char));
-    if (!buf) {
-        fclose(in);
-#ifdef WIN32
-        unlink(tmpname);
-#endif
-        return BadAlloc;
-    }
-    while ((status == Success) && ((tmp = fgets(buf, PATH_MAX, in)) != NULL)) {
-        unsigned flags;
-        register unsigned int i;
-
-        if (*tmp == '#')        /* comment, skip it */
-            continue;
-        if (!strncmp(tmp, "Warning:", 8) || !strncmp(tmp, "        ", 8))
-            /* skip warnings too */
-            continue;
-        flags = 0;
-        /* each line in the listing is supposed to start with two */
-        /* groups of eight characters, which specify the general  */
-        /* flags and the flags that are specific to the component */
-        /* if they're missing, fail with BadImplementation        */
-        for (i = 0; (i < 8) && (status == Success); i++) {      /* read the general flags */
-            if (isalpha(*tmp))
-                flags |= (1L << i);
-            else if (*tmp != '-')
-                status = BadImplementation;
-            tmp++;
-        }
-        if (status != Success)
-            break;
-        if (!isspace(*tmp)) {
-            status = BadImplementation;
-            break;
-        }
-        else
-            tmp++;
-        for (i = 0; (i < 8) && (status == Success); i++) {      /* read the component flags */
-            if (isalpha(*tmp))
-                flags |= (1L << (i + 8));
-            else if (*tmp != '-')
-                status = BadImplementation;
-            tmp++;
-        }
-        if (status != Success)
-            break;
-        if (isspace(*tmp)) {
-            while (isspace(*tmp)) {
-                tmp++;
-            }
-        }
-        else {
-            status = BadImplementation;
-            break;
-        }
-        status = _AddListComponent(list, what, flags, tmp, client);
-    }
-#ifndef WIN32
-    if (haveDir)
-        fclose(in);
-    else if ((rval = Pclose(in)) != 0) {
-        if (xkbDebugFlags)
-            ErrorF("[xkb] xkbcomp returned exit code %d\n", rval);
-    }
-#else
-    fclose(in);
-    unlink(tmpname);
-#endif
-    free(buf);
-    return status;
-}
-
-/***====================================================================***/
-
-/* ARGSUSED */
-Status
-XkbDDXList(DeviceIntPtr dev, XkbSrvListInfoPtr list, ClientPtr client)
-{
-    Status status;
-
-    status = XkbDDXListComponent(dev, _XkbListKeycodes, list, client);
-    if (status == Success)
-        status = XkbDDXListComponent(dev, _XkbListTypes, list, client);
-    if (status == Success)
-        status = XkbDDXListComponent(dev, _XkbListCompat, list, client);
-    if (status == Success)
-        status = XkbDDXListComponent(dev, _XkbListSymbols, list, client);
-    if (status == Success)
-        status = XkbDDXListComponent(dev, _XkbListGeometry, list, client);
-    return status;
-}
diff --git a/xkb/xkb.c b/xkb/xkb.c
index efb178c..c67896f 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5620,9 +5620,9 @@ ProcXkbListComponents(ClientPtr client)
     DeviceIntPtr dev;
     xkbListComponentsReply rep;
     unsigned len;
-    int status;
     unsigned char *str;
-    XkbSrvListInfoRec list;
+    uint8_t size;
+    int i;
 
     REQUEST(xkbListComponentsReq);
     REQUEST_AT_LEAST_SIZE(xkbListComponentsReq);
@@ -5632,40 +5632,33 @@ ProcXkbListComponents(ClientPtr client)
 
     CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
 
-    status = Success;
+    /* The request is followed by six Pascal strings (i.e. size in characters
+     * followed by a string pattern) describing what the client wants us to
+     * list.  We don't care, but might as well check they haven't got the
+     * length wrong. */
     str = (unsigned char *) &stuff[1];
-    memset(&list, 0, sizeof(XkbSrvListInfoRec));
-    list.maxRtrn = stuff->maxNames;
-    list.pattern[_XkbListKeycodes] = GetComponentSpec(&str, FALSE, &status);
-    list.pattern[_XkbListTypes] = GetComponentSpec(&str, FALSE, &status);
-    list.pattern[_XkbListCompat] = GetComponentSpec(&str, FALSE, &status);
-    list.pattern[_XkbListSymbols] = GetComponentSpec(&str, FALSE, &status);
-    list.pattern[_XkbListGeometry] = GetComponentSpec(&str, FALSE, &status);
-    if (status != Success)
-        return status;
-    len = str - ((unsigned char *) stuff);
+    for (i = 0; i < 6; i++) {
+        size = *((uint8_t *)str);
+        len = (str + size + 1) - ((unsigned char *) stuff);
+        if ((XkbPaddedSize(len) / 4) > stuff->length)
+            return BadLength;
+        str += (size + 1);
+    }
     if ((XkbPaddedSize(len) / 4) != stuff->length)
         return BadLength;
-    if ((status = XkbDDXList(dev, &list, client)) != Success) {
-        free(list.pool);
-        list.pool = NULL;
-        return status;
-    }
     rep = (xkbListComponentsReply) {
         .type = X_Reply,
         .deviceID = dev->id,
         .sequenceNumber = client->sequence,
-        .length = XkbPaddedSize(list.nPool) / 4,
+        .length = 0,
         .nKeymaps = 0,
-        .nKeycodes = list.nFound[_XkbListKeycodes],
-        .nTypes = list.nFound[_XkbListTypes],
-        .nCompatMaps = list.nFound[_XkbListCompat],
-        .nSymbols = list.nFound[_XkbListSymbols],
-        .nGeometries = list.nFound[_XkbListGeometry],
+        .nKeycodes = 0,
+        .nTypes = 0,
+        .nCompatMaps = 0,
+        .nSymbols = 0,
+        .nGeometries = 0,
         .extra = 0
     };
-    if (list.nTotal > list.maxRtrn)
-        rep.extra = (list.nTotal - list.maxRtrn);
     if (client->swapped) {
         swaps(&rep.sequenceNumber);
         swapl(&rep.length);
@@ -5678,11 +5671,6 @@ ProcXkbListComponents(ClientPtr client)
         swaps(&rep.extra);
     }
     WriteToClient(client, SIZEOF(xkbListComponentsReply), &rep);
-    if (list.nPool && list.pool) {
-        WriteToClient(client, XkbPaddedSize(list.nPool), list.pool);
-        free(list.pool);
-        list.pool = NULL;
-    }
     return Success;
 }
 
commit fd214aabf77c44ba0ca3fd438f0c3c8eb22c7211
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Nov 6 10:27:25 2012 +1000

    input: drop FP1616 macro
    
    The double_to_f1616() functions do the same thing, and they're tested.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index 7e6852d..e9bdd42 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -50,6 +50,7 @@
 #include "panoramiXsrv.h"
 #endif
 
+#include "inpututils.h"
 #include "xiquerypointer.h"
 
 /***********************************************************************
@@ -127,8 +128,8 @@ ProcXIQueryPointer(ClientPtr client)
         .sequenceNumber = client->sequence,
         .length = 6,
         .root = (GetCurrentRootWindow(pDev))->drawable.id,
-        .root_x = FP1616(pSprite->hot.x, 0),
-        .root_y = FP1616(pSprite->hot.y, 0),
+        .root_x = double_to_fp1616(pSprite->hot.x),
+        .root_y = double_to_fp1616(pSprite->hot.y),
         .child = None
     };
 
@@ -166,8 +167,8 @@ ProcXIQueryPointer(ClientPtr client)
 
     if (pSprite->hot.pScreen == pWin->drawable.pScreen) {
         rep.same_screen = xTrue;
-        rep.win_x = FP1616(pSprite->hot.x - pWin->drawable.x, 0);
-        rep.win_y = FP1616(pSprite->hot.y - pWin->drawable.y, 0);
+        rep.win_x = double_to_fp1616(pSprite->hot.x - pWin->drawable.x);
+        rep.win_y = double_to_fp1616(pSprite->hot.y - pWin->drawable.y);
         for (t = pSprite->win; t; t = t->parent)
             if (t->parent == pWin) {
                 rep.child = t->drawable.id;
@@ -182,11 +183,11 @@ ProcXIQueryPointer(ClientPtr client)
 
 #ifdef PANORAMIX
     if (!noPanoramiXExtension) {
-        rep.root_x += FP1616(screenInfo.screens[0]->x, 0);
-        rep.root_y += FP1616(screenInfo.screens[0]->y, 0);
+        rep.root_x += double_to_fp1616(screenInfo.screens[0]->x);
+        rep.root_y += double_to_fp1616(screenInfo.screens[0]->y);
         if (stuff->win == rep.root) {
-            rep.win_x += FP1616(screenInfo.screens[0]->x, 0);
-            rep.win_y += FP1616(screenInfo.screens[0]->y, 0);
+            rep.win_x += double_to_fp1616(screenInfo.screens[0]->x);
+            rep.win_y += double_to_fp1616(screenInfo.screens[0]->y);
         }
     }
 #endif
diff --git a/dix/enterleave.c b/dix/enterleave.c
index 431566f..54f4b85 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -39,6 +39,7 @@
 #include "enterleave.h"
 #include "eventconvert.h"
 #include "xkbsrv.h"
+#include "inpututils.h"
 
 /**
  * @file
@@ -799,8 +800,8 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
     xi2event->deviceid = dev->id;
     xi2event->sourceid = dev->id;       /* a device doesn't change focus by itself */
     xi2event->mode = mode;
-    xi2event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
-    xi2event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
+    xi2event->root_x = double_to_fp1616(mouse->spriteInfo->sprite->hot.x);
+    xi2event->root_y = double_to_fp1616(mouse->spriteInfo->sprite->hot.y);
 
     for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
         if (BitIsOn(mouse->button->down, i))
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 41a3174..2e422d7 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -673,8 +673,8 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
     xde->valuators_len = vallen;
     xde->deviceid = ev->deviceid;
     xde->sourceid = ev->sourceid;
-    xde->root_x = FP1616(ev->root_x, ev->root_x_frac);
-    xde->root_y = FP1616(ev->root_y, ev->root_y_frac);
+    xde->root_x = double_to_fp1616(ev->root_x + ev->root_x_frac);
+    xde->root_y = double_to_fp1616(ev->root_y + ev->root_y_frac);
 
     if (ev->type == ET_TouchUpdate)
         xde->flags |= (ev->flags & TOUCH_PENDING_END) ? XITouchPendingEnd : 0;
diff --git a/dix/events.c b/dix/events.c
index e790bfc..3282ef8 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2444,8 +2444,8 @@ FixUpEventFromWindow(SpritePtr pSprite,
         }
 
         if (pSprite->hot.pScreen == pWin->drawable.pScreen) {
-            event->event_x = event->root_x - FP1616(pWin->drawable.x, 0);
-            event->event_y = event->root_y - FP1616(pWin->drawable.y, 0);
+            event->event_x = event->root_x - double_to_fp1616(pWin->drawable.x);
+            event->event_y = event->root_y - double_to_fp1616(pWin->drawable.y);
             event->child = child;
         }
         else {
@@ -4573,8 +4573,8 @@ DeviceEnterLeaveEvent(DeviceIntPtr mouse,
     event->deviceid = mouse->id;
     event->sourceid = sourceid;
     event->mode = mode;
-    event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
-    event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);
+    event->root_x = double_to_fp1616(mouse->spriteInfo->sprite->hot.x);
+    event->root_y = double_to_fp1616(mouse->spriteInfo->sprite->hot.y);
 
     for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
         if (BitIsOn(mouse->button->down, i))
diff --git a/include/eventconvert.h b/include/eventconvert.h
index 4c56d53..01172f0 100644
--- a/include/eventconvert.h
+++ b/include/eventconvert.h
@@ -29,8 +29,6 @@
 #include "events.h"
 #include "eventstr.h"
 
-#define FP1616(integral, frac) ((integral) * (1 << 16) + (frac) * (1 << 16))
-
 _X_EXPORT int EventToCore(InternalEvent *event, xEvent **core, int *count);
 _X_EXPORT int EventToXI(InternalEvent *ev, xEvent **xi, int *count);
 _X_EXPORT int EventToXI2(InternalEvent *ev, xEvent **xi);
diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index 1188e8b..bb3177c 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -338,8 +338,8 @@ test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent * out, BOOL swap)
     assert(out->event_x == 0);  /* set in FixUpEventFromWindow */
     assert(out->event_y == 0);  /* set in FixUpEventFromWindow */
 
-    assert(out->root_x == FP1616(in->root_x, in->root_x_frac));
-    assert(out->root_y == FP1616(in->root_y, in->root_y_frac));
+    assert(out->root_x == double_to_fp1616(in->root_x + in->root_x_frac));
+    assert(out->root_y == double_to_fp1616(in->root_y + in->root_y_frac));
 
     buttons = 0;
     for (i = 0; i < bits_to_bytes(sizeof(in->buttons)); i++) {


More information about the Xquartz-changes mailing list