Merge remote-tracking branch 'jturney/xserver-next'

This commit is contained in:
Keith Packard 2013-01-20 15:58:38 -08:00
commit 069d8ed3eb
10 changed files with 154 additions and 71 deletions

View File

@ -28,6 +28,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/Xwindows.h> #include <X11/Xwindows.h>
#include <pthread.h>
#include "winwindow.h" #include "winwindow.h"
#include "os.h" #include "os.h"
#include "winmsg.h" #include "winmsg.h"

View File

@ -42,14 +42,26 @@ winBlockHandler(ScreenPtr pScreen,
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
winScreenPriv(pScreen); winScreenPriv(pScreen);
#endif #endif
MSG msg;
#ifndef HAS_DEVWINDOWS #ifndef HAS_DEVWINDOWS
struct timeval **tvp = pTimeout; struct timeval **tvp = pTimeout;
if (*tvp != NULL) { if (*tvp != NULL) {
if (GetQueueStatus(QS_ALLINPUT | QS_ALLPOSTMESSAGE) != 0) {
/* If there are still messages to process on the Windows message
queue, make sure select() just polls rather than blocking.
*/
(*tvp)->tv_sec = 0;
(*tvp)->tv_usec = 0;
}
else {
/* Otherwise, lacking /dev/windows, we must wake up again in
a reasonable time to check the Windows message queue. without
noticeable delay.
*/
(*tvp)->tv_sec = 0; (*tvp)->tv_sec = 0;
(*tvp)->tv_usec = 100; (*tvp)->tv_usec = 100;
}
} }
#endif #endif
@ -68,25 +80,13 @@ winBlockHandler(ScreenPtr pScreen,
if (iReturn != 0) { if (iReturn != 0) {
ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n", ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
iReturn); iReturn);
goto winBlockHandler_ProcessMessages;
} }
else {
winDebug("winBlockHandler - pthread_mutex_unlock () returned\n"); winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
}
} }
winBlockHandler_ProcessMessages:
#endif #endif
/* Process all messages on our queue */
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if ((g_hDlgDepthChange == 0
|| !IsDialogMessage(g_hDlgDepthChange, &msg))
&& (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg))
&& (g_hDlgAbout == 0 || !IsDialogMessage(g_hDlgAbout, &msg))) {
DispatchMessage(&msg);
}
}
/* /*
At least one X client has asked to suspend the screensaver, so At least one X client has asked to suspend the screensaver, so
reset Windows' display idle timer reset Windows' display idle timer

View File

@ -26,6 +26,10 @@
#ifndef WINGLOBALS_H #ifndef WINGLOBALS_H
#define WINGLOBALS_H #define WINGLOBALS_H
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
/* /*
* References to external symbols * References to external symbols
*/ */

View File

@ -56,7 +56,7 @@ static void
static void static void
winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl); winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl);
/* /*
* Translate a Windows WM_[SYS]KEY(UP/DOWN) message * Translate a Windows WM_[SYS]KEY(UP/DOWN) message
* into an ASCII scan code. * into an ASCII scan code.
* *
@ -134,7 +134,7 @@ winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl)
{ {
} }
/* /*
* See Porting Layer Definition - p. 18 * See Porting Layer Definition - p. 18
* winKeybdProc is known as a DeviceProc. * winKeybdProc is known as a DeviceProc.
*/ */
@ -509,8 +509,8 @@ winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
return FALSE; return FALSE;
} }
/* Only on shift release message is sent even if both are pressed. /* Only one shift release message is sent even if both are pressed.
* Fix this here * Fix this here
*/ */
void void
winFixShiftKeys(int iScanCode) winFixShiftKeys(int iScanCode)

View File

@ -186,7 +186,7 @@ static void
winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle); winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle);
void void
winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle); winUpdateWindowPosition(HWND hWnd, HWND * zstyle);
/* /*
* Local globals * Local globals
@ -590,6 +590,45 @@ UpdateIcon(WMInfoPtr pWMInfo, Window iWindow)
winUpdateIcon(hWnd, pWMInfo->pDisplay, iWindow, hIconNew); winUpdateIcon(hWnd, pWMInfo->pDisplay, iWindow, hIconNew);
} }
/*
* Updates the style of a HWND according to its X style properties
*/
static void
UpdateStyle(WMInfoPtr pWMInfo, Window iWindow)
{
HWND hWnd;
HWND zstyle = HWND_NOTOPMOST;
UINT flags;
hWnd = getHwnd(pWMInfo, iWindow);
if (!hWnd)
return;
/* Determine the Window style, which determines borders and clipping region... */
winApplyHints(pWMInfo->pDisplay, iWindow, hWnd, &zstyle);
winUpdateWindowPosition(hWnd, &zstyle);
/* Apply the updated window style, without changing it's show or activation state */
flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE;
if (zstyle == HWND_NOTOPMOST)
flags |= SWP_NOZORDER | SWP_NOOWNERZORDER;
SetWindowPos(hWnd, NULL, 0, 0, 0, 0, flags);
/*
Use the WS_EX_TOOLWINDOW style to remove window from Alt-Tab window switcher
According to MSDN, this is supposed to remove the window from the taskbar as well,
if we SW_HIDE before changing the style followed by SW_SHOW afterwards.
But that doesn't seem to work reliably, and causes the window to flicker, so use
the iTaskbarList interface to tell the taskbar to show or hide this window.
*/
winShowWindowOnTaskbar(hWnd,
(GetWindowLongPtr(hWnd, GWL_EXSTYLE) &
WS_EX_APPWINDOW) ? TRUE : FALSE);
}
#if 0 #if 0
/* /*
* Fix up any differences between the X11 and Win32 window stacks * Fix up any differences between the X11 and Win32 window stacks
@ -737,13 +776,19 @@ winMultiWindowWMProc(void *pArg)
(unsigned char *) &(pNode->msg.hwndWindow), 1); (unsigned char *) &(pNode->msg.hwndWindow), 1);
UpdateName(pWMInfo, pNode->msg.iWindow); UpdateName(pWMInfo, pNode->msg.iWindow);
UpdateIcon(pWMInfo, pNode->msg.iWindow); UpdateIcon(pWMInfo, pNode->msg.iWindow);
{ UpdateStyle(pWMInfo, pNode->msg.iWindow);
HWND zstyle = HWND_NOTOPMOST;
winApplyHints(pWMInfo->pDisplay, pNode->msg.iWindow,
pNode->msg.hwndWindow, &zstyle); /* Reshape */
winUpdateWindowPosition(pNode->msg.hwndWindow, TRUE, &zstyle); {
WindowPtr pWin =
GetProp(pNode->msg.hwndWindow, WIN_WINDOW_PROP);
if (pWin) {
winReshapeMultiWindow(pWin);
winUpdateRgnMultiWindow(pWin);
}
} }
break; break;
case WM_WM_UNMAP: case WM_WM_UNMAP:
@ -802,6 +847,19 @@ winMultiWindowWMProc(void *pArg)
UpdateIcon(pWMInfo, pNode->msg.iWindow); UpdateIcon(pWMInfo, pNode->msg.iWindow);
break; break;
case WM_WM_HINTS_EVENT:
{
XWindowAttributes attr;
/* Don't do anything if this is an override-redirect window */
XGetWindowAttributes (pWMInfo->pDisplay, pNode->msg.iWindow, &attr);
if (attr.override_redirect)
break;
UpdateStyle(pWMInfo, pNode->msg.iWindow);
}
break;
case WM_WM_CHANGE_STATE: case WM_WM_CHANGE_STATE:
/* Minimize the window in Windows */ /* Minimize the window in Windows */
winMinimizeWindow(pNode->msg.iWindow); winMinimizeWindow(pNode->msg.iWindow);
@ -851,6 +909,7 @@ winMultiWindowXMsgProc(void *pArg)
Atom atmWmHints; Atom atmWmHints;
Atom atmWmChange; Atom atmWmChange;
Atom atmNetWmIcon; Atom atmNetWmIcon;
Atom atmWindowState, atmMotifWmHints, atmWindowType, atmNormalHints;
int iReturn; int iReturn;
XIconSize *xis; XIconSize *xis;
@ -977,6 +1036,10 @@ winMultiWindowXMsgProc(void *pArg)
atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False); atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False);
atmWmChange = XInternAtom(pProcArg->pDisplay, "WM_CHANGE_STATE", False); atmWmChange = XInternAtom(pProcArg->pDisplay, "WM_CHANGE_STATE", False);
atmNetWmIcon = XInternAtom(pProcArg->pDisplay, "_NET_WM_ICON", False); atmNetWmIcon = XInternAtom(pProcArg->pDisplay, "_NET_WM_ICON", False);
atmWindowState = XInternAtom(pProcArg->pDisplay, "_NET_WM_STATE", False);
atmMotifWmHints = XInternAtom(pProcArg->pDisplay, "_MOTIF_WM_HINTS", False);
atmWindowType = XInternAtom(pProcArg->pDisplay, "_NET_WM_WINDOW_TYPE", False);
atmNormalHints = XInternAtom(pProcArg->pDisplay, "WM_NORMAL_HINTS", False);
/* /*
iiimxcf had a bug until 2009-04-27, assuming that the iiimxcf had a bug until 2009-04-27, assuming that the
@ -1114,14 +1177,34 @@ winMultiWindowXMsgProc(void *pArg)
/* Other fields ignored */ /* Other fields ignored */
winSendMessageToWM(pProcArg->pWMInfo, &msg); winSendMessageToWM(pProcArg->pWMInfo, &msg);
} }
else if ((event.xproperty.atom == atmWmHints) || else {
(event.xproperty.atom == atmNetWmIcon)) { /*
memset(&msg, 0, sizeof(msg)); Several properties are considered for WM hints, check if this property change affects any of them...
msg.msg = WM_WM_ICON_EVENT; (this list needs to be kept in sync with winApplyHints())
msg.iWindow = event.xproperty.window; */
if ((event.xproperty.atom == atmWmHints) ||
(event.xproperty.atom == atmWindowState) ||
(event.xproperty.atom == atmMotifWmHints) ||
(event.xproperty.atom == atmWindowType) ||
(event.xproperty.atom == atmNormalHints)) {
memset(&msg, 0, sizeof(msg));
msg.msg = WM_WM_HINTS_EVENT;
msg.iWindow = event.xproperty.window;
/* Other fields ignored */ /* Other fields ignored */
winSendMessageToWM(pProcArg->pWMInfo, &msg); winSendMessageToWM(pProcArg->pWMInfo, &msg);
}
/* Not an else as WM_HINTS affects both style and icon */
if ((event.xproperty.atom == atmWmHints) ||
(event.xproperty.atom == atmNetWmIcon)) {
memset(&msg, 0, sizeof(msg));
msg.msg = WM_WM_ICON_EVENT;
msg.iWindow = event.xproperty.window;
/* Other fields ignored */
winSendMessageToWM(pProcArg->pWMInfo, &msg);
}
} }
} }
else if (event.type == ClientMessage else if (event.type == ClientMessage
@ -1749,7 +1832,7 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
} }
void void
winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle) winUpdateWindowPosition(HWND hWnd, HWND * zstyle)
{ {
int iX, iY, iWidth, iHeight; int iX, iY, iWidth, iHeight;
int iDx, iDy; int iDx, iDy;
@ -1800,8 +1883,4 @@ winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle)
SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top, SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top,
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, 0); rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, 0);
if (reshape) {
winReshapeMultiWindow(pWin);
winUpdateRgnMultiWindow(pWin);
}
} }

View File

@ -42,7 +42,7 @@
#include "winmsg.h" #include "winmsg.h"
#include "inputstr.h" #include "inputstr.h"
extern void winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle); extern void winUpdateWindowPosition(HWND hWnd, HWND * zstyle);
/* /*
* Local globals * Local globals
@ -870,41 +870,36 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
/* */ /* */
if (!pWin->overrideRedirect) { if (!pWin->overrideRedirect) {
HWND zstyle = HWND_NOTOPMOST;
/* Flag that this window needs to be made active when clicked */ /* Flag that this window needs to be made active when clicked */
SetProp(hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1); SetProp(hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1);
if (!(GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_APPWINDOW)) { /* Set the transient style flags */
HWND zstyle = HWND_NOTOPMOST; if (GetParent(hwnd))
SetWindowLongPtr(hwnd, GWL_STYLE,
WS_POPUP | WS_OVERLAPPED | WS_SYSMENU |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
/* Set the window standard style flags */
else
SetWindowLongPtr(hwnd, GWL_STYLE,
(WS_POPUP | WS_OVERLAPPEDWINDOW |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS)
& ~WS_CAPTION & ~WS_SIZEBOX);
/* Set the window extended style flags */ winUpdateWindowPosition(hwnd, &zstyle);
SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
/* Set the transient style flags */ {
if (GetParent(hwnd)) WinXWMHints hints;
SetWindowLongPtr(hwnd, GWL_STYLE,
WS_POPUP | WS_OVERLAPPED | WS_SYSMENU |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
/* Set the window standard style flags */
else
SetWindowLongPtr(hwnd, GWL_STYLE,
(WS_POPUP | WS_OVERLAPPEDWINDOW |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS)
& ~WS_CAPTION & ~WS_SIZEBOX);
winUpdateWindowPosition(hwnd, FALSE, &zstyle); if (winMultiWindowGetWMHints(pWin, &hints)) {
/*
{ Give the window focus, unless it has an InputHint
WinXWMHints hints; which is FALSE (this is used by e.g. glean to
avoid every test window grabbing the focus)
if (winMultiWindowGetWMHints(pWin, &hints)) { */
/* if (!((hints.flags & InputHint) && (!hints.input))) {
Give the window focus, unless it has an InputHint SetForegroundWindow(hwnd);
which is FALSE (this is used by e.g. glean to
avoid every test window grabbing the focus)
*/
if (!((hints.flags & InputHint) && (!hints.input))) {
SetForegroundWindow(hwnd);
}
} }
} }
} }

View File

@ -114,7 +114,7 @@ winHandleIconMessage(HWND hwnd, UINT message,
switch (lParam) { switch (lParam) {
case WM_LBUTTONUP: case WM_LBUTTONUP:
/* Restack and bring all windows to top */ /* Restack and bring all windows to top */
SetForegroundWindow(hwnd); SetForegroundWindow (pScreenPriv->hwndScreen);
#ifdef XWIN_MULTIWINDOWEXTWM #ifdef XWIN_MULTIWINDOWEXTWM
if (pScreenInfo->fMWExtWM) if (pScreenInfo->fMWExtWM)

View File

@ -43,8 +43,8 @@ winWakeupHandler(ScreenPtr pScreen,
{ {
MSG msg; MSG msg;
/* Process all messages on our queue */ /* Process one message from our queue */
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if ((g_hDlgDepthChange == 0 if ((g_hDlgDepthChange == 0
|| !IsDialogMessage(g_hDlgDepthChange, &msg)) || !IsDialogMessage(g_hDlgDepthChange, &msg))
&& (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg)) && (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg))

View File

@ -110,6 +110,7 @@ typedef struct _winWMMessageRec {
#define WM_WM_CHANGE_STATE (WM_USER + 11) #define WM_WM_CHANGE_STATE (WM_USER + 11)
#define WM_WM_MAP2 (WM_USER + 12) #define WM_WM_MAP2 (WM_USER + 12)
#define WM_WM_MAP3 (WM_USER + 13) #define WM_WM_MAP3 (WM_USER + 13)
#define WM_WM_HINTS_EVENT (WM_USER + 14)
#define WM_MANAGE (WM_USER + 100) #define WM_MANAGE (WM_USER + 100)
#define WM_UNMANAGE (WM_USER + 102) #define WM_UNMANAGE (WM_USER + 102)

View File

@ -31,3 +31,6 @@
/* Default log location */ /* Default log location */
#undef DEFAULT_LOGDIR #undef DEFAULT_LOGDIR
/* Whether we should re-locate the root to where the executable lives */
#undef RELOCATE_PROJECTROOT