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
* Look at hw/darwin/quartz/xpr/xprFrame.c and hw/darwin/quartz/cr/crFrame.c
35
#ifdef HAVE_XWIN_CONFIG_H
36
#include <xwin-config.h>
40
#define _WINDOWSWM_SERVER_
41
#include "windowswmstr.h"
42
#include "dixevents.h"
43
#include "winmultiwindowclass.h"
45
#include <X11/Xatom.h>
52
#define MOUSE_POLLING_INTERVAL 500
54
#define ULW_COLORKEY 0x00000001
55
#define ULW_ALPHA 0x00000002
56
#define ULW_OPAQUE 0x00000004
57
#define AC_SRC_ALPHA 0x01
63
DEFINE_ATOM_HELPER(AtmWindowsWmNativeHwnd, WINDOWSWM_NATIVE_HWND)
65
winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame);
71
Bool g_fNoConfigureWindow = FALSE;
74
extern void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon);
77
* Internal function to get the DIB format that is compatible with the screen
78
* Fixme: Share code with winshadgdi.c
83
winMWExtWMQueryDIBFormat (win32RootlessWindowPtr pRLWinPriv, BITMAPINFOHEADER *pbmih)
86
#if CYGMULTIWINDOW_DEBUG
90
/* Create a memory bitmap compatible with the screen */
91
hbmp = CreateCompatibleBitmap (pRLWinPriv->hdcScreen, 1, 1);
94
ErrorF ("winMWExtWMQueryDIBFormat - CreateCompatibleBitmap failed\n");
98
/* Initialize our bitmap info header */
99
ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
100
pbmih->biSize = sizeof (BITMAPINFOHEADER);
102
/* Get the biBitCount */
103
if (!GetDIBits (pRLWinPriv->hdcScreen,
110
ErrorF ("winMWExtWMQueryDIBFormat - First call to GetDIBits failed\n");
115
#if CYGMULTIWINDOW_DEBUG
116
/* Get a pointer to bitfields */
117
pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
119
winDebug ("winMWExtWMQueryDIBFormat - First call masks: %08x %08x %08x\n",
120
(unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
123
/* Get optimal color table, or the optimal bitfields */
124
if (!GetDIBits (pRLWinPriv->hdcScreen,
131
ErrorF ("winMWExtWMQueryDIBFormat - Second call to GetDIBits "
144
winMWExtWMCreateRgnFromRegion (RegionPtr pShape)
150
if (pShape == NULL) return NULL;
152
nRects = REGION_NUM_RECTS(pShape);
153
pRects = REGION_RECTS(pShape);
155
hRgn = CreateRectRgn (0, 0, 0, 0);
158
ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
160
0, 0, 0, 0, (int) GetLastError ());
163
/* Loop through all rectangles in the X region */
164
for (pEnd = pRects + nRects; pRects < pEnd; pRects++)
166
/* Create a Windows region for the X rectangle */
167
hRgnRect = CreateRectRgn (pRects->x1,
171
if (hRgnRect == NULL)
173
ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
179
(int) GetLastError ());
182
/* Merge the Windows region with the accumulated region */
183
if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
185
ErrorF ("winReshape - CombineRgn () failed: %d\n",
186
(int) GetLastError ());
189
/* Delete the temporary Windows region */
190
DeleteObject (hRgnRect);
197
InitWin32RootlessEngine (win32RootlessWindowPtr pRLWinPriv)
199
pRLWinPriv->hdcScreen = GetDC (pRLWinPriv->hWnd);
200
pRLWinPriv->hdcShadow = CreateCompatibleDC (pRLWinPriv->hdcScreen);
201
pRLWinPriv->hbmpShadow = NULL;
203
/* Allocate bitmap info header */
204
pRLWinPriv->pbmihShadow = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
205
+ 256 * sizeof (RGBQUAD));
206
if (pRLWinPriv->pbmihShadow == NULL)
208
ErrorF ("InitWin32RootlessEngine - malloc () failed\n");
212
/* Query the screen format */
213
winMWExtWMQueryDIBFormat (pRLWinPriv,
214
pRLWinPriv->pbmihShadow);
218
winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
219
int newX, int newY, RegionPtr pShape)
221
#define CLASS_NAME_LENGTH 512
223
win32RootlessWindowPtr pRLWinPriv;
225
char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
228
char *res_name, *res_class, *res_role;
229
static int s_iWindowID = 0;
231
#if CYGMULTIWINDOW_DEBUG
232
winDebug ("winMWExtWMCreateFrame %d %d - %d %d\n",
233
newX, newY, pFrame->width, pFrame->height);
236
pRLWinPriv = (win32RootlessWindowPtr) malloc (sizeof (win32RootlessWindowRec));
237
pRLWinPriv->pFrame = pFrame;
238
pRLWinPriv->pfb = NULL;
239
pRLWinPriv->hbmpShadow = NULL;
240
pRLWinPriv->hdcShadow = NULL;
241
pRLWinPriv->hdcScreen = NULL;
242
pRLWinPriv->pbmihShadow = NULL;
243
pRLWinPriv->fResized = TRUE;
244
pRLWinPriv->fClose = FALSE;
245
pRLWinPriv->fRestackingNow = FALSE;
246
pRLWinPriv->fDestroyed = FALSE;
247
pRLWinPriv->fMovingOrSizing = FALSE;
249
// Store the implementation private frame ID
250
pFrame->wid = (RootlessFrameID) pRLWinPriv;
252
winSelectIcons(pFrame->win, &hIcon, &hIconSmall);
254
/* Set standard class name prefix so we can identify window easily */
255
strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
257
if (winMultiWindowGetClassHint (pFrame->win, &res_name, &res_class))
259
strncat (pszClass, "-", 1);
260
strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass));
261
strncat (pszClass, "-", 1);
262
strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass));
264
/* Check if a window class is provided by the WM_WINDOW_ROLE property,
265
* if not use the WM_CLASS information.
266
* For further information see:
267
* http://tronche.com/gui/x/icccm/sec-5.html
269
if (winMultiWindowGetWindowRole (pFrame->win, &res_role) )
271
strcat (pszClass, "-");
272
strcat (pszClass, res_role);
280
/* Add incrementing window ID to make unique class name */
281
snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
282
pszWindowID[sizeof(pszWindowID)-1] = 0;
283
strcat (pszClass, pszWindowID);
285
#if CYGMULTIWINDOW_DEBUG
286
winDebug ("winCreateWindowsWindow - Creating class: %s\n", pszClass);
289
/* Setup our window class */
290
wc.cbSize = sizeof(wc);
291
wc.style = CS_HREDRAW | CS_VREDRAW;
292
wc.lpfnWndProc = winMWExtWMWindowProc;
295
wc.hInstance = g_hInstance;
297
wc.hIconSm = hIconSmall;
299
wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
300
wc.lpszMenuName = NULL;
301
wc.lpszClassName = pszClass;
302
RegisterClassEx (&wc);
304
/* Create the window */
305
g_fNoConfigureWindow = TRUE;
306
pRLWinPriv->hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
307
pszClass, /* Class name */
308
WINDOW_TITLE_X, /* Window name */
309
WS_POPUP | WS_CLIPCHILDREN,
310
newX, /* Horizontal position */
311
newY, /* Vertical position */
312
pFrame->width, /* Right edge */
313
pFrame->height, /* Bottom edge */
314
(HWND) NULL, /* No parent or owner window */
315
(HMENU) NULL, /* No menu */
316
GetModuleHandle (NULL), /* Instance handle */
317
pRLWinPriv); /* ScreenPrivates */
318
if (pRLWinPriv->hWnd == NULL)
320
ErrorF ("winMWExtWMCreateFrame - CreateWindowExA () failed: %d\n",
321
(int) GetLastError ());
325
#if CYGMULTIWINDOW_DEBUG
326
winDebug ("winMWExtWMCreateFrame - ShowWindow\n");
329
//ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
330
g_fNoConfigureWindow = FALSE;
334
winMWExtWMReshapeFrame (pFrame->wid, pShape);
337
#if CYGMULTIWINDOW_DEBUG
338
winDebug ("winMWExtWMCreateFrame - (%08x) %08x\n",
339
(int) pFrame->wid, (int) pRLWinPriv->hWnd);
342
WindowPtr pWin2 = NULL;
343
win32RootlessWindowPtr pRLWinPriv2 = NULL;
345
/* Check if the Windows window property for our X window pointer is valid */
346
if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
348
pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
350
winDebug ("winMWExtWMCreateFrame2 (%08x) %08x\n",
351
pRLWinPriv2, pRLWinPriv2->hWnd);
352
if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
354
winDebug ("Error param missmatch\n");
360
winMWExtWMSetNativeProperty (pFrame);
366
winMWExtWMDestroyFrame (RootlessFrameID wid)
368
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
373
char pszClass[CLASS_NAME_LENGTH];
375
#if CYGMULTIWINDOW_DEBUG
376
winDebug ("winMWExtWMDestroyFrame (%08x) %08x\n",
377
(int) pRLWinPriv, (int) pRLWinPriv->hWnd);
380
WindowPtr pWin2 = NULL;
381
win32RootlessWindowPtr pRLWinPriv2 = NULL;
383
/* Check if the Windows window property for our X window pointer is valid */
384
if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
386
pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
388
winDebug ("winMWExtWMDestroyFrame2 (%08x) %08x\n",
389
pRLWinPriv2, pRLWinPriv2->hWnd);
390
if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
392
winDebug ("Error param missmatch\n");
393
*(int*)0 = 1;//raise exseption
399
/* Store the info we need to destroy after this window is gone */
400
hInstance = (HINSTANCE) GetClassLong (pRLWinPriv->hWnd, GCL_HMODULE);
401
hiconClass = (HICON) GetClassLong (pRLWinPriv->hWnd, GCL_HICON);
402
hiconSmClass = (HICON) GetClassLong (pRLWinPriv->hWnd, GCL_HICONSM);
403
iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
405
pRLWinPriv->fClose = TRUE;
406
pRLWinPriv->fDestroyed = TRUE;
408
/* Destroy the Windows window */
409
DestroyWindow (pRLWinPriv->hWnd);
411
/* Only if we were able to get the name */
414
#if CYGMULTIWINDOW_DEBUG
415
winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
417
iReturn = UnregisterClass (pszClass, hInstance);
419
#if CYGMULTIWINDOW_DEBUG
420
winDebug ("winMWExtWMDestroyFramew - %d Deleting Icon: ", iReturn);
423
winDestroyIcon(hiconClass);
424
winDestroyIcon(hiconSmClass);
427
#if CYGMULTIWINDOW_DEBUG
428
winDebug ("winMWExtWMDestroyFrame - done\n");
433
winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int iNewX, int iNewY)
435
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
439
int iX, iY, iWidth, iHeight;
441
#if CYGMULTIWINDOW_DEBUG
442
winDebug ("winMWExtWMMoveFrame (%08x) (%d %d)\n", (int) pRLWinPriv, iNewX, iNewY);
445
/* Get the Windows window style and extended style */
446
dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
447
dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
449
/* Get the X and Y location of the X window */
450
iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
451
iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
453
/* Get the height and width of the X window */
454
iWidth = pRLWinPriv->pFrame->width;
455
iHeight = pRLWinPriv->pFrame->height;
457
/* Store the origin, height, and width in a rectangle structure */
458
SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
460
#ifdef CYGMULTIWINDOW_DEBUG
461
winDebug("\tWindow {%d, %d, %d, %d}, {%d, %d}\n",
462
rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
463
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
466
* Calculate the required size of the Windows window rectangle,
467
* given the size of the Windows window client area.
469
AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
471
#ifdef CYGMULTIWINDOW_DEBUG
472
winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
473
rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
474
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
476
g_fNoConfigureWindow = TRUE;
477
SetWindowPos (pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, 0, 0,
478
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
479
g_fNoConfigureWindow = FALSE;
480
#if CYGMULTIWINDOW_DEBUG
481
winDebug ("winMWExtWMMoveFrame (%08x) done\n", (int) pRLWinPriv);
486
winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
487
int iNewX, int iNewY,
488
unsigned int uiNewWidth, unsigned int uiNewHeight,
489
unsigned int uiGravity)
491
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
498
#if CYGMULTIWINDOW_DEBUG
499
winDebug ("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n",
500
(int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight);
503
pRLWinPriv->fResized = TRUE;
505
/* Get the Windows window style and extended style */
506
dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
507
dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
509
/* Get the X and Y location of the X window */
510
iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
511
iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
513
/* Store the origin, height, and width in a rectangle structure */
514
SetRect (&rcNew, iX, iY, iX + uiNewWidth, iY + uiNewHeight);
517
* Calculate the required size of the Windows window rectangle,
518
* given the size of the Windows window client area.
520
AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
522
/* Get a rectangle describing the old Windows window */
523
GetWindowRect (pRLWinPriv->hWnd, &rcOld);
525
/* Check if the old rectangle and new rectangle are the same */
526
if (!EqualRect (&rcNew, &rcOld))
529
g_fNoConfigureWindow = TRUE;
530
MoveWindow (pRLWinPriv->hWnd,
531
rcNew.left, rcNew.top,
532
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
534
g_fNoConfigureWindow = FALSE;
539
winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
541
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
542
win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid;
543
winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen);
544
winScreenInfo *pScreenInfo = NULL;
545
DWORD dwCurrentProcessID = GetCurrentProcessId ();
546
DWORD dwWindowProcessID = 0;
549
Bool fNeedRestack = TRUE;
550
#if CYGMULTIWINDOW_DEBUG
551
winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv);
554
if (pScreenPriv->fRestacking) return;
556
if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
558
pRLWinPriv->fRestackingNow = TRUE;
561
if(!IsWindowVisible (pRLWinPriv->hWnd))
562
ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
564
if (pRLNextWinPriv == NULL)
566
#if CYGMULTIWINDOW_DEBUG
567
winDebug ("Win %08x is top\n", pRLWinPriv);
569
pScreenPriv->widTop = wid;
570
SetWindowPos (pRLWinPriv->hWnd, HWND_TOP,
571
0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
573
else if (winIsInternalWMRunning(pScreenInfo))
575
/* using mulwinidow wm */
576
#if CYGMULTIWINDOW_DEBUG
577
winDebug ("Win %08x is not top\n", pRLWinPriv);
579
for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDPREV);
580
fNeedRestack && hWnd != NULL;
581
hWnd = GetNextWindow (hWnd, GW_HWNDPREV))
583
GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
585
if ((dwWindowProcessID == dwCurrentProcessID)
586
&& GetProp (hWnd, WIN_WINDOW_PROP))
588
if (hWnd == pRLNextWinPriv->hWnd)
590
/* Enable interleave X window and Windows window */
593
#if CYGMULTIWINDOW_DEBUG
594
winDebug ("raise: Insert after Win %08x\n", pRLNextWinPriv);
596
SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
598
SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
602
#if CYGMULTIWINDOW_DEBUG
603
winDebug ("No change\n");
606
fNeedRestack = FALSE;
609
if (fFirst) fFirst = FALSE;
613
for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDNEXT);
614
fNeedRestack && hWnd != NULL;
615
hWnd = GetNextWindow (hWnd, GW_HWNDNEXT))
617
GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
619
if ((dwWindowProcessID == dwCurrentProcessID)
620
&& GetProp (hWnd, WIN_WINDOW_PROP))
622
if (hWnd == pRLNextWinPriv->hWnd)
624
#if CYGMULTIWINDOW_DEBUG
625
winDebug ("lower: Insert after Win %08x\n", pRLNextWinPriv);
627
SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
629
SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
630
fNeedRestack = FALSE;
638
/* using general wm like twm, wmaker etc.
639
Interleave X window and Windows window will cause problem. */
640
SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
642
SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
646
#if CYGMULTIWINDOW_DEBUG
647
winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
650
pRLWinPriv->fRestackingNow = FALSE;
654
winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape)
656
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
657
HRGN hRgn, hRgnWindow, hRgnClient;
658
RECT rcWindow, rcClient;
659
#if CYGMULTIWINDOW_DEBUG
660
winDebug ("winMWExtWMReshapeFrame (%08x)\n", (int) pRLWinPriv);
663
hRgn = winMWExtWMCreateRgnFromRegion (pShape);
665
/* Create region for non-client area */
666
GetWindowRect (pRLWinPriv->hWnd, &rcWindow);
667
GetClientRect (pRLWinPriv->hWnd, &rcClient);
668
MapWindowPoints (pRLWinPriv->hWnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
669
OffsetRgn (hRgn, rcClient.left - rcWindow.left, rcClient.top - rcWindow.top);
670
OffsetRect (&rcClient, -rcWindow.left, -rcWindow.top);
671
OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
672
hRgnWindow = CreateRectRgnIndirect (&rcWindow);
673
hRgnClient = CreateRectRgnIndirect (&rcClient);
674
CombineRgn (hRgnWindow, hRgnWindow, hRgnClient, RGN_DIFF);
675
CombineRgn (hRgn, hRgnWindow, hRgn, RGN_OR);
678
SetWindowRgn (pRLWinPriv->hWnd, hRgn, TRUE);
680
DeleteObject (hRgnWindow);
681
DeleteObject (hRgnClient);
685
winMWExtWMUnmapFrame (RootlessFrameID wid)
687
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
688
#if CYGMULTIWINDOW_DEBUG
689
winDebug ("winMWExtWMUnmapFrame (%08x)\n", (int) pRLWinPriv);
692
g_fNoConfigureWindow = TRUE;
693
//ShowWindow (pRLWinPriv->hWnd, SW_MINIMIZE);
694
ShowWindow (pRLWinPriv->hWnd, SW_HIDE);
695
g_fNoConfigureWindow = FALSE;
699
* Fixme: Code sharing with winshadgdi.c and other engine support
702
winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
704
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
705
winPrivScreenPtr pScreenPriv = NULL;
706
winScreenInfo *pScreenInfo = NULL;
707
ScreenPtr pScreen = NULL;
708
DIBSECTION dibsection;
712
#if CYGMULTIWINDOW_DEBUG
713
winDebug ("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv, pRLWinPriv->fDestroyed);
716
if (!pRLWinPriv->fDestroyed)
718
pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
719
if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
720
if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
722
#if CYGMULTIWINDOW_DEBUG
723
winDebug ("\tpScreenPriv %08X\n", (int) pScreenPriv);
724
winDebug ("\tpScreenInfo %08X\n", (int) pScreenInfo);
725
winDebug ("\t(%d, %d)\n", (int)pRLWinPriv->pFrame->width,
726
(int) pRLWinPriv->pFrame->height);
728
if (pRLWinPriv->hdcScreen == NULL)
730
InitWin32RootlessEngine (pRLWinPriv);
733
if (pRLWinPriv->fResized)
735
/* width * bpp must be multiple of 4 to match 32bit alignment */
739
pRLWinPriv->pbmihShadow->biWidth = pRLWinPriv->pFrame->width;
740
pRLWinPriv->pbmihShadow->biHeight = -pRLWinPriv->pFrame->height;
742
stridesize = pRLWinPriv->pFrame->width * (pScreenInfo->dwBPP >> 3);
743
misalignment = stridesize & 3;
744
if (misalignment != 0)
746
stridesize += 4 - misalignment;
747
pRLWinPriv->pbmihShadow->biWidth = stridesize / (pScreenInfo->dwBPP >> 3);
748
winDebug("\tresizing to %d (was %d)\n",
749
pRLWinPriv->pbmihShadow->biWidth, pRLWinPriv->pFrame->width);
752
hdcNew = CreateCompatibleDC (pRLWinPriv->hdcScreen);
753
/* Create a DI shadow bitmap with a bit pointer */
754
hbmpNew = CreateDIBSection (pRLWinPriv->hdcScreen,
755
(BITMAPINFO *) pRLWinPriv->pbmihShadow,
757
(VOID**) &pRLWinPriv->pfb,
760
if (hbmpNew == NULL || pRLWinPriv->pfb == NULL)
762
ErrorF ("winMWExtWMStartDrawing - CreateDIBSection failed\n");
767
#if CYGMULTIWINDOW_DEBUG
768
winDebug ("winMWExtWMStartDrawing - Shadow buffer allocated\n");
772
/* Get information about the bitmap that was allocated */
773
GetObject (hbmpNew, sizeof (dibsection), &dibsection);
775
#if CYGMULTIWINDOW_DEBUG
776
/* Print information about bitmap allocated */
777
winDebug ("winMWExtWMStartDrawing - Dibsection width: %d height: %d "
778
"depth: %d size image: %d\n",
779
(unsigned int)dibsection.dsBmih.biWidth,
780
(unsigned int)dibsection.dsBmih.biHeight,
781
(unsigned int)dibsection.dsBmih.biBitCount,
782
(unsigned int)dibsection.dsBmih.biSizeImage);
785
/* Select the shadow bitmap into the shadow DC */
786
SelectObject (hdcNew, hbmpNew);
788
#if CYGMULTIWINDOW_DEBUG
789
winDebug ("winMWExtWMStartDrawing - Attempting a shadow blit\n");
792
/* Blit from the old shadow to the new shadow */
793
fReturn = BitBlt (hdcNew,
795
pRLWinPriv->pFrame->width, pRLWinPriv->pFrame->height,
796
pRLWinPriv->hdcShadow,
801
#if CYGMULTIWINDOW_DEBUG
802
winDebug ("winMWExtWMStartDrawing - Shadow blit success\n");
807
ErrorF ("winMWExtWMStartDrawing - Shadow blit failure\n");
810
/* Look for height weirdness */
811
if (dibsection.dsBmih.biHeight < 0)
813
/* FIXME: Figure out why biHeight is sometimes negative */
814
ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
815
"biHeight still negative: %d\n",
816
(int) dibsection.dsBmih.biHeight);
817
ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
818
"Flipping biHeight sign\n");
819
dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
822
pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes;
824
#if CYGMULTIWINDOW_DEBUG
825
winDebug ("winMWExtWMStartDrawing - bytesPerRow: %d\n",
826
(unsigned int)dibsection.dsBm.bmWidthBytes);
829
/* Free the old shadow bitmap */
830
DeleteObject (pRLWinPriv->hdcShadow);
831
DeleteObject (pRLWinPriv->hbmpShadow);
833
pRLWinPriv->hdcShadow = hdcNew;
834
pRLWinPriv->hbmpShadow = hbmpNew;
836
pRLWinPriv->fResized = FALSE;
837
#if CYGMULTIWINDOW_DEBUG && FALSE
838
winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n",
839
(unsigned int)pRLWinPriv->pfb,
840
(unsigned int)dibsection.dsBm.bmWidthBytes);
846
ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
848
#if CYGMULTIWINDOW_DEBUG
849
winDebug ("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n",
851
(unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes);
853
*pixelData = pRLWinPriv->pfb;
854
*bytesPerRow = pRLWinPriv->dwWidthBytes;
858
winMWExtWMStopDrawing (RootlessFrameID wid, Bool fFlush)
861
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
862
BLENDFUNCTION bfBlend;
865
#if CYGMULTIWINDOW_DEBUG || TRUE
866
winDebug ("winMWExtWMStopDrawing (%08x)\n", pRLWinPriv);
868
szWin.cx = pRLWinPriv->dwWidth;
869
szWin.cy = pRLWinPriv->dwHeight;
872
bfBlend.BlendOp = AC_SRC_OVER;
873
bfBlend.BlendFlags = 0;
874
bfBlend.SourceConstantAlpha = 255;
875
bfBlend.AlphaFormat = AC_SRC_ALPHA;
877
if (!UpdateLayeredWindow (pRLWinPriv->hWnd,
879
pRLWinPriv->hdcShadow, &ptSrc,
880
0, &bfBlend, ULW_ALPHA))
882
ErrorF ("winMWExtWMStopDrawing - UpdateLayeredWindow failed\n");
888
winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
890
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
892
BLENDFUNCTION bfBlend;
896
#if CYGMULTIWINDOW_DEBUG && 0
897
winDebug ("winMWExtWMUpdateRegion (%08x)\n", pRLWinPriv);
900
szWin.cx = pRLWinPriv->dwWidth;
901
szWin.cy = pRLWinPriv->dwHeight;
904
bfBlend.BlendOp = AC_SRC_OVER;
905
bfBlend.BlendFlags = 0;
906
bfBlend.SourceConstantAlpha = 255;
907
bfBlend.AlphaFormat = AC_SRC_ALPHA;
909
if (!UpdateLayeredWindow (pRLWinPriv->hWnd,
911
pRLWinPriv->hdcShadow, &ptSrc,
912
0, &bfBlend, ULW_ALPHA))
916
/* Display a fancy error message */
917
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
918
FORMAT_MESSAGE_FROM_SYSTEM |
919
FORMAT_MESSAGE_IGNORE_INSERTS,
922
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
926
ErrorF ("winMWExtWMUpdateRegion - UpdateLayeredWindow failed: %s\n",
928
LocalFree (lpMsgBuf);
931
if (!g_fNoConfigureWindow) UpdateWindow (pRLWinPriv->hWnd);
935
winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
936
int shift_x, int shift_y)
938
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
940
#if CYGMULTIWINDOW_DEBUG && 0
941
winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
942
pRLWinPriv, nCount, pRects, shift_x, shift_y);
945
for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
947
rcDmg.left = pRects->x1 + shift_x;
948
rcDmg.top = pRects->y1 + shift_y;
949
rcDmg.right = pRects->x2 + shift_x;
950
rcDmg.bottom = pRects->y2 + shift_y;
952
InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
957
winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
959
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
960
#if CYGMULTIWINDOW_DEBUG
961
winDebug ("winMWExtWMRootlessSwitchWindow (%08x) %08x\n",
962
(int) pRLWinPriv, (int) pRLWinPriv->hWnd);
964
pRLWinPriv->pFrame = pFrame;
965
pRLWinPriv->fResized = TRUE;
967
/* Set the window extended style flags */
968
SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
970
/* Set the window standard style flags */
971
SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
972
WS_POPUP | WS_CLIPCHILDREN);
974
DeleteProperty (oldWin, AtmWindowsWmNativeHwnd ());
975
winMWExtWMSetNativeProperty (pFrame);
976
#if CYGMULTIWINDOW_DEBUG
979
WindowPtr pWin2 = NULL;
980
win32RootlessWindowPtr pRLWinPriv2 = NULL;
982
/* Check if the Windows window property for our X window pointer is valid */
983
if ((pWin2 = (WindowPtr)GetProp (pRLWinPriv->hWnd, WIN_WINDOW_PROP)) != NULL)
985
pRLWinPriv2 = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin2, FALSE);
987
winDebug ("winMWExtWMSwitchFrame2 (%08x) %08x\n",
988
pRLWinPriv2, pRLWinPriv2->hWnd);
989
if (pRLWinPriv != pRLWinPriv2 || pRLWinPriv->hWnd != pRLWinPriv2->hWnd)
991
winDebug ("Error param missmatch\n");
999
winMWExtWMCopyBytes (unsigned int width, unsigned int height,
1000
const void *src, unsigned int srcRowBytes,
1001
void *dst, unsigned int dstRowBytes)
1003
#if CYGMULTIWINDOW_DEBUG
1004
winDebug ("winMWExtWMCopyBytes - Not implemented\n");
1009
winMWExtWMFillBytes (unsigned int width, unsigned int height, unsigned int value,
1010
void *dst, unsigned int dstRowBytes)
1012
#if CYGMULTIWINDOW_DEBUG
1013
winDebug ("winMWExtWMFillBytes - Not implemented\n");
1018
winMWExtWMCompositePixels (unsigned int width, unsigned int height, unsigned int function,
1019
void *src[2], unsigned int srcRowBytes[2],
1020
void *mask, unsigned int maskRowBytes,
1021
void *dst[2], unsigned int dstRowBytes[2])
1023
#if CYGMULTIWINDOW_DEBUG
1024
winDebug ("winMWExtWMCompositePixels - Not implemented\n");
1031
winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRects,
1034
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
1037
#if CYGMULTIWINDOW_DEBUG
1038
winDebug ("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n",
1039
(int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy);
1042
for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++)
1044
#if CYGMULTIWINDOW_DEBUG
1045
winDebug ("BitBlt (%d, %d, %d, %d) (%d, %d)\n",
1046
pDstRects->x1, pDstRects->y1,
1047
pDstRects->x2 - pDstRects->x1,
1048
pDstRects->y2 - pDstRects->y1,
1049
pDstRects->x1 + nDx,
1050
pDstRects->y1 + nDy);
1053
if (!BitBlt (pRLWinPriv->hdcShadow,
1054
pDstRects->x1, pDstRects->y1,
1055
pDstRects->x2 - pDstRects->x1,
1056
pDstRects->y2 - pDstRects->y1,
1057
pRLWinPriv->hdcShadow,
1058
pDstRects->x1 + nDx, pDstRects->y1 + nDy,
1061
ErrorF ("winMWExtWMCopyWindow - BitBlt failed.\n");
1064
rcDmg.left = pDstRects->x1;
1065
rcDmg.top = pDstRects->y1;
1066
rcDmg.right = pDstRects->x2;
1067
rcDmg.bottom = pDstRects->y2;
1069
InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
1071
#if CYGMULTIWINDOW_DEBUG
1072
winDebug ("winMWExtWMCopyWindow - done\n");
1078
* winMWExtWMSetNativeProperty
1082
winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
1084
win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
1087
/* FIXME: move this to WindowsWM extension */
1089
lData = (long) pRLWinPriv->hWnd;
1090
ChangeWindowProperty (pFrame->win, AtmWindowsWmNativeHwnd (),
1091
XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);