summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2016-02-26 18:03:04 +0000
committerJon Turney <jon.turney@dronecode.org.uk>2016-02-26 18:17:50 +0000
commitd65795048584c78a9a7526f68c840ceed47ab82a (patch)
tree4a065bc018290f7564444636a15b6f7c1b9e973e
parent3cfa6cd1ac801a62b45345ceabf02e114a4b489c (diff)
Fix a crash in reloading multiwindow mode icons when not in multiwindow mode.unmap-minimized-windows
ReloadEnumWindowsProc() acesses window privates, which are only valid in multiwindow mode, but is called in all modes. Fix this potential crash by not doing this unless in multiwindow mode. Reproduction steps: 1/ XWin -mwextwm 2/ Run a client which creates an X window e.g. xterm 3/ Right click on notification area icon, and choose 'Reload .XWinrc' from the menu
-rw-r--r--hw/xwin/winmultiwindowwndproc.c2
-rw-r--r--hw/xwin/winprefs.c29
-rw-r--r--hw/xwin/winprefs.h9
-rw-r--r--hw/xwin/winwndproc.c2
4 files changed, 26 insertions, 16 deletions
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 392f67988..c0ef480da 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -464,7 +464,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/*
* Any window menu items go through here
*/
- if (HandleCustomWM_COMMAND(hwnd, LOWORD(wParam))) {
+ if (HandleCustomWM_COMMAND(hwnd, LOWORD(wParam), s_pScreenPriv)) {
/* Don't pass customized menus to DefWindowProc */
return 0;
}
diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c
index b67a1af7b..c1d8378d8 100644
--- a/hw/xwin/winprefs.c
+++ b/hw/xwin/winprefs.c
@@ -206,18 +206,21 @@ ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam)
* Set custom icons and menus again.
*/
static void
-ReloadPrefs(void)
+ReloadPrefs(winPrivScreenPtr pScreenPriv)
{
int i;
#ifdef XWIN_MULTIWINDOW
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
/* First, iterate over all windows, deleting their icons and custom menus.
* This is really only needed because winDestroyIcon() will try to
* destroy the old global icons, which will have changed.
* It is probably better to set a windows USER_DATA to flag locally defined
* icons, and use that to accurately know when to destroy old icons.
*/
- EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
#endif
/* Now, free/clear all info from our prefs structure */
@@ -262,12 +265,12 @@ ReloadPrefs(void)
g_hSmallIconX = NULL;
#ifdef XWIN_MULTIWINDOW
- winInitGlobalIcons();
-#endif
+ if (pScreenInfo->fMultiWindow) {
+ winInitGlobalIcons();
-#ifdef XWIN_MULTIWINDOW
- /* Rebuild the icons and menus */
- EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
+ /* Rebuild the icons and menus */
+ EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
+ }
#endif
/* Whew, done */
@@ -407,7 +410,7 @@ ExecAndLogThread(void *cmd)
* Return TRUE if command is proccessed, FALSE otherwise.
*/
Bool
-HandleCustomWM_COMMAND(HWND hwnd, int command)
+HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv)
{
int i, j;
MENUPARSED *m;
@@ -480,13 +483,17 @@ HandleCustomWM_COMMAND(HWND hwnd, int command)
HWND_TOPMOST,
0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
#if XWIN_MULTIWINDOW
- /* Reflect the changed Z order */
- winReorderWindowsMultiWindow();
+ {
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pScreenInfo->fMultiWindow)
+ /* Reflect the changed Z order */
+ winReorderWindowsMultiWindow();
+ }
#endif
return TRUE;
case CMD_RELOAD:
- ReloadPrefs();
+ ReloadPrefs(pScreenPriv);
return TRUE;
default:
diff --git a/hw/xwin/winprefs.h b/hw/xwin/winprefs.h
index b53d50c85..d1fef2ed9 100644
--- a/hw/xwin/winprefs.h
+++ b/hw/xwin/winprefs.h
@@ -1,5 +1,3 @@
-#if !defined(WINPREFS_H)
-#define WINPREFS_H
/*
* Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
* Copyright (C) Colin Harrison 2005-2008
@@ -32,6 +30,9 @@
* Colin Harrison
*/
+#if !defined(WINPREFS_H)
+#define WINPREFS_H
+
/* Need Bool */
#include <X11/Xdefs.h>
/* Need to know how long paths can be... */
@@ -39,6 +40,8 @@
/* Xwindows redefines PATH_MAX to at least 1024 */
#include <X11/Xwindows.h>
+#include "winwindow.h"
+
#ifndef NAME_MAX
#define NAME_MAX PATH_MAX
#endif
@@ -157,7 +160,7 @@ void
HandleCustomWM_INITMENU(HWND hwnd, HMENU hmenu);
Bool
- HandleCustomWM_COMMAND(HWND hwnd, int command);
+ HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv);
int
winIconIsOverride(HICON hicon);
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index 61c185785..2129fed1b 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -1217,7 +1217,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
default:
/* It's probably one of the custom menus... */
- if (HandleCustomWM_COMMAND(0, LOWORD(wParam)))
+ if (HandleCustomWM_COMMAND(0, LOWORD(wParam), s_pScreenPriv))
return 0;
}
break;