Mercurial > vim
comparison src/gui_w32.c @ 3248:e0248b732a5c v7.3.393
updated for version 7.3.393
Problem: Win32: When resizing Vim it is always moved to the primary monitor
if the secondary monitor is on the left.
Solution: Use the nearest monitor. (Yukihiro Nakadaira)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 04 Jan 2012 20:29:22 +0100 |
parents | 2260435283f2 |
children | e6d8b44065bc |
comparison
equal
deleted
inserted
replaced
3247:10409da047b3 | 3248:e0248b732a5c |
---|---|
1659 int min_width, int min_height, int base_width, int base_height, | 1659 int min_width, int min_height, int base_width, int base_height, |
1660 int direction) | 1660 int direction) |
1661 { | 1661 { |
1662 RECT workarea_rect; | 1662 RECT workarea_rect; |
1663 int win_width, win_height; | 1663 int win_width, win_height; |
1664 int win_xpos, win_ypos; | |
1665 WINDOWPLACEMENT wndpl; | 1664 WINDOWPLACEMENT wndpl; |
1666 int workarea_left; | |
1667 | 1665 |
1668 /* Try to keep window completely on screen. */ | 1666 /* Try to keep window completely on screen. */ |
1669 /* Get position of the screen work area. This is the part that is not | 1667 /* Get position of the screen work area. This is the part that is not |
1670 * used by the taskbar or appbars. */ | 1668 * used by the taskbar or appbars. */ |
1671 get_work_area(&workarea_rect); | 1669 get_work_area(&workarea_rect); |
1682 { | 1680 { |
1683 ShowWindow(s_hwnd, SW_SHOWNORMAL); | 1681 ShowWindow(s_hwnd, SW_SHOWNORMAL); |
1684 /* Need to get the settings of the normal window. */ | 1682 /* Need to get the settings of the normal window. */ |
1685 GetWindowPlacement(s_hwnd, &wndpl); | 1683 GetWindowPlacement(s_hwnd, &wndpl); |
1686 } | 1684 } |
1687 | |
1688 win_xpos = wndpl.rcNormalPosition.left; | |
1689 win_ypos = wndpl.rcNormalPosition.top; | |
1690 | 1685 |
1691 /* compute the size of the outside of the window */ | 1686 /* compute the size of the outside of the window */ |
1692 win_width = width + GetSystemMetrics(SM_CXFRAME) * 2; | 1687 win_width = width + GetSystemMetrics(SM_CXFRAME) * 2; |
1693 win_height = height + GetSystemMetrics(SM_CYFRAME) * 2 | 1688 win_height = height + GetSystemMetrics(SM_CYFRAME) * 2 |
1694 + GetSystemMetrics(SM_CYCAPTION) | 1689 + GetSystemMetrics(SM_CYCAPTION) |
1695 #ifdef FEAT_MENU | 1690 #ifdef FEAT_MENU |
1696 + gui_mswin_get_menu_height(FALSE) | 1691 + gui_mswin_get_menu_height(FALSE) |
1697 #endif | 1692 #endif |
1698 ; | 1693 ; |
1699 | 1694 |
1700 /* There is an inconsistency when using two monitors and Vim is on the | 1695 /* The following should take care of keeping Vim on the same monitor, no |
1701 * second (right) one: win_xpos will be the offset from the workarea of | 1696 * matter if the secondary monitor is left or right of the primary |
1702 * the left monitor. While with one monitor it's the offset from the | 1697 * monitor. */ |
1703 * workarea (including a possible taskbar on the left). Detect the second | 1698 wndpl.rcNormalPosition.right = wndpl.rcNormalPosition.left + win_width; |
1704 * monitor by checking for the left offset to be quite big. */ | 1699 wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + win_height; |
1705 if (workarea_rect.left > 300) | 1700 |
1706 workarea_left = 0; | 1701 /* If the window is going off the screen, move it on to the screen. */ |
1707 else | |
1708 workarea_left = workarea_rect.left; | |
1709 | |
1710 /* If the window is going off the screen, move it on to the screen. | |
1711 * win_xpos and win_ypos are relative to the workarea. */ | |
1712 if ((direction & RESIZE_HOR) | 1702 if ((direction & RESIZE_HOR) |
1713 && workarea_left + win_xpos + win_width > workarea_rect.right) | 1703 && wndpl.rcNormalPosition.right > workarea_rect.right) |
1714 win_xpos = workarea_rect.right - win_width - workarea_left; | 1704 OffsetRect(&wndpl.rcNormalPosition, |
1715 | 1705 workarea_rect.right - wndpl.rcNormalPosition.right, 0); |
1716 if ((direction & RESIZE_HOR) && win_xpos < 0) | 1706 |
1717 win_xpos = 0; | 1707 if ((direction & RESIZE_HOR) |
1708 && wndpl.rcNormalPosition.left < workarea_rect.left) | |
1709 OffsetRect(&wndpl.rcNormalPosition, | |
1710 workarea_rect.left - wndpl.rcNormalPosition.left, 0); | |
1718 | 1711 |
1719 if ((direction & RESIZE_VERT) | 1712 if ((direction & RESIZE_VERT) |
1720 && workarea_rect.top + win_ypos + win_height > workarea_rect.bottom) | 1713 && wndpl.rcNormalPosition.bottom > workarea_rect.bottom) |
1721 win_ypos = workarea_rect.bottom - win_height - workarea_rect.top; | 1714 OffsetRect(&wndpl.rcNormalPosition, |
1722 | 1715 0, workarea_rect.bottom - wndpl.rcNormalPosition.bottom); |
1723 if ((direction & RESIZE_VERT) && win_ypos < 0) | 1716 |
1724 win_ypos = 0; | 1717 if ((direction & RESIZE_VERT) |
1725 | 1718 && wndpl.rcNormalPosition.top < workarea_rect.top) |
1726 wndpl.rcNormalPosition.left = win_xpos; | 1719 OffsetRect(&wndpl.rcNormalPosition, |
1727 wndpl.rcNormalPosition.right = win_xpos + win_width; | 1720 0, workarea_rect.top - wndpl.rcNormalPosition.top); |
1728 wndpl.rcNormalPosition.top = win_ypos; | |
1729 wndpl.rcNormalPosition.bottom = win_ypos + win_height; | |
1730 | 1721 |
1731 /* set window position - we should use SetWindowPlacement rather than | 1722 /* set window position - we should use SetWindowPlacement rather than |
1732 * SetWindowPos as the MSDN docs say the coord systems returned by | 1723 * SetWindowPos as the MSDN docs say the coord systems returned by |
1733 * these two are not compatible. */ | 1724 * these two are not compatible. */ |
1734 SetWindowPlacement(s_hwnd, &wndpl); | 1725 SetWindowPlacement(s_hwnd, &wndpl); |