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)
Files: src/gui_w32.c
*** ../vim-8.0.0112/src/gui_w32.c 2016-11-10 20:01:41.193582919 +0100
--- src/gui_w32.c 2016-12-01 20:16:47.184213794 +0100
***************
*** 2297,2315 ****
# define GetTextWidthEnc(h, s, l) GetTextWidth((h), (s), (l))
#endif
/*
* A quick little routine that will center one window over another, handy for
! * dialog boxes. Taken from the Win32SDK samples.
*/
static BOOL
CenterWindow(
HWND hwndChild,
HWND hwndParent)
{
! RECT rChild, rParent;
! int wChild, hChild, wParent, hParent;
! int wScreen, hScreen, xNew, yNew;
! HDC hdc;
GetWindowRect(hwndChild, &rChild);
wChild = rChild.right - rChild.left;
--- 2297,2320 ----
# define GetTextWidthEnc(h, s, l) GetTextWidth((h), (s), (l))
#endif
+ static void get_work_area(RECT *spi_rect);
+
/*
* A quick little routine that will center one window over another, handy for
! * dialog boxes. Taken from the Win32SDK samples and modified for multiple
! * monitors.
*/
static BOOL
CenterWindow(
HWND hwndChild,
HWND hwndParent)
{
! HMONITOR mon;
! MONITORINFO moninfo;
! RECT rChild, rParent, rScreen;
! int wChild, hChild, wParent, hParent;
! int xNew, yNew;
! HDC hdc;
GetWindowRect(hwndChild, &rChild);
wChild = rChild.right - rChild.left;
***************
*** 2317,2348 ****
/* If Vim is minimized put the window in the middle of the screen. */
if (hwndParent == NULL || IsMinimized(hwndParent))
! SystemParametersInfo(SPI_GETWORKAREA, 0, &rParent, 0);
else
GetWindowRect(hwndParent, &rParent);
wParent = rParent.right - rParent.left;
hParent = rParent.bottom - rParent.top;
! hdc = GetDC(hwndChild);
! wScreen = GetDeviceCaps (hdc, HORZRES);
! hScreen = GetDeviceCaps (hdc, VERTRES);
! ReleaseDC(hwndChild, hdc);
!
! xNew = rParent.left + ((wParent - wChild) /2);
! if (xNew < 0)
{
! xNew = 0;
}
! else if ((xNew+wChild) > wScreen)
{
! xNew = wScreen - wChild;
! }
!
! yNew = rParent.top + ((hParent - hChild) /2);
! if (yNew < 0)
! yNew = 0;
! else if ((yNew+hChild) > hScreen)
! yNew = hScreen - hChild;
return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
SWP_NOSIZE | SWP_NOZORDER);
--- 2322,2360 ----
/* If Vim is minimized put the window in the middle of the screen. */
if (hwndParent == NULL || IsMinimized(hwndParent))
! get_work_area(&rParent);
else
GetWindowRect(hwndParent, &rParent);
wParent = rParent.right - rParent.left;
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);
! rScreen.left = 0;
! rScreen.top = 0;
! rScreen.right = GetDeviceCaps(hdc, HORZRES);
! rScreen.bottom = GetDeviceCaps(hdc, VERTRES);
! ReleaseDC(hwndChild, hdc);
! }
!
! xNew = rParent.left + ((wParent - wChild) / 2);
! if (xNew < rScreen.left)
! xNew = rScreen.left;
! else if ((xNew + wChild) > rScreen.right)
! xNew = rScreen.right - wChild;
!
! yNew = rParent.top + ((hParent - hChild) / 2);
! if (yNew < rScreen.top)
! yNew = rScreen.top;
! else if ((yNew + hChild) > rScreen.bottom)
! yNew = rScreen.bottom - hChild;
return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
SWP_NOSIZE | SWP_NOZORDER);
***************
*** 5559,5565 ****
MONITORINFO moninfo;
/* work out which monitor the window is on, and get *it's* work area */
! mon = MonitorFromWindow(s_hwnd, 1 /*MONITOR_DEFAULTTOPRIMARY*/);
if (mon != NULL)
{
moninfo.cbSize = sizeof(MONITORINFO);
--- 5571,5577 ----
MONITORINFO moninfo;
/* work out which monitor the window is on, and get *it's* work area */
! mon = MonitorFromWindow(s_hwnd, MONITOR_DEFAULTTOPRIMARY);
if (mon != NULL)
{
moninfo.cbSize = sizeof(MONITORINFO);
*** ../vim-8.0.0112/src/version.c 2016-12-01 18:47:06.595684409 +0100
--- src/version.c 2016-12-01 20:18:09.215671446 +0100
***************
*** 766,767 ****
--- 766,769 ----
{ /* Add new patch number below this line */
+ /**/
+ 113,
/**/
--
hundred-and-one symptoms of being an internet addict:
72. Somebody at IRC just mentioned a way to obtain full motion video without
a PC using a wireless protocol called NTSC, you wonder how you never
heard about it
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.