Mercurial > pidgin.yaz
comparison pidgin/win32/gtkwin32dep.c @ 20242:c320bc7b1383
applied changes from 1036f20a46ec1ba10dd2519fd09b44a607cdf202
through efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 28 Sep 2007 15:56:31 +0000 |
parents | 44b4e8bd759b |
children | c9c6f77f624e |
comparison
equal
deleted
inserted
replaced
20241:76960ecdc159 | 20242:c320bc7b1383 |
---|---|
426 CopyRect(workingAreaRc, &(info.rcWork)); | 426 CopyRect(workingAreaRc, &(info.rcWork)); |
427 return TRUE; | 427 return TRUE; |
428 } | 428 } |
429 | 429 |
430 void winpidgin_ensure_onscreen(GtkWidget *win) { | 430 void winpidgin_ensure_onscreen(GtkWidget *win) { |
431 RECT windowRect, workingAreaRect, intersectionRect; | 431 RECT winR, wAR, intR; |
432 HWND hwnd = GDK_WINDOW_HWND(win->window); | 432 HWND hwnd = GDK_WINDOW_HWND(win->window); |
433 | 433 |
434 g_return_if_fail(hwnd != NULL); | 434 g_return_if_fail(hwnd != NULL); |
435 GetWindowRect(hwnd, &windowRect); | 435 GetWindowRect(hwnd, &winR); |
436 | 436 |
437 purple_debug_info("win32placement", | 437 purple_debug_info("win32placement", |
438 "Window RECT: L:%ld R:%ld T:%ld B:%ld\n", | 438 "Window RECT: L:%ld R:%ld T:%ld B:%ld\n", |
439 windowRect.left, windowRect.right, | 439 winR.left, winR.right, |
440 windowRect.top, windowRect.bottom); | 440 winR.top, winR.bottom); |
441 | 441 |
442 if(!get_WorkingAreaRectForWindow(hwnd, &workingAreaRect)) { | 442 if(!get_WorkingAreaRectForWindow(hwnd, &wAR)) { |
443 purple_debug_info("win32placement", | 443 purple_debug_info("win32placement", |
444 "Couldn't get multimonitor working area\n"); | 444 "Couldn't get multimonitor working area\n"); |
445 if(!SystemParametersInfo(SPI_GETWORKAREA, 0, &workingAreaRect, FALSE)) { | 445 if(!SystemParametersInfo(SPI_GETWORKAREA, 0, &wAR, FALSE)) { |
446 /* I don't think this will ever happen */ | 446 /* I don't think this will ever happen */ |
447 workingAreaRect.left = 0; | 447 wAR.left = 0; |
448 workingAreaRect.top = 0; | 448 wAR.top = 0; |
449 workingAreaRect.bottom = GetSystemMetrics(SM_CYSCREEN); | 449 wAR.bottom = GetSystemMetrics(SM_CYSCREEN); |
450 workingAreaRect.right = GetSystemMetrics(SM_CXSCREEN); | 450 wAR.right = GetSystemMetrics(SM_CXSCREEN); |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 purple_debug_info("win32placement", | 454 purple_debug_info("win32placement", |
455 "Working Area RECT: L:%ld R:%ld T:%ld B:%ld\n", | 455 "Working Area RECT: L:%ld R:%ld T:%ld B:%ld\n", |
456 workingAreaRect.left, workingAreaRect.right, | 456 wAR.left, wAR.right, |
457 workingAreaRect.top, workingAreaRect.bottom); | 457 wAR.top, wAR.bottom); |
458 | 458 |
459 /** If the conversation window doesn't intersect perfectly with the working area, | 459 /** If the conversation window doesn't intersect perfectly, move it to do so */ |
460 * move it to the top left corner of the working area */ | 460 if(!(IntersectRect(&intR, &winR, &wAR) |
461 if(!(IntersectRect(&intersectionRect, &windowRect, &workingAreaRect) | 461 && EqualRect(&intR, &winR))) { |
462 && EqualRect(&intersectionRect, &windowRect))) { | |
463 purple_debug_info("win32placement", | 462 purple_debug_info("win32placement", |
464 "conversation window out of working area, relocating\n"); | 463 "conversation window out of working area, relocating\n"); |
465 MoveWindow(hwnd, workingAreaRect.left, workingAreaRect.top, | 464 |
466 (windowRect.right - windowRect.left), | 465 /* Make sure the working area is big enough. */ |
467 (windowRect.bottom - windowRect.top), TRUE); | 466 if ((winR.right - winR.left) <= (wAR.right - wAR.left) |
468 } | 467 && (winR.bottom - winR.top) <= (wAR.bottom - wAR.top)) { |
469 } | 468 /* Is it off the bottom? */ |
470 | 469 if (winR.bottom > wAR.bottom) { |
470 winR.top = wAR.bottom - (winR.bottom - winR.top); | |
471 winR.bottom = wAR.bottom; | |
472 } | |
473 /* Is it off the top? */ | |
474 else if (winR.top < wAR.top) { | |
475 winR.bottom = wAR.top + (winR.bottom - winR.top); | |
476 winR.top = wAR.top; | |
477 } | |
478 | |
479 /* Is it off the left? */ | |
480 if (winR.left < wAR.left) { | |
481 winR.right = wAR.left + (winR.right - winR.left); | |
482 winR.left = wAR.left; | |
483 } | |
484 /* Is it off the right? */ | |
485 else if (winR.right > wAR.right) { | |
486 winR.left = wAR.right - (winR.right - winR.left); | |
487 winR.right = wAR.right; | |
488 } | |
489 | |
490 } else { | |
491 /* We couldn't salvage it; move it to the top left corner of the working area */ | |
492 winR.right = wAR.left + (winR.right - winR.left); | |
493 winR.bottom = wAR.top + (winR.bottom - winR.top); | |
494 winR.left = wAR.left; | |
495 winR.top = wAR.top; | |
496 } | |
497 | |
498 purple_debug_info("win32placement", | |
499 "Relocation RECT: L:%ld R:%ld T:%ld B:%ld\n", | |
500 winR.left, winR.right, | |
501 winR.top, winR.bottom); | |
502 | |
503 MoveWindow(hwnd, winR.left, winR.top, | |
504 (winR.right - winR.left), | |
505 (winR.bottom - winR.top), TRUE); | |
506 } | |
507 } | |
508 |