aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winmultiwindowwm.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-03-04 12:18:13 +0100
committermarha <marha@users.sourceforge.net>2014-03-04 12:23:48 +0100
commit45392e4a0642880b569ea5d4a350cdc395a2c7db (patch)
treec3c2a49de903a18c3f8e1bf79684c29337ebcf7c /xorg-server/hw/xwin/winmultiwindowwm.c
parent5ec0616d4e3c4c6095f4975abbe9c21e5b6af967 (diff)
parent321c01267ae1c446f1bd22b642567fcafa016c02 (diff)
downloadvcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.tar.gz
vcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.tar.bz2
vcxsrv-45392e4a0642880b569ea5d4a350cdc395a2c7db.zip
Merge remote-tracking branch 'origin/released'
* origin/released: libX11 libxcb mesa xserver xcb-proto xkeyboard-config git update 4 Mar 2014 Conflicts: mesalib/src/mapi/glapi/glapi.h mesalib/src/mapi/glapi/glthread.c mesalib/src/mesa/drivers/dri/common/dri_util.c mesalib/src/mesa/main/bufferobj.c xorg-server/dix/dispatch.c xorg-server/hw/xwin/glx/gen_gl_wrappers.py xorg-server/hw/xwin/winmultiwindowwm.c
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwm.c')
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwm.c91
1 files changed, 66 insertions, 25 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c
index 2b619a2b6..8518147a6 100644
--- a/xorg-server/hw/xwin/winmultiwindowwm.c
+++ b/xorg-server/hw/xwin/winmultiwindowwm.c
@@ -114,6 +114,7 @@ typedef struct _WMInfo {
WMMsgQueueRec wmMsgQueue;
Atom atmWmProtos;
Atom atmWmDelete;
+ Atom atmWmTakeFocus;
Atom atmPrivMap;
#ifdef XWIN_MULTIWINDOWINTWM
Bool fAllowOtherWM;
@@ -372,7 +373,7 @@ Xutf8TextPropertyToString(Display * pDisplay, XTextProperty * xtp)
for (i = 0; i < nNum; i++)
iLen += strlen(ppList[i]);
- pszReturnData = (char *) malloc(iLen + 1);
+ pszReturnData = malloc(iLen + 1);
pszReturnData[0] = '\0';
for (i = 0; i < nNum; i++)
strcat(pszReturnData, ppList[i]);
@@ -380,7 +381,7 @@ Xutf8TextPropertyToString(Display * pDisplay, XTextProperty * xtp)
XFreeStringList(ppList);
}
else {
- pszReturnData = (char *) malloc(1);
+ pszReturnData = malloc(1);
pszReturnData[0] = '\0';
}
@@ -416,6 +417,27 @@ GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName)
}
/*
+ * Does the client support the specified WM_PROTOCOLS protocol?
+ */
+
+static Bool
+IsWmProtocolAvailable(Display * pDisplay, Window iWindow, Atom atmProtocol)
+{
+ int i, n, found = 0;
+ Atom *protocols;
+
+ if (XGetWMProtocols(pDisplay, iWindow, &protocols, &n)) {
+ for (i = 0; i < n; ++i)
+ if (protocols[i] == atmProtocol)
+ ++found;
+
+ XFree(protocols);
+ }
+
+ return found > 0;
+}
+
+/*
* Send a message to the X server from the WM thread
*/
@@ -500,7 +522,7 @@ UpdateName(WMInfoPtr pWMInfo, Window iWindow)
int iLen =
MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, NULL, 0);
wchar_t *pwszWideWindowName =
- (wchar_t *) malloc(sizeof(wchar_t) * (iLen + 1));
+ malloc(sizeof(wchar_t)*(iLen + 1));
MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1,
pwszWideWindowName, iLen);
@@ -743,21 +765,10 @@ winMultiWindowWMProc(void *pArg)
case WM_WM_KILL:
winDebug ("\tWM_WM_KILL\n");
{
- int i, n, found = 0;
- Atom *protocols;
-
- /* --- */
- if (XGetWMProtocols(pWMInfo->pDisplay,
- pNode->msg.iWindow, &protocols, &n)) {
- for (i = 0; i < n; ++i)
- if (protocols[i] == pWMInfo->atmWmDelete)
- ++found;
-
- XFree(protocols);
- }
-
/* --- */
- if (found)
+ if (IsWmProtocolAvailable(pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmWmDelete))
SendXMessage(pWMInfo->pDisplay,
pNode->msg.iWindow,
pWMInfo->atmWmProtos, pWMInfo->atmWmDelete);
@@ -768,11 +779,39 @@ winMultiWindowWMProc(void *pArg)
case WM_WM_ACTIVATE:
winDebug ("\tWM_WM_ACTIVATE\n");
-
/* Set the input focus */
- XSetInputFocus(pWMInfo->pDisplay,
- pNode->msg.iWindow,
- RevertToPointerRoot, CurrentTime);
+
+ /*
+ ICCCM 4.1.7 is pretty opaque, but it appears that the rules are
+ actually quite simple:
+ -- the WM_HINTS input field determines whether the WM should call
+ XSetInputFocus()
+ -- independently, the WM_TAKE_FOCUS protocol determines whether
+ the WM should send a WM_TAKE_FOCUS ClientMessage.
+ */
+ {
+ Bool neverFocus = FALSE;
+ XWMHints *hints = XGetWMHints(pWMInfo->pDisplay, pNode->msg.iWindow);
+
+ if (hints) {
+ if (hints->flags & InputHint)
+ neverFocus = !hints->input;
+ XFree(hints);
+ }
+
+ if (!neverFocus)
+ XSetInputFocus(pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ RevertToPointerRoot, CurrentTime);
+
+ if (IsWmProtocolAvailable(pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmWmTakeFocus))
+ SendXMessage(pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmWmProtos, pWMInfo->atmWmTakeFocus);
+
+ }
break;
case WM_WM_NAME_EVENT:
@@ -1177,9 +1216,9 @@ winInitWM(void **ppWMInfo,
pthread_mutex_t * ppmServerStarted,
int dwScreen, HWND hwndScreen, BOOL allowOtherWM)
{
- WMProcArgPtr pArg = (WMProcArgPtr) malloc(sizeof(WMProcArgRec));
- WMInfoPtr pWMInfo = (WMInfoPtr) malloc(sizeof(WMInfoRec));
- XMsgProcArgPtr pXMsgArg = (XMsgProcArgPtr) malloc(sizeof(XMsgProcArgRec));
+ WMProcArgPtr pArg = malloc(sizeof(WMProcArgRec));
+ WMInfoPtr pWMInfo = malloc(sizeof(WMInfoRec));
+ XMsgProcArgPtr pXMsgArg = malloc(sizeof(XMsgProcArgRec));
/* Bail if the input parameters are bad */
if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
@@ -1332,6 +1371,8 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
"WM_PROTOCOLS", False);
pWMInfo->atmWmDelete = XInternAtom(pWMInfo->pDisplay,
"WM_DELETE_WINDOW", False);
+ pWMInfo->atmWmTakeFocus = XInternAtom(pWMInfo->pDisplay,
+ "WM_TAKE_FOCUS", False);
pWMInfo->atmPrivMap = XInternAtom(pWMInfo->pDisplay,
WINDOWSWM_NATIVE_HWND, False);
@@ -1358,7 +1399,7 @@ winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg)
winDebug("winSendMessageToWM ()\n");
- pNode = (WMMsgNodePtr) malloc(sizeof(WMMsgNodeRec));
+ pNode = malloc(sizeof(WMMsgNodeRec));
if (pNode != NULL) {
memcpy(&pNode->msg, pMsg, sizeof(winWMMessageRec));
PushMessage(&((WMInfoPtr) pWMInfo)->wmMsgQueue, pNode);