mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.0.0113
Problem: MS-Windows: message box to prompt for saving changes may appear on the wrong monitor. Solution: Adjust the CenterWindow function. (Ken Takata)
This commit is contained in:
parent
eca626fcdb
commit
87f3d202a9
@ -2297,18 +2297,23 @@ GetTextWidthEnc(HDC hdc, char_u *str, int len)
|
|||||||
# define GetTextWidthEnc(h, s, l) GetTextWidth((h), (s), (l))
|
# define GetTextWidthEnc(h, s, l) GetTextWidth((h), (s), (l))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void get_work_area(RECT *spi_rect);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A quick little routine that will center one window over another, handy for
|
* A quick little routine that will center one window over another, handy for
|
||||||
* dialog boxes. Taken from the Win32SDK samples.
|
* dialog boxes. Taken from the Win32SDK samples and modified for multiple
|
||||||
|
* monitors.
|
||||||
*/
|
*/
|
||||||
static BOOL
|
static BOOL
|
||||||
CenterWindow(
|
CenterWindow(
|
||||||
HWND hwndChild,
|
HWND hwndChild,
|
||||||
HWND hwndParent)
|
HWND hwndParent)
|
||||||
{
|
{
|
||||||
RECT rChild, rParent;
|
HMONITOR mon;
|
||||||
|
MONITORINFO moninfo;
|
||||||
|
RECT rChild, rParent, rScreen;
|
||||||
int wChild, hChild, wParent, hParent;
|
int wChild, hChild, wParent, hParent;
|
||||||
int wScreen, hScreen, xNew, yNew;
|
int xNew, yNew;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
|
|
||||||
GetWindowRect(hwndChild, &rChild);
|
GetWindowRect(hwndChild, &rChild);
|
||||||
@ -2317,32 +2322,39 @@ CenterWindow(
|
|||||||
|
|
||||||
/* If Vim is minimized put the window in the middle of the screen. */
|
/* If Vim is minimized put the window in the middle of the screen. */
|
||||||
if (hwndParent == NULL || IsMinimized(hwndParent))
|
if (hwndParent == NULL || IsMinimized(hwndParent))
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &rParent, 0);
|
get_work_area(&rParent);
|
||||||
else
|
else
|
||||||
GetWindowRect(hwndParent, &rParent);
|
GetWindowRect(hwndParent, &rParent);
|
||||||
wParent = rParent.right - rParent.left;
|
wParent = rParent.right - rParent.left;
|
||||||
hParent = rParent.bottom - rParent.top;
|
hParent = rParent.bottom - rParent.top;
|
||||||
|
|
||||||
|
moninfo.cbSize = sizeof(MONITORINFO);
|
||||||
|
mon = MonitorFromWindow(hwndChild, MONITOR_DEFAULTTOPRIMARY);
|
||||||
|
if (mon != NULL && GetMonitorInfo(mon, &moninfo))
|
||||||
|
{
|
||||||
|
rScreen = moninfo.rcWork;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
hdc = GetDC(hwndChild);
|
hdc = GetDC(hwndChild);
|
||||||
wScreen = GetDeviceCaps (hdc, HORZRES);
|
rScreen.left = 0;
|
||||||
hScreen = GetDeviceCaps (hdc, VERTRES);
|
rScreen.top = 0;
|
||||||
|
rScreen.right = GetDeviceCaps(hdc, HORZRES);
|
||||||
|
rScreen.bottom = GetDeviceCaps(hdc, VERTRES);
|
||||||
ReleaseDC(hwndChild, hdc);
|
ReleaseDC(hwndChild, hdc);
|
||||||
|
}
|
||||||
|
|
||||||
xNew = rParent.left + ((wParent - wChild) / 2);
|
xNew = rParent.left + ((wParent - wChild) / 2);
|
||||||
if (xNew < 0)
|
if (xNew < rScreen.left)
|
||||||
{
|
xNew = rScreen.left;
|
||||||
xNew = 0;
|
else if ((xNew + wChild) > rScreen.right)
|
||||||
}
|
xNew = rScreen.right - wChild;
|
||||||
else if ((xNew+wChild) > wScreen)
|
|
||||||
{
|
|
||||||
xNew = wScreen - wChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
yNew = rParent.top + ((hParent - hChild) / 2);
|
yNew = rParent.top + ((hParent - hChild) / 2);
|
||||||
if (yNew < 0)
|
if (yNew < rScreen.top)
|
||||||
yNew = 0;
|
yNew = rScreen.top;
|
||||||
else if ((yNew+hChild) > hScreen)
|
else if ((yNew + hChild) > rScreen.bottom)
|
||||||
yNew = hScreen - hChild;
|
yNew = rScreen.bottom - hChild;
|
||||||
|
|
||||||
return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
|
return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
|
||||||
SWP_NOSIZE | SWP_NOZORDER);
|
SWP_NOSIZE | SWP_NOZORDER);
|
||||||
@ -5559,7 +5571,7 @@ get_work_area(RECT *spi_rect)
|
|||||||
MONITORINFO moninfo;
|
MONITORINFO moninfo;
|
||||||
|
|
||||||
/* work out which monitor the window is on, and get *it's* work area */
|
/* work out which monitor the window is on, and get *it's* work area */
|
||||||
mon = MonitorFromWindow(s_hwnd, 1 /*MONITOR_DEFAULTTOPRIMARY*/);
|
mon = MonitorFromWindow(s_hwnd, MONITOR_DEFAULTTOPRIMARY);
|
||||||
if (mon != NULL)
|
if (mon != NULL)
|
||||||
{
|
{
|
||||||
moninfo.cbSize = sizeof(MONITORINFO);
|
moninfo.cbSize = sizeof(MONITORINFO);
|
||||||
|
@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
113,
|
||||||
/**/
|
/**/
|
||||||
112,
|
112,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user