summaryrefslogtreecommitdiff
path: root/hw/xquartz/xpr
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-10-31 18:58:57 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-10-31 19:03:38 -0700
commitc5086badf0387d4d5af10882de90a1faa180550f (patch)
tree06f0a9ab1fe6b0071e83a27d757b3b05ebd831af /hw/xquartz/xpr
parent20239a4deebccc9f86586ef6b8ef61311a6fa6a0 (diff)
XQuartz: LP64 related casting fixes from Bob Murphy
(cherry picked from commit ea71710aaa7166ab510abe70f2dc47942de0ead7)
Diffstat (limited to 'hw/xquartz/xpr')
-rw-r--r--hw/xquartz/xpr/appledri.c6
-rw-r--r--hw/xquartz/xpr/dri.c10
-rw-r--r--hw/xquartz/xpr/x-hash.c12
-rw-r--r--hw/xquartz/xpr/x-hash.h31
-rw-r--r--hw/xquartz/xpr/xprAppleWM.c7
-rw-r--r--hw/xquartz/xpr/xprCursor.c1
-rw-r--r--hw/xquartz/xpr/xprFrame.c54
7 files changed, 89 insertions, 32 deletions
diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index b4a4725e2..3667c0dea 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 5b79419dd..8feba7e9b 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -376,7 +376,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;
@@ -472,7 +472,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);
@@ -554,7 +554,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)
@@ -716,7 +716,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)
@@ -725,7 +725,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 55d28bacd..7c6a67bd1 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 3456dbedf..78bc7b317 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 64802620a..fae9a0422 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 9c131fbf8..6d1ca07ad 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 7c143b8a8..9a143ade0 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;
}