aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/xpr
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-04-28 11:14:32 +0000
committermarha <marha@users.sourceforge.net>2011-04-28 11:14:32 +0000
commit1840c5631682e0a69ed11487a23a43d45f2d15e1 (patch)
treefe954636044c0057b9f08e76d19489493ff09745 /xorg-server/hw/xquartz/xpr
parent2ab09dc03e4ecc726ee7b5528306b0fe3e5b1837 (diff)
parent57a879849643e79d9674198a3a77c59532fb79b4 (diff)
downloadvcxsrv-1840c5631682e0a69ed11487a23a43d45f2d15e1.tar.gz
vcxsrv-1840c5631682e0a69ed11487a23a43d45f2d15e1.tar.bz2
vcxsrv-1840c5631682e0a69ed11487a23a43d45f2d15e1.zip
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server/hw/xquartz/xpr')
-rw-r--r--xorg-server/hw/xquartz/xpr/dri.c5
-rw-r--r--xorg-server/hw/xquartz/xpr/xpr.h128
-rw-r--r--xorg-server/hw/xquartz/xpr/xprAppleWM.c4
-rw-r--r--xorg-server/hw/xquartz/xpr/xprEvent.c2
-rw-r--r--xorg-server/hw/xquartz/xpr/xprFrame.c167
5 files changed, 129 insertions, 177 deletions
diff --git a/xorg-server/hw/xquartz/xpr/dri.c b/xorg-server/hw/xquartz/xpr/dri.c
index 7b730df8e..cdfe13622 100644
--- a/xorg-server/hw/xquartz/xpr/dri.c
+++ b/xorg-server/hw/xquartz/xpr/dri.c
@@ -562,7 +562,6 @@ DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
(*pScreen->WindowExposures)(pWin, prgn, bsreg);
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
pScreen->WindowExposures = DRIWindowExposures;
}
@@ -587,7 +586,6 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
(*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
/* rewrap */
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
pScreen->CopyWindow = DRICopyWindow;
}
@@ -605,7 +603,6 @@ DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
/* rewrap */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
pScreen->ValidateTree = DRIValidateTree;
return returnValue;
@@ -632,7 +629,6 @@ DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
(*pScreen->PostValidateTree)(pParent, pChild, kind);
/* rewrap */
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
pScreen->PostValidateTree = DRIPostValidateTree;
}
}
@@ -653,7 +649,6 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
(*pScreen->ClipNotify)(pWin, dx, dy);
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
pScreen->ClipNotify = DRIClipNotify;
}
}
diff --git a/xorg-server/hw/xquartz/xpr/xpr.h b/xorg-server/hw/xquartz/xpr/xpr.h
index af1a90ca0..ea06b7eeb 100644
--- a/xorg-server/hw/xquartz/xpr/xpr.h
+++ b/xorg-server/hw/xquartz/xpr/xpr.h
@@ -1,64 +1,64 @@
-/*
- * Xplugin rootless implementation
- *
- * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
- *
- * 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 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-
-#ifndef XPR_H
-#define XPR_H
-
-#include "windowstr.h"
-#include "screenint.h"
-#include <Xplugin.h>
-
-Bool QuartzModeBundleInit(void);
-
-void AppleDRIExtensionInit(void);
-void xprAppleWMInit(void);
-Bool xprInit(ScreenPtr pScreen);
-Bool xprIsX11Window(void *nsWindow, int windowNumber);
-WindowPtr xprGetXWindow(xp_window_id wid);
-
-void xprHideWindows(Bool hide);
-
-Bool QuartzInitCursor(ScreenPtr pScreen);
-void QuartzSuspendXCursor(ScreenPtr pScreen);
-void QuartzResumeXCursor(ScreenPtr pScreen);
-
-/* If we are rooted, we need the root window and desktop levels to be below
- * the menubar (24) but above native windows. Normal window level is 0.
- * Floating window level is 3. The rest are filled in as appropriate.
- * See CGWindowLevel.h
- */
-
-#include <X11/extensions/applewmconst.h>
-static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
-0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
-};
-static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
-20, 21, 22, 23, 19, 18,
-};
-
-#endif /* XPR_H */
+/*
+ * Xplugin rootless implementation
+ *
+ * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
+ *
+ * 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 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+
+#ifndef XPR_H
+#define XPR_H
+
+#include "windowstr.h"
+#include "screenint.h"
+#include <Xplugin.h>
+
+Bool QuartzModeBundleInit(void);
+
+void AppleDRIExtensionInit(void);
+void xprAppleWMInit(void);
+Bool xprInit(ScreenPtr pScreen);
+Bool xprIsX11Window(int windowNumber);
+WindowPtr xprGetXWindow(xp_window_id wid);
+
+void xprHideWindows(Bool hide);
+
+Bool QuartzInitCursor(ScreenPtr pScreen);
+void QuartzSuspendXCursor(ScreenPtr pScreen);
+void QuartzResumeXCursor(ScreenPtr pScreen);
+
+/* If we are rooted, we need the root window and desktop levels to be below
+ * the menubar (24) but above native windows. Normal window level is 0.
+ * Floating window level is 3. The rest are filled in as appropriate.
+ * See CGWindowLevel.h
+ */
+
+#include <X11/extensions/applewmconst.h>
+static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
+0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
+};
+static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
+20, 21, 22, 23, 19, 18,
+};
+
+#endif /* XPR_H */
diff --git a/xorg-server/hw/xquartz/xpr/xprAppleWM.c b/xorg-server/hw/xquartz/xpr/xprAppleWM.c
index 1e99a07dc..6f501e201 100644
--- a/xorg-server/hw/xquartz/xpr/xprAppleWM.c
+++ b/xorg-server/hw/xquartz/xpr/xprAppleWM.c
@@ -114,8 +114,8 @@ static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) {
static int xprFrameDraw(
WindowPtr pWin,
- int class,
- unsigned int attr,
+ xp_frame_class class,
+ xp_frame_attr attr,
const BoxRec *outer,
const BoxRec *inner,
unsigned int title_len,
diff --git a/xorg-server/hw/xquartz/xpr/xprEvent.c b/xorg-server/hw/xquartz/xpr/xprEvent.c
index 38952b091..0ea6540f0 100644
--- a/xorg-server/hw/xquartz/xpr/xprEvent.c
+++ b/xorg-server/hw/xquartz/xpr/xprEvent.c
@@ -57,8 +57,6 @@
#include "xprEvent.h"
Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) {
- TA_SERVER();
-
switch(e->subtype) {
case kXquartzWindowState:
DEBUG_LOG("kXquartzWindowState\n");
diff --git a/xorg-server/hw/xquartz/xpr/xprFrame.c b/xorg-server/hw/xquartz/xpr/xprFrame.c
index cddec5ce2..e88019c2d 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;