diff options
author | marha <marha@users.sourceforge.net> | 2011-04-28 07:58:00 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-04-28 07:58:00 +0000 |
commit | 57a879849643e79d9674198a3a77c59532fb79b4 (patch) | |
tree | 19ece2254fadb6c2077aa09098dd8a51a5578d2a /xorg-server/hw/xquartz/xpr/xprFrame.c | |
parent | 96d6df5da9cddedf4931bf8e17f96e242467c661 (diff) | |
download | vcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.tar.gz vcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.tar.bz2 vcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.zip |
xserver xkeyboard-config mesa git update 28 Apr 2011
Diffstat (limited to 'xorg-server/hw/xquartz/xpr/xprFrame.c')
-rw-r--r-- | xorg-server/hw/xquartz/xpr/xprFrame.c | 167 |
1 files changed, 63 insertions, 104 deletions
diff --git a/xorg-server/hw/xquartz/xpr/xprFrame.c b/xorg-server/hw/xquartz/xpr/xprFrame.c index 15598e942..5f6b1cb7b 100644 --- a/xorg-server/hw/xquartz/xpr/xprFrame.c +++ b/xorg-server/hw/xquartz/xpr/xprFrame.c @@ -1,7 +1,7 @@ /* * Xplugin rootless implementation frame functions * - * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2002-2011 Apple Computer, Inc. All rights reserved. * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -35,7 +35,6 @@ #include "rootlessCommon.h" #include <Xplugin.h> #include "x-hash.h" -#include "x-list.h" #include "applewmExt.h" #include "propertyst.h" @@ -44,9 +43,11 @@ #include "windowstr.h" #include "quartz.h" -#include "threadSafety.h" - +#ifdef HAVE_LIBDISPATCH +#include <dispatch/dispatch.h> +#else #include <pthread.h> +#endif #define DEFINE_ATOM_HELPER(func,atom_name) \ static Atom func (void) { \ @@ -63,7 +64,13 @@ DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID") /* Maps xp_window_id -> RootlessWindowRec */ static x_hash_table *window_hash; + +/* Need to guard window_hash since xprIsX11Window can be called from any thread. */ +#ifdef HAVE_LIBDISPATCH +static dispatch_queue_t window_hash_serial_q; +#else static pthread_mutex_t window_hash_mutex; +#endif /* Prototypes for static functions */ static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, @@ -93,8 +100,6 @@ static inline xp_error xprConfigureWindow(xp_window_id id, unsigned int mask, const xp_window_changes *values) { - TA_SERVER(); - return xp_configure_window(id, mask, values); } @@ -106,8 +111,6 @@ xprSetNativeProperty(RootlessWindowPtr pFrame) unsigned int native_id; long data; - TA_SERVER(); - err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id); if (err == Success) { @@ -137,8 +140,6 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, unsigned int mask = 0; xp_error err; - TA_SERVER(); - wc.x = newX; wc.y = newY; wc.width = pFrame->width; @@ -186,15 +187,15 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, return FALSE; } - if (window_hash == NULL) - { - window_hash = x_hash_table_new(NULL, NULL, NULL, NULL); - pthread_mutex_init(&window_hash_mutex, NULL); - } - +#ifdef HAVE_LIBDISPATCH + dispatch_async(window_hash_serial_q, ^{ + x_hash_table_insert(window_hash, pFrame->wid, pFrame); + }); +#else pthread_mutex_lock(&window_hash_mutex); x_hash_table_insert(window_hash, pFrame->wid, pFrame); pthread_mutex_unlock(&window_hash_mutex); +#endif xprSetNativeProperty(pFrame); @@ -209,11 +210,16 @@ static void xprDestroyFrame(RootlessFrameID wid) { xp_error err; - TA_SERVER(); - + +#ifdef HAVE_LIBDISPATCH + dispatch_async(window_hash_serial_q, ^{ + x_hash_table_remove(window_hash, wid); + }); +#else pthread_mutex_lock(&window_hash_mutex); x_hash_table_remove(window_hash, wid); pthread_mutex_unlock(&window_hash_mutex); +#endif err = xp_destroy_window(x_cvt_vptr_to_uint(wid)); if (err != Success) @@ -229,8 +235,6 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY) { xp_window_changes wc; - TA_SERVER(); - wc.x = newX; wc.y = newY; // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY); @@ -248,8 +252,6 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, { xp_window_changes wc; - TA_SERVER(); - wc.x = newX; wc.y = newY; wc.width = newW; @@ -269,9 +271,11 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { xp_window_changes wc; unsigned int mask = XP_STACKING; +#ifdef HAVE_LIBDISPATCH + __block +#endif + RootlessWindowRec *winRec; - TA_SERVER(); - /* Stack frame below nextWid it if it exists, or raise frame above everything otherwise. */ @@ -283,18 +287,24 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { wc.sibling = x_cvt_vptr_to_uint(nextWid); } - if(window_hash) { - RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, wid, NULL); - - if(winRec) { - if(XQuartzIsRootless) - wc.window_level = normal_window_levels[winRec->level]; - else if(XQuartzShieldingWindowLevel) - wc.window_level = XQuartzShieldingWindowLevel + 1; - else - wc.window_level = rooted_window_levels[winRec->level]; - mask |= XP_WINDOW_LEVEL; - } +#ifdef HAVE_LIBDISPATCH + dispatch_sync(window_hash_serial_q, ^{ + winRec = x_hash_table_lookup(window_hash, wid, NULL); + }); +#else + pthread_mutex_lock(&window_hash_mutex); + winRec = x_hash_table_lookup(window_hash, wid, NULL); + pthread_mutex_unlock(&window_hash_mutex); +#endif + + if(winRec) { + if(XQuartzIsRootless) + wc.window_level = normal_window_levels[winRec->level]; + else if(XQuartzShieldingWindowLevel) + wc.window_level = XQuartzShieldingWindowLevel + 1; + else + wc.window_level = rooted_window_levels[winRec->level]; + mask |= XP_WINDOW_LEVEL; } xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc); @@ -309,8 +319,6 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape) { xp_window_changes wc; - TA_SERVER(); - if (pShape != NULL) { wc.shape_nrects = RegionNumRects(pShape); @@ -336,8 +344,6 @@ xprUnmapFrame(RootlessFrameID wid) { xp_window_changes wc; - TA_SERVER(); - wc.stack_mode = XP_UNMAPPED; wc.sibling = 0; @@ -356,8 +362,6 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow) unsigned int rowbytes[2]; xp_error err; - TA_SERVER(); - 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)x_cvt_vptr_to_uint(wid)); @@ -374,8 +378,7 @@ static void xprStopDrawing(RootlessFrameID wid, Bool flush) { xp_error err; - TA_SERVER(); - + err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush); if(err != Success) FatalError("Could not unlock window %i after drawing.", (int)x_cvt_vptr_to_uint(wid)); @@ -388,8 +391,6 @@ xprStopDrawing(RootlessFrameID wid, Bool flush) static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage) { - TA_SERVER(); - xp_flush_window(x_cvt_vptr_to_uint(wid)); } @@ -401,8 +402,6 @@ static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects, int shift_x, int shift_y) { - TA_SERVER(); - xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y); } @@ -416,8 +415,6 @@ xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin) { DeleteProperty(serverClient, oldWin, xa_native_window_id()); - TA_SERVER(); - xprSetNativeProperty(pFrame); } @@ -429,8 +426,6 @@ static Bool xprDoReorderWindow(RootlessWindowPtr pFrame) { WindowPtr pWin = pFrame->win; - TA_SERVER(); - return AppleWMDoReorderWindow(pWin); } @@ -443,8 +438,6 @@ static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, int dx, int dy) { - TA_SERVER(); - xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid), dstNrects, dstRects, dx, dy); } @@ -479,11 +472,16 @@ xprInit(ScreenPtr pScreen) { RootlessInit(pScreen, &xprRootlessProcs); - TA_SERVER(); - rootless_CopyBytes_threshold = xp_copy_bytes_threshold; rootless_CopyWindow_threshold = xp_scroll_area_threshold; + assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL))); +#ifdef HAVE_LIBDISPATCH + assert((window_hash_serial_q = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.xpr_window_hash", NULL))); +#else + assert(0 == pthread_mutex_init(&window_hash_mutex, NULL)); +#endif + return TRUE; } @@ -495,73 +493,36 @@ xprInit(ScreenPtr pScreen) WindowPtr xprGetXWindow(xp_window_id wid) { +#ifdef HAVE_LIBDISPATCH + RootlessWindowRec *winRec __block; + dispatch_sync(window_hash_serial_q, ^{ + winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); + }); +#else RootlessWindowRec *winRec; - - if (window_hash == NULL) - return NULL; - - winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); - - return winRec != NULL ? winRec->win : NULL; -} - -#ifdef UNUSED_CODE -/* - * Given the id of a physical window, try to find the top-level (or root) - * X window that it represents. - */ -WindowPtr -xprGetXWindowFromAppKit(int windowNumber) -{ - RootlessWindowRec *winRec; - Bool ret; - xp_window_id wid; - - if (window_hash == NULL) - return FALSE; - - /* need to lock, since this function can be called by any thread */ - pthread_mutex_lock(&window_hash_mutex); - - if (xp_lookup_native_window(windowNumber, &wid)) - ret = xprGetXWindow(wid) != NULL; - else - ret = FALSE; - - pthread_mutex_unlock(&window_hash_mutex); - - if (!ret) return NULL; winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); + pthread_mutex_unlock(&window_hash_mutex); +#endif return winRec != NULL ? winRec->win : NULL; } -#endif /* * The windowNumber is an AppKit window number. Returns TRUE if xpr is * displaying a window with that number. */ Bool -xprIsX11Window(void *nsWindow, int windowNumber) +xprIsX11Window(int windowNumber) { Bool ret; xp_window_id wid; - if (window_hash == NULL) - return FALSE; - - /* need to lock, since this function can be called by any thread */ - - pthread_mutex_lock(&window_hash_mutex); - if (xp_lookup_native_window(windowNumber, &wid)) ret = xprGetXWindow(wid) != NULL; else ret = FALSE; - pthread_mutex_unlock(&window_hash_mutex); - return ret; } @@ -578,8 +539,6 @@ xprHideWindows(Bool hide) int screen; WindowPtr pRoot, pWin; - TA_SERVER(); - for (screen = 0; screen < screenInfo.numScreens; screen++) { RootlessFrameID prevWid = NULL; pRoot = screenInfo.screens[screen]->root; |