summaryrefslogtreecommitdiff
path: root/hw/xwin/winmultiwindowwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xwin/winmultiwindowwm.c')
-rw-r--r--hw/xwin/winmultiwindowwm.c77
1 files changed, 53 insertions, 24 deletions
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 615786af9..62edb7fa9 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -134,6 +134,7 @@ typedef struct _WMInfo {
Atom atmWmDelete;
Atom atmWmTakeFocus;
Atom atmPrivMap;
+ Atom atmNetWmName;
Bool fAllowOtherWM;
} WMInfoRec, *WMInfoPtr;
@@ -164,7 +165,7 @@ static Bool
InitQueue(WMMsgQueuePtr pQueue);
static void
- GetWindowName(Display * pDpy, Window iWin, char **ppWindowName);
+ GetWindowName(Display * pDpy, Window iWin, char **ppWindowName, Atom atmNetWmName);
static int
SendXMessage(Display * pDisplay, Window iWin, Atom atmType, long nData);
@@ -450,14 +451,10 @@ Xutf8TextPropertyToString(Display * pDisplay, XTextProperty * xtp)
*/
static void
-GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName)
+GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName, Atom atmNetWmName)
{
int nResult;
- XTextProperty xtpWindowName;
- XTextProperty xtpClientMachine;
- char *pszWindowName;
- char *pszClientMachine;
- char hostname[HOST_NAME_MAX + 1];
+ char *pszWindowName = NULL;
#if CYGMULTIWINDOW_DEBUG
ErrorF("GetWindowName\n");
@@ -466,19 +463,47 @@ GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName)
/* Intialize ppWindowName to NULL */
*ppWindowName = NULL;
- /* Try to get window name */
- nResult = XGetWMName(pDisplay, iWin, &xtpWindowName);
- if (!nResult || !xtpWindowName.value || !xtpWindowName.nitems) {
+ /* Try to get window name from _NET_WM_NAME */
+ {
+ char *utf8WindowName;
+ Atom type;
+ int format;
+ unsigned long nitems, after;
+
+ nResult = XGetWindowProperty(pDisplay, iWin, atmNetWmName,
+ 0, INT_MAX, False,
+ AnyPropertyType, &type, &format,
+ &nitems, &after,
+ (unsigned char **)&utf8WindowName);
+ if ((nResult == Success) && (type != None))
+ {
+ pszWindowName = strdup(utf8WindowName);
+ XFree(utf8WindowName);
+ }
+ }
+
+ /* Otherwise, try to get window name from WM_NAME */
+ if (!pszWindowName)
+ {
+ XTextProperty xtpWindowName;
+
+ nResult = XGetWMName(pDisplay, iWin, &xtpWindowName);
+ if (!nResult || !xtpWindowName.value || !xtpWindowName.nitems) {
#if CYGMULTIWINDOW_DEBUG
- ErrorF("GetWindowName - XGetWMName failed. No name.\n");
+ ErrorF("GetWindowName - XGetWMName failed. No name.\n");
#endif
- return;
- }
+ return;
+ }
- pszWindowName = Xutf8TextPropertyToString(pDisplay, &xtpWindowName);
- XFree(xtpWindowName.value);
+ pszWindowName = Xutf8TextPropertyToString(pDisplay, &xtpWindowName);
+ XFree(xtpWindowName.value);
+ }
if (g_fHostInTitle) {
+ XTextProperty xtpClientMachine;
+ char *pszClientMachine;
+ char hostname[HOST_NAME_MAX + 1];
+
/* Try to get client machine name */
nResult = XGetWMClientMachine(pDisplay, iWin, &xtpClientMachine);
if (nResult && xtpClientMachine.value && xtpClientMachine.nitems) {
@@ -615,7 +640,7 @@ UpdateName(WMInfoPtr pWMInfo, Window iWindow)
char *pszWindowName;
/* Get the X windows window name */
- GetWindowName(pWMInfo->pDisplay, iWindow, &pszWindowName);
+ GetWindowName(pWMInfo->pDisplay, iWindow, &pszWindowName, pWMInfo->atmNetWmName);
if (pszWindowName) {
/* Convert from UTF-8 to wide char */
@@ -1016,6 +1041,7 @@ winMultiWindowXMsgProc(void *pArg)
int iRetries;
XEvent event;
Atom atmWmName;
+ Atom atmNetWmName;
Atom atmWmHints;
Atom atmWmChange;
Atom atmNetWmIcon;
@@ -1033,7 +1059,7 @@ winMultiWindowXMsgProc(void *pArg)
pthread_exit(NULL);
}
- ErrorF("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n");
+ winDebug("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n");
/* Grab the server started mutex - pause until we get it */
iReturn = pthread_mutex_lock(pProcArg->ppmServerStarted);
@@ -1043,12 +1069,12 @@ winMultiWindowXMsgProc(void *pArg)
pthread_exit(NULL);
}
- ErrorF("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n");
+ winDebug("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n");
/* Release the server started mutex */
pthread_mutex_unlock(pProcArg->ppmServerStarted);
- ErrorF("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
+ winDebug("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
/* Install our error handler */
XSetErrorHandler(winMultiWindowXMsgProcErrorHandler);
@@ -1133,6 +1159,7 @@ winMultiWindowXMsgProc(void *pArg)
}
atmWmName = XInternAtom(pProcArg->pDisplay, "WM_NAME", False);
+ atmNetWmName = XInternAtom(pProcArg->pDisplay, "_NET_WM_NAME", False);
atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False);
atmWmChange = XInternAtom(pProcArg->pDisplay, "WM_CHANGE_STATE", False);
atmNetWmIcon = XInternAtom(pProcArg->pDisplay, "_NET_WM_ICON", False);
@@ -1270,7 +1297,8 @@ winMultiWindowXMsgProc(void *pArg)
XGetAtomName(pProcArg->pDisplay, event.xproperty.atom);
winDebug("winMultiWindowXMsgProc: PropertyNotify %s\n", atomName);
XFree(atomName);
- if (event.xproperty.atom == atmWmName) {
+ if ((event.xproperty.atom == atmWmName) ||
+ (event.xproperty.atom == atmNetWmName)) {
memset(&msg, 0, sizeof(msg));
msg.msg = WM_WM_NAME_EVENT;
@@ -1418,7 +1446,7 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
pthread_exit(NULL);
}
- ErrorF("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n");
+ winDebug("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n");
/* Grab our garbage mutex to satisfy pthread_cond_wait */
iReturn = pthread_mutex_lock(pProcArg->ppmServerStarted);
@@ -1428,12 +1456,12 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
pthread_exit(NULL);
}
- ErrorF("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
+ winDebug("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
/* Release the server started mutex */
pthread_mutex_unlock(pProcArg->ppmServerStarted);
- ErrorF("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
+ winDebug("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
/* Install our error handler */
XSetErrorHandler(winMultiWindowWMErrorHandler);
@@ -1498,9 +1526,10 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
"WM_DELETE_WINDOW", False);
pWMInfo->atmWmTakeFocus = XInternAtom(pWMInfo->pDisplay,
"WM_TAKE_FOCUS", False);
-
pWMInfo->atmPrivMap = XInternAtom(pWMInfo->pDisplay,
WINDOWSWM_NATIVE_HWND, False);
+ pWMInfo->atmNetWmName = XInternAtom(pWMInfo->pDisplay,
+ "_NET_WM_NAME", False);
if (1) {
Cursor cursor = XCreateFontCursor(pWMInfo->pDisplay, XC_left_ptr);