| 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 | */
|
|---|
| 48 | static 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 {
|
|---|
| 328 | static RECT oldRect = {0};
|
|---|
| 329 |
|
|---|
| 330 | if(fRedraw && EqualRect(&oldRect, rect)) {
|
|---|
| 331 | return;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | if(fRedraw) {
|
|---|
| 335 | DrawFocusRect( hdc, &oldRect );
|
|---|
| 336 | }
|
|---|
| 337 | DrawFocusRect( hdc, rect );
|
|---|
| 338 | oldRect = *rect;
|
|---|
| 339 | }
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 | /***********************************************************************
|
|---|
| 344 | * start_size_move
|
|---|
| 345 | *
|
|---|
| 346 | * Initialisation of a move or resize, when initiatied from a menu choice.
|
|---|
| 347 | * Return hit test code for caption or sizing border.
|
|---|
| 348 | */
|
|---|
| 349 | static LONG start_size_move( Win32BaseWindow *win32wnd, WPARAM wParam, POINT *capturePoint, LONG style )
|
|---|
| 350 | {
|
|---|
| 351 | HWND hwnd = win32wnd->getWindowHandle();
|
|---|
| 352 | LONG hittest = 0;
|
|---|
| 353 | POINT pt;
|
|---|
| 354 | MSG msg;
|
|---|
| 355 | RECT rectWindow;
|
|---|
| 356 |
|
|---|
| 357 | GetWindowRect( hwnd, &rectWindow );
|
|---|
| 358 |
|
|---|
| 359 | if ((wParam & 0xfff0) == SC_MOVE)
|
|---|
| 360 | {
|
|---|
| 361 | /* Move pointer at the center of the caption */
|
|---|
| 362 | RECT rect;
|
|---|
| 363 | win32wnd->GetInsideRect( &rect );
|
|---|
| 364 | if (style & WS_SYSMENU)
|
|---|
| 365 | rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
|
|---|
| 366 | if (style & WS_MINIMIZEBOX)
|
|---|
| 367 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
|---|
| 368 | if (style & WS_MAXIMIZEBOX)
|
|---|
| 369 | rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
|
|---|
| 370 | pt.x = rectWindow.left + (rect.right - rect.left) / 2;
|
|---|
| 371 | pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2;
|
|---|
| 372 | hittest = HTCAPTION;
|
|---|
| 373 | *capturePoint = pt;
|
|---|
| 374 | }
|
|---|
| 375 | else /* SC_SIZE */
|
|---|
| 376 | {
|
|---|
| 377 | while(!hittest)
|
|---|
| 378 | {
|
|---|
| 379 | // GetMessageW( &msg, 0, WM_KEYFIRST, WM_MOUSELAST );
|
|---|
| 380 | GetMessageW( &msg, 0, 0, 0 );
|
|---|
| 381 | if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
|
|---|
| 382 |
|
|---|
| 383 | switch(msg.message)
|
|---|
| 384 | {
|
|---|
| 385 | case WM_MOUSEMOVE:
|
|---|
| 386 | hittest = win32wnd->HandleNCHitTest( msg.pt );
|
|---|
| 387 | // hittest = NC_HandleNCHitTest( hwnd, msg.pt );
|
|---|
| 388 | if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
|
|---|
| 389 | hittest = 0;
|
|---|
| 390 | break;
|
|---|
| 391 |
|
|---|
| 392 | case WM_LBUTTONUP:
|
|---|
| 393 | return 0;
|
|---|
| 394 |
|
|---|
| 395 | case WM_KEYDOWN:
|
|---|
| 396 | switch(msg.wParam)
|
|---|
| 397 | {
|
|---|
| 398 | case VK_UP:
|
|---|
| 399 | hittest = HTTOP;
|
|---|
| 400 | pt.x =(rectWindow.left+rectWindow.right)/2;
|
|---|
| 401 | pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2;
|
|---|
| 402 | break;
|
|---|
| 403 | case VK_DOWN:
|
|---|
| 404 | hittest = HTBOTTOM;
|
|---|
| 405 | pt.x =(rectWindow.left+rectWindow.right)/2;
|
|---|
| 406 | pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
|
|---|
| 407 | break;
|
|---|
| 408 | case VK_LEFT:
|
|---|
| 409 | hittest = HTLEFT;
|
|---|
| 410 | pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2;
|
|---|
| 411 | pt.y =(rectWindow.top+rectWindow.bottom)/2;
|
|---|
| 412 | break;
|
|---|
| 413 | case VK_RIGHT:
|
|---|
| 414 | hittest = HTRIGHT;
|
|---|
| 415 | pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2;
|
|---|
| 416 | pt.y =(rectWindow.top+rectWindow.bottom)/2;
|
|---|
| 417 | break;
|
|---|
| 418 | case VK_RETURN:
|
|---|
| 419 | case VK_ESCAPE: return 0;
|
|---|
| 420 | }
|
|---|
| 421 | }
|
|---|
| 422 | }
|
|---|
| 423 | *capturePoint = pt;
|
|---|
| 424 | }
|
|---|
| 425 | SetCursorPos( pt.x, pt.y );
|
|---|
| 426 | win32wnd->DefWindowProcA(WM_SETCURSOR, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
|
|---|
| 427 | // NC_HandleSetCursor( hwnd, (WPARAM)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
|
|---|
| 428 | dprintf(("start_size_move: hittest %d", hittest));
|
|---|
| 429 | return hittest;
|
|---|
| 430 | }
|
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 | /***********************************************************************
|
|---|
| 434 | * SysCommandSizeMove (X11DRV.@)
|
|---|
| 435 | *
|
|---|
| 436 | * Perform SC_MOVE and SC_SIZE commands.
|
|---|
| 437 | */
|
|---|
| 438 | void Frame_SysCommandSizeMove(Win32BaseWindow *win32wnd, WPARAM wParam )
|
|---|
| 439 | {
|
|---|
| 440 | HWND hwnd = win32wnd->getWindowHandle();
|
|---|
| 441 | MSG msg;
|
|---|
| 442 | RECT sizingRect, mouseRect, origRect, lastsizingRect;
|
|---|
| 443 | HDC hdc;
|
|---|
| 444 | HWND parent;
|
|---|
| 445 | LONG hittest = (LONG)(wParam & 0x0f);
|
|---|
| 446 | HCURSOR hDragCursor = 0, hOldCursor = 0;
|
|---|
| 447 | POINT minTrack, maxTrack;
|
|---|
| 448 | POINT capturePoint, pt;
|
|---|
| 449 | LONG style = GetWindowLongA( hwnd, GWL_STYLE );
|
|---|
| 450 | LONG exstyle = GetWindowLongA( hwnd, GWL_EXSTYLE );
|
|---|
| 451 | BOOL thickframe = HAS_THICKFRAME( style, exstyle );
|
|---|
| 452 | BOOL iconic = style & WS_MINIMIZE;
|
|---|
| 453 | BOOL moved = FALSE;
|
|---|
| 454 | DWORD dwPoint = GetMessagePos ();
|
|---|
| 455 | BOOL DragFullWindows = FALSE;
|
|---|
| 456 | BOOL fControl = FALSE;
|
|---|
| 457 | BOOL grab;
|
|---|
| 458 | int iWndsLocks;
|
|---|
| 459 |
|
|---|
| 460 | dprintf(("FrameTrackFrame %x", wParam));
|
|---|
| 461 |
|
|---|
| 462 | SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
|
|---|
| 463 |
|
|---|
| 464 | pt.x = SLOWORD(dwPoint);
|
|---|
| 465 | pt.y = SHIWORD(dwPoint);
|
|---|
| 466 | capturePoint = pt;
|
|---|
| 467 |
|
|---|
| 468 | // if (IsZoomed(hwnd) || !IsWindowVisible(hwnd) || (exstyle & WS_EX_MANAGED)) return;
|
|---|
| 469 | if (IsZoomed(hwnd) || !IsWindowVisible(hwnd)) return;
|
|---|
| 470 |
|
|---|
| 471 | if(fOS2Look) {
|
|---|
| 472 | fControl = GetAsyncKeyState(VK_CONTROL);
|
|---|
| 473 | if(DragFullWindows && !fControl) {
|
|---|
| 474 | //Bring window to top and activate it
|
|---|
| 475 | SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
|---|
| 476 | }
|
|---|
| 477 | }
|
|---|
| 478 |
|
|---|
| 479 | if ((wParam & 0xfff0) == SC_MOVE)
|
|---|
| 480 | {
|
|---|
| 481 | if (!hittest) hittest = start_size_move( win32wnd, wParam, &capturePoint, style );
|
|---|
| 482 | if (!hittest) return;
|
|---|
| 483 | }
|
|---|
| 484 | else /* SC_SIZE */
|
|---|
| 485 | {
|
|---|
| 486 | if (!thickframe) return;
|
|---|
| 487 | if ( hittest && hittest != HTSYSMENU ) hittest += 2;
|
|---|
| 488 | else
|
|---|
| 489 | {
|
|---|
| 490 | SetCapture(hwnd);
|
|---|
| 491 | hittest = start_size_move( win32wnd, wParam, &capturePoint, style );
|
|---|
| 492 | if (!hittest)
|
|---|
| 493 | {
|
|---|
| 494 | ReleaseCapture();
|
|---|
| 495 | return;
|
|---|
| 496 | }
|
|---|
| 497 | }
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | /* Get min/max info */
|
|---|
| 501 |
|
|---|
| 502 | // WINPOS_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack );
|
|---|
| 503 | win32wnd->AdjustTrackInfo(&minTrack, &maxTrack);
|
|---|
| 504 | GetWindowRect( hwnd, &sizingRect );
|
|---|
| 505 | if (style & WS_CHILD)
|
|---|
| 506 | {
|
|---|
| 507 | parent = GetParent(hwnd);
|
|---|
| 508 | /* make sizing rect relative to parent */
|
|---|
| 509 | MapWindowPoints( 0, parent, (POINT*)&sizingRect, 2 );
|
|---|
| 510 | GetClientRect( parent, &mouseRect );
|
|---|
| 511 | }
|
|---|
| 512 | else
|
|---|
| 513 | {
|
|---|
| 514 | parent = GetDesktopWindow();
|
|---|
| 515 | SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
|---|
| 516 | }
|
|---|
| 517 | origRect = sizingRect;
|
|---|
| 518 |
|
|---|
| 519 | if (ON_LEFT_BORDER(hittest))
|
|---|
| 520 | {
|
|---|
| 521 | mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x );
|
|---|
| 522 | mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x );
|
|---|
| 523 | }
|
|---|
| 524 | else if (ON_RIGHT_BORDER(hittest))
|
|---|
| 525 | {
|
|---|
| 526 | mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x );
|
|---|
| 527 | mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x );
|
|---|
| 528 | }
|
|---|
| 529 | if (ON_TOP_BORDER(hittest))
|
|---|
| 530 | {
|
|---|
| 531 | mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y );
|
|---|
| 532 | mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y);
|
|---|
| 533 | }
|
|---|
| 534 | else if (ON_BOTTOM_BORDER(hittest))
|
|---|
| 535 | {
|
|---|
| 536 | mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y );
|
|---|
| 537 | mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
|
|---|
| 538 | }
|
|---|
| 539 | if (parent) MapWindowPoints( parent, 0, (LPPOINT)&mouseRect, 2 );
|
|---|
| 540 |
|
|---|
| 541 | /* Retrieve a default cache DC (without using the window style) */
|
|---|
| 542 | hdc = GetDCEx( parent, 0, DCX_CACHE);
|
|---|
| 543 |
|
|---|
| 544 | if( iconic ) /* create a cursor for dragging */
|
|---|
| 545 | {
|
|---|
| 546 | HICON hIcon = GetClassLongA( hwnd, GCL_HICON);
|
|---|
| 547 | if(!hIcon) hIcon = (HICON)SendMessageA( hwnd, WM_QUERYDRAGICON, 0, 0L);
|
|---|
| 548 | if( hIcon ) hDragCursor = hIcon;
|
|---|
| 549 | // CURSORICON_IconToCursor( hIcon, TRUE );
|
|---|
| 550 | if( !hDragCursor ) iconic = FALSE;
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | /* repaint the window before moving it around */
|
|---|
| 554 | RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
|
|---|
| 555 |
|
|---|
| 556 | SendMessageA( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
|
|---|
| 557 | SetCapture( hwnd );
|
|---|
| 558 |
|
|---|
| 559 | //prevent the app from drawing to this window (or its children)
|
|---|
| 560 | if(!DragFullWindows)
|
|---|
| 561 | LockWindowUpdate(hwnd);
|
|---|
| 562 |
|
|---|
| 563 | while(1)
|
|---|
| 564 | {
|
|---|
| 565 | int dx = 0, dy = 0;
|
|---|
| 566 |
|
|---|
| 567 | // if (!GetMessageW( &msg, 0, WM_KEYFIRST, WM_MOUSELAST )) break;
|
|---|
| 568 | if (!GetMessageW( &msg, 0, 0, 0 )) break;
|
|---|
| 569 | if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
|
|---|
| 570 |
|
|---|
| 571 | /* Exit on button-up, Return, or Esc */
|
|---|
| 572 | if ((msg.message == WM_LBUTTONUP) || (msg.message == WM_RBUTTONUP) ||
|
|---|
| 573 | ((msg.message == WM_KEYDOWN) &&
|
|---|
| 574 | ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
|
|---|
| 575 |
|
|---|
| 576 | if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE)) {
|
|---|
| 577 | DispatchMessageA(&msg);
|
|---|
| 578 | continue; /* We are not interested in other messages */
|
|---|
| 579 | }
|
|---|
| 580 |
|
|---|
| 581 | pt = msg.pt;
|
|---|
| 582 |
|
|---|
| 583 | if (msg.message == WM_KEYDOWN) switch(msg.wParam)
|
|---|
| 584 | {
|
|---|
| 585 | case VK_UP: pt.y -= 8; break;
|
|---|
| 586 | case VK_DOWN: pt.y += 8; break;
|
|---|
| 587 | case VK_LEFT: pt.x -= 8; break;
|
|---|
| 588 | case VK_RIGHT: pt.x += 8; break;
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | pt.x = max( pt.x, mouseRect.left );
|
|---|
| 592 | pt.x = min( pt.x, mouseRect.right );
|
|---|
| 593 | pt.y = max( pt.y, mouseRect.top );
|
|---|
| 594 | pt.y = min( pt.y, mouseRect.bottom );
|
|---|
| 595 |
|
|---|
| 596 | dprintf(("mouseRect (%d,%d)(%d,%d)", mouseRect.left, mouseRect.top, mouseRect.right, mouseRect.bottom));
|
|---|
| 597 | dprintf(("capturePoint (%d,%d)", capturePoint.x, capturePoint.y));
|
|---|
| 598 | dx = pt.x - capturePoint.x;
|
|---|
| 599 | dy = pt.y - capturePoint.y;
|
|---|
| 600 |
|
|---|
| 601 | if (dx || dy)
|
|---|
| 602 | {
|
|---|
| 603 | if( !moved )
|
|---|
| 604 | {
|
|---|
| 605 | moved = TRUE;
|
|---|
| 606 |
|
|---|
| 607 | if( iconic ) /* ok, no system popup tracking */
|
|---|
| 608 | {
|
|---|
| 609 | hOldCursor = SetCursor(hDragCursor);
|
|---|
| 610 | ShowCursor( TRUE );
|
|---|
| 611 | // WINPOS_ShowIconTitle( hwnd, FALSE );
|
|---|
| 612 | }
|
|---|
| 613 | else if(!DragFullWindows)
|
|---|
| 614 | draw_moving_frame( hdc, &sizingRect, thickframe, hittest, FALSE );
|
|---|
| 615 | }
|
|---|
| 616 |
|
|---|
| 617 | if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
|
|---|
| 618 | else
|
|---|
| 619 | {
|
|---|
| 620 | RECT newRect = sizingRect, tempRect;
|
|---|
| 621 | WPARAM wpSizingHit = 0;
|
|---|
| 622 |
|
|---|
| 623 | if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
|
|---|
| 624 |
|
|---|
| 625 | if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
|
|---|
| 626 | else
|
|---|
| 627 | if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
|
|---|
| 628 |
|
|---|
| 629 | if (ON_TOP_BORDER(hittest)) newRect.top += dy;
|
|---|
| 630 | else
|
|---|
| 631 | if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
|
|---|
| 632 |
|
|---|
| 633 | //// if(!iconic && !DragFullWindows) draw_moving_frame( hdc, &sizingRect, thickframe, hittest, TRUE);
|
|---|
| 634 |
|
|---|
| 635 | /* determine the hit location */
|
|---|
| 636 | if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
|
|---|
| 637 | wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
|
|---|
| 638 |
|
|---|
| 639 | tempRect = newRect;
|
|---|
| 640 |
|
|---|
| 641 | dprintf(("WM_SIZING rect (%d,%d)(%d,%d)", newRect.left, newRect.top, newRect.right, newRect.bottom));
|
|---|
| 642 |
|
|---|
| 643 | //Although the docs say the app should return TRUE when processing
|
|---|
| 644 | //this message, experiments show that NT checks the rectangle
|
|---|
| 645 | //regardless of the return value
|
|---|
| 646 | if ((wParam & 0xfff0) == SC_MOVE) {
|
|---|
| 647 | SendMessageA( hwnd, WM_MOVING, wpSizingHit, (LPARAM)&newRect );
|
|---|
| 648 | }
|
|---|
| 649 | else SendMessageA( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
|
|---|
| 650 |
|
|---|
| 651 | dprintf(("WM_SIZING rect (%d,%d)(%d,%d)", newRect.left, newRect.top, newRect.right, newRect.bottom));
|
|---|
| 652 |
|
|---|
| 653 | dprintf(("update capture point dx %d dy %d", dx, dy));
|
|---|
| 654 | capturePoint = pt;
|
|---|
| 655 | sizingRect = tempRect;
|
|---|
| 656 | lastsizingRect = newRect;
|
|---|
| 657 |
|
|---|
| 658 | if (!iconic)
|
|---|
| 659 | {
|
|---|
| 660 | if(!DragFullWindows)
|
|---|
| 661 | draw_moving_frame( hdc, &newRect, thickframe, hittest, TRUE );
|
|---|
| 662 | else {
|
|---|
| 663 | /* To avoid any deadlocks, all the locks on the windows
|
|---|
| 664 | structures must be suspended before the SetWindowPos */
|
|---|
| 665 | // iWndsLocks = WIN_SuspendWndsLock();
|
|---|
| 666 | SetWindowPos( hwnd, 0, newRect.left, newRect.top,
|
|---|
| 667 | newRect.right - newRect.left,
|
|---|
| 668 | newRect.bottom - newRect.top,
|
|---|
| 669 | ((hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ) |
|
|---|
| 670 | ((fControl) ? (SWP_NOACTIVATE|SWP_NOZORDER) : 0));
|
|---|
| 671 | // WIN_RestoreWndsLock(iWndsLocks);
|
|---|
| 672 | }
|
|---|
| 673 | }
|
|---|
| 674 | }
|
|---|
| 675 | }
|
|---|
| 676 | }
|
|---|
| 677 |
|
|---|
| 678 | //Enable window update
|
|---|
| 679 | if(!DragFullWindows)
|
|---|
| 680 | LockWindowUpdate(NULL);
|
|---|
| 681 |
|
|---|
| 682 | ReleaseCapture();
|
|---|
| 683 | if( iconic )
|
|---|
| 684 | {
|
|---|
| 685 | if( moved ) /* restore cursors, show icon title later on */
|
|---|
| 686 | {
|
|---|
| 687 | ShowCursor( FALSE );
|
|---|
| 688 | SetCursor( hOldCursor );
|
|---|
| 689 | }
|
|---|
| 690 | DestroyCursor( hDragCursor );
|
|---|
| 691 | }
|
|---|
| 692 | else if (moved && !DragFullWindows)
|
|---|
| 693 | draw_moving_frame( hdc, &lastsizingRect, thickframe, hittest, FALSE);
|
|---|
| 694 |
|
|---|
| 695 | ReleaseDC( parent, hdc );
|
|---|
| 696 |
|
|---|
| 697 | // wine_tsx11_lock();
|
|---|
| 698 | // XUngrabPointer( display, CurrentTime );
|
|---|
| 699 | // if (grab)
|
|---|
| 700 | // {
|
|---|
| 701 | // XSync( display, False );
|
|---|
| 702 | // XUngrabServer( display );
|
|---|
| 703 | // XSync( display, False );
|
|---|
| 704 | // gdi_display = old_gdi_display;
|
|---|
| 705 | // }
|
|---|
| 706 | // wine_tsx11_unlock();
|
|---|
| 707 |
|
|---|
| 708 | if (HOOK_CallHooksA( WH_CBT, HCBT_MOVESIZE, (WPARAM)hwnd, (LPARAM)&lastsizingRect )) moved = FALSE;
|
|---|
| 709 |
|
|---|
| 710 | SendMessageA( hwnd, WM_EXITSIZEMOVE, 0, 0 );
|
|---|
| 711 | SendMessageA( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
|
|---|
| 712 |
|
|---|
| 713 | /* window moved or resized */
|
|---|
| 714 | if (moved)
|
|---|
| 715 | {
|
|---|
| 716 | /* To avoid any deadlocks, all the locks on the windows
|
|---|
| 717 | structures must be suspended before the SetWindowPos */
|
|---|
| 718 | // iWndsLocks = WIN_SuspendWndsLock();
|
|---|
| 719 |
|
|---|
| 720 | /* if the moving/resizing isn't canceled call SetWindowPos
|
|---|
| 721 | * with the new position or the new size of the window
|
|---|
| 722 | */
|
|---|
| 723 | if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
|
|---|
| 724 | {
|
|---|
| 725 | /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
|
|---|
| 726 | if( (!DragFullWindows) || iconic)
|
|---|
| 727 | SetWindowPos( hwnd, 0, lastsizingRect.left, lastsizingRect.top,
|
|---|
| 728 | lastsizingRect.right - lastsizingRect.left,
|
|---|
| 729 | lastsizingRect.bottom - lastsizingRect.top,
|
|---|
| 730 | ((hittest == HTCAPTION ) ? SWP_NOSIZE : 0 ) |
|
|---|
| 731 | ((fControl) ? (SWP_NOACTIVATE|SWP_NOZORDER) : 0));
|
|---|
| 732 | }
|
|---|
| 733 | else
|
|---|
| 734 | { /* restore previous size/position */
|
|---|
| 735 | //SvL: TODO: should really restore z-order & activation here
|
|---|
| 736 | if(DragFullWindows)
|
|---|
| 737 | SetWindowPos( hwnd, 0, origRect.left, origRect.top,
|
|---|
| 738 | origRect.right - origRect.left,
|
|---|
| 739 | origRect.bottom - origRect.top,
|
|---|
| 740 | ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
|
|---|
| 741 | }
|
|---|
| 742 |
|
|---|
| 743 | // WIN_RestoreWndsLock(iWndsLocks);
|
|---|
| 744 | }
|
|---|
| 745 | else
|
|---|
| 746 | if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) ) {
|
|---|
| 747 | //if action wasn't cancelled, ctrl wasn't pressed and we didn't
|
|---|
| 748 | //activate the window before (!DragFullWindows), then activate
|
|---|
| 749 | //and bring it to the top now
|
|---|
| 750 | if(!fControl && !DragFullWindows) {
|
|---|
| 751 | //Bring window to top and activate it
|
|---|
| 752 | SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
|---|
| 753 | }
|
|---|
| 754 | }
|
|---|
| 755 |
|
|---|
| 756 | if (IsIconic(hwnd))
|
|---|
| 757 | {
|
|---|
| 758 | /* Single click brings up the system menu when iconized */
|
|---|
| 759 |
|
|---|
| 760 | if( !moved )
|
|---|
| 761 | {
|
|---|
| 762 | if(style & WS_SYSMENU )
|
|---|
| 763 | SendMessageA( hwnd, WM_SYSCOMMAND,
|
|---|
| 764 | SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
|
|---|
| 765 | }
|
|---|
| 766 | // else WINPOS_ShowIconTitle( hwnd, TRUE );
|
|---|
| 767 | }
|
|---|
| 768 | }
|
|---|
| 769 |
|
|---|
| 770 | #endif //#ifdef CUSTOM_TRACKFRAME
|
|---|