Commit bac34a54 authored by Jeremy Huddleston's avatar Jeremy Huddleston

XQuartz: xpr: Initialize window_hash in xprInit

Signed-off-by: default avatarJeremy Huddleston <jeremyhu@apple.com>
parent 1596ea72
/*
* 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"
......@@ -61,6 +60,10 @@ 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 xprGetXWindowFromAppKit and xprIsX11Window
* can be called from any thread.
*/
static pthread_mutex_t window_hash_mutex;
/* Prototypes for static functions */
......@@ -178,12 +181,6 @@ 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);
}
pthread_mutex_lock(&window_hash_mutex);
x_hash_table_insert(window_hash, pFrame->wid, pFrame);
pthread_mutex_unlock(&window_hash_mutex);
......@@ -256,6 +253,7 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
xp_window_changes wc;
unsigned int mask = XP_STACKING;
RootlessWindowRec *winRec;
/* Stack frame below nextWid it if it exists, or raise
frame above everything otherwise. */
......@@ -268,18 +266,16 @@ 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;
}
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;
}
xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc);
......@@ -450,6 +446,9 @@ xprInit(ScreenPtr pScreen)
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)));
assert(0 == pthread_mutex_init(&window_hash_mutex, NULL));
return TRUE;
}
......@@ -463,9 +462,6 @@ xprGetXWindow(xp_window_id wid)
{
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;
......@@ -483,11 +479,6 @@ xprGetXWindowFromAppKit(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))
......@@ -514,11 +505,6 @@ xprIsX11Window(void *nsWindow, 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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment