xserver: Branch 'xorg-server-1.5-apple' - 3 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Oct 31 19:05:55 PDT 2008


 glx/glxcmds.c                   |    2 -
 glx/indirect_dispatch.c         |    8 ++---
 glx/indirect_dispatch_swap.c    |    8 ++---
 glx/indirect_program.c          |    2 -
 hw/xquartz/GL/indirect.c        |   14 +++++-----
 hw/xquartz/X11Application.m     |    6 ++++
 hw/xquartz/quartzAudio.c        |    8 ++---
 hw/xquartz/quartzKeyboard.c     |   16 +++++++++--
 hw/xquartz/xpr/appledri.c       |    6 ++--
 hw/xquartz/xpr/dri.c            |   10 +++----
 hw/xquartz/xpr/x-hash.c         |   12 ++++----
 hw/xquartz/xpr/x-hash.h         |   31 ++++++++++++++++++++++
 hw/xquartz/xpr/xprAppleWM.c     |    7 ++---
 hw/xquartz/xpr/xprCursor.c      |    1 
 hw/xquartz/xpr/xprFrame.c       |   54 ++++++++++++++++++++++++++++------------
 miext/rootless/rootlessCommon.h |    2 -
 miext/rootless/rootlessWindow.c |    8 +++--
 17 files changed, 135 insertions(+), 60 deletions(-)

New commits:
commit 01fcbc410d7fa578dd2bcdae00b36718d189a169
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Oct 31 18:57:48 2008 -0700

    GL: LP64 related casting fixes from Bob Murphy
    (cherry picked from commit 0afd2ca49bb0dbf1b5c97ee4bcced6ab371ee385)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 95221a7..35fc3ef 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -2024,7 +2024,7 @@ int __glXDisp_BindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
             if (ret == Success) {
                 if (barrier)
                     /* add source for cleanup when drawable is gone */
-                    AddResource(drawable, __glXSwapBarrierRes, (pointer)screen);
+                    AddResource(drawable, __glXSwapBarrierRes, (pointer)(size_t)screen);
                 else
                     /* delete source */
                     FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
diff --git a/glx/indirect_dispatch.c b/glx/indirect_dispatch.c
index 2afd3eb..38ebd82 100644
--- a/glx/indirect_dispatch.c
+++ b/glx/indirect_dispatch.c
@@ -2973,7 +2973,7 @@ void __glXDisp_PrioritizeTextures(GLbyte * pc)
 void __glXDisp_TexSubImage1D(GLbyte * pc)
 {
     const CARD32 ptr_is_null = *(CARD32 *)(pc + 52);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 56);
+    const GLvoid * const pixels = (const GLvoid *) ((ptr_is_null != 0) ? NULL : (pc + 56));
     __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -2997,7 +2997,7 @@ void __glXDisp_TexSubImage1D(GLbyte * pc)
 void __glXDisp_TexSubImage2D(GLbyte * pc)
 {
     const CARD32 ptr_is_null = *(CARD32 *)(pc + 52);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 56);
+    const GLvoid * const pixels = (const GLvoid *) ((ptr_is_null != 0) ? NULL : (pc + 56));
     __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -3745,7 +3745,7 @@ void __glXDisp_ResetMinmax(GLbyte * pc)
 void __glXDisp_TexImage3D(GLbyte * pc)
 {
     const CARD32 ptr_is_null = *(CARD32 *)(pc + 76);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 80);
+    const GLvoid * const pixels = (const GLvoid *) ((ptr_is_null != 0) ? NULL : (pc + 80));
     __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -3774,7 +3774,7 @@ void __glXDisp_TexImage3D(GLbyte * pc)
 void __glXDisp_TexSubImage3D(GLbyte * pc)
 {
     const CARD32 ptr_is_null = *(CARD32 *)(pc + 84);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 88);
+    const GLvoid * const pixels = (const GLvoid *) ((ptr_is_null != 0) ? NULL : (pc + 88));
     __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
diff --git a/glx/indirect_dispatch_swap.c b/glx/indirect_dispatch_swap.c
index f137cbe..e4ad617 100644
--- a/glx/indirect_dispatch_swap.c
+++ b/glx/indirect_dispatch_swap.c
@@ -3093,7 +3093,7 @@ void __glXDispSwap_PrioritizeTextures(GLbyte * pc)
 void __glXDispSwap_TexSubImage1D(GLbyte * pc)
 {
     const CARD32 ptr_is_null = *(CARD32 *)(pc + 52);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 56);
+    const GLvoid * const pixels = (const GLvoid *) ((ptr_is_null != 0) ? NULL : (pc + 56));
     __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -3117,7 +3117,7 @@ void __glXDispSwap_TexSubImage1D(GLbyte * pc)
 void __glXDispSwap_TexSubImage2D(GLbyte * pc)
 {
     const CARD32 ptr_is_null = *(CARD32 *)(pc + 52);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 56);
+    const GLvoid * const pixels = (const GLvoid *) ((ptr_is_null != 0) ? NULL : (pc + 56));
     __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -3881,7 +3881,7 @@ void __glXDispSwap_ResetMinmax(GLbyte * pc)
 void __glXDispSwap_TexImage3D(GLbyte * pc)
 {
     const CARD32 ptr_is_null = *(CARD32 *)(pc + 76);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 80);
+    const GLvoid * const pixels = (const GLvoid *) ((ptr_is_null != 0) ? NULL : (pc + 80));
     __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
@@ -3910,7 +3910,7 @@ void __glXDispSwap_TexImage3D(GLbyte * pc)
 void __glXDispSwap_TexSubImage3D(GLbyte * pc)
 {
     const CARD32 ptr_is_null = *(CARD32 *)(pc + 84);
-    const GLvoid * const pixels = (const GLvoid *) (ptr_is_null != 0) ? NULL : (pc + 88);
+    const GLvoid * const pixels = (const GLvoid *) ((ptr_is_null != 0) ? NULL : (pc + 88));
     __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);
 
     CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );
diff --git a/glx/indirect_program.c b/glx/indirect_program.c
index d23a0a9..cbea40e 100644
--- a/glx/indirect_program.c
+++ b/glx/indirect_program.c
@@ -103,7 +103,7 @@ int DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte *pc,
 	    CALL_by_offset(GET_DISPATCH(), 
 			   (void (GLAPIENTRYP)(GLuint, GLenum, GLubyte *)),
 			   get_program_string_offset,
-			   (target, pname, answer));
+			   (target, pname, (GLubyte *)answer));
 	}
 
 	if (__glXErrorOccured()) {
commit b7ec1fa59c32d188184c37811588fe1f92ad2576
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Oct 31 18:58:57 2008 -0700

    XQuartz: LP64 related casting fixes from Bob Murphy
    (cherry picked from commit ea71710aaa7166ab510abe70f2dc47942de0ead7)

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index 5cf12cc..f24f1fb 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -232,9 +232,9 @@ static void __glXAquaContextDestroy(__GLXcontext *baseContext) {
                      (unsigned int) baseContext);
     if (context != NULL) {
       if (context->sid != 0 && surface_hash != NULL) {
-		lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL);
+		lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
 		lst = x_list_remove(lst, context);
-		x_hash_table_insert(surface_hash, (void *) context->sid, lst);
+		x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
       }
 
       if (context->ctx != NULL) CGLDestroyContext(context->ctx);
@@ -275,14 +275,14 @@ static void surface_notify(void *_arg, void *data) {
     switch (arg->kind) {
     case AppleDRISurfaceNotifyDestroyed:
         if (surface_hash != NULL)
-            x_hash_table_remove(surface_hash, (void *) arg->id);
+            x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id));
 	        draw->base.pDraw = NULL;
 			draw->sid = 0;
         break;
 
     case AppleDRISurfaceNotifyChanged:
         if (surface_hash != NULL) {
-            lst = x_hash_table_lookup(surface_hash, (void *) arg->id, NULL);
+            lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL);
             for (; lst != NULL; lst = lst->next)
             {
                 context = lst->data;
@@ -318,7 +318,7 @@ static void attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
             DRIDestroySurface(pDraw->pScreen, pDraw->id, pDraw,
 								surface_notify, draw);
             if (surface_hash != NULL)
-                x_hash_table_remove(surface_hash, (void *) draw->sid);
+                x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(draw->sid));
 
             draw->sid = 0;
             return;
@@ -330,10 +330,10 @@ static void attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
         if (surface_hash == NULL)
             surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
 
-        lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL);
+        lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
         if (x_list_find(lst, context) == NULL) {
             lst = x_list_prepend(lst, context);
-            x_hash_table_insert(surface_hash, (void *) context->sid, lst);
+            x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
         }
 
         GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id,
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 055ce2a..fb97477 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -353,8 +353,14 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 }
 
 - (void) show_hide_menubar:(NSNumber *)state {
+#if defined(__LP64__)
+	/* Also shows/hides the dock */
+	if ([state boolValue]) SetSystemUIMode(kUIModeNormal, 0);
+	else SetSystemUIMode(kUIModeAllHidden, 0);
+#else
 	if ([state boolValue]) ShowMenuBar ();
 	else HideMenuBar ();
+#endif
 }
 
 
diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c
index d3698d7..2e8f3a4 100644
--- a/hw/xquartz/quartzAudio.c
+++ b/hw/xquartz/quartzAudio.c
@@ -238,7 +238,7 @@ static void QuartzCoreAudioBell(
         OSStatus status;
         status = AudioDeviceStart(quartzAudioDevice, QuartzAudioIOProc);
         if (status) {
-            ErrorF("QuartzAudioBell: AudioDeviceStart returned %ld\n", status);
+            ErrorF("QuartzAudioBell: AudioDeviceStart returned %ld\n", (long)status);
         } else {
             data.playing = TRUE;
         }
@@ -299,7 +299,7 @@ void QuartzAudioInit(void)
                     &propertySize, &outputDevice);
     if (status) {
         ErrorF("QuartzAudioInit: AudioHardwareGetProperty returned %ld\n",
-               status);
+               (long)status);
         return;
     }
     if (outputDevice == kAudioDeviceUnknown) {
@@ -314,7 +314,7 @@ void QuartzAudioInit(void)
                                     &propertySize, &outputStreamDescription);
     if (status) {
         ErrorF("QuartzAudioInit: GetProperty(stream format) returned %ld\n",
-               status);
+               (long)status);
         return;
     }
     sampleRate = outputStreamDescription.mSampleRate;
@@ -339,7 +339,7 @@ void QuartzAudioInit(void)
     // Prepare for playback
     status = AudioDeviceAddIOProc(outputDevice, QuartzAudioIOProc, &data);
     if (status) {
-        ErrorF("QuartzAudioInit: AddIOProc returned %ld\n", status);
+        ErrorF("QuartzAudioInit: AddIOProc returned %ld\n", (long)status);
         return;
     }
 
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index eb57546..b462c77 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -701,13 +701,16 @@ static KeySym make_dead_key(KeySym in) {
 }
 
 Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
-#if !defined(__x86_64__) && !defined(__ppc64__)
+#if !defined(__LP64__)
     KeyboardLayoutRef key_layout;
 #endif
     const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
     UInt32 keyboard_type = 0;
-    int is_uchr = 1, i, j;
+#if !defined(__LP64__)
+    int is_uchr = 1;
+#endif
+    int i, j;
     OSStatus err;
     KeySym *k;
     CFDataRef currentKeyLayoutDataRef = NULL;
@@ -721,7 +724,7 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
           chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
     }
 
-#if !defined(__x86_64__) && !defined(__ppc64__)
+#if !defined(__LP64__)
     if (chr_data == NULL) {
         ErrorF("X11.app: Error detected in determining keyboard layout.  If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
         ErrorF("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
@@ -757,6 +760,9 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
        key produces in the four shift states. Then convert that to
        an X11 keysym (which may just the bit that says "this is
        Unicode" if it can't find the real symbol.) */
+       
+    /* KeyTranslate is not available on 64-bit platforms; UCKeyTranslate
+       must be used instead. */
 
     for (i = 0; i < num_keycodes; i++) {
         static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
@@ -765,7 +771,9 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
         k = info->keyMap + i * GLYPHS_PER_KEY;
 
         for (j = 0; j < 4; j++) {
+#if !defined(__LP64__)
             if (is_uchr)  {
+#endif
                 UniChar s[8];
                 UniCharCount len;
                 UInt32 dead_key_state = 0, extra_dead = 0;
@@ -789,6 +797,7 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
                     k[j] = ucs2keysym (s[0]);
                     if (dead_key_state != 0) k[j] = make_dead_key (k[j]);
                 }
+#if !defined(__LP64__)
             } else { // kchr
 	      UInt32 c, state = 0, state2 = 0;
                 UInt16 code;
@@ -812,6 +821,7 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
                     if (state != 0) k[j] = make_dead_key (k[j]);
                 }
             }
+#endif
         }
 	
         if (k[3] == k[2]) k[3] = NoSymbol;
diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index b4a4725..3667c0d 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -56,6 +56,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "dri.h"
 #include "dristruct.h"
 #include "xpr.h"
+#include "x-hash.h"
 
 static int DRIErrorBase = 0;
 
@@ -190,7 +191,7 @@ static void surface_notify(
 )
 {
     DRISurfaceNotifyArg *arg = _arg;
-    int client_index = (int) data;
+    int client_index = (int) x_cvt_vptr_to_uint(data);
     ClientPtr client;
     xAppleDRINotifyEvent se;
 
@@ -236,7 +237,8 @@ ProcAppleDRICreateSurface(
     if (!DRICreateSurface( screenInfo.screens[stuff->screen],
                            (Drawable)stuff->drawable, pDrawable,
                            stuff->client_id, &sid, key,
-                           surface_notify, (void *) client->index)) {
+                           surface_notify,
+                           x_cvt_uint_to_vptr(client->index))) {
         return BadValue;
     }
 
diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index 3aacb19..591568e 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -373,7 +373,7 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
             pDRIDrawablePriv->notifiers = NULL;
 
             /* find the physical window */
-            wid = (xp_window_id) RootlessFrameForWindow(pWin, TRUE);
+            wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
             if (wid == 0) {
                 xfree(pDRIDrawablePriv);
                 return FALSE;
@@ -469,7 +469,7 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
         if (surface_hash == NULL)
             surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
         x_hash_table_insert(surface_hash,
-                            (void *) pDRIDrawablePriv->sid, pDRIDrawablePriv);
+                            x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), pDRIDrawablePriv);
 
         /* track this in case this window is destroyed */
         AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
@@ -551,7 +551,7 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
 
     if (pDRIDrawablePriv->sid != 0) {
         xp_destroy_surface(pDRIDrawablePriv->sid);
-        x_hash_table_remove(surface_hash, (void *) pDRIDrawablePriv->sid);
+        x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(pDRIDrawablePriv->sid));
     }
 
     if (pDRIDrawablePriv->notifiers != NULL)
@@ -713,7 +713,7 @@ DRISurfaceNotify(xp_surface_id id, int kind)
     if (surface_hash != NULL)
     {
         pDRIDrawablePriv = x_hash_table_lookup(surface_hash,
-                                               (void *) id, NULL);
+                                               x_cvt_uint_to_vptr(id), NULL);
     }
 
     if (pDRIDrawablePriv == NULL)
@@ -722,7 +722,7 @@ DRISurfaceNotify(xp_surface_id id, int kind)
     if (kind == AppleDRISurfaceNotifyDestroyed)
     {
         pDRIDrawablePriv->sid = 0;
-        x_hash_table_remove(surface_hash, (void *) id);
+        x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id));
     }
 
     x_hook_run(pDRIDrawablePriv->notifiers, &arg);
diff --git a/hw/xquartz/xpr/x-hash.c b/hw/xquartz/xpr/x-hash.c
index 55d28ba..7c6a67b 100644
--- a/hw/xquartz/xpr/x-hash.c
+++ b/hw/xquartz/xpr/x-hash.c
@@ -80,13 +80,13 @@ hash_table_destroy_item (x_hash_table *h, void *k, void *v)
         (*h->destroy_value) (v);
 }
 
-static inline unsigned int
+static inline size_t
 hash_table_hash_key (x_hash_table *h, void *k)
 {
     if (h->hash_key != 0)
         return (*h->hash_key) (k);
     else
-        return (unsigned int) k;
+        return (size_t) k;
 }
 
 static inline int
@@ -104,7 +104,7 @@ hash_table_split (x_hash_table *h)
     x_list **new, **old;
     x_list *node, *item, *next;
     int new_size, old_size;
-    unsigned int b;
+    size_t b;
     int i;
 
     if (h->bucket_index == N_BUCKET_SIZES - 1)
@@ -207,7 +207,7 @@ X_PFX (hash_table_size) (x_hash_table *h)
 static void
 hash_table_modify (x_hash_table *h, void *k, void *v, int replace)
 {
-    unsigned int hash_value;
+    size_t hash_value;
     x_list *node, *item;
 
     assert (h != NULL);
@@ -266,7 +266,7 @@ X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v)
 X_EXTERN void
 X_PFX (hash_table_remove) (x_hash_table *h, void *k)
 {
-    unsigned int hash_value;
+    size_t hash_value;
     x_list **ptr, *item;
 
     assert (h != NULL);
@@ -294,7 +294,7 @@ X_PFX (hash_table_remove) (x_hash_table *h, void *k)
 X_EXTERN void *
 X_PFX (hash_table_lookup) (x_hash_table *h, void *k, void **k_ret)
 {
-    unsigned int hash_value;
+    size_t hash_value;
     x_list *node, *item;
 
     assert (h != NULL);
diff --git a/hw/xquartz/xpr/x-hash.h b/hw/xquartz/xpr/x-hash.h
index 3456dbe..78bc7b3 100644
--- a/hw/xquartz/xpr/x-hash.h
+++ b/hw/xquartz/xpr/x-hash.h
@@ -30,6 +30,9 @@
 #ifndef X_HASH_H
 #define X_HASH_H 1
 
+#include <stdlib.h>
+#include <assert.h>
+
 typedef struct x_hash_table_struct x_hash_table;
 
 typedef int (x_compare_fun) (const void *a, const void *b);
@@ -57,4 +60,32 @@ X_EXTERN void X_PFX (hash_table_foreach) (x_hash_table *h,
 					  x_hash_foreach_fun *fun,
 					  void *data);
 
+/* Conversion between unsigned int (e.g. xp_resource_id) and void pointer */
+
+/* Forward declarations */
+static __inline__ void *
+X_PFX (cvt_uint_to_vptr) (unsigned int val) __attribute__((always_inline));
+static __inline__ unsigned int
+X_PFX (cvt_vptr_to_uint) (void * val) __attribute__((always_inline));
+
+/* Implementations */
+static __inline__ void *
+X_PFX (cvt_uint_to_vptr) (unsigned int val)
+{
+	return (void*)((size_t)(val));
+}
+
+static __inline__ unsigned int
+X_PFX (cvt_vptr_to_uint) (void * val)
+{
+	size_t sv = (size_t)val;
+	unsigned int uv = (unsigned int)sv;
+	
+	/* If this assert fails, chances are val actually is a pointer,
+	   or there's been memory corruption */
+	assert(sv == uv);
+	
+	return uv;
+}
+
 #endif /* X_HASH_H */
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index 6480262..fae9a04 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -41,12 +41,13 @@
 #include <Xplugin.h>
 #include <X11/X.h>
 #include "quartz.h"
+#include "x-hash.h"
 
 /* This lookup table came straight from the Tiger X11 source.  I tried to figure
  * it out based on CGWindowLevel.h, but I dunno... -JH
  */
 static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
-0, 3, 4, 5, LONG_MIN + 30, LONG_MIN + 29,
+0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
 };
 static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
 202, 203, 204, 205, 201, 200
@@ -59,7 +60,7 @@ static int xprSetWindowLevel(
     xp_window_id wid;
     xp_window_changes wc;
 
-    wid = (xp_window_id) RootlessFrameForWindow (pWin, TRUE);
+    wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, TRUE));
     if (wid == 0)
         return BadWindow;
 
@@ -90,7 +91,7 @@ static int xprFrameDraw(
 {
     xp_window_id wid;
 
-    wid = (xp_window_id) RootlessFrameForWindow (pWin, FALSE);
+    wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, FALSE));
     if (wid == 0)
         return BadWindow;
 
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index 7088223..5c448c9 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -49,6 +49,7 @@
 #include "globals.h"
 #include "servermd.h"
 #include "dixevents.h"
+#include "x-hash.h"
 
 typedef struct {
     int                     cursorVisible;
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 7c143b8..9a143ad 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -64,6 +64,28 @@ DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
 static x_hash_table *window_hash;
 static pthread_mutex_t window_hash_mutex;
 
+/* Prototypes for static functions */
+static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+               int newX, int newY, RegionPtr pShape);
+static void xprDestroyFrame(RootlessFrameID wid);
+static void xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
+static void xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+               int newX, int newY, unsigned int newW, unsigned int newH,
+               unsigned int gravity);
+static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid);
+static void xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape);
+static void xprUnmapFrame(RootlessFrameID wid);
+static void xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow);
+static void xprStopDrawing(RootlessFrameID wid, Bool flush);
+static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage);
+static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
+               int shift_x, int shift_y);
+static void xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
+static Bool xprDoReorderWindow(RootlessWindowPtr pFrame);
+static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+              int dx, int dy);
+
+
 static inline xp_error
 xprConfigureWindow(xp_window_id id, unsigned int mask,
                    const xp_window_changes *values)
@@ -83,7 +105,7 @@ xprSetNativeProperty(RootlessWindowPtr pFrame)
 
     TA_SERVER();
     
-    err = xp_get_native_window((xp_window_id) pFrame->wid, &native_id);
+    err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id);
     if (err == Success)
     {
         /* FIXME: move this to AppleWM extension */
@@ -174,7 +196,7 @@ xprDestroyFrame(RootlessFrameID wid)
     x_hash_table_remove(window_hash, wid);
     pthread_mutex_unlock(&window_hash_mutex);
 
-    xp_destroy_window((xp_window_id) wid);
+    xp_destroy_window(x_cvt_vptr_to_uint(wid));
 }
 
 
@@ -191,7 +213,7 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
     wc.x = newX;
     wc.y = newY;
     //    ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
-    xprConfigureWindow((xp_window_id) wid, XP_ORIGIN, &wc);
+    xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_ORIGIN, &wc);
 }
 
 
@@ -216,7 +238,7 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
     /* It's unlikely that being async will save us anything here.
        But it can't hurt. */
 
-    xprConfigureWindow((xp_window_id) wid, XP_BOUNDS, &wc);
+    xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_BOUNDS, &wc);
 }
 
 
@@ -241,10 +263,10 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
     else
     {
         wc.stack_mode = XP_MAPPED_BELOW;
-        wc.sibling = (xp_window_id) nextWid;
+        wc.sibling = x_cvt_vptr_to_uint(nextWid);
     }
 
-    xprConfigureWindow((xp_window_id) wid, XP_STACKING, &wc);
+    xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc);
 }
 
 
@@ -271,7 +293,7 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
 
     wc.shape_tx = wc.shape_ty = 0;
 
-    xprConfigureWindow((xp_window_id) wid, XP_SHAPE, &wc);
+    xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_SHAPE, &wc);
 }
 
 
@@ -288,7 +310,7 @@ xprUnmapFrame(RootlessFrameID wid)
     wc.stack_mode = XP_UNMAPPED;
     wc.sibling = 0;
 
-    xprConfigureWindow((xp_window_id) wid, XP_STACKING, &wc);
+    xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc);
 }
 
 
@@ -305,9 +327,9 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
 
     TA_SERVER();
     
-    err = xp_lock_window((xp_window_id) wid, NULL, NULL, data, rowbytes, NULL);
+    err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL);
     if (err != Success)
-        FatalError("Could not lock window %i for drawing.", (int) wid);
+        FatalError("Could not lock window %i for drawing.", (int)x_cvt_vptr_to_uint(wid));
 
     *pixelData = data[0];
     *bytesPerRow = rowbytes[0];
@@ -322,7 +344,7 @@ xprStopDrawing(RootlessFrameID wid, Bool flush)
 {
     TA_SERVER();
     
-    xp_unlock_window((xp_window_id) wid, flush);
+    xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
 }
 
 
@@ -334,7 +356,7 @@ xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
 {
     TA_SERVER();
     
-    xp_flush_window((xp_window_id) wid);
+    xp_flush_window(x_cvt_vptr_to_uint(wid));
 }
 
 
@@ -347,7 +369,7 @@ xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
 {
     TA_SERVER();
     
-    xp_mark_window((xp_window_id) wid, nrects, rects, shift_x, shift_y);
+    xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y);
 }
 
 
@@ -389,7 +411,7 @@ xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
 {
     TA_SERVER();
     
-    xp_copy_window((xp_window_id) wid, (xp_window_id) wid,
+    xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid),
                    dstNrects, dstRects, dx, dy);
 }
 
@@ -446,7 +468,7 @@ xprGetXWindow(xp_window_id wid)
     if (window_hash == NULL)
         return NULL;
 
-    winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
+    winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
 
     return winRec != NULL ? winRec->win : NULL;
 }
@@ -477,7 +499,7 @@ xprGetXWindowFromAppKit(int windowNumber)
     pthread_mutex_unlock(&window_hash_mutex);
 
     if (!ret) return NULL;
-    winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
+    winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
 
     return winRec != NULL ? winRec->win : NULL;
 }
commit 836ed7b7bc7a758fc1ed1e1415166bb60b813970
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Oct 31 18:58:25 2008 -0700

    Rootless: LP64 related casting fixes from Bob Murphy
    (cherry picked from commit 40441c4e31167932721a79d7ca572caaa1d36e72)

diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index a8c2878..3cbd359 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -242,7 +242,7 @@ extern RegionRec rootlessHugeRoot;
                             ((int)(_x) * _pPix->drawable.bitsPerPixel/8 +   \
                              (int)(_y) * _pPix->devKind);                   \
     if (_pPix->drawable.bitsPerPixel != FB_UNIT) {                          \
-        unsigned _diff = ((unsigned) _pPix->devPrivate.ptr) &               \
+        size_t _diff = ((size_t) _pPix->devPrivate.ptr) &               \
                          (FB_UNIT / CHAR_BIT - 1);                          \
         _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) -          \
                                 _diff;                                      \
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index ea47d63..cffc164 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -63,6 +63,8 @@ extern int darwinMainScreenX, darwinMainScreenY;
 #define SCREEN_TO_GLOBAL_Y 0
 #endif
 
+#define MAKE_WINDOW_ID(x)		((xp_window_id)((size_t)(x)))
+
 #define DEFINE_ATOM_HELPER(func,atom_name)                      \
   static Atom func (void) {                                       \
     static unsigned int generation = 0;                             \
@@ -134,7 +136,7 @@ void RootlessNativeWindowMoved (WindowPtr pWin) {
     
     winRec = WINREC(pWin);
     
-    if (xp_get_window_bounds ((xp_window_id)winRec->wid, &bounds) != Success) return;
+    if (xp_get_window_bounds (MAKE_WINDOW_ID(winRec->wid), &bounds) != Success) return;
     
     sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
     sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
@@ -1507,7 +1509,7 @@ RootlessFlushWindowColormap (WindowPtr pWin)
   wc.colormap = RootlessColormapCallback;
   wc.colormap_data = pWin->drawable.pScreen;
 
-  configure_window ((xp_window_id)winRec->wid, XP_COLORMAP, &wc);
+  configure_window (MAKE_WINDOW_ID(winRec->wid), XP_COLORMAP, &wc);
 }
 
 /*
@@ -1653,7 +1655,7 @@ RootlessHideAllWindows (void)
             {
                 wc.stack_mode = XP_UNMAPPED;
                 wc.sibling = 0;
-                configure_window ((xp_window_id)winRec->wid, XP_STACKING, &wc);
+                configure_window (MAKE_WINDOW_ID(winRec->wid), XP_STACKING, &wc);
             }
         }
     }


More information about the xorg-commit mailing list