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

Last change on this file since 7191 was 7189, checked in by sandervl, 24 years ago

window tracking activation fixes

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