xserver: Branch 'server-1.10-branch' - 6 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Wed Oct 26 10:53:37 PDT 2011


 hw/xfree86/common/xf86Events.c         |    9 -
 hw/xfree86/os-support/linux/lnx_init.c |   14 +--
 hw/xnest/Keyboard.c                    |   25 ++++-
 hw/xquartz/xpr/appledri.c              |  149 ++++++++++++++++++++++++++++++---
 xkb/xkb.c                              |    3 
 5 files changed, 173 insertions(+), 27 deletions(-)

New commits:
commit 491bdaa83628fa0631422b5403fe671f205cc2e9
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Oct 21 10:27:16 2011 -0700

    XQuartz: appledri: Allow byte swapped requests
    
    Even though it's only valid when local, it is possible for a local
    client and the server to not match endianness, such as when running
    a ppc application under Rosetta.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 1c8bda798b4480bab0f0da6f531e4770c7a1f771)
    (cherry picked from commit 7be5492bcfab540676d6f849b85ad3db64a5ada0)

diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index 1d37de2..129fc78 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -2,7 +2,7 @@
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
 Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002, 2009 Apple Computer, Inc.
+Copyright (c) 2002, 2009-2011 Apple Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -416,21 +416,113 @@ SProcAppleDRIQueryVersion(
 }
 
 static int
+SProcAppleDRIQueryDirectRenderingCapable(
+    register ClientPtr client
+)
+{
+    register int n;
+    REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->screen, n);
+    return ProcAppleDRIQueryDirectRenderingCapable(client);
+}
+
+static int
+SProcAppleDRIAuthConnection(
+    register ClientPtr client
+)
+{
+    register int n;
+    REQUEST(xAppleDRIAuthConnectionReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->screen, n);
+    swapl(&stuff->magic, n);
+    return ProcAppleDRIAuthConnection(client);
+}
+
+static int
+SProcAppleDRICreateSurface(
+    register ClientPtr client
+)
+{
+    register int n;
+    REQUEST(xAppleDRICreateSurfaceReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->screen, n);
+    swapl(&stuff->drawable, n);
+    swapl(&stuff->client_id, n);
+    return ProcAppleDRICreateSurface(client);
+}
+
+static int
+SProcAppleDRIDestroySurface(
+    register ClientPtr client
+)
+{
+    register int n;
+    REQUEST(xAppleDRIDestroySurfaceReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->screen, n);
+    swapl(&stuff->drawable, n);
+    return ProcAppleDRIDestroySurface(client);
+}
+
+static int
+SProcAppleDRICreatePixmap(
+    register ClientPtr client
+)
+{
+    register int n;
+    REQUEST(xAppleDRICreatePixmapReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->screen, n);
+    swapl(&stuff->drawable, n);
+    return ProcAppleDRICreatePixmap(client);
+}
+
+static int
+SProcAppleDRIDestroyPixmap(
+    register ClientPtr client
+)
+{
+    register int n;
+    REQUEST(xAppleDRIDestroyPixmapReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->drawable, n);
+    return ProcAppleDRIDestroyPixmap(client);
+}
+
+static int
 SProcAppleDRIDispatch (
     register ClientPtr client
 )
 {
     REQUEST(xReq);
 
-    /* It is bound to be non-local when there is byte swapping */
+    switch (stuff->data)
+    {
+    case X_AppleDRIQueryVersion:
+        return SProcAppleDRIQueryVersion(client);
+    case X_AppleDRIQueryDirectRenderingCapable:
+        return SProcAppleDRIQueryDirectRenderingCapable(client);
+    }
+
     if (!LocalClient(client))
         return DRIErrorBase + AppleDRIClientNotLocal;
 
-    /* only local clients are allowed DRI access */
     switch (stuff->data)
     {
-    case X_AppleDRIQueryVersion:
-        return SProcAppleDRIQueryVersion(client);
+    case X_AppleDRIAuthConnection:
+        return SProcAppleDRIAuthConnection(client);
+    case X_AppleDRICreateSurface:
+        return SProcAppleDRICreateSurface(client);
+    case X_AppleDRIDestroySurface:
+        return SProcAppleDRIDestroySurface(client);
+    case X_AppleDRICreatePixmap:
+	return SProcAppleDRICreatePixmap(client);
+    case X_AppleDRIDestroyPixmap:
+	return SProcAppleDRIDestroyPixmap(client);
+
     default:
         return BadRequest;
     }
commit d9e271822012db95bc2604b59a9f2595efe0a5d7
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu Oct 20 22:34:44 2011 -0700

    XQuartz: appledri: Fix byte swapping in replies
    
    Even though it's only valid when local, it is possible for a local
    client and the server to not match endianness, such as when running
    a ppc application under Rosetta.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    (cherry picked from commit 14205ade0c750191bf43fba8bd55c65dba912cf4)
    
    Conflicts:
    
    	hw/xquartz/xpr/appledri.c
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 0ad049706d2fa8ff2758c42bdd412fb62bb1e86a)

diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index e1b4134..1d37de2 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -91,7 +91,6 @@ ProcAppleDRIQueryVersion(
 )
 {
     xAppleDRIQueryVersionReply rep;
-    register int n;
 
     REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq);
     rep.type = X_Reply;
@@ -101,8 +100,12 @@ ProcAppleDRIQueryVersion(
     rep.minorVersion = SERVER_APPLEDRI_MINOR_VERSION;
     rep.patchVersion = SERVER_APPLEDRI_PATCH_VERSION;
     if (client->swapped) {
+        register int n;
         swaps(&rep.sequenceNumber, n);
         swapl(&rep.length, n);
+        swaps(&rep.majorVersion, n);
+        swaps(&rep.minorVersion, n);
+        swapl(&rep.patchVersion, n);
     }
     WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
     return Success;
@@ -134,6 +137,12 @@ ProcAppleDRIQueryDirectRenderingCapable(
     if (!LocalClient(client))
         rep.isCapable = 0;
 
+    if (client->swapped) {
+        register int n;
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+    }
+
     WriteToClient(client, 
         sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
     return Success;
@@ -158,6 +167,14 @@ ProcAppleDRIAuthConnection(
         ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
         rep.authenticated = 0;
     }
+
+    if (client->swapped) {
+        register int n;
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+        swapl(&rep.authenticated, n); /* Yes, this is a CARD32 ... sigh */
+    }
+
     WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
     return Success;
 }
@@ -217,6 +234,15 @@ ProcAppleDRICreateSurface(
     rep.key_1 = key[1];
     rep.uid = sid;
 
+    if (client->swapped) {
+        register int n;
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+        swapl(&rep.key_0, n);
+        swapl(&rep.key_1, n);
+        swapl(&rep.uid, n);
+    }
+
     WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep);
     return Success;
 }
@@ -278,7 +304,6 @@ ProcAppleDRICreatePixmap(ClientPtr client)
 	
     rep.stringLength = strlen(path) + 1;
 		
-    /* No need for swapping, because this only runs if LocalClient is true. */
     rep.type = X_Reply;
     rep.length = bytes_to_int32(rep.stringLength);
     rep.sequenceNumber = client->sequence;
@@ -291,8 +316,20 @@ ProcAppleDRICreatePixmap(ClientPtr client)
     if(sizeof(rep) != sz_xAppleDRICreatePixmapReply)
 	ErrorF("error sizeof(rep) is %zu\n", sizeof(rep)); 
     
-    WriteReplyToClient(client, sizeof(rep), &rep);
-    (void)WriteToClient(client, rep.stringLength, path);
+    if (client->swapped) {
+        register int n;
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+        swapl(&rep.stringLength, n);
+        swapl(&rep.width, n);
+        swapl(&rep.height, n);
+        swapl(&rep.pitch, n);
+        swapl(&rep.bpp, n);
+        swapl(&rep.size, n);
+    }
+
+    WriteToClient(client, sizeof(rep), &rep);
+    WriteToClient(client, rep.stringLength, path);
 
     return Success;
 }
commit 1987c90aa4420269572ef668c4c56cf97480f5f5
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu Oct 20 22:23:07 2011 -0700

    XQuartz: appledri: Set the correct reply length for XAppleDRICreatePixmap
    
    http://xquartz.macosforge.org/trac/ticket/508
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    (cherry picked from commit 2ba0ac202ad64eb4a555715980ba538de19c9fd7)

diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index ff70a38..e1b4134 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -280,7 +280,7 @@ ProcAppleDRICreatePixmap(ClientPtr client)
 		
     /* No need for swapping, because this only runs if LocalClient is true. */
     rep.type = X_Reply;
-    rep.length = sizeof(rep) + rep.stringLength;
+    rep.length = bytes_to_int32(rep.stringLength);
     rep.sequenceNumber = client->sequence;
     rep.width = width;
     rep.height = height;
commit 6a8263737464bf07d0dd0de202afa8a78dd032e4
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun Oct 16 02:12:38 2011 -0700

    Xnest: Match the host's keymap
    
    This was a regression.
    
    Introduced by: 08363c5830bdea34012dcd954b45ccfdc79a3a7e and
                   32db27a7f867b503c2840ca7b815e96d10be9210
    Masked by: 1e69fd4a60147287b31e53bfc61543fb17bb82c8
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    (cherry picked from commit 83fef4235db86343477b4ec9858c6ba35e1aa7d9)

diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
index ec629dc..5ef376b 100644
--- a/hw/xnest/Keyboard.c
+++ b/hw/xnest/Keyboard.c
@@ -114,11 +114,13 @@ xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
 int
 xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
 {
+  XModifierKeymap *modifier_keymap;
   KeySym *keymap;
   int mapWidth;
   int min_keycode, max_keycode;
   KeySymsRec keySyms;
-  int i;
+  CARD8 modmap[MAP_LENGTH];
+  int i, j;
   XKeyboardState values;
   XkbDescPtr xkb;
   int op, event, error, major, minor;
@@ -130,7 +132,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
 #ifdef _XSERVER64
       {
 	KeySym64 *keymap64;
-	int i, len;
+	int len;
 	keymap64 = XGetKeyboardMapping(xnestDisplay,
 				     min_keycode,
 				     max_keycode - min_keycode + 1,
@@ -147,7 +149,17 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
 				   max_keycode - min_keycode + 1,
 				   &mapWidth);
 #endif
-      
+
+      memset(modmap, 0, sizeof(modmap));
+      modifier_keymap = XGetModifierMapping(xnestDisplay);
+      for (j = 0; j < 8; j++)
+            for(i = 0; i < modifier_keymap->max_keypermod; i++) {
+                  CARD8 keycode;
+                  if ((keycode = modifier_keymap->modifiermap[j * modifier_keymap->max_keypermod + i]))
+                      modmap[keycode] |= 1<<j;
+      }
+      XFreeModifiermap(modifier_keymap);
+
       keySyms.minKeyCode = min_keycode;
       keySyms.maxKeyCode = max_keycode;
       keySyms.mapWidth = mapWidth;
@@ -165,7 +177,12 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
       XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb);
 
       InitKeyboardDeviceStruct(pDev, NULL,
-			       xnestBell, xnestChangeKeyboardControl);
+                               xnestBell, xnestChangeKeyboardControl);
+
+      XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode,
+                            keySyms.maxKeyCode - keySyms.minKeyCode + 1,
+                            modmap, serverClient);
+
       XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls);
       XkbFreeKeyboard(xkb, 0, False);
       free(keymap);
commit a3dfc9c9131cc3d41f04f4d3ad194278fcb5bb25
Author: Tomáš Trnka <tomastrnka at gmx.com>
Date:   Tue Oct 11 09:11:18 2011 +0200

    Fix drain_console unregistration
    
    Bug introduced by 9dca441670d261a9a9fb6108960ed48f3d58fb7f
    xfree86: add a hook to replace the new console handler.
    
    console_handler was not being set, making the server eat up CPU spinning
    in WaitForSomething selecting consoleFd over and over again, every time
    trying to unregister drain_console without success due to
    console_handler being NULL.
    
    Let's just fix the unregistration in xf86SetConsoleHandler() and use that.
    
    But wait, there could be a catch: If some driver replaced the handler using
    xf86SetConsoleHandler(), the unregistration in xf86CloseConsole will unregister
    that one. I don't understand Xorg well enough to know whether this poses a
    problem (could mess up driver deinit somehow or something like that). As it is,
    xf86SetConsoleHandler() doesn't offer any way to prevent this (i.e. check which
    handler is currently registered).
    
    I had been using it for two days on my machine that previously hit 100% CPU
    several times a day. That has now gone away without any new problems appearing.
    
    Signed-off-by: Tomas Trnka <tomastrnka at gmx.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 323869f3298cbbfe864af9404a8aed1bf7995d79)
    (cherry picked from commit 82445286d56fdac36f21ec5eed436646bda768dd)

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 84c0d18..8511ea1 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -603,16 +603,15 @@ xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
 InputHandlerProc
 xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
 {
-    static InputHandlerProc handler = NULL;
-    InputHandlerProc old_handler = handler;
+    static IHPtr handler = NULL;
+    IHPtr old_handler = handler;
 
     if (old_handler)
         xf86RemoveGeneralHandler(old_handler);
 
-    xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
-    handler = proc;
+    handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
 
-    return old_handler;
+    return (old_handler) ? old_handler->ihproc : NULL;
 }
 
 static void
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 77dfb2f..e098e14 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -47,15 +47,12 @@ static char vtname[11];
 static struct termios tty_attr; /* tty state to restore */
 static int tty_mode; /* kbd mode to restore */
 
-static void *console_handler;
-
 static void
 drain_console(int fd, void *closure)
 {
     errno = 0;
     if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) {
-	xf86RemoveGeneralHandler(console_handler);
-	console_handler = NULL;
+        xf86SetConsoleHandler(NULL, NULL);
     }
 }
 
@@ -259,10 +256,11 @@ xf86CloseConsole(void)
         return;
     }
 
-    if (console_handler) {
-	xf86RemoveGeneralHandler(console_handler);
-	console_handler = NULL;
-    };
+    /*
+     * unregister the drain_console handler
+     * - what to do if someone else changed it in the meantime?
+     */
+    xf86SetConsoleHandler(NULL, NULL);
 
     /* Back to text mode ... */
     SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT));
commit 8011c9f160ea41120e89b55a146dc58dcb1fb716
Author: Peter Harris <pharris at opentext.com>
Date:   Fri Sep 2 18:45:16 2011 -0400

    xkb: add missing swaps for xkbGetDeviceInfoReply
    
    Caught during review of e095369bf.
    
    Signed-off-by: Peter Harris <pharris at opentext.com>
    Reviewed-by-by: Matt Turner <mattst88 at gmail.com>
    Signed-off-by: Matt Turner <mattst88 at gmail.com>
    (cherry picked from commit c90903b4f7a826ae6826a8dd0a901c8362500e46)
    
    Conflicts:
    
    	xkb/xkb.c
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit ec8ee3a9f76cc94d6fa4e7245c1a8fb68a42783c)

diff --git a/xkb/xkb.c b/xkb/xkb.c
index a8d0e80..77a9862 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -6215,6 +6215,9 @@ char *			str;
 	swaps(&rep.unsupported,n);
 	swaps(&rep.nDeviceLedFBs,n);
 	swapl(&rep.type,n);
+	swaps(&rep.dfltKbdFB, n);
+	swaps(&rep.dfltLedFB, n);
+	swapl(&rep.devType, n);
     }
     WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep);
 


More information about the xorg-commit mailing list