2
*Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
4
*Permission is hereby granted, free of charge, to any person obtaining
5
* a copy of this software and associated documentation files (the
6
*"Software"), to deal in the Software without restriction, including
7
*without limitation the rights to use, copy, modify, merge, publish,
8
*distribute, sublicense, and/or sell copies of the Software, and to
9
*permit persons to whom the Software is furnished to do so, subject to
10
*the following conditions:
12
*The above copyright notice and this permission notice shall be
13
*included in all copies or substantial portions of the Software.
15
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
*EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
*MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
*NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
19
*ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20
*CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
*WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*Except as contained in this notice, the name of the XFree86 Project
24
*shall not be used in advertising or otherwise to promote the sale, use
25
*or other dealings in this Software without prior written authorization
26
*from the XFree86 Project.
28
* Authors: Kensuke Matsuzaki
29
* Earle F. Philhower, III
33
#ifdef HAVE_XWIN_CONFIG_H
34
#include <xwin-config.h>
41
* winMWExtWMReorderWindows
45
winMWExtWMReorderWindows (ScreenPtr pScreen)
47
winScreenPriv(pScreen);
49
win32RootlessWindowPtr pRLWin = NULL;
50
win32RootlessWindowPtr pRLWinSib = NULL;
51
DWORD dwCurrentProcessID = GetCurrentProcessId ();
52
DWORD dwWindowProcessID = 0;
55
#if CYGMULTIWINDOW_DEBUG && FALSE
56
winDebug ("winMWExtWMReorderWindows\n");
59
pScreenPriv->fRestacking = TRUE;
61
if (pScreenPriv->fWindowOrderChanged)
63
#if CYGMULTIWINDOW_DEBUG
64
winDebug ("winMWExtWMReorderWindows - Need to restack\n");
66
hwnd = GetTopWindow (NULL);
70
GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
72
if ((dwWindowProcessID == dwCurrentProcessID)
73
&& GetProp (hwnd, WIN_WINDOW_PROP))
76
pRLWin = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP);
80
vlist[0] = pRLWinSib->pFrame->win->drawable.id;
83
ConfigureWindow (pRLWin->pFrame->win, CWSibling | CWStackMode,
84
vlist, wClient(pRLWin->pFrame->win));
88
/* 1st window - raise to the top */
91
ConfigureWindow (pRLWin->pFrame->win, CWStackMode,
92
vlist, wClient(pRLWin->pFrame->win));
95
hwnd = GetNextWindow (hwnd, GW_HWNDNEXT);
99
pScreenPriv->fRestacking = FALSE;
100
pScreenPriv->fWindowOrderChanged = FALSE;
106
* winMWExtWMMoveXWindow
110
winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y)
112
CARD32 *vlist = malloc(sizeof(CARD32)*2);
116
ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
122
* winMWExtWMResizeXWindow
126
winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h)
128
CARD32 *vlist = malloc(sizeof(CARD32)*2);
132
ConfigureWindow (pWin, CWWidth | CWHeight, vlist, wClient(pWin));
138
* winMWExtWMMoveResizeXWindow
142
winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h)
144
CARD32 *vlist = malloc(sizeof(long)*4);
151
ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin));
157
* winMWExtWMUpdateIcon
158
* Change the Windows window icon
162
winMWExtWMUpdateIcon (Window id)
165
HICON hIcon, hiconOld;
167
pWin = LookupIDByType (id, RT_WINDOW);
168
hIcon = (HICON)winOverrideIcon ((unsigned long)pWin);
171
hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
175
win32RootlessWindowPtr pRLWinPriv
176
= (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
178
if (pRLWinPriv->hWnd)
180
hiconOld = (HICON) SetClassLong (pRLWinPriv->hWnd,
184
winDestroyIcon(hiconOld);
191
* winMWExtWMDecorateWindow - Update window style. Called by EnumWindows.
195
winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam)
197
win32RootlessWindowPtr pRLWinPriv = NULL;
198
ScreenPtr pScreen = NULL;
199
winPrivScreenPtr pScreenPriv = NULL;
200
winScreenInfo *pScreenInfo = NULL;
202
/* Check if the Windows window property for our X window pointer is valid */
203
if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
205
pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
206
if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
207
if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
208
if (pRLWinPriv && pScreenInfo) winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
215
* winMWExtWMUpdateWindowDecoration - Update window style.
219
winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
220
winScreenInfoPtr pScreenInfo)
222
Bool fDecorate = FALSE;
225
WINDOWPLACEMENT wndPlace;
228
wndPlace.length = sizeof (WINDOWPLACEMENT);
230
/* Get current window placement */
231
GetWindowPlacement (pRLWinPriv->hWnd, &wndPlace);
233
if (winIsInternalWMRunning(pScreenInfo))
235
if (!pRLWinPriv->pFrame->win->overrideRedirect)
239
if (wndPlace.showCmd == SW_HIDE)
240
return;//showCmd = SWP_HIDEWINDOW;
242
showCmd = SWP_SHOWWINDOW;
244
if (wndPlace.showCmd == SW_HIDE)
247
if (IsWindowVisible (pRLWinPriv->hWnd))
248
showCmd = SWP_SHOWWINDOW;
251
showCmd |= SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER;
253
winDebug ("winMWExtWMUpdateWindowDecoration %08x %s\n",
254
(int)pRLWinPriv, fDecorate?"Decorate":"Bare");
256
/* Get the standard and extended window style information */
257
dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
258
dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
264
winWMMessageRec wmMsg;
265
winScreenPriv(pScreenInfo->pScreen);
268
if (!(dwExStyle & WS_EX_APPWINDOW))
270
winDebug ("\tBare=>Decorate\n");
271
/* Setup a rectangle with the X window position and size */
273
pRLWinPriv->pFrame->x,
274
pRLWinPriv->pFrame->y,
275
pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
276
pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
278
#ifdef CYGMULTIWINDOW_DEBUG
279
winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
280
rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
281
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
284
AdjustWindowRectEx (&rcNew,
285
WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
289
#ifdef CYGMULTIWINDOW_DEBUG
290
winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
291
rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
292
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
294
/* Calculate position deltas */
295
iDx = pRLWinPriv->pFrame->x - rcNew.left;
296
iDy = pRLWinPriv->pFrame->y - rcNew.top;
298
/* Calculate new rectangle */
304
/* Set the window extended style flags */
305
SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
307
/* Set the window standard style flags */
308
SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
309
WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW);
311
#ifdef CYGMULTIWINDOW_DEBUG
312
winDebug("\tWindowStyle: %08x %08x\n",
313
WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
316
/* Position the Windows window */
317
#ifdef CYGMULTIWINDOW_DEBUG
318
winDebug("\tMoved {%d, %d, %d, %d}, {%d, %d}\n",
319
rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
320
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
322
SetWindowPos (pRLWinPriv->hWnd, NULL,
323
rcNew.left, rcNew.top,
324
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
328
wmMsg.hwndWindow = pRLWinPriv->hWnd;
329
wmMsg.iWindow = (Window)pRLWinPriv->pFrame->win->drawable.id;
330
wmMsg.msg = WM_WM_NAME_EVENT;
331
winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
333
winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
334
wBoundingShape(pRLWinPriv->pFrame->win));
342
if (dwExStyle & WS_EX_APPWINDOW)
344
winDebug ("\tDecorate=>Bare\n");
345
/* Setup a rectangle with the X window position and size */
347
pRLWinPriv->pFrame->x,
348
pRLWinPriv->pFrame->y,
349
pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
350
pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
353
AdjustWindowRectEx (&rcNew,
354
WS_POPUP | WS_CLIPCHILDREN,
358
/* Calculate position deltas */
359
iDx = pRLWinPriv->pFrame->x - rcNew.left;
360
iDy = pRLWinPriv->pFrame->y - rcNew.top;
362
/* Calculate new rectangle */
369
/* Hide window temporary to remove from taskbar. */
370
ShowWindow( pRLWinPriv->hWnd, SW_HIDE );
372
/* Set the window extended style flags */
373
SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
375
/* Set the window standard style flags */
376
SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
377
WS_POPUP | WS_CLIPCHILDREN);
379
/* Position the Windows window */
380
SetWindowPos (pRLWinPriv->hWnd, NULL,
381
rcNew.left, rcNew.top,
382
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
385
winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
386
wBoundingShape(pRLWinPriv->pFrame->win));
393
* winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
396
winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
398
return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning;
403
* winMWExtWMRestackWindows
407
winMWExtWMRestackWindows (ScreenPtr pScreen)
409
winScreenPriv(pScreen);
410
WindowPtr pRoot = WindowTable[pScreen->myNum];
411
WindowPtr pWin = NULL;
412
WindowPtr pWinPrev = NULL;
413
win32RootlessWindowPtr pRLWin = NULL;
414
win32RootlessWindowPtr pRLWinPrev = NULL;
416
HDWP hWinPosInfo = NULL;
418
#if CYGMULTIWINDOW_DEBUG
419
winDebug ("winMWExtWMRestackWindows\n");
422
pScreenPriv->fRestacking = TRUE;
426
for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
429
hWinPosInfo = BeginDeferWindowPos(nWindow);
431
for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
437
pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
438
if (pRLWin == NULL) continue;
441
pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow (pWinPrev, FALSE);
443
uFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW;
444
if (pRLWinPrev != NULL) uFlags |= SWP_NOACTIVATE;
446
#if CYGMULTIWINDOW_DEBUG
447
winDebug ("winMWExtWMRestackWindows - DeferWindowPos (%08x, %08x)\n",
449
pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP);
451
hWinPosInfo = DeferWindowPos (hWinPosInfo, pRLWin->hWnd,
452
pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP,
455
if (hWinPosInfo == NULL)
457
ErrorF ("winMWExtWMRestackWindows - DeferWindowPos () failed: %d\n",
458
(int) GetLastError ());
464
if (!EndDeferWindowPos (hWinPosInfo))
466
ErrorF ("winMWExtWMRestackWindows - EndDeferWindowPos () failed: %d\n",
467
(int) GetLastError ());
472
#if CYGMULTIWINDOW_DEBUG
473
winDebug ("winMWExtWMRestackWindows - done\n");
475
pScreenPriv->fRestacking = FALSE;