Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / xwin / winwin32rootlesswndproc.c
CommitLineData
a09e091a
JB
1/*
2 *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
3 *
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:
11 *
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
14 *
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.
22 *
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.
27 *
28 * Authors: Kensuke Matsuzaki
29 * Earle F. Philhower, III
30 * Harold L Hunt II
31 */
32#ifdef HAVE_XWIN_CONFIG_H
33#include <xwin-config.h>
34#endif
35#include "win.h"
36#include <winuser.h>
37#define _WINDOWSWM_SERVER_
38#include <X11/extensions/windowswmstr.h>
39#include "dixevents.h"
40#include "propertyst.h"
41#include <X11/Xatom.h>
42#include "winmultiwindowclass.h"
43#include "winmsg.h"
44#include "inputstr.h"
45
46/*
47 * Constant defines
48 */
49
50#define MOUSE_ACTIVATE_DEFAULT TRUE
51#define RAISE_ON_CLICK_DEFAULT FALSE
52
53/*
54 * Local globals
55 */
56
57static UINT_PTR g_uipMousePollingTimerID = 0;
58
59/*
60 * Local function
61 */
62
63DEFINE_ATOM_HELPER(AtmWindowsWmRaiseOnClick, WINDOWSWM_RAISE_ON_CLICK)
64 DEFINE_ATOM_HELPER(AtmWindowsWMMouseActivate, WINDOWSWM_MOUSE_ACTIVATE)
65/* DEFINE_ATOM_HELPER(AtmWindowsWMClientWindow, WINDOWSWM_CLIENT_WINDOW) */
66/*
67 * ConstrainSize - Taken from TWM sources - Respects hints for sizing
68 */
69#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
70static void
71ConstrainSize(WinXSizeHints hints, int *widthp, int *heightp)
72{
73 int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
74 int baseWidth, baseHeight;
75 int dwidth = *widthp, dheight = *heightp;
76
77 if (hints.flags & PMinSize) {
78 minWidth = hints.min_width;
79 minHeight = hints.min_height;
80 }
81 else if (hints.flags & PBaseSize) {
82 minWidth = hints.base_width;
83 minHeight = hints.base_height;
84 }
85 else
86 minWidth = minHeight = 1;
87
88 if (hints.flags & PBaseSize) {
89 baseWidth = hints.base_width;
90 baseHeight = hints.base_height;
91 }
92 else if (hints.flags & PMinSize) {
93 baseWidth = hints.min_width;
94 baseHeight = hints.min_height;
95 }
96 else
97 baseWidth = baseHeight = 0;
98
99 if (hints.flags & PMaxSize) {
100 maxWidth = hints.max_width;
101 maxHeight = hints.max_height;
102 }
103 else {
104 maxWidth = MAXINT;
105 maxHeight = MAXINT;
106 }
107
108 if (hints.flags & PResizeInc) {
109 xinc = hints.width_inc;
110 yinc = hints.height_inc;
111 }
112 else
113 xinc = yinc = 1;
114
115 /*
116 * First, clamp to min and max values
117 */
118 if (dwidth < minWidth)
119 dwidth = minWidth;
120 if (dheight < minHeight)
121 dheight = minHeight;
122
123 if (dwidth > maxWidth)
124 dwidth = maxWidth;
125 if (dheight > maxHeight)
126 dheight = maxHeight;
127
128 /*
129 * Second, fit to base + N * inc
130 */
131 dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
132 dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
133
134 /*
135 * Third, adjust for aspect ratio
136 */
137
138 /*
139 * The math looks like this:
140 *
141 * minAspectX dwidth maxAspectX
142 * ---------- <= ------- <= ----------
143 * minAspectY dheight maxAspectY
144 *
145 * If that is multiplied out, then the width and height are
146 * invalid in the following situations:
147 *
148 * minAspectX * dheight > minAspectY * dwidth
149 * maxAspectX * dheight < maxAspectY * dwidth
150 *
151 */
152
153 if (hints.flags & PAspect) {
154 if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth) {
155 delta =
156 makemult(hints.min_aspect.x * dheight / hints.min_aspect.y -
157 dwidth, xinc);
158 if (dwidth + delta <= maxWidth)
159 dwidth += delta;
160 else {
161 delta =
162 makemult(dheight -
163 dwidth * hints.min_aspect.y / hints.min_aspect.x,
164 yinc);
165 if (dheight - delta >= minHeight)
166 dheight -= delta;
167 }
168 }
169
170 if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth) {
171 delta =
172 makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x -
173 dheight, yinc);
174 if (dheight + delta <= maxHeight)
175 dheight += delta;
176 else {
177 delta =
178 makemult(dwidth -
179 hints.max_aspect.x * dheight / hints.max_aspect.y,
180 xinc);
181 if (dwidth - delta >= minWidth)
182 dwidth -= delta;
183 }
184 }
185 }
186
187 /* Return computed values */
188 *widthp = dwidth;
189 *heightp = dheight;
190}
191
192#undef makemult
193
194/*
195 * ValidateSizing - Ensures size request respects hints
196 */
197static int
198ValidateSizing(HWND hwnd, WindowPtr pWin, WPARAM wParam, LPARAM lParam)
199{
200 WinXSizeHints sizeHints;
201 RECT *rect;
202 int iWidth, iHeight, iTopBorder;
203 POINT pt;
204
205 /* Invalid input checking */
206 if (pWin == NULL || lParam == 0) {
207 ErrorF("Invalid input checking\n");
208 return FALSE;
209 }
210
211 /* No size hints, no checking */
212 if (!winMultiWindowGetWMNormalHints(pWin, &sizeHints)) {
213 ErrorF("No size hints, no checking\n");
214 return FALSE;
215 }
216
217 /* Avoid divide-by-zero */
218 if (sizeHints.flags & PResizeInc) {
219 if (sizeHints.width_inc == 0)
220 sizeHints.width_inc = 1;
221 if (sizeHints.height_inc == 0)
222 sizeHints.height_inc = 1;
223 }
224
225 rect = (RECT *) lParam;
226
227 iWidth = rect->right - rect->left;
228 iHeight = rect->bottom - rect->top;
229
230 /* Get title bar height, there must be an easier way?! */
231 pt.x = pt.y = 0;
232 ClientToScreen(hwnd, &pt);
233 iTopBorder = pt.y - rect->top;
234
235 /* Now remove size of any borders */
236 iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
237 iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
238
239 /* Constrain the size to legal values */
240 ConstrainSize(sizeHints, &iWidth, &iHeight);
241
242 /* Add back the borders */
243 iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
244 iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
245
246 /* Adjust size according to where we're dragging from */
247 switch (wParam) {
248 case WMSZ_TOP:
249 case WMSZ_TOPRIGHT:
250 case WMSZ_BOTTOM:
251 case WMSZ_BOTTOMRIGHT:
252 case WMSZ_RIGHT:
253 rect->right = rect->left + iWidth;
254 break;
255 default:
256 rect->left = rect->right - iWidth;
257 break;
258 }
259 switch (wParam) {
260 case WMSZ_BOTTOM:
261 case WMSZ_BOTTOMRIGHT:
262 case WMSZ_BOTTOMLEFT:
263 case WMSZ_RIGHT:
264 case WMSZ_LEFT:
265 rect->bottom = rect->top + iHeight;
266 break;
267 default:
268 rect->top = rect->bottom - iHeight;
269 break;
270 }
271 return TRUE;
272}
273
274/*
275 * IsRaiseOnClick
276 */
277
278static Bool
279IsRaiseOnClick(WindowPtr pWin)
280{
281
282 struct _Window *pwin;
283 struct _Property *prop;
284
285 /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
286 * Which pointer's current window do we want? */
287 WindowPtr pRoot = GetCurrentRootWindow(inputInfo.pointer);
288
289 if (!pWin) {
290 ErrorF("IsRaiseOnClick - no prop use default value:%d\n",
291 RAISE_ON_CLICK_DEFAULT);
292 return RAISE_ON_CLICK_DEFAULT;
293 }
294
295 pwin = (struct _Window *) pWin;
296
297 if (pwin->optional)
298 prop = (struct _Property *) pwin->optional->userProps;
299 else
300 prop = NULL;
301
302 while (prop) {
303 if (prop->propertyName == AtmWindowsWmRaiseOnClick()
304 && prop->type == XA_INTEGER && prop->format == 32) {
305 return *(int *) prop->data;
306 }
307 else
308 prop = prop->next;
309 }
310
311 if (pWin != pRoot) {
312 return IsRaiseOnClick(pRoot);
313 }
314 else {
315#if CYGMULTIWINDOW_DEBUG
316 winDebug("IsRaiseOnClick - no prop use default value:%d\n",
317 RAISE_ON_CLICK_DEFAULT);
318#endif
319 return RAISE_ON_CLICK_DEFAULT;
320 }
321}
322
323/*
324 * IsMouseActive
325 */
326
327static Bool
328IsMouseActive(WindowPtr pWin)
329{
330
331 struct _Window *pwin;
332 struct _Property *prop;
333
334 /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
335 * Which pointer's current window do we want? */
336 WindowPtr pRoot = GetCurrentRootWindow(inputInfo.pointer);
337
338 if (!pWin) {
339 ErrorF("IsMouseActive - pWin was NULL use default value:%d\n",
340 MOUSE_ACTIVATE_DEFAULT);
341 return MOUSE_ACTIVATE_DEFAULT;
342 }
343
344 pwin = (struct _Window *) pWin;
345
346 if (pwin->optional)
347 prop = (struct _Property *) pwin->optional->userProps;
348 else
349 prop = NULL;
350
351 while (prop) {
352 if (prop->propertyName == AtmWindowsWMMouseActivate()
353 && prop->type == XA_INTEGER && prop->format == 32) {
354 return *(int *) prop->data;
355 }
356 else
357 prop = prop->next;
358 }
359
360 if (pWin != pRoot) {
361 return IsMouseActive(pRoot);
362 }
363 else {
364#if CYGMULTIWINDOW_DEBUG
365 winDebug("IsMouseActive - no prop use default value:%d\n",
366 MOUSE_ACTIVATE_DEFAULT);
367#endif
368 return MOUSE_ACTIVATE_DEFAULT;
369 }
370}
371
372/*
373 * winMWExtWMWindowProc - Window procedure
374 */
375
376LRESULT CALLBACK
377winMWExtWMWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
378{
379 WindowPtr pWin = NULL;
380 win32RootlessWindowPtr pRLWinPriv = NULL;
381 ScreenPtr pScreen = NULL;
382 winPrivScreenPtr pScreenPriv = NULL;
383 winScreenInfo *pScreenInfo = NULL;
384 HWND hwndScreen = NULL;
385 POINT ptMouse;
386 static Bool s_fTracking = FALSE;
387 HDC hdcUpdate;
388 PAINTSTRUCT ps;
389 LPWINDOWPOS pWinPos = NULL;
390 RECT rcClient;
391 winWMMessageRec wmMsg;
392 Bool fWMMsgInitialized = FALSE;
393
394 /* Check if the Windows window property for our X window pointer is valid */
395 if ((pRLWinPriv =
396 (win32RootlessWindowPtr) GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) {
397 pWin = pRLWinPriv->pFrame->win;
398 pScreen = pWin->drawable.pScreen;
399 if (pScreen)
400 pScreenPriv = winGetScreenPriv(pScreen);
401 if (pScreenPriv)
402 pScreenInfo = pScreenPriv->pScreenInfo;
403 if (pScreenPriv)
404 hwndScreen = pScreenPriv->hwndScreen;
405
406 wmMsg.msg = 0;
407 wmMsg.hwndWindow = hwnd;
408 wmMsg.iWindow = (Window) pWin->drawable.id;
409
410 wmMsg.iX = pRLWinPriv->pFrame->x;
411 wmMsg.iY = pRLWinPriv->pFrame->y;
412 wmMsg.iWidth = pRLWinPriv->pFrame->width;
413 wmMsg.iHeight = pRLWinPriv->pFrame->height;
414
415 fWMMsgInitialized = TRUE;
416#if CYGDEBUG
417 winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam,
418 lParam);
419
420 winDebug("\thWnd %08X\n", hwnd);
421 winDebug("\tpScreenPriv %08X\n", pScreenPriv);
422 winDebug("\tpScreenInfo %08X\n", pScreenInfo);
423 winDebug("\thwndScreen %08X\n", hwndScreen);
424 winDebug("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
425 pRLWinPriv, message, wParam, lParam);
426#endif
427 }
428 /* Branch on message type */
429 switch (message) {
430 case WM_CREATE:
431#if CYGMULTIWINDOW_DEBUG
432 winDebug("winMWExtWMWindowProc - WM_CREATE\n");
433#endif
434 /* */
435 SetProp(hwnd,
436 WIN_WINDOW_PROP,
437 (HANDLE) ((LPCREATESTRUCT) lParam)->lpCreateParams);
438 return 0;
439
440 case WM_CLOSE:
441#if CYGMULTIWINDOW_DEBUG
442 winDebug("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
443#endif
444 /* Tell window-manager to close window */
445 if (pRLWinPriv->fClose) {
446 DestroyWindow(hwnd);
447 }
448 else {
449 if (winIsInternalWMRunning(pScreenInfo)) {
450 /* Tell our Window Manager thread to kill the window */
451 wmMsg.msg = WM_WM_KILL;
452 if (fWMMsgInitialized)
453 winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
454 }
455 winWindowsWMSendEvent(WindowsWMControllerNotify,
456 WindowsWMControllerNotifyMask,
457 1,
458 WindowsWMCloseWindow,
459 pWin->drawable.id, 0, 0, 0, 0);
460 }
461 return 0;
462
463 case WM_DESTROY:
464#if CYGMULTIWINDOW_DEBUG
465 winDebug("winMWExtWMWindowProc - WM_DESTROY\n");
466#endif
467 /* Free the shaodw DC; which allows the bitmap to be freed */
468 DeleteDC(pRLWinPriv->hdcShadow);
469 pRLWinPriv->hdcShadow = NULL;
470
471 /* Free the shadow bitmap */
472 DeleteObject(pRLWinPriv->hbmpShadow);
473 pRLWinPriv->hbmpShadow = NULL;
474
475 /* Free the screen DC */
476 ReleaseDC(pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
477 pRLWinPriv->hdcScreen = NULL;
478
479 /* Free shadow buffer info header */
480 free(pRLWinPriv->pbmihShadow);
481 pRLWinPriv->pbmihShadow = NULL;
482
483 pRLWinPriv->fResized = FALSE;
484 pRLWinPriv->pfb = NULL;
485 free(pRLWinPriv);
486 RemoveProp(hwnd, WIN_WINDOW_PROP);
487 break;
488
489 case WM_MOUSEMOVE:
490#if CYGMULTIWINDOW_DEBUG && 0
491 winDebug("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
492#endif
493 /* Unpack the client area mouse coordinates */
494 ptMouse.x = GET_X_LPARAM(lParam);
495 ptMouse.y = GET_Y_LPARAM(lParam);
496
497 /* Translate the client area mouse coordinates to screen coordinates */
498 ClientToScreen(hwnd, &ptMouse);
499
500 /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
501 ptMouse.x -= GetSystemMetrics(SM_XVIRTUALSCREEN);
502 ptMouse.y -= GetSystemMetrics(SM_YVIRTUALSCREEN);
503
504 /* We can't do anything without privates */
505 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
506 break;
507
508 /* Has the mouse pointer crossed screens? */
509 if (pScreen != miPointerGetScreen(inputInfo.pointer))
510 miPointerSetScreen(inputInfo.pointer, pScreenInfo->dwScreen,
511 ptMouse.x - pScreenInfo->dwXOffset,
512 ptMouse.y - pScreenInfo->dwYOffset);
513
514 /* Are we tracking yet? */
515 if (!s_fTracking) {
516 TRACKMOUSEEVENT tme;
517
518 /* Setup data structure */
519 ZeroMemory(&tme, sizeof(tme));
520 tme.cbSize = sizeof(tme);
521 tme.dwFlags = TME_LEAVE;
522 tme.hwndTrack = hwnd;
523
524 /* Call the tracking function */
525 if (!TrackMouseEvent(&tme))
526 ErrorF("winMWExtWMWindowProc - TrackMouseEvent failed\n");
527
528 /* Flag that we are tracking now */
529 s_fTracking = TRUE;
530 }
531
532 /* Kill the timer used to poll mouse events */
533 if (g_uipMousePollingTimerID != 0) {
534 KillTimer(pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
535 g_uipMousePollingTimerID = 0;
536 }
537
538 /* Deliver absolute cursor position to X Server */
539 winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset,
540 ptMouse.y - pScreenInfo->dwYOffset);
541
542 return 0;
543
544 case WM_NCMOUSEMOVE:
545#if CYGMULTIWINDOW_DEBUG && 0
546 winDebug("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
547#endif
548 /*
549 * We break instead of returning 0 since we need to call
550 * DefWindowProc to get the mouse cursor changes
551 * and min/max/close button highlighting in Windows XP.
552 * The Platform SDK says that you should return 0 if you
553 * process this message, but it fails to mention that you
554 * will give up any default functionality if you do return 0.
555 */
556
557 /* We can't do anything without privates */
558 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
559 break;
560
561 /*
562 * Timer to poll mouse events. This is needed to make
563 * programs like xeyes follow the mouse properly.
564 */
565 if (g_uipMousePollingTimerID == 0)
566 g_uipMousePollingTimerID = SetTimer(pScreenPriv->hwndScreen,
567 WIN_POLLING_MOUSE_TIMER_ID,
568 MOUSE_POLLING_INTERVAL, NULL);
569 break;
570
571 case WM_MOUSELEAVE:
572#if CYGMULTIWINDOW_DEBUG
573 winDebug("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
574#endif
575 /* Mouse has left our client area */
576
577 /* Flag that we are no longer tracking */
578 s_fTracking = FALSE;
579
580 /*
581 * Timer to poll mouse events. This is needed to make
582 * programs like xeyes follow the mouse properly.
583 */
584 if (g_uipMousePollingTimerID == 0)
585 g_uipMousePollingTimerID = SetTimer(pScreenPriv->hwndScreen,
586 WIN_POLLING_MOUSE_TIMER_ID,
587 MOUSE_POLLING_INTERVAL, NULL);
588 return 0;
589
590 case WM_LBUTTONDBLCLK:
591 case WM_LBUTTONDOWN:
592#if CYGMULTIWINDOW_DEBUG
593 winDebug("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
594#endif
595 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
596 break;
597 SetCapture(hwnd);
598 return winMouseButtonsHandle(pScreen, ButtonPress, Button1, wParam);
599
600 case WM_LBUTTONUP:
601#if CYGMULTIWINDOW_DEBUG
602 winDebug("winMWExtWMWindowProc - WM_LBUTTONUP\n");
603#endif
604 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
605 break;
606 ReleaseCapture();
607 return winMouseButtonsHandle(pScreen, ButtonRelease, Button1, wParam);
608
609 case WM_MBUTTONDBLCLK:
610 case WM_MBUTTONDOWN:
611#if CYGMULTIWINDOW_DEBUG
612 winDebug("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
613#endif
614 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
615 break;
616 SetCapture(hwnd);
617 return winMouseButtonsHandle(pScreen, ButtonPress, Button2, wParam);
618
619 case WM_MBUTTONUP:
620#if CYGMULTIWINDOW_DEBUG
621 winDebug("winMWExtWMWindowProc - WM_MBUTTONUP\n");
622#endif
623 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
624 break;
625 ReleaseCapture();
626 return winMouseButtonsHandle(pScreen, ButtonRelease, Button2, wParam);
627
628 case WM_RBUTTONDBLCLK:
629 case WM_RBUTTONDOWN:
630#if CYGMULTIWINDOW_DEBUG
631 winDebug("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
632#endif
633 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
634 break;
635 SetCapture(hwnd);
636 return winMouseButtonsHandle(pScreen, ButtonPress, Button3, wParam);
637
638 case WM_RBUTTONUP:
639#if CYGMULTIWINDOW_DEBUG
640 winDebug("winMWExtWMWindowProc - WM_RBUTTONUP\n");
641#endif
642 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
643 break;
644 ReleaseCapture();
645 return winMouseButtonsHandle(pScreen, ButtonRelease, Button3, wParam);
646
647 case WM_XBUTTONDBLCLK:
648 case WM_XBUTTONDOWN:
649 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
650 break;
651 SetCapture(hwnd);
652 return winMouseButtonsHandle(pScreen, ButtonPress, HIWORD(wParam) + 7,
653 wParam);
654 case WM_XBUTTONUP:
655 if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
656 break;
657 ReleaseCapture();
658 return winMouseButtonsHandle(pScreen, ButtonRelease, HIWORD(wParam) + 7,
659 wParam);
660
661 case WM_MOUSEWHEEL:
662#if CYGMULTIWINDOW_DEBUG
663 winDebug("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
664#endif
665
666 /* Pass the message to the root window */
667 SendMessage(hwndScreen, message, wParam, lParam);
668 return 0;
669
670 case WM_MOUSEHWHEEL:
671#if CYGMULTIWINDOW_DEBUG
672 winDebug("winMWExtWMWindowProc - WM_MOUSEHWHEEL\n");
673#endif
674
675 /* Pass the message to the root window */
676 SendMessage(hwndScreen, message, wParam, lParam);
677 return 0;
678
679 case WM_MOUSEACTIVATE:
680#if CYGMULTIWINDOW_DEBUG
681 winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
682#endif
683#if 1
684 /* Check if this window needs to be made active when clicked */
685 if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect) {
686#if CYGMULTIWINDOW_DEBUG
687 winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
688 "MA_NOACTIVATE\n");
689#endif
690
691 /* */
692 return MA_NOACTIVATE;
693 }
694#endif
695 if (!winIsInternalWMRunning(pScreenInfo) && !IsMouseActive(pWin))
696 return MA_NOACTIVATE;
697
698 break;
699
700 case WM_KILLFOCUS:
701 /* Pop any pressed keys since we are losing keyboard focus */
702 winKeybdReleaseKeys();
703 return 0;
704
705 case WM_SYSDEADCHAR:
706 case WM_DEADCHAR:
707 /*
708 * NOTE: We do nothing with WM_*CHAR messages,
709 * nor does the root window, so we can just toss these messages.
710 */
711 return 0;
712
713 case WM_SYSKEYDOWN:
714 case WM_KEYDOWN:
715#if CYGMULTIWINDOW_DEBUG
716 winDebug("winMWExtWMWindowProc - WM_*KEYDOWN\n");
717#endif
718
719 /*
720 * Don't pass Alt-F4 key combo to root window,
721 * let Windows translate to WM_CLOSE and close this top-level window.
722 *
723 * NOTE: We purposely don't check the fUseWinKillKey setting because
724 * it should only apply to the key handling for the root window,
725 * not for top-level window-manager windows.
726 *
727 * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
728 * because that is a key combo that no X app should be expecting to
729 * receive, since it has historically been used to shutdown the X server.
730 * Passing Ctrl-Alt-Backspace to the root window preserves that
731 * behavior, assuming that -unixkill has been passed as a parameter.
732 */
733 if (wParam == VK_F4 && (GetKeyState(VK_MENU) & 0x8000))
734 break;
735
736 /* Pass the message to the root window */
737 SendMessage(hwndScreen, message, wParam, lParam);
738 return 0;
739
740 case WM_SYSKEYUP:
741 case WM_KEYUP:
742
743#if CYGMULTIWINDOW_DEBUG
744 winDebug("winMWExtWMWindowProc - WM_*KEYUP\n");
745#endif
746
747 /* Pass the message to the root window */
748 SendMessage(hwndScreen, message, wParam, lParam);
749 return 0;
750
751 case WM_HOTKEY:
752#if CYGMULTIWINDOW_DEBUG
753 winDebug("winMWExtWMWindowProc - WM_HOTKEY\n");
754#endif
755
756 /* Pass the message to the root window */
757 SendMessage(hwndScreen, message, wParam, lParam);
758 return 0;
759
760 case WM_ERASEBKGND:
761#if CYGDEBUG
762 winDebug("winMWExtWMWindowProc - WM_ERASEBKGND\n");
763#endif
764 /*
765 * Pretend that we did erase the background but we don't care,
766 * since we repaint the entire region anyhow
767 * This avoids some flickering when resizing.
768 */
769 return TRUE;
770
771 case WM_PAINT:
772
773 /* BeginPaint gives us an hdc that clips to the invalidated region */
774 hdcUpdate = BeginPaint(hwnd, &ps);
775
776 /* Try to copy from the shadow buffer */
777 if (!BitBlt(hdcUpdate,
778 ps.rcPaint.left, ps.rcPaint.top,
779 ps.rcPaint.right - ps.rcPaint.left,
780 ps.rcPaint.bottom - ps.rcPaint.top,
781 pRLWinPriv->hdcShadow,
782 ps.rcPaint.left, ps.rcPaint.top, SRCCOPY)) {
783 LPVOID lpMsgBuf;
784
785 /* Display a fancy error message */
786 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
787 FORMAT_MESSAGE_FROM_SYSTEM |
788 FORMAT_MESSAGE_IGNORE_INSERTS,
789 NULL,
790 GetLastError(),
791 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
792 (LPTSTR) &lpMsgBuf, 0, NULL);
793
794 ErrorF("winMWExtWMWindowProc - BitBlt failed: %s\n",
795 (LPSTR) lpMsgBuf);
796 LocalFree(lpMsgBuf);
797 }
798
799 /* EndPaint frees the DC */
800 EndPaint(hwnd, &ps);
801 break;
802
803 case WM_ACTIVATE:
804#if CYGMULTIWINDOW_DEBUG
805 winDebug("winMWExtWMWindowProc - WM_ACTIVATE\n");
806#endif
807 if (LOWORD(wParam) != WA_INACTIVE) {
808 if (winIsInternalWMRunning(pScreenInfo)) {
809#if 0
810 /* Raise the window to the top in Z order */
811 wmMsg.msg = WM_WM_RAISE;
812 if (fWMMsgInitialized)
813 winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
814#endif
815 /* Tell our Window Manager thread to activate the window */
816 wmMsg.msg = WM_WM_ACTIVATE;
817 if (fWMMsgInitialized)
818 if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
819 winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
820 }
821 winWindowsWMSendEvent(WindowsWMControllerNotify,
822 WindowsWMControllerNotifyMask,
823 1,
824 WindowsWMActivateWindow,
825 pWin->drawable.id, 0, 0, 0, 0);
826 }
827 return 0;
828
829#if 1
830 case WM_WINDOWPOSCHANGING:
831 pWinPos = (LPWINDOWPOS) lParam;
832 if (!(pWinPos->flags & SWP_NOZORDER)) {
833 if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking) {
834#if CYGMULTIWINDOW_DEBUG
835 winDebug("Win %p is now restacking.\n",
836 pRLWinPriv);
837#endif
838 break;
839 }
840
841 if (winIsInternalWMRunning(pScreenInfo) || IsRaiseOnClick(pWin)) {
842#if CYGMULTIWINDOW_DEBUG
843 winDebug("Win %p has WINDOWSWM_RAISE_ON_CLICK.\n",
844 pRLWinPriv);
845#endif
846 break;
847 }
848
849#if CYGMULTIWINDOW_DEBUG
850 winDebug("Win %p forbid to change z order (%p).\n",
851 pRLWinPriv,
852 pWinPos->hwndInsertAfter);
853#endif
854 pWinPos->flags |= SWP_NOZORDER;
855 }
856 break;
857#endif
858
859 case WM_MOVE:
860#if CYGMULTIWINDOW_DEBUG
861 winDebug("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
862 (unsigned int) GetTickCount());
863#endif
864 if (g_fNoConfigureWindow)
865 break;
866#if 0
867 /* Bail if Windows window is not actually moving */
868 if (pRLWinPriv->dwX == (short) LOWORD(lParam)
869 && pRLWinPriv->dwY == (short) HIWORD(lParam))
870 break;
871
872 /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
873 {
874 WINDOWPLACEMENT windPlace;
875
876 windPlace.length = sizeof(WINDOWPLACEMENT);
877
878 /* Get current window placement */
879 GetWindowPlacement(hwnd, &windPlace);
880
881 /* Bail if maximizing */
882 if (windPlace.showCmd == SW_MAXIMIZE
883 || windPlace.showCmd == SW_SHOWMAXIMIZED)
884 break;
885 }
886#endif
887
888#if CYGMULTIWINDOW_DEBUG
889 winDebug("\t(%d, %d)\n", (short) LOWORD(lParam),
890 (short) HIWORD(lParam));
891#endif
892 if (!pRLWinPriv->fMovingOrSizing) {
893 if (winIsInternalWMRunning(pScreenInfo))
894 winAdjustXWindow(pWin, hwnd);
895
896 winMWExtWMMoveXWindow(pWin, (LOWORD(lParam) - wBorderWidth(pWin)
897 - GetSystemMetrics(SM_XVIRTUALSCREEN)),
898 (HIWORD(lParam) - wBorderWidth(pWin)
899 - GetSystemMetrics(SM_YVIRTUALSCREEN)));
900 }
901 return 0;
902
903 case WM_SHOWWINDOW:
904#if CYGMULTIWINDOW_DEBUG || TRUE
905 winDebug("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
906 (unsigned int) GetTickCount());
907#endif
908 /* Bail out if the window is being hidden */
909 if (!wParam)
910 return 0;
911
912 if (!pScreenInfo->fInternalWM) //XXXX
913 return 0;
914
915 winMWExtWMUpdateWindowDecoration(pRLWinPriv, pScreenInfo);
916
917 if (winIsInternalWMRunning(pScreenInfo)) {
918#if CYGMULTIWINDOW_DEBUG || TRUE
919 winDebug("\tMapWindow\n");
920#endif
921 /* Tell X to map the window */
922 MapWindow(pWin, wClient(pWin));
923
924 if (!pRLWinPriv->pFrame->win->overrideRedirect)
925 /* Bring the Windows window to the foreground */
926 SetForegroundWindow(hwnd);
927
928 /* Setup the Window Manager message */
929 wmMsg.msg = WM_WM_MAP;
930 wmMsg.iWidth = pRLWinPriv->pFrame->width;
931 wmMsg.iHeight = pRLWinPriv->pFrame->height;
932
933 /* Tell our Window Manager thread to map the window */
934 if (fWMMsgInitialized)
935 winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
936 }
937 break;
938
939 case WM_SIZING:
940 /* Need to legalize the size according to WM_NORMAL_HINTS */
941 /* for applications like xterm */
942 return ValidateSizing(hwnd, pWin, wParam, lParam);
943
944 case WM_WINDOWPOSCHANGED:
945 {
946 pWinPos = (LPWINDOWPOS) lParam;
947#if CYGMULTIWINDOW_DEBUG
948 winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED\n");
949 winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
950 (pWinPos->flags & SWP_DRAWFRAME) ? "SWP_DRAWFRAME " : "",
951 (pWinPos->flags & SWP_FRAMECHANGED) ? "SWP_FRAMECHANGED " : "",
952 (pWinPos->flags & SWP_HIDEWINDOW) ? "SWP_HIDEWINDOW " : "",
953 (pWinPos->flags & SWP_NOACTIVATE) ? "SWP_NOACTIVATE " : "",
954 (pWinPos->flags & SWP_NOCOPYBITS) ? "SWP_NOCOPYBITS " : "",
955 (pWinPos->flags & SWP_NOMOVE) ? "SWP_NOMOVE " : "",
956 (pWinPos->
957 flags & SWP_NOOWNERZORDER) ? "SWP_NOOWNERZORDER " : "",
958 (pWinPos->flags & SWP_NOSIZE) ? "SWP_NOSIZE " : "",
959 (pWinPos->flags & SWP_NOREDRAW) ? "SWP_NOREDRAW " : "",
960 (pWinPos->
961 flags & SWP_NOSENDCHANGING) ? "SWP_NOSENDCHANGING " : "",
962 (pWinPos->flags & SWP_NOZORDER) ? "SWP_NOZORDER " : "",
963 (pWinPos->flags & SWP_SHOWWINDOW) ? "SWP_SHOWWINDOW " : "");
964 winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow ? "Yes" : "No"));
965 winDebug("\textend: (%d, %d, %d, %d)\n",
966 pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);
967
968#endif
969 if (pWinPos->flags & SWP_HIDEWINDOW)
970 break;
971
972 /* Reorder if window z order was changed */
973 if ((pScreenPriv != NULL)
974 && !(pWinPos->flags & SWP_NOZORDER)
975 && !(pWinPos->flags & SWP_SHOWWINDOW)
976 && winIsInternalWMRunning(pScreenInfo)) {
977#if CYGMULTIWINDOW_DEBUG
978 winDebug("\twindow z order was changed\n");
979#endif
980 if (pWinPos->hwndInsertAfter == HWND_TOP
981 || pWinPos->hwndInsertAfter == HWND_TOPMOST
982 || pWinPos->hwndInsertAfter == HWND_NOTOPMOST) {
983#if CYGMULTIWINDOW_DEBUG
984 winDebug("\traise to top\n");
985#endif
986 /* Raise the window to the top in Z order */
987 wmMsg.msg = WM_WM_RAISE;
988 if (fWMMsgInitialized)
989 winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
990 }
991#if 1
992 else if (pWinPos->hwndInsertAfter == HWND_BOTTOM) {
993 }
994 else {
995 /* Check if this window is top of X windows. */
996 HWND hWndAbove = NULL;
997 DWORD dwCurrentProcessID = GetCurrentProcessId();
998 DWORD dwWindowProcessID = 0;
999
1000 for (hWndAbove = pWinPos->hwndInsertAfter;
1001 hWndAbove != NULL;
1002 hWndAbove = GetNextWindow(hWndAbove, GW_HWNDPREV)) {
1003 /* Ignore other XWin process's window */
1004 GetWindowThreadProcessId(hWndAbove, &dwWindowProcessID);
1005
1006 if ((dwWindowProcessID == dwCurrentProcessID)
1007 && GetProp(hWndAbove, WIN_WINDOW_PROP)
1008 && !IsWindowVisible(hWndAbove)
1009 && !IsIconic(hWndAbove)) /* ignore minimized windows */
1010 break;
1011 }
1012 /* If this is top of X windows in Windows stack,
1013 raise it in X stack. */
1014 if (hWndAbove == NULL) {
1015#if CYGMULTIWINDOW_DEBUG
1016 winDebug("\traise to top\n");
1017#endif
1018 /* Raise the window to the top in Z order */
1019 wmMsg.msg = WM_WM_RAISE;
1020 if (fWMMsgInitialized)
1021 winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
1022 }
1023 }
1024#endif
1025 }
1026
1027 if (!(pWinPos->flags & SWP_NOSIZE)) {
1028 if (IsIconic(hwnd)) {
1029#if CYGMULTIWINDOW_DEBUG
1030 winDebug("\tIconic -> MINIMIZED\n");
1031#endif
1032 if (winIsInternalWMRunning(pScreenInfo)) {
1033 /* Raise the window to the top in Z order */
1034 wmMsg.msg = WM_WM_LOWER;
1035 if (fWMMsgInitialized)
1036 winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
1037 }
1038 winWindowsWMSendEvent(WindowsWMControllerNotify,
1039 WindowsWMControllerNotifyMask,
1040 1,
1041 WindowsWMMinimizeWindow,
1042 pWin->drawable.id, 0, 0, 0, 0);
1043 }
1044 else if (IsZoomed(hwnd)) {
1045#if CYGMULTIWINDOW_DEBUG
1046 winDebug("\tZoomed -> MAXIMIZED\n");
1047#endif
1048 winWindowsWMSendEvent(WindowsWMControllerNotify,
1049 WindowsWMControllerNotifyMask,
1050 1,
1051 WindowsWMMaximizeWindow,
1052 pWin->drawable.id, 0, 0, 0, 0);
1053 }
1054 else {
1055#if CYGMULTIWINDOW_DEBUG
1056 winDebug("\tnone -> RESTORED\n");
1057#endif
1058 winWindowsWMSendEvent(WindowsWMControllerNotify,
1059 WindowsWMControllerNotifyMask,
1060 1,
1061 WindowsWMRestoreWindow,
1062 pWin->drawable.id, 0, 0, 0, 0);
1063 }
1064 }
1065 if (!g_fNoConfigureWindow) {
1066
1067 if (!pRLWinPriv->fMovingOrSizing
1068 /*&& (pWinPos->flags & SWP_SHOWWINDOW) */ ) {
1069 GetClientRect(hwnd, &rcClient);
1070 MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT) &rcClient, 2);
1071
1072 if (!(pWinPos->flags & SWP_NOMOVE)
1073 && !(pWinPos->flags & SWP_NOSIZE)) {
1074#if CYGMULTIWINDOW_DEBUG
1075 winDebug("\tmove & resize\n");
1076#endif
1077 if (winIsInternalWMRunning(pScreenInfo))
1078 winAdjustXWindow(pWin, hwnd);
1079
1080 winMWExtWMMoveResizeXWindow(pWin,
1081 rcClient.left -
1082 wBorderWidth(pWin)
1083 -
1084 GetSystemMetrics
1085 (SM_XVIRTUALSCREEN),
1086 rcClient.top -
1087 wBorderWidth(pWin)
1088 -
1089 GetSystemMetrics
1090 (SM_YVIRTUALSCREEN),
1091 rcClient.right - rcClient.left -
1092 wBorderWidth(pWin) * 2,
1093 rcClient.bottom - rcClient.top -
1094 wBorderWidth(pWin) * 2);
1095 }
1096 else if (!(pWinPos->flags & SWP_NOMOVE)) {
1097#if CYGMULTIWINDOW_DEBUG
1098 winDebug("\tmove\n");
1099#endif
1100 if (winIsInternalWMRunning(pScreenInfo))
1101 winAdjustXWindow(pWin, hwnd);
1102
1103 winMWExtWMMoveResizeXWindow(pWin,
1104 rcClient.left -
1105 wBorderWidth(pWin)
1106 -
1107 GetSystemMetrics
1108 (SM_XVIRTUALSCREEN),
1109 rcClient.top -
1110 wBorderWidth(pWin)
1111 -
1112 GetSystemMetrics
1113 (SM_YVIRTUALSCREEN),
1114 rcClient.right - rcClient.left -
1115 wBorderWidth(pWin) * 2,
1116 rcClient.bottom - rcClient.top -
1117 wBorderWidth(pWin) * 2);
1118 }
1119 else if (!(pWinPos->flags & SWP_NOMOVE)) {
1120#if CYGMULTIWINDOW_DEBUG
1121 winDebug("\tmove\n");
1122#endif
1123 if (winIsInternalWMRunning(pScreenInfo))
1124 winAdjustXWindow(pWin, hwnd);
1125
1126 winMWExtWMMoveXWindow(pWin,
1127 rcClient.left - wBorderWidth(pWin)
1128 - GetSystemMetrics(SM_XVIRTUALSCREEN),
1129 rcClient.top - wBorderWidth(pWin)
1130 -
1131 GetSystemMetrics(SM_YVIRTUALSCREEN));
1132 }
1133 else if (!(pWinPos->flags & SWP_NOSIZE)) {
1134#if CYGMULTIWINDOW_DEBUG
1135 winDebug("\tresize\n");
1136#endif
1137 if (winIsInternalWMRunning(pScreenInfo))
1138 winAdjustXWindow(pWin, hwnd);
1139
1140 winMWExtWMResizeXWindow(pWin,
1141 rcClient.right - rcClient.left
1142 - wBorderWidth(pWin) * 2,
1143 rcClient.bottom - rcClient.top
1144 - wBorderWidth(pWin) * 2);
1145 }
1146 }
1147 }
1148 }
1149#if CYGMULTIWINDOW_DEBUG
1150 winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
1151#endif
1152 return 0;
1153
1154 case WM_SIZE:
1155 /* see dix/window.c */
1156 /* FIXME: Maximize/Restore? */
1157#if CYGMULTIWINDOW_DEBUG
1158 winDebug("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
1159 (unsigned int) GetTickCount());
1160#endif
1161#if CYGMULTIWINDOW_DEBUG
1162 winDebug("\t(%d, %d) %d\n", (short) LOWORD(lParam),
1163 (short) HIWORD(lParam), g_fNoConfigureWindow);
1164#endif
1165 if (g_fNoConfigureWindow)
1166 break;
1167
1168 /* Branch on type of resizing occurring */
1169 switch (wParam) {
1170 case SIZE_MINIMIZED:
1171#if CYGMULTIWINDOW_DEBUG
1172 winDebug("\tSIZE_MINIMIZED\n");
1173#endif
1174 if (winIsInternalWMRunning(pScreenInfo)) {
1175 /* Raise the window to the top in Z order */
1176 wmMsg.msg = WM_WM_LOWER;
1177 if (fWMMsgInitialized)
1178 winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
1179 }
1180 winWindowsWMSendEvent(WindowsWMControllerNotify,
1181 WindowsWMControllerNotifyMask,
1182 1,
1183 WindowsWMMinimizeWindow,
1184 pWin->drawable.id,
1185 0, 0, LOWORD(lParam), HIWORD(lParam));
1186 break;
1187
1188 case SIZE_RESTORED:
1189#if CYGMULTIWINDOW_DEBUG
1190 winDebug("\tSIZE_RESTORED\n");
1191#endif
1192 winWindowsWMSendEvent(WindowsWMControllerNotify,
1193 WindowsWMControllerNotifyMask,
1194 1,
1195 WindowsWMRestoreWindow,
1196 pWin->drawable.id,
1197 0, 0, LOWORD(lParam), HIWORD(lParam));
1198 break;
1199
1200 case SIZE_MAXIMIZED:
1201#if CYGMULTIWINDOW_DEBUG
1202 winDebug("\tSIZE_MAXIMIZED\n");
1203#endif
1204 winWindowsWMSendEvent(WindowsWMControllerNotify,
1205 WindowsWMControllerNotifyMask,
1206 1,
1207 WindowsWMMaximizeWindow,
1208 pWin->drawable.id,
1209 0, 0, LOWORD(lParam), HIWORD(lParam));
1210 break;
1211 }
1212
1213 /* Perform the resize and notify the X client */
1214 if (!pRLWinPriv->fMovingOrSizing) {
1215 if (winIsInternalWMRunning(pScreenInfo))
1216 winAdjustXWindow(pWin, hwnd);
1217
1218 winMWExtWMResizeXWindow(pWin, (short) LOWORD(lParam)
1219 - wBorderWidth(pWin) * 2,
1220 (short) HIWORD(lParam)
1221 - wBorderWidth(pWin) * 2);
1222 }
1223 break;
1224
1225 case WM_ACTIVATEAPP:
1226#if CYGMULTIWINDOW_DEBUG
1227 winDebug("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
1228 (unsigned int) GetTickCount());
1229#endif
1230 if (wParam) {
1231 if (winIsInternalWMRunning(pScreenInfo)) {
1232 }
1233 else {
1234 }
1235 winWindowsWMSendEvent(WindowsWMActivationNotify,
1236 WindowsWMActivationNotifyMask,
1237 1,
1238 WindowsWMIsActive,
1239 pWin->drawable.id, 0, 0, 0, 0);
1240 }
1241 else {
1242 winWindowsWMSendEvent(WindowsWMActivationNotify,
1243 WindowsWMActivationNotifyMask,
1244 1,
1245 WindowsWMIsInactive,
1246 pWin->drawable.id, 0, 0, 0, 0);
1247 }
1248 break;
1249
1250 case WM_SETCURSOR:
1251 if (LOWORD(lParam) == HTCLIENT) {
1252 if (!g_fSoftwareCursor)
1253 SetCursor(pScreenPriv->cursor.handle);
1254 return TRUE;
1255 }
1256 break;
1257
1258 case WM_ENTERSIZEMOVE:
1259#if CYGMULTIWINDOW_DEBUG
1260 winDebug("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
1261 (unsigned int) GetTickCount());
1262#endif
1263 pRLWinPriv->fMovingOrSizing = TRUE;
1264 break;
1265
1266 case WM_EXITSIZEMOVE:
1267#if CYGMULTIWINDOW_DEBUG
1268 winDebug("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
1269 (unsigned int) GetTickCount());
1270#endif
1271 pRLWinPriv->fMovingOrSizing = FALSE;
1272
1273 GetClientRect(hwnd, &rcClient);
1274
1275 MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT) &rcClient, 2);
1276
1277 if (winIsInternalWMRunning(pScreenInfo))
1278 winAdjustXWindow(pWin, hwnd);
1279
1280 winMWExtWMMoveResizeXWindow(pWin, rcClient.left - wBorderWidth(pWin)
1281 - GetSystemMetrics(SM_XVIRTUALSCREEN),
1282 rcClient.top - wBorderWidth(pWin)
1283 - GetSystemMetrics(SM_YVIRTUALSCREEN),
1284 rcClient.right - rcClient.left
1285 - wBorderWidth(pWin) * 2,
1286 rcClient.bottom - rcClient.top
1287 - wBorderWidth(pWin) * 2);
1288 break;
1289
1290 case WM_MANAGE:
1291 ErrorF("winMWExtWMWindowProc - WM_MANAGE\n");
1292 break;
1293
1294 case WM_UNMANAGE:
1295 ErrorF("winMWExtWMWindowProc - WM_UNMANAGE\n");
1296 break;
1297
1298 default:
1299 break;
1300 }
1301
1302 return DefWindowProc(hwnd, message, wParam, lParam);
1303}