summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKensuke Matsuzaki <zakki@peppermint.jp>2004-11-04 11:52:22 +0000
committerKensuke Matsuzaki <zakki@peppermint.jp>2004-11-04 11:52:22 +0000
commit1aef1060647d22b676a29f6dcf1ac54f9fe7ff5d (patch)
tree70900e674813002e49a88c2a9deb77dbd2817165
parent522c878fca3bfe97cd408e37065f827c004faa04 (diff)
Add InternalWM mode.
-rw-r--r--hw/xwin/ChangeLog25
-rw-r--r--hw/xwin/InitOutput.c3
-rw-r--r--hw/xwin/win.h15
-rw-r--r--hw/xwin/winmultiwindowwindow.c28
-rw-r--r--hw/xwin/winmultiwindowwm.c120
-rwxr-xr-xhw/xwin/winprocarg.c28
-rw-r--r--hw/xwin/winscrinit.c5
-rwxr-xr-xhw/xwin/wintrayicon.c8
-rwxr-xr-xhw/xwin/winwin32rootless.c48
-rwxr-xr-xhw/xwin/winwin32rootlesswindow.c272
-rwxr-xr-xhw/xwin/winwin32rootlesswndproc.c253
-rw-r--r--hw/xwin/winwindow.h10
-rw-r--r--hw/xwin/winwndproc.c41
13 files changed, 748 insertions, 108 deletions
diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog
index 926469011..5c6339152 100644
--- a/hw/xwin/ChangeLog
+++ b/hw/xwin/ChangeLog
@@ -1,3 +1,28 @@
+2004-11-04 Kensuke Matsuzaki <zakki@peppermint.jp>
+
+ * InitOutput.c: (winUseMsg):
+ * win.h:
+ * winmultiwindowwindow.c: (winMinimizeWindow):
+ * winmultiwindowwm.c: (PushMessage), (UpdateName),
+ (PreserveWin32Stack), (winMultiWindowWMProc),
+ (winMultiWindowXMsgProc), (winInitWM), (winInitMultiWindowWM),
+ (CheckAnotherWindowManager):
+ * winprocarg.c: (winInitializeDefaultScreens),
+ (ddxProcessArgument):
+ * winscrinit.c: (winFinishScreenInitFB):
+ * wintrayicon.c: (winHandleIconMessage):
+ * winwin32rootless.c: (InitWin32RootlessEngine),
+ (winMWExtWMResizeFrame), (winMWExtWMRestackFrame),
+ (winMWExtWMStartDrawing), (winMWExtWMRootlessSwitchWindow),
+ (winMWExtWMSetNativeProperty):
+ * winwin32rootlesswindow.c: (winMWExtWMReorderWindows),
+ (winMWExtWMDecorateWindow), (winMWExtWMUpdateWindowDecoration),
+ (winIsInternalWMRunning), (winMWExtWMRestackWindows):
+ * winwin32rootlesswndproc.c: (winMWExtWMWindowProc):
+ * winwindow.h:
+ * winwndproc.c: (winWindowProc):
+ Add internalwm mode.
+
2004-10-28 Alexander Gottwald <ago at freedesktop dot org>
* win.h:
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 78e2bc70d..dafd7e7fd 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -451,6 +451,9 @@ winUseMsg (void)
#ifdef XWIN_MULTIWINDOWEXTWM
ErrorF ("-mwextwm\n"
"\tRun the server in multi-window external window manager mode.\n");
+
+ ErrorF ("-internalwm\n"
+ "\tRun the internal window manager.\n");
#endif
ErrorF ("-rootless\n"
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 8fd8d21af..759d18657 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -420,6 +420,8 @@ typedef struct
Bool fDecoration;
#ifdef XWIN_MULTIWINDOWEXTWM
Bool fMWExtWM;
+ Bool fInternalWM;
+ Bool fAnotherWMRunning;
#endif
Bool fRootless;
#ifdef XWIN_MULTIWINDOW
@@ -1391,6 +1393,19 @@ winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h);
void
winMWExtWMUpdateIcon (Window id);
+
+void
+winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
+ winScreenInfoPtr pScreenInfo);
+
+BOOL CALLBACK
+winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam);
+
+Bool
+winIsInternalWMRunning (winScreenInfoPtr pScreenInfo);
+
+void
+winMWExtWMRestackWindows (ScreenPtr pScreen);
#endif
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 1c5e2fbbf..a9fff7a65 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -813,16 +813,34 @@ winMinimizeWindow (Window id)
{
WindowPtr pWin;
winPrivWinPtr pWinPriv;
+ win32RootlessWindowPtr pRLWinPriv;
+ HWND hWnd;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
#if CYGWINDOWING_DEBUG
ErrorF ("winMinimizeWindow\n");
#endif
-
+
pWin = LookupIDByType (id, RT_WINDOW);
-
- pWinPriv = winGetWindowPriv (pWin);
-
- ShowWindow (pWinPriv->hWnd, SW_MINIMIZE);
+
+ pScreen = pWin->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+ if (pScreenPriv && pScreenInfo->fInternalWM)
+ {
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ hWnd = pRLWinPriv->hWnd;
+ }
+ else
+ {
+ pWinPriv = winGetWindowPriv (pWin);
+ hWnd = pWinPriv->hWnd;
+ }
+
+ ShowWindow (hWnd, SW_MINIMIZE);
}
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 786b4e001..266448dc7 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -54,10 +54,11 @@
#include "obj_base.h"
#include "ddraw.h"
#include "winwindow.h"
+#include "windowswmstr.h"
extern void winDebug(const char *format, ...);
-#ifndef CYGDEBUG
+#ifndef CYGDEBUG
#define CYGDEBUG NO
#endif
@@ -108,6 +109,7 @@ typedef struct _XMsgProcArgRec {
DWORD dwScreen;
WMInfoPtr pWMInfo;
pthread_mutex_t *ppmServerStarted;
+ HWND hwndScreen;
} XMsgProcArgRec, *XMsgProcArgPtr;
@@ -170,6 +172,9 @@ static void
PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction);
#endif
+static Bool
+CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen);
+
/*
* Local globals
@@ -177,8 +182,9 @@ PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction);
static jmp_buf g_jmpWMEntry;
static jmp_buf g_jmpXMsgProcEntry;
-static Bool g_shutdown = FALSE;
+static Bool g_shutdown = FALSE;
static Bool redirectError = FALSE;
+static Bool g_fAnotherWMRunnig = FALSE;
/*
@@ -212,11 +218,14 @@ PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
case WM_WM_MOVE:
ErrorF ("\tWM_WM_MOVE\n");
break;
+ case WM_WM_SIZE:
+ ErrorF ("\tWM_WM_SIZE\n");
+ break;
case WM_WM_RAISE:
ErrorF ("\tWM_WM_RAISE\n");
break;
case WM_WM_LOWER:
- ErrorF ("\tWM_WM_RAISE\n");
+ ErrorF ("\tWM_WM_LOWER\n");
break;
case WM_WM_MAP:
ErrorF ("\tWM_WM_MAP\n");
@@ -227,8 +236,11 @@ PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
case WM_WM_KILL:
ErrorF ("\tWM_WM_KILL\n");
break;
+ case WM_WM_ACTIVATE:
+ ErrorF ("\tWM_WM_ACTIVATE\n");
+ break;
default:
- ErrorF ("Unknown Message.\n");
+ ErrorF ("\tUnknown Message.\n");
break;
}
#endif
@@ -482,7 +494,7 @@ UpdateName (WMInfoPtr pWMInfo, Window iWindow)
0,
1,
False,
- pWMInfo->atmPrivMap,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
&atmType,
&fmtRet,
&items,
@@ -499,7 +511,7 @@ UpdateName (WMInfoPtr pWMInfo, Window iWindow)
/* Some sanity checks */
if (!hWnd) return;
if (!IsWindow (hWnd)) return;
-
+
/* Set the Windows window name */
GetWindowName (pWMInfo->pDisplay, iWindow, &pszName);
if (pszName)
@@ -543,7 +555,7 @@ PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction)
0,
1,
False,
- pWMInfo->atmPrivMap,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
&atmType,
&fmtRet,
&items,
@@ -609,6 +621,12 @@ winMultiWindowWMProc (void *pArg)
{
WMMsgNodePtr pNode;
+ if(g_fAnotherWMRunnig)/* Another Window manager exists. */
+ {
+ Sleep (1000);
+ continue;
+ }
+
/* Pop a message off of our queue */
pNode = PopMessage (&pWMInfo->wmMsgQueue, pWMInfo);
if (pNode == NULL)
@@ -623,7 +641,7 @@ winMultiWindowWMProc (void *pArg)
ErrorF ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n",
GetTickCount (), (int)pNode->msg.msg, (int)pNode->msg.dwID);
#endif
-
+
/* Branch on the message type */
switch (pNode->msg.msg)
{
@@ -665,7 +683,7 @@ winMultiWindowWMProc (void *pArg)
XChangeProperty (pWMInfo->pDisplay,
pNode->msg.iWindow,
pWMInfo->atmPrivMap,
- pWMInfo->atmPrivMap,
+ XA_INTEGER,//pWMInfo->atmPrivMap,
32,
PropModeReplace,
(unsigned char *) &(pNode->msg.hwndWindow),
@@ -897,19 +915,7 @@ winMultiWindowXMsgProc (void *pArg)
"successfully opened the display.\n");
/* Check if another window manager is already running */
- redirectError = FALSE;
- XSetErrorHandler (winRedirectErrorHandler);
- XSelectInput(pProcArg->pDisplay,
- RootWindow (pProcArg->pDisplay, pProcArg->dwScreen),
- SubstructureNotifyMask | ButtonPressMask);
- XSync (pProcArg->pDisplay, 0);
- XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
- if (redirectError)
- {
- ErrorF ("winMultiWindowXMsgProc - "
- "another window manager is running. Exiting.\n");
- pthread_exit (NULL);
- }
+ g_fAnotherWMRunnig = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen);
/* Set up the supported icon sizes */
xis = XAllocIconSize ();
@@ -938,15 +944,49 @@ winMultiWindowXMsgProc (void *pArg)
/* Loop until we explicitly break out */
while (1)
{
+ if (!XPending (pProcArg->pDisplay))
+ {
+ if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen))
+ {
+ if (!g_fAnotherWMRunnig)
+ {
+ g_fAnotherWMRunnig = TRUE;
+ SendMessage(*(HWND*)pProcArg->hwndScreen, WM_UNMANAGE, 0, 0);
+ }
+ }
+ else
+ {
+ if (g_fAnotherWMRunnig)
+ {
+ g_fAnotherWMRunnig = FALSE;
+ SendMessage(*(HWND*)pProcArg->hwndScreen, WM_MANAGE, 0, 0);
+ }
+ }
+ Sleep (500);
+ continue;
+ }
+
/* Fetch next event */
XNextEvent (pProcArg->pDisplay, &event);
/* Branch on event type */
if (event.type == CreateNotify)
{
+ XWindowAttributes attr;
+
XSelectInput (pProcArg->pDisplay,
event.xcreatewindow.window,
PropertyChangeMask);
+
+ /* Get the window attributes */
+ XGetWindowAttributes (pProcArg->pDisplay,
+ event.xcreatewindow.window,
+ &attr);
+
+ if (!attr.override_redirect)
+ XSetWindowBorderWidth(pProcArg->pDisplay,
+ event.xcreatewindow.window,
+ 0);
}
else if (event.type == PropertyNotify
&& event.xproperty.atom == atmWmName)
@@ -998,7 +1038,8 @@ winInitWM (void **ppWMInfo,
pthread_t *ptWMProc,
pthread_t *ptXMsgProc,
pthread_mutex_t *ppmServerStarted,
- int dwScreen)
+ int dwScreen,
+ HWND hwndScreen)
{
WMProcArgPtr pArg = (WMProcArgPtr) malloc (sizeof(WMProcArgRec));
WMInfoPtr pWMInfo = (WMInfoPtr) malloc (sizeof(WMInfoRec));
@@ -1043,6 +1084,7 @@ winInitWM (void **ppWMInfo,
pXMsgArg->dwScreen = dwScreen;
pXMsgArg->pWMInfo = pWMInfo;
pXMsgArg->ppmServerStarted = ppmServerStarted;
+ pXMsgArg->hwndScreen = hwndScreen;
if (pthread_create (ptXMsgProc, NULL, winMultiWindowXMsgProc, pXMsgArg))
{
/* Bail if thread creation failed */
@@ -1182,7 +1224,7 @@ winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
"WM_DELETE_WINDOW",
False);
pWMInfo->atmPrivMap = XInternAtom (pWMInfo->pDisplay,
- WIN_HWND_CACHE,
+ WINDOWSWM_NATIVE_HWND,
False);
}
@@ -1300,6 +1342,36 @@ winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr)
/*
+ * Check if another window manager is running
+ */
+
+static Bool
+CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen)
+{
+ redirectError = FALSE;
+ XSetErrorHandler (winRedirectErrorHandler);
+ XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
+ // SubstructureNotifyMask | ButtonPressMask
+ ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
+ SubstructureRedirectMask | KeyPressMask |
+ ButtonPressMask | ButtonReleaseMask);
+ XSync (pDisplay, 0);
+ XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
+ XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
+ SubstructureNotifyMask);
+ XSync (pDisplay, 0);
+ if (redirectError)
+ {
+ //ErrorF ("CheckAnotherWindowManager() - another window manager is running. Exiting.\n");
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+/*
* Notify the MWM thread we're exiting and not to reconnect
*/
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index dd61b94b5..46d665013 100755
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -123,6 +123,7 @@ winInitializeDefaultScreens (void)
g_ScreenInfo[i].fDecoration = TRUE;
#ifdef XWIN_MULTIWINDOWEXTWM
g_ScreenInfo[i].fMWExtWM = FALSE;
+ g_ScreenInfo[i].fInternalWM = FALSE;
#endif
g_ScreenInfo[i].fRootless = FALSE;
#ifdef XWIN_MULTIWINDOW
@@ -505,6 +506,33 @@ ddxProcessArgument (int argc, char *argv[], int i)
/* Indicate that we have processed this argument */
return 1;
}
+ /*
+ * Look for the '-internalwm' argument
+ */
+ if (IS_OPTION ("-internalwm"))
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fMWExtWM = TRUE;
+ g_ScreenInfo[j].fInternalWM = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
+ g_ScreenInfo[g_iLastScreen].fInternalWM = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
#endif
/*
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index c0840da47..63de01fee 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -592,12 +592,13 @@ winFinishScreenInitFB (int index,
#endif
/* Initialize multi window mode */
- if (pScreenInfo->fMultiWindow
+ if ((pScreenInfo->fMultiWindow || pScreenInfo->fInternalWM)
&& !winInitWM (&pScreenPriv->pWMInfo,
&pScreenPriv->ptWMProc,
&pScreenPriv->ptXMsgProc,
&pScreenPriv->pmServerStarted,
- pScreenInfo->dwScreen))
+ pScreenInfo->dwScreen,
+ (HWND)&pScreenPriv->hwndScreen))
{
ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n");
return FALSE;
diff --git a/hw/xwin/wintrayicon.c b/hw/xwin/wintrayicon.c
index 6a4c90f1a..7eeaa6a90 100755
--- a/hw/xwin/wintrayicon.c
+++ b/hw/xwin/wintrayicon.c
@@ -115,6 +115,14 @@ winHandleIconMessage (HWND hwnd, UINT message,
switch (lParam)
{
+ case WM_LBUTTONUP:
+ /* Restack and bring all windows to top */
+ SetForegroundWindow (hwnd);
+
+ if (pScreenInfo->fMWExtWM)
+ winMWExtWMRestackWindows (pScreenInfo->pScreen);
+ break;
+
case WM_LBUTTONDBLCLK:
/* Display Exit dialog box */
winDisplayExitDialog (pScreenPriv);
diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index 308411c3e..04e940c02 100755
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -203,7 +203,7 @@ InitWin32RootlessEngine (win32RootlessWindowPtr pRLWinPriv)
+ 256 * sizeof (RGBQUAD));
if (pRLWinPriv->pbmihShadow == NULL)
{
- ErrorF ("winMWExtWMCreateFrame - malloc () failed\n");
+ ErrorF ("InitWin32RootlessEngine - malloc () failed\n");
return;
}
@@ -478,7 +478,7 @@ winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
DWORD dwExStyle;
DWORD dwStyle;
int iX, iY;
-
+
#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n",
(int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight);
@@ -525,6 +525,7 @@ winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid;
winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen);
+ winScreenInfo *pScreenInfo = NULL;
DWORD dwCurrentProcessID = GetCurrentProcessId ();
DWORD dwWindowProcessID = 0;
HWND hWnd;
@@ -536,6 +537,8 @@ winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
if (pScreenPriv->fRestacking) return;
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
pRLWinPriv->fRestackingNow = TRUE;
/* Show window */
@@ -551,8 +554,9 @@ winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
SetWindowPos (pRLWinPriv->hWnd, HWND_TOP,
0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
}
- else
+ else if (winIsInternalWMRunning(pScreenInfo))
{
+ /* using mulwinidow wm */
#if CYGMULTIWINDOW_DEBUG
winDebug ("Win %08x is not top\n", pRLWinPriv);
#endif
@@ -613,6 +617,19 @@ winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
}
}
}
+ else
+ {
+ /* using general wm like twm, wmaker etc.
+ Interleave X window and Windows window will cause problem. */
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+#if 0
+#endif
+ }
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
+#endif
pRLWinPriv->fRestackingNow = FALSE;
}
@@ -676,7 +693,7 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
Bool fReturn = TRUE;
HDC hdcNew;
HBITMAP hbmpNew;
-#if CYGMULTIWINDOW_DEBUG
+#if CYGMULTIWINDOW_DEBUG && FALSE
winDebug ("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv, pRLWinPriv->fDestroyed);
#endif
@@ -686,9 +703,11 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("pScreenPriv %08X\n", (int) pScreenPriv);
- winDebug ("pScreenInfo %08X\n", (int) pScreenInfo);
+#if CYGMULTIWINDOW_DEBUG && FALSE
+ winDebug ("\tpScreenPriv %08X\n", (int) pScreenPriv);
+ winDebug ("\tpScreenInfo %08X\n", (int) pScreenInfo);
+ winDebug ("\t(%d, %d)\n", (int)pRLWinPriv->pFrame->width,
+ (int) -pRLWinPriv->pFrame->height);
#endif
if (pRLWinPriv->hdcScreen == NULL)
{
@@ -786,7 +805,7 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
pRLWinPriv->fResized = FALSE;
}
-#if CYGMULTIWINDOW_DEBUG
+#if CYGMULTIWINDOW_DEBUG && FALSE
winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n",
(unsigned int)pRLWinPriv->pfb, (unsigned int)dibsection.dsBm.bmWidthBytes);
#endif
@@ -795,8 +814,8 @@ winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
{
ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
}
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMStartDrawing - done (0x08x) 0x%08x %d\n",
+#if CYGMULTIWINDOW_DEBUG && FALSE
+ winDebug ("winMWExtWMStartDrawing - done (0x08%x) 0x%08x %d\n",
(int) pRLWinPriv,
(unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes);
#endif
@@ -914,6 +933,13 @@ winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
pRLWinPriv->pFrame = pFrame;
pRLWinPriv->fResized = TRUE;
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN);
+
DeleteProperty (oldWin, AtmWindowsWmNativeHwnd ());
winMWExtWMSetNativeProperty (pFrame);
#if CYGMULTIWINDOW_DEBUG
@@ -1029,7 +1055,7 @@ winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
/* FIXME: move this to WindowsWM extension */
- lData = pRLWinPriv->hWnd;
+ lData = (long) pRLWinPriv->hWnd;
ChangeWindowProperty (pFrame->win, AtmWindowsWmNativeHwnd (),
XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
}
diff --git a/hw/xwin/winwin32rootlesswindow.c b/hw/xwin/winwin32rootlesswindow.c
index eedfe2f0c..f3605a216 100755
--- a/hw/xwin/winwin32rootlesswindow.c
+++ b/hw/xwin/winwin32rootlesswindow.c
@@ -50,7 +50,7 @@ winMWExtWMReorderWindows (ScreenPtr pScreen)
XID vlist[2];
#if CYGMULTIWINDOW_DEBUG && FALSE
- ErrorF ("winMWExtWMReorderWindows\n");
+ winDebug ("winMWExtWMReorderWindows\n");
#endif
pScreenPriv->fRestacking = TRUE;
@@ -58,7 +58,7 @@ winMWExtWMReorderWindows (ScreenPtr pScreen)
if (pScreenPriv->fWindowOrderChanged)
{
#if CYGMULTIWINDOW_DEBUG
- ErrorF ("winMWExtWMReorderWindows - Need to restack\n");
+ winDebug ("winMWExtWMReorderWindows - Need to restack\n");
#endif
hwnd = GetTopWindow (NULL);
@@ -182,3 +182,271 @@ winMWExtWMUpdateIcon (Window id)
}
}
}
+
+
+/*
+ * winMWExtWMDecorateWindow - Update window style. Called by EnumWindows.
+ */
+
+BOOL CALLBACK
+winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam)
+{
+ win32RootlessWindowPtr pRLWinPriv = NULL;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pRLWinPriv && pScreenInfo) winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+ }
+ return TRUE;
+}
+
+
+/*
+ * winMWExtWMUpdateWindowDecoration - Update window style.
+ */
+
+void
+winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
+ winScreenInfoPtr pScreenInfo)
+{
+ Bool fDecorate = FALSE;
+ DWORD dwExStyle = 0;
+ DWORD dwStyle = 0;
+ WINDOWPLACEMENT wndPlace;
+ UINT showCmd = 0;
+
+ wndPlace.length = sizeof (WINDOWPLACEMENT);
+
+ /* Get current window placement */
+ GetWindowPlacement (pRLWinPriv->hWnd, &wndPlace);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ fDecorate = TRUE;
+ }
+#if 0
+ if (wndPlace.showCmd == SW_HIDE)
+ return;//showCmd = SWP_HIDEWINDOW;
+ else
+ showCmd = SWP_SHOWWINDOW;
+#else
+ if (wndPlace.showCmd == SW_HIDE)
+ return;
+
+ if (IsWindowVisible (pRLWinPriv->hWnd))
+ showCmd = SWP_SHOWWINDOW;
+#endif
+
+ showCmd |= SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER;
+
+ winDebug ("winMWExtWMUpdateWindowDecoration %08x %s\n",
+ (int)pRLWinPriv, fDecorate?"Decorate":"Bare");
+
+ /* Get the standard and extended window style information */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ if (fDecorate)
+ {
+ RECT rcNew;
+ int iDx, iDy;
+ winWMMessageRec wmMsg;
+ winScreenPriv(pScreenInfo->pScreen);
+
+ /* */
+ if (!(dwExStyle & WS_EX_APPWINDOW))
+ {
+ winDebug ("\tBare=>Decorate\n");
+ /* Setup a rectangle with the X window position and size */
+ SetRect (&rcNew,
+ pRLWinPriv->pFrame->x,
+ pRLWinPriv->pFrame->y,
+ pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
+
+ /* */
+ AdjustWindowRectEx (&rcNew,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
+ FALSE,
+ WS_EX_APPWINDOW);
+
+ /* Calculate position deltas */
+ iDx = pRLWinPriv->pFrame->x - rcNew.left;
+ iDy = pRLWinPriv->pFrame->y - rcNew.top;
+
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW);
+
+ /* Position the Windows window */
+ SetWindowPos (pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ showCmd);
+
+ wmMsg.hwndWindow = pRLWinPriv->hWnd;
+ wmMsg.iWindow = (Window)pRLWinPriv->pFrame->win->drawable.id;
+ wmMsg.msg = WM_WM_NAME_EVENT;
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+
+ winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
+ wBoundingShape(pRLWinPriv->pFrame->win));
+ }
+ }
+ else
+ {
+ RECT rcNew;
+
+ /* */
+ if (dwExStyle & WS_EX_APPWINDOW)
+ {
+ winDebug ("\tDecorate=>Bare\n");
+ /* Setup a rectangle with the X window position and size */
+ SetRect (&rcNew,
+ pRLWinPriv->pFrame->x,
+ pRLWinPriv->pFrame->y,
+ pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
+#if 0
+ /* */
+ AdjustWindowRectEx (&rcNew,
+ WS_POPUP | WS_CLIPCHILDREN,
+ FALSE,
+ WS_EX_TOOLWINDOW);
+
+ /* Calculate position deltas */
+ iDx = pRLWinPriv->pFrame->x - rcNew.left;
+ iDy = pRLWinPriv->pFrame->y - rcNew.top;
+
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+#endif
+
+ /* Hide window temporary to remove from taskbar. */
+ ShowWindow( pRLWinPriv->hWnd, SW_HIDE );
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN);
+
+ /* Position the Windows window */
+ SetWindowPos (pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ showCmd);
+
+ winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
+ wBoundingShape(pRLWinPriv->pFrame->win));
+ }
+ }
+}
+
+
+/*
+ * winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
+ */
+Bool
+winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
+{
+ return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning;
+}
+
+
+/*
+ * winMWExtWMRestackWindows
+ */
+
+void
+winMWExtWMRestackWindows (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pWin = NULL;
+ WindowPtr pWinPrev = NULL;
+ win32RootlessWindowPtr pRLWin = NULL;
+ win32RootlessWindowPtr pRLWinPrev = NULL;
+ int nWindow = 0;
+ HDWP hWinPosInfo = NULL;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows\n");
+#endif
+
+ pScreenPriv->fRestacking = TRUE;
+
+ if (pRoot != NULL)
+ {
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
+ nWindow ++;
+
+ hWinPosInfo = BeginDeferWindowPos(nWindow);
+
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
+ {
+ if (pWin->realized)
+ {
+ UINT uFlags;
+
+ pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ if (pRLWin == NULL) continue;
+
+ if (pWinPrev)
+ pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow (pWinPrev, FALSE);
+
+ uFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW;
+ if (pRLWinPrev != NULL) uFlags |= SWP_NOACTIVATE;
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows - DeferWindowPos (%08x, %08x)\n",
+ pRLWin->hWnd,
+ pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP);
+#endif
+ hWinPosInfo = DeferWindowPos (hWinPosInfo, pRLWin->hWnd,
+ pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP,
+ 0, 0, 0, 0,
+ uFlags);
+ if (hWinPosInfo == NULL)
+ {
+ ErrorF ("winMWExtWMRestackWindows - DeferWindowPos () failed: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+ pWinPrev = pWin;
+ }
+ }
+ if (!EndDeferWindowPos (hWinPosInfo))
+ {
+ ErrorF ("winMWExtWMRestackWindows - EndDeferWindowPos () failed: %d\n",
+ (int) GetLastError ());
+ return;
+ }
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMRestackWindows - done\n");
+#endif
+ pScreenPriv->fRestacking = FALSE;
+}
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index 0c1ae555c..7c34d0a4e 100755
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -37,6 +37,9 @@
#include "propertyst.h"
#include "Xatom.h"
#include "winmultiwindowclass.h"
+#if CYGDEBUG
+#include "winmessages.h"
+#endif
/*
@@ -48,7 +51,6 @@
#define RAISE_ON_CLICK_DEFAULT FALSE
-
/*
* Global variables
*/
@@ -412,7 +414,8 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
PAINTSTRUCT ps;
LPWINDOWPOS pWinPos = NULL;
RECT rcClient;
- XID vlist[2];
+ winWMMessageRec wmMsg;
+ Bool fWMMsgInitialized = FALSE;
/* Check if the Windows window property for our X window pointer is valid */
if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
@@ -422,11 +425,35 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
if (pScreenPriv) hwndScreen = pScreenPriv->hwndScreen;
+
+ wmMsg.msg = 0;
+ wmMsg.hwndWindow = hwnd;
+ wmMsg.iWindow = (Window)pWin->drawable.id;
+
+ wmMsg.iX = pRLWinPriv->pFrame->x;
+ wmMsg.iY = pRLWinPriv->pFrame->y;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ fWMMsgInitialized = TRUE;
#if 0
- winDebug ("hWnd %08X\n", hwnd);
- winDebug ("pScreenPriv %08X\n", pScreenPriv);
- winDebug ("pScreenInfo %08X\n", pScreenInfo);
- winDebug ("hwndScreen %08X\n", hwndScreen);
+ if (message >= WM_USER)
+ {
+ winDebug("winMWExtWMWindowProc - Message WM_USER + %d",
+ message - WM_USER);
+ winDebug(" wParam 0x%x lParam 0x%x\n", wParam, lParam);
+ }
+ else if (message < MESSAGE_NAMES_LEN && MESSAGE_NAMES[message])
+ {
+ winDebug("winMWExtWMWindowProc - Message %s",
+ MESSAGE_NAMES[message]);
+ winDebug(" wParam 0x%x lParam 0x%x\n", wParam, lParam);
+ }
+
+ winDebug ("\thWnd %08X\n", hwnd);
+ winDebug ("\tpScreenPriv %08X\n", pScreenPriv);
+ winDebug ("\tpScreenInfo %08X\n", pScreenInfo);
+ winDebug ("\thwndScreen %08X\n", hwndScreen);
winDebug ("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
pRLWinPriv, message, wParam, lParam);
#endif
@@ -455,7 +482,14 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
}
else
{
- winWindowsWMSendEvent(WindowsWMControllerNotify,
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
WindowsWMControllerNotifyMask,
1,
WindowsWMCloseWindow,
@@ -677,9 +711,9 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
#endif
-#if 0
+#if 1
/* Check if this window needs to be made active when clicked */
- if (pWin->overrideRedirect)
+ if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect)
{
#if CYGMULTIWINDOW_DEBUG
winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
@@ -690,10 +724,11 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
return MA_NOACTIVATE;
}
#endif
- if (!IsMouseActive (pWin)) return MA_NOACTIVATE;
+ if (!winIsInternalWMRunning(pScreenInfo) && !IsMouseActive (pWin))
+ return MA_NOACTIVATE;
break;
-
+
case WM_KILLFOCUS:
/* Pop any pressed keys since we are losing keyboard focus */
winKeybdReleaseKeys ();
@@ -795,6 +830,20 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
#endif
if (LOWORD(wParam) != WA_INACTIVE)
{
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+#if 0
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+#endif
+ /* Tell our Window Manager thread to activate the window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized)
+ if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
winWindowsWMSendEvent(WindowsWMControllerNotify,
WindowsWMControllerNotifyMask,
1,
@@ -804,13 +853,13 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
0, 0);
}
return 0;
-
+
#if 1
case WM_WINDOWPOSCHANGING:
pWinPos = (LPWINDOWPOS)lParam;
if (!(pWinPos->flags & SWP_NOZORDER))
{
- if (pRLWinPriv->fRestackingNow)
+ if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking)
{
#if CYGMULTIWINDOW_DEBUG
winDebug ("Win %08x is now restacking.\n", (unsigned int)pRLWinPriv);
@@ -818,7 +867,7 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
break;
}
- if (IsRaiseOnClick (pWin))
+ if (winIsInternalWMRunning(pScreenInfo) || IsRaiseOnClick (pWin))
{
#if CYGMULTIWINDOW_DEBUG
winDebug ("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n", (unsigned int)pRLWinPriv);
@@ -867,19 +916,52 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
#endif
if (!pRLWinPriv->fMovingOrSizing)
{
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
winMWExtWMMoveXWindow (pWin,
- (LOWORD(lParam) - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN)),
- (HIWORD(lParam) - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN)));
+ (LOWORD(lParam) - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN)),
+ (HIWORD(lParam) - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN)));
}
return 0;
case WM_SHOWWINDOW:
-#if CYGMULTIWINDOW_DEBUG
+#if CYGMULTIWINDOW_DEBUG || TRUE
winDebug ("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
(unsigned int)GetTickCount ());
#endif
+ /* Bail out if the window is being hidden */
+ if (!wParam)
+ return 0;
+
+ if (!pScreenInfo->fInternalWM)//XXXX
+ return 0;
+
+ winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+#if CYGMULTIWINDOW_DEBUG || TRUE
+ winDebug ("\tMapWindow\n");
+#endif
+ /* Tell X to map the window */
+ MapWindow (pWin, wClient(pWin));
+
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ /* Bring the Windows window to the foreground */
+ SetForegroundWindow (hwnd);
+
+ /* Setup the Window Manager message */
+ wmMsg.msg = WM_WM_MAP;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
break;
case WM_SIZING:
@@ -914,15 +996,23 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
/* Reorder if window z order was changed */
if ((pScreenPriv != NULL)
&& !(pWinPos->flags & SWP_NOZORDER)
- && !(pWinPos->flags & SWP_SHOWWINDOW))
+ && !(pWinPos->flags & SWP_SHOWWINDOW)
+ && winIsInternalWMRunning(pScreenInfo))
{
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\twindow z order was changed\n");
+#endif
if (pWinPos->hwndInsertAfter == HWND_TOP
||pWinPos->hwndInsertAfter == HWND_TOPMOST
||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
{
- vlist[0] = Above;
- ConfigureWindow (pWin, CWStackMode,
- vlist, wClient(pWin));
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
}
#if 1
else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
@@ -943,7 +1033,8 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (Above, WIN_WINDOW_PROP)
+ && GetProp (hWndAbove, WIN_WINDOW_PROP)
+ && !IsWindowVisible (hWndAbove)
&& !IsIconic (hWndAbove) ) /* ignore minimized windows */
break;
}
@@ -951,9 +1042,13 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
raise it in X stack. */
if (hWndAbove == NULL)
{
- vlist[0] = Above;
- ConfigureWindow (pWin, CWStackMode,
- vlist, wClient(pWin));
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
}
}
#endif
@@ -964,6 +1059,13 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
#if CYGMULTIWINDOW_DEBUG
winDebug ("\tIconic -> MINIMIZED\n");
#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
winWindowsWMSendEvent(WindowsWMControllerNotify,
WindowsWMControllerNotifyMask,
1,
@@ -1004,33 +1106,42 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
#if CYGMULTIWINDOW_DEBUG
winDebug ("\tmove & resize\n");
#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
} else if (!(pWinPos->flags & SWP_NOMOVE)) {
#if CYGMULTIWINDOW_DEBUG
winDebug ("\tmove\n");
#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
winMWExtWMMoveXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN));
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN));
} else if (!(pWinPos->flags & SWP_NOSIZE)) {
#if CYGMULTIWINDOW_DEBUG
winDebug ("\tresize\n");
#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
winMWExtWMResizeXWindow (pWin,
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
}
}
}
@@ -1059,6 +1170,13 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
#if CYGMULTIWINDOW_DEBUG
winDebug ("\tSIZE_MINIMIZED\n");
#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
winWindowsWMSendEvent(WindowsWMControllerNotify,
WindowsWMControllerNotifyMask,
1,
@@ -1098,17 +1216,30 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
/* Perform the resize and notify the X client */
if (!pRLWinPriv->fMovingOrSizing)
{
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
winMWExtWMResizeXWindow (pWin,
- (short) LOWORD(lParam)
- - wBorderWidth (pWin)*2,
- (short) HIWORD(lParam)
- - wBorderWidth (pWin)*2);
+ (short) LOWORD(lParam)
+ - wBorderWidth (pWin)*2,
+ (short) HIWORD(lParam)
+ - wBorderWidth (pWin)*2);
}
break;
case WM_ACTIVATEAPP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
if (wParam)
{
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ }
+ else
+ {
+ }
winWindowsWMSendEvent(WindowsWMActivationNotify,
WindowsWMActivationNotifyMask,
1,
@@ -1155,15 +1286,27 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
GetClientRect (hwnd, &rcClient);
MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ break;
+
+ case WM_MANAGE:
+ ErrorF ("winMWExtWMWindowProc - WM_MANAGE\n");
+ break;
+
+ case WM_UNMANAGE:
+ ErrorF ("winMWExtWMWindowProc - WM_UNMANAGE\n");
break;
default:
diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index b4a92187a..cea662a86 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -49,7 +49,6 @@
#define WIN_MSG_QUEUE_FNAME "/dev/windows"
#define WIN_WID_PROP "cyg_wid_prop_rl"
#define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl"
-#define WIN_HWND_CACHE "cyg_privmap_rl"
#ifndef CYGMULTIWINDOW_DEBUG
#define CYGMULTIWINDOW_DEBUG NO
#endif
@@ -105,9 +104,11 @@ typedef struct _winWMMessageRec{
#define WM_WM_UNMAP (WM_USER + 6)
#define WM_WM_KILL (WM_USER + 7)
#define WM_WM_ACTIVATE (WM_USER + 8)
-#define WM_WM_NAME_EVENT (WM_USER + 9)
-#define WM_WM_HINTS_EVENT (WM_USER + 10)
+#define WM_WM_NAME_EVENT (WM_USER + 9)
+#define WM_WM_HINTS_EVENT (WM_USER + 10)
#define WM_WM_CHANGE_STATE (WM_USER + 11)
+#define WM_MANAGE (WM_USER + 100)
+#define WM_UNMANAGE (WM_USER + 102)
void
winSendMessageToWM (void *pWMInfo, winWMMessagePtr msg);
@@ -117,7 +118,8 @@ winInitWM (void **ppWMInfo,
pthread_t *ptWMProc,
pthread_t *ptXMsgProc,
pthread_mutex_t *ppmServerStarted,
- int dwScreen);
+ int dwScreen,
+ HWND hwndScreen);
void
winDeinitMultiWindowWM (void);
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index 6188425dd..ab9b08a27 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -56,7 +56,8 @@ extern Bool g_fClipboard;
extern HWND g_hDlgDepthChange;
extern Bool g_fKeyboardHookLL;
extern HWND g_hwndKeyboardFocus;
-extern Bool g_fSoftwareCursor;
+extern Bool g_fSoftwareCursor;
+extern DWORD g_dwCurrentThreadID;
/*
* Called by winWakeupHandler
@@ -1131,7 +1132,7 @@ winWindowProc (HWND hwnd, UINT message,
|| s_pScreenInfo->fIgnoreInput)
break;
-#if CYGDEBUG
+#if CYGDEBUG || TRUE
winDebug ("winWindowProc - WM_ACTIVATEAPP\n");
#endif
@@ -1152,6 +1153,14 @@ winWindowProc (HWND hwnd, UINT message,
/* Call engine specific screen activation/deactivation function */
(*s_pScreenPriv->pwinActivateApp) (s_pScreen);
+
+ if (s_pScreenPriv->fActive)
+ {
+ /* Restack all window unless using built-in wm. */
+ if (s_pScreenInfo->fInternalWM && s_pScreenInfo->fAnotherWMRunning)
+ winMWExtWMRestackWindows (s_pScreen);
+ }
+
return 0;
case WM_COMMAND:
@@ -1161,9 +1170,9 @@ winWindowProc (HWND hwnd, UINT message,
/* Display Exit dialog */
winDisplayExitDialog (s_pScreenPriv);
return 0;
- case ID_APP_SHOWCURSOR:
- winDebug("ShowCursor: %d\n", ShowCursor(TRUE));
- return 0;
+ case ID_APP_SHOWCURSOR:
+ winDebug("ShowCursor: %d\n", ShowCursor(TRUE));
+ return 0;
#ifdef XWIN_MULTIWINDOW
case ID_APP_HIDE_ROOT:
@@ -1210,6 +1219,28 @@ winWindowProc (HWND hwnd, UINT message,
}
break;
+ case WM_MANAGE:
+ ErrorF ("winWindowProc - WM_MANAGE\n");
+ s_pScreenInfo->fAnotherWMRunning = FALSE;
+
+ if (s_pScreenInfo->fInternalWM)
+ {
+ EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
+ //RootlessRepositionWindows (s_pScreen);
+ }
+ break;
+
+ case WM_UNMANAGE:
+ ErrorF ("winWindowProc - WM_UNMANAGE\n");
+ s_pScreenInfo->fAnotherWMRunning = TRUE;
+
+ if (s_pScreenInfo->fInternalWM)
+ {
+ EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
+ winMWExtWMRestackWindows (s_pScreen);
+ }
+ break;
+
default:
if(message == s_uTaskbarRestart)
{