source: trunk/src/user32/wintrack.cpp@ 9001

Last change on this file since 9001 was 9001, checked in by sandervl, 23 years ago

CUSTOM_TRACKFRAME code is the default now. removed old code;RMB on system menu icon pops up system menu (OS/2 look); GetSysPopupPos fix

File size: 28.4 KB
Line 
1/*
2 * Window tracking related functions.
3 *
4 * Copyright 2001 Sander van Leeuwen
5 *
6 * Changes from Wine code: (20011004)
7 * - Only draw changed track frame instead of clearing the old one and
8 * drawing the new one (less flickering)
9 * - Send WM_MOVING when moving a window (not done in Wine)
10 * - Send WM_SIZING only when sizing a window
11 * - Fixed handling of rectangles changed by WM_SIZING/MOVING
12 *
13 * Based on Wine code: (dlls\x11drv\winpos.c)
14 *
15 * Copyright 1993, 1994, 1995, 2001 Alexandre Julliard
16 * Copyright 1995, 1996, 1999 Alex Korobka
17 *
18 */
19#include <os2win.h>
20#include <string.h>
21
22#include "win32wbase.h"
23#include "hook.h"
24#include "pmwindow.h"
25
26#define ON_LEFT_BORDER(hit) \
27 (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
28#define ON_RIGHT_BORDER(hit) \
29 (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
30#define ON_TOP_BORDER(hit) \
31 (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
32#define ON_BOTTOM_BORDER(hit) \
33 (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
34
35#define RECT_WIDTH(a) ((a)->right - (a)->left)
36#define RECT_HEIGHT(a) ((a)->bottom - (a)->top)
37#define RECT_EQUAL(a,b) (memcmp(a, b, sizeof(RECT)) == 0)
38
39
40/***********************************************************************
41 * draw_moving_frame
42 *
43 * Draw the frame used when moving or resizing window.
44 *
45 * FIXME: This causes problems in Win95 mode. (why?)
46 */
47static void draw_moving_frame( HDC hdc, RECT *rect, BOOL thickframe, DWORD hittest, BOOL fRedraw)
48{
49 if (thickframe)
50 {
51 const int width = GetSystemMetrics(SM_CXFRAME);
52 const int height = GetSystemMetrics(SM_CYFRAME);
53
54 static RECT oldRect = {0};
55
56 if(fRedraw && EqualRect(&oldRect, rect)) {
57 return;
58 }
59
60 HBRUSH hbrush = SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
61 if(fRedraw && hittest != HTCAPTION)
62 {
63 int x, y, linewidth, lineheight;
64
65 //This should be done in a better way (less code), but at least
66 //it works.
67 switch(hittest) {
68 case HTLEFT:
69 //clear old edge
70 PatBlt( hdc, oldRect.left, oldRect.top + height,
71 width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
72 //and draw new one
73 PatBlt( hdc, rect->left, rect->top + height,
74 width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
75
76 if(oldRect.left > rect->left) {
77 x = rect->left;
78 linewidth = oldRect.left - rect->left;
79 }
80 else {
81 x = oldRect.left;
82 linewidth = rect->left - oldRect.left;
83 }
84 PatBlt(hdc, x, oldRect.top, linewidth, height, PATINVERT);
85 PatBlt(hdc, x, oldRect.bottom-1, linewidth, -height, PATINVERT);
86 break;
87 case HTRIGHT:
88 //clear old edge
89 PatBlt( hdc, oldRect.right-1, oldRect.top + height,
90 -width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
91 //and draw new one
92 PatBlt( hdc, rect->right-1, rect->top + height,
93 -width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
94
95 if(oldRect.right > rect->right) {
96 x = rect->right;
97 linewidth = oldRect.right - rect->right;
98 }
99 else {
100 x = oldRect.right;
101 linewidth = rect->right - oldRect.right;
102 }
103 PatBlt( hdc, x, oldRect.top, linewidth, height, PATINVERT );
104 PatBlt( hdc, x, oldRect.bottom-1, linewidth, -height, PATINVERT );
105 break;
106
107 case HTTOP:
108 //clear old edge
109 PatBlt( hdc, oldRect.left + width, oldRect.top,
110 RECT_WIDTH(&oldRect) - 2*width, height, PATINVERT );
111 //and draw new one
112 PatBlt( hdc, rect->left + width, rect->top,
113 RECT_WIDTH(rect) - 2*width, height, PATINVERT );
114
115 if(oldRect.top > rect->top) {
116 y = rect->top;
117 lineheight = oldRect.top - rect->top;
118 }
119 else {
120 y = oldRect.top;
121 lineheight = rect->top - oldRect.top;
122 }
123
124 PatBlt( hdc, oldRect.left, y, width, lineheight, PATINVERT );
125 PatBlt( hdc, oldRect.right - 1, y, -width, lineheight, PATINVERT );
126 break;
127
128 case HTBOTTOM:
129 //clear old edge
130 PatBlt( hdc, oldRect.left + width, oldRect.bottom-1,
131 RECT_WIDTH(&oldRect) - 2*width, -height, PATINVERT );
132 //and draw new one
133 PatBlt( hdc, rect->left + width, rect->bottom-1,
134 RECT_WIDTH(rect) - 2*width, -height, PATINVERT );
135
136 if(oldRect.bottom > rect->bottom) {
137 y = rect->bottom;
138 lineheight = oldRect.bottom - rect->bottom;
139 }
140 else {
141 y = oldRect.bottom;
142 lineheight = rect->bottom - oldRect.bottom;
143 }
144
145 PatBlt( hdc, oldRect.left, y, width, lineheight, PATINVERT );
146 PatBlt( hdc, oldRect.right - 1, y, -width, lineheight, PATINVERT );
147 break;
148
149 case HTBOTTOMLEFT:
150 //clear old edge (bottom)
151 PatBlt( hdc, oldRect.left, oldRect.bottom-1,
152 RECT_WIDTH(&oldRect) - width, -height, PATINVERT );
153 //and draw new one
154 PatBlt( hdc, rect->left, rect->bottom-1,
155 RECT_WIDTH(rect) - width, -height, PATINVERT );
156
157 //clear old edge (left)
158 PatBlt( hdc, oldRect.left, oldRect.top + height,
159 width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
160 //and draw new one
161 PatBlt( hdc, rect->left, rect->top + height,
162 width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
163
164 //right
165 if(oldRect.bottom > rect->bottom) {
166 y = rect->bottom;
167 lineheight = oldRect.bottom - rect->bottom;
168 }
169 else {
170 y = oldRect.bottom;
171 lineheight = rect->bottom - oldRect.bottom;
172 }
173 PatBlt( hdc, oldRect.right-1, y, -width, lineheight, PATINVERT );
174
175 //top
176 if(oldRect.left > rect->left) {
177 x = rect->left;
178 linewidth = oldRect.left - rect->left;
179 }
180 else {
181 x = oldRect.left;
182 linewidth = rect->left - oldRect.left;
183 }
184 PatBlt(hdc, x, oldRect.top, linewidth, height, PATINVERT);
185 break;
186
187 case HTBOTTOMRIGHT:
188 //clear old edge (bottom)
189 PatBlt( hdc, oldRect.left + width, oldRect.bottom-1,
190 RECT_WIDTH(&oldRect) - width, -height, PATINVERT );
191 //and draw new one
192 PatBlt( hdc, rect->left + width, rect->bottom-1,
193 RECT_WIDTH(rect) - width, -height, PATINVERT );
194
195 //clear old edge (right)
196 PatBlt( hdc, oldRect.right-1, oldRect.top + height,
197 -width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
198 //and draw new one
199 PatBlt( hdc, rect->right-1, rect->top + height,
200 -width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
201
202 //left
203 if(oldRect.bottom > rect->bottom) {
204 y = rect->bottom;
205 lineheight = oldRect.bottom - rect->bottom;
206 }
207 else {
208 y = oldRect.bottom;
209 lineheight = rect->bottom - oldRect.bottom;
210 }
211 PatBlt( hdc, oldRect.left, y, width, lineheight, PATINVERT );
212
213 //top
214 if(oldRect.right > rect->right) {
215 x = rect->right;
216 linewidth = oldRect.right - rect->right;
217 }
218 else {
219 x = oldRect.right;
220 linewidth = rect->right - oldRect.right;
221 }
222 PatBlt(hdc, x, oldRect.top, linewidth, height, PATINVERT);
223 break;
224
225 case HTTOPLEFT:
226 //clear old edge (top)
227 PatBlt( hdc, oldRect.left, oldRect.top,
228 RECT_WIDTH(&oldRect) - width, height, PATINVERT );
229 //and draw new one
230 PatBlt( hdc, rect->left, rect->top,
231 RECT_WIDTH(rect) - width, height, PATINVERT );
232
233 //clear old edge (left)
234 PatBlt( hdc, oldRect.left, oldRect.top + height,
235 width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
236 //and draw new one
237 PatBlt( hdc, rect->left, rect->top + height,
238 width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
239
240 //right
241 if(oldRect.top > rect->top) {
242 y = rect->top;
243 lineheight = oldRect.top - rect->top;
244 }
245 else {
246 y = oldRect.top;
247 lineheight = rect->top - oldRect.top;
248 }
249 PatBlt( hdc, oldRect.right-1, y, -width, lineheight, PATINVERT );
250
251 //bottom
252 if(oldRect.left > rect->left) {
253 x = rect->left;
254 linewidth = oldRect.left - rect->left;
255 }
256 else {
257 x = oldRect.left;
258 linewidth = rect->left - oldRect.left;
259 }
260 PatBlt(hdc, x, oldRect.bottom-1, linewidth, -height, PATINVERT);
261 break;
262
263 case HTTOPRIGHT:
264 //clear old edge (top)
265 PatBlt( hdc, oldRect.left+width, oldRect.top,
266 RECT_WIDTH(&oldRect) - width, height, PATINVERT );
267 //and draw new one
268 PatBlt( hdc, rect->left+width, rect->top,
269 RECT_WIDTH(rect) - width, height, PATINVERT );
270
271 //clear old edge (right)
272 PatBlt( hdc, oldRect.right-1, oldRect.top + height,
273 -width, RECT_HEIGHT(&oldRect) - 2*height, PATINVERT );
274 //and draw new one
275 PatBlt( hdc, rect->right-1, rect->top + height,
276 -width, RECT_HEIGHT(rect) - 2*height, PATINVERT );
277
278 //left
279 if(oldRect.top > rect->top) {
280 y = rect->top;
281 lineheight = oldRect.top - rect->top;
282 }
283 else {
284 y = oldRect.top;
285 lineheight = rect->top - oldRect.top;
286 }
287 PatBlt( hdc, oldRect.left, y, width, lineheight, PATINVERT);
288
289 //bottom
290 if(oldRect.right > rect->right) {
291 x = rect->right;
292 linewidth = oldRect.right - rect->right;
293 }
294 else {
295 x = oldRect.right;
296 linewidth = rect->right - oldRect.right;
297 }
298 PatBlt(hdc, x, oldRect.bottom-1, linewidth, -height, PATINVERT);
299 break;
300 }
301 oldRect = *rect;
302 }
303 else {
304 if(fRedraw) {
305 PatBlt( hdc, oldRect.left, oldRect.top,
306 RECT_WIDTH(&oldRect) - width, height, PATINVERT );
307 PatBlt( hdc, oldRect.left, oldRect.top + height, width,
308 RECT_HEIGHT(&oldRect) - height, PATINVERT );
309 PatBlt( hdc, oldRect.left + width, oldRect.bottom - 1,
310 RECT_WIDTH(&oldRect) - width, -height, PATINVERT );
311 PatBlt( hdc, oldRect.right - 1, oldRect.top, -width,
312 RECT_HEIGHT(&oldRect) - height, PATINVERT );
313 }
314 oldRect = *rect;
315 PatBlt( hdc, rect->left, rect->top,
316 rect->right - rect->left - width, height, PATINVERT );
317 PatBlt( hdc, rect->left, rect->top + height, width,
318 rect->bottom - rect->top - height, PATINVERT );
319 PatBlt( hdc, rect->left + width, rect->bottom - 1,
320 rect->right - rect->left - width, -height, PATINVERT );
321 PatBlt( hdc, rect->right - 1, rect->top, -width,
322 rect->bottom - rect->top - height, PATINVERT );
323 }
324 SelectObject( hdc, hbrush );
325 }
326 else {
327 static RECT oldRect = {0};
328
329 if(fRedraw && EqualRect(&oldRect, rect)) {
330 return;
331 }
332
333 if(fRedraw) {
334 DrawFocusRect( hdc, &oldRect );
335 }
336 DrawFocusRect( hdc, rect );
337 oldRect = *rect;
338 }
339}
340
341
342/***********************************************************************
343 * start_size_move
344 *
345 * Initialisation of a move or resize, when initiatied from a menu choice.
346 * Return hit test code for caption or sizing border.
347 */
348static LONG start_size_move( Win32BaseWindow *win32wnd, WPARAM wParam, POINT *capturePoint, LONG style )
349{
350 HWND hwnd = win32wnd->getWindowHandle();
351 LONG hittest = 0;
352 POINT pt;
353 MSG msg;
354 RECT rectWindow;
355
356 GetWindowRect( hwnd, &rectWindow );
357
358 if ((wParam & 0xfff0) == SC_MOVE)
359 {
360 /* Move pointer at the center of the caption */
361 RECT rect;
362 win32wnd->GetInsideRect( &rect );
363 if (style & WS_SYSMENU)
364 rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
365 if (style & WS_MINIMIZEBOX)
366 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
367 if (style & WS_MAXIMIZEBOX)
368 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
369 pt.x = rectWindow.left + (rect.right - rect.left) / 2;
370 pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2;
371 hittest = HTCAPTION;
372 *capturePoint = pt;
373 }
374 else /* SC_SIZE */
375 {
376 while(!hittest)
377 {
378// GetMessageW( &msg, 0, WM_KEYFIRST, WM_MOUSELAST );
379 GetMessageW( &msg, 0, 0, 0 );
380 if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
381
382 switch(msg.message)
383 {
384 case WM_MOUSEMOVE:
385 hittest = win32wnd->HandleNCHitTest( msg.pt );
386// hittest = NC_HandleNCHitTest( hwnd, msg.pt );
387 if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
388 hittest = 0;
389 break;
390
391 case WM_LBUTTONUP:
392 return 0;
393
394 case WM_KEYDOWN:
395 switch(msg.wParam)
396 {
397 case VK_UP:
398 hittest = HTTOP;
399 pt.x =(rectWindow.left+rectWindow.right)/2;
400 pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2;
401 break;
402 case VK_DOWN:
403 hittest = HTBOTTOM;
404 pt.x =(rectWindow.left+rectWindow.right)/2;
405 pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
406 break;
407 case VK_LEFT:
408 hittest = HTLEFT;
409 pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2;
410 pt.y =(rectWindow.top+rectWindow.bottom)/2;
411 break;
412 case VK_RIGHT:
413 hittest = HTRIGHT;
414 pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2;
415 pt.y =(rectWindow.top+rectWindow.bottom)/2;
416 break;
417 case VK_RETURN:
418 case VK_ESCAPE: return 0;
419 }
420 }
421 }
422 *capturePoint = pt;
423 }
424 SetCursorPos( pt.x, pt.y );
425 win32wnd->DefWindowProcA(WM_SETCURSOR, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
426// NC_HandleSetCursor( hwnd, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
427 dprintf(("start_size_move: hittest %d", hittest));
428 return hittest;
429}
430
431
432/***********************************************************************
433 * SysCommandSizeMove (X11DRV.@)
434 *
435 * Perform SC_MOVE and SC_SIZE commands.
436 */
437void Frame_SysCommandSizeMove(Win32BaseWindow *win32wnd, WPARAM wParam )
438{
439 HWND hwnd = win32wnd->getWindowHandle();
440 MSG msg;
441 RECT sizingRect, mouseRect, origRect, lastsizingRect;
442 HDC hdc;
443 HWND parent;
444 LONG hittest = (LONG)(wParam & 0x0f);
445 HCURSOR hDragCursor = 0, hOldCursor = 0;
446 POINT minTrack, maxTrack;
447 POINT capturePoint, pt;
448 LONG style = GetWindowLongA( hwnd, GWL_STYLE );
449 LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
450 BOOL thickframe = HAS_THICKFRAME( style, exstyle );
451 BOOL iconic = style & WS_MINIMIZE;
452 BOOL moved = FALSE;
453 DWORD dwPoint = GetMessagePos ();
454 BOOL DragFullWindows = FALSE;
455 BOOL fControl = FALSE;
456 BOOL grab;
457 int iWndsLocks;
458
459 dprintf(("FrameTrackFrame %x", wParam));
460
461 SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
462
463 pt.x = SLOWORD(dwPoint);
464 pt.y = SHIWORD(dwPoint);
465 capturePoint = pt;
466
467// if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || (exstyle & WS_EX_MANAGED)) return;
468 if (IsZoomed(hwnd) || !IsWindowVisible(hwnd)) return;
469
470 if(fOS2Look) {
471 fControl = GetAsyncKeyState(VK_CONTROL);
472 if(DragFullWindows && !fControl) {
473 //Bring window to top and activate it
474 SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
475 }
476 }
477
478 if ((wParam & 0xfff0) == SC_MOVE)
479 {
480 if (!hittest) hittest = start_size_move( win32wnd, wParam, &capturePoint, style );
481 if (!hittest) return;
482 }
483 else /* SC_SIZE */
484 {
485 if (!thickframe) return;
486 if ( hittest && hittest != HTSYSMENU ) hittest += 2;
487 else
488 {
489 SetCapture(hwnd);
490 hittest = start_size_move( win32wnd, wParam, &capturePoint, style );
491 if (!hittest)
492 {
493 ReleaseCapture();
494 return;
495 }
496 }
497 }
498
499 /* Get min/max info */
500
501// WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
502 win32wnd->AdjustTrackInfo(&minTrack, &maxTrack);
503 GetWindowRect( hwnd, &sizingRect );
504 if (style & WS_CHILD)
505 {
506 parent = GetParent(hwnd);
507 /* make sizing rect relative to parent */
508 MapWindowPoints( 0, parent, (POINT*)&sizingRect, 2 );
509 GetClientRect( parent, &mouseRect );
510 }
511 else
512 {
513 parent = GetDesktopWindow();
514 SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
515 }
516 origRect = sizingRect;
517
518 if (ON_LEFT_BORDER(hittest))
519 {
520 mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x );
521 mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x );
522 }
523 else if (ON_RIGHT_BORDER(hittest))
524 {
525 mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x );
526 mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x );
527 }
528 if (ON_TOP_BORDER(hittest))
529 {
530 mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y );
531 mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y);
532 }
533 else if (ON_BOTTOM_BORDER(hittest))
534 {
535 mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y );
536 mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
537 }
538 if (parent) MapWindowPoints( parent, 0, (LPPOINT)&mouseRect, 2 );
539
540 /* Retrieve a default cache DC (without using the window style) */
541 hdc = GetDCEx( parent, 0, DCX_CACHE);
542
543 if( iconic ) /* create a cursor for dragging */
544 {
545 HICON hIcon = GetClassLongA( hwnd, GCL_HICON);
546 if(!hIcon) hIcon = (HICON)SendMessageA( hwnd, WM_QUERYDRAGICON, 0, 0L);
547 if( hIcon ) hDragCursor = hIcon;
548// CURSORICON_IconToCursor( hIcon, TRUE );
549 if( !hDragCursor ) iconic = FALSE;
550 }
551
552 /* repaint the window before moving it around */
553 RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
554
555 SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
556 SetCapture( hwnd );
557
558 //prevent the app from drawing to this window (or its children)
559 if(!DragFullWindows)
560 LockWindowUpdate(hwnd);
561
562 while(1)
563 {
564 int dx = 0, dy = 0;
565
566// if (!GetMessageW( &msg, 0, WM_KEYFIRST, WM_MOUSELAST )) break;
567 if (!GetMessageW( &msg, 0, 0, 0 )) break;
568 if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
569
570 /* Exit on button-up, Return, or Esc */
571 if ((msg.message == WM_LBUTTONUP) || (msg.message == WM_RBUTTONUP) ||
572 ((msg.message == WM_KEYDOWN) &&
573 ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
574
575 if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE)) {
576 DispatchMessageA(&msg);
577 continue; /* We are not interested in other messages */
578 }
579
580 pt = msg.pt;
581
582 if (msg.message == WM_KEYDOWN) switch(msg.wParam)
583 {
584 case VK_UP: pt.y -= 8; break;
585 case VK_DOWN: pt.y += 8; break;
586 case VK_LEFT: pt.x -= 8; break;
587 case VK_RIGHT: pt.x += 8; break;
588 }
589
590 pt.x = max( pt.x, mouseRect.left );
591 pt.x = min( pt.x, mouseRect.right );
592 pt.y = max( pt.y, mouseRect.top );
593 pt.y = min( pt.y, mouseRect.bottom );
594
595 dprintf(("mouseRect (%d,%d)(%d,%d)", mouseRect.left, mouseRect.top, mouseRect.right, mouseRect.bottom));
596 dprintf(("capturePoint (%d,%d)", capturePoint.x, capturePoint.y));
597 dx = pt.x - capturePoint.x;
598 dy = pt.y - capturePoint.y;
599
600 if (dx || dy)
601 {
602 if( !moved )
603 {
604 moved = TRUE;
605
606 if( iconic ) /* ok, no system popup tracking */
607 {
608 hOldCursor = SetCursor(hDragCursor);
609 ShowCursor( TRUE );
610// WINPOS_ShowIconTitle( hwnd, FALSE );
611 }
612 else if(!DragFullWindows)
613 draw_moving_frame( hdc, &sizingRect, thickframe, hittest, FALSE );
614 }
615
616 if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
617 else
618 {
619 RECT newRect = sizingRect, tempRect;
620 WPARAM wpSizingHit = 0;
621
622 if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
623
624 if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
625 else
626 if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
627
628 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
629 else
630 if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
631
632//// if(!iconic && !DragFullWindows) draw_moving_frame( hdc, &sizingRect, thickframe, hittest, TRUE);
633
634 /* determine the hit location */
635 if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
636 wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
637
638 tempRect = newRect;
639
640 dprintf(("WM_SIZING rect (%d,%d)(%d,%d)", newRect.left, newRect.top, newRect.right, newRect.bottom));
641
642 //Although the docs say the app should return TRUE when processing
643 //this message, experiments show that NT checks the rectangle
644 //regardless of the return value
645 if ((wParam & 0xfff0) == SC_MOVE) {
646 SendMessageA( hwnd, WM_MOVING, wpSizingHit, (LPARAM)&newRect );
647 }
648 else SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
649
650 dprintf(("WM_SIZING rect (%d,%d)(%d,%d)", newRect.left, newRect.top, newRect.right, newRect.bottom));
651
652 dprintf(("update capture point dx %d dy %d", dx, dy));
653 capturePoint = pt;
654 sizingRect = tempRect;
655 lastsizingRect = newRect;
656
657 if (!iconic)
658 {
659 if(!DragFullWindows)
660 draw_moving_frame( hdc, &newRect, thickframe, hittest, TRUE );
661 else {
662 /* To avoid any deadlocks, all the locks on the windows
663 structures must be suspended before the SetWindowPos */
664// iWndsLocks = WIN_SuspendWndsLock();
665 SetWindowPos( hwnd, 0, newRect.left, newRect.top,
666 newRect.right - newRect.left,
667 newRect.bottom - newRect.top,
668 ((hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ) |
669 ((fControl) ? (SWP_NOACTIVATE|SWP_NOZORDER) : 0));
670// WIN_RestoreWndsLock(iWndsLocks);
671 }
672 }
673 }
674 }
675 }
676
677 //Enable window update
678 if(!DragFullWindows)
679 LockWindowUpdate(NULL);
680
681 ReleaseCapture();
682 if( iconic )
683 {
684 if( moved ) /* restore cursors, show icon title later on */
685 {
686 ShowCursor( FALSE );
687 SetCursor( hOldCursor );
688 }
689 DestroyCursor( hDragCursor );
690 }
691 else if (moved && !DragFullWindows)
692 draw_moving_frame( hdc, &lastsizingRect, thickframe, hittest, FALSE);
693
694 ReleaseDC( parent, hdc );
695
696// wine_tsx11_lock();
697// XUngrabPointer( display, CurrentTime );
698// if (grab)
699// {
700// XSync( display, False );
701// XUngrabServer( display );
702// XSync( display, False );
703// gdi_display = old_gdi_display;
704// }
705// wine_tsx11_unlock();
706
707 if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, (WPARAM)hwnd, (LPARAM)&lastsizingRect )) moved = FALSE;
708
709 SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 );
710 SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
711
712 /* window moved or resized */
713 if (moved)
714 {
715 /* To avoid any deadlocks, all the locks on the windows
716 structures must be suspended before the SetWindowPos */
717// iWndsLocks = WIN_SuspendWndsLock();
718
719 /* if the moving/resizing isn't canceled call SetWindowPos
720 * with the new position or the new size of the window
721 */
722 if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
723 {
724 /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
725 if( (!DragFullWindows) || iconic)
726 SetWindowPos( hwnd, 0, lastsizingRect.left, lastsizingRect.top,
727 lastsizingRect.right - lastsizingRect.left,
728 lastsizingRect.bottom - lastsizingRect.top,
729 ((hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ) |
730 ((fControl) ? (SWP_NOACTIVATE|SWP_NOZORDER) : 0));
731 }
732 else
733 { /* restore previous size/position */
734 //SvL: TODO: should really restore z-order & activation here
735 if(DragFullWindows)
736 SetWindowPos( hwnd, 0, origRect.left, origRect.top,
737 origRect.right - origRect.left,
738 origRect.bottom - origRect.top,
739 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
740 }
741
742// WIN_RestoreWndsLock(iWndsLocks);
743 }
744 else
745 if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) ) {
746 //if action wasn't cancelled, ctrl wasn't pressed and we didn't
747 //activate the window before (!DragFullWindows), then activate
748 //and bring it to the top now
749 if(!fControl && !DragFullWindows) {
750 //Bring window to top and activate it
751 SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
752 }
753 }
754
755 if (IsIconic(hwnd))
756 {
757 /* Single click brings up the system menu when iconized */
758
759 if( !moved && !fOS2Look)
760 {
761 if(style & WS_SYSMENU )
762 SendMessageA( hwnd, WM_SYSCOMMAND,
763 SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
764 }
765// else WINPOS_ShowIconTitle( hwnd, TRUE );
766 }
767}
768
Note: See TracBrowser for help on using the repository browser.