summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2010-03-23 20:06:33 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2010-07-24 00:46:03 +0100
commit9d6c7d852b740019119eeda877d9049ba4701ba5 (patch)
treebcce0c7ac230c30577c7031d5764dca123ea8c93
parent44df10e6071c6e1ebc5fbe5e15d4516ec1d8eb30 (diff)
Cygwin/X: Make winOverrrideStyle() thread-safe
Make winOverrrideStyle() thread-safe winOverrideStyle() is called from the internal WM client thread. Accessing server-internal data structures to get window name and class is not safe, as there is no lock to ensure we do not collide with these data structures being updated in the server thread. Rewrite so the internal client thread uses X client calls to obtain this data safely
-rw-r--r--hw/xwin/winmultiwindowwm.c22
-rw-r--r--hw/xwin/winprefs.c28
-rw-r--r--hw/xwin/winprefs.h2
3 files changed, 24 insertions, 28 deletions
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 2fcad3249..9ab41f7a9 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1552,7 +1552,6 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
Atom type, *pAtom = NULL;
int format;
unsigned long hint = 0, maxmin = 0, style, nitems = 0 , left = 0;
- WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
if (!hWnd) return;
if (!IsWindow (hWnd)) return;
@@ -1645,7 +1644,26 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
}
/* Override hint settings from above with settings from config file */
- style = winOverrideStyle((unsigned long)pWin);
+ {
+ XClassHint class_hint = {0,0};
+ char *window_name = 0;
+
+ if (XGetClassHint(pDisplay, iWindow, &class_hint))
+ {
+ XFetchName(pDisplay, iWindow, &window_name);
+
+ style = winOverrideStyle(class_hint.res_name, class_hint.res_class, window_name);
+
+ if (class_hint.res_name) XFree(class_hint.res_name);
+ if (class_hint.res_class) XFree(class_hint.res_class);
+ if (window_name) XFree(window_name);
+ }
+ else
+ {
+ style = STYLE_NONE;
+ }
+ }
+
if (style & STYLE_TOPMOST) *zstyle = HWND_TOPMOST;
else if (style & STYLE_MAXIMIZE) maxmin = (hint & ~HINT_MIN) | HINT_MAX;
else if (style & STYLE_MINIMIZE) maxmin = (hint & ~HINT_MAX) | HINT_MIN;
diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c
index 93901cac7..2641c737d 100644
--- a/hw/xwin/winprefs.c
+++ b/hw/xwin/winprefs.c
@@ -826,42 +826,20 @@ LoadPreferences (void)
* STYLES{} section in the prefs file, and return the style type
*/
unsigned long
-winOverrideStyle (unsigned long longpWin)
+winOverrideStyle (char *res_name, char *res_class, char *wmName)
{
- WindowPtr pWin = (WindowPtr) longpWin;
- char *res_name, *res_class;
int i;
- char *wmName;
-
- if (pWin==NULL)
- return STYLE_NONE;
-
- /* If we can't find the class, we can't override from default! */
- if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class))
- return STYLE_NONE;
-
- winMultiWindowGetWMName (pWin, &wmName);
for (i=0; i<pref.styleItems; i++) {
- if (!strcmp(pref.style[i].match, res_name) ||
- !strcmp(pref.style[i].match, res_class) ||
+ if ((res_name && !strcmp(pref.style[i].match, res_name)) ||
+ (res_class && !strcmp(pref.style[i].match, res_class)) ||
(wmName && strstr(wmName, pref.style[i].match)))
{
- free (res_name);
- free (res_class);
- if (wmName)
- free (wmName);
-
if (pref.style[i].type)
return pref.style[i].type;
}
}
/* Didn't find the style, fail gracefully */
- free (res_name);
- free (res_class);
- if (wmName)
- free (wmName);
-
return STYLE_NONE;
}
diff --git a/hw/xwin/winprefs.h b/hw/xwin/winprefs.h
index 4daf47401..e672b6ea1 100644
--- a/hw/xwin/winprefs.h
+++ b/hw/xwin/winprefs.h
@@ -179,7 +179,7 @@ HICON
winOverrideIcon (unsigned long longpWin);
unsigned long
-winOverrideStyle (unsigned long longpWin);
+winOverrideStyle (char *res_name, char *res_class, char *wmName);
HICON
winTaskbarIcon(void);