home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.1.382 < prev    next >
Encoding:
Internet Message Format  |  2003-03-08  |  5.1 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.382 (extra)
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.1.382 (extra)
  11. Problem:    Win32 GUI: When using two monitors, the code that checks/fixes the
  12.         window size and position (e.g. when a font changes) doesn't work
  13.         properly.  (George Reilly)
  14. Solution:   Handle a double monitor situation. (Helmut Stiegler)
  15. Files:        src/gui_w32.c
  16.  
  17.  
  18. *** ../vim61.381/src/gui_w32.c    Sat Feb 22 14:09:00 2003
  19. --- src/gui_w32.c    Sun Mar  9 16:13:10 2003
  20. ***************
  21. *** 271,276 ****
  22. --- 271,293 ----
  23.   # define ETO_IGNORELANGUAGE  0x1000
  24.   #endif
  25.   
  26. + /* multi monitor support */
  27. + typedef struct _MONITORINFOstruct
  28. + {
  29. +     DWORD cbSize;
  30. +     RECT rcMonitor;
  31. +     RECT rcWork;
  32. +     DWORD dwFlags;
  33. + } _MONITORINFO;
  34. + typedef HANDLE _HMONITOR;
  35. + typedef _HMONITOR (WINAPI *TMonitorFromWindow)(HWND, DWORD);
  36. + typedef BOOL (WINAPI *TGetMonitorInfo)(_HMONITOR, _MONITORINFO *);
  37. + static TMonitorFromWindow   pMonitorFromWindow = NULL;
  38. + static TGetMonitorInfo        pGetMonitorInfo = NULL;
  39. + static HANDLE            user32_lib = NULL;
  40.   /*
  41.    * Return TRUE when running under Windows NT 3.x or Win32s, both of which have
  42.    * less fancy GUI APIs.
  43. ***************
  44. *** 944,949 ****
  45. --- 961,979 ----
  46.       /* get the OS version info */
  47.       os_version.dwOSVersionInfoSize = sizeof(os_version);
  48.       GetVersionEx(&os_version); /* this call works on Win32s, Win95 and WinNT */
  49. +     /* try and load the user32.dll library and get the entry points for
  50. +      * multi-monitor-support. */
  51. +     if ((user32_lib = LoadLibrary("User32.dll")) != NULL)
  52. +     {
  53. +         pMonitorFromWindow = (TMonitorFromWindow)GetProcAddress(user32_lib,
  54. +                              "MonitorFromWindow");
  55. +         /* there are ...A and ...W version of GetMonitorInfo - looking at
  56. +          * winuser.h, they have exactly the same declaration. */
  57. +         pGetMonitorInfo = (TGetMonitorInfo)GetProcAddress(user32_lib,
  58. +                                                           "GetMonitorInfoA");
  59. +     }
  60.   }
  61.   
  62.   /*
  63. ***************
  64. *** 1128,1133 ****
  65. --- 1158,1191 ----
  66.       return OK;
  67.   }
  68.   
  69. + /*
  70. +  * Get the size of the screen, taking position on multiple monitors into
  71. +  * account (if supported).
  72. +  */
  73. +     static void
  74. + get_work_area(RECT *spi_rect)
  75. + {
  76. +     _HMONITOR        mon;
  77. +     _MONITORINFO    moninfo;
  78. +     /* use these functions only if available */
  79. +     if (pMonitorFromWindow != NULL && pGetMonitorInfo != NULL)
  80. +     {
  81. +     /* work out which monitor the window is on, and get *it's* work area */
  82. +     mon = pMonitorFromWindow(s_hwnd, 1 /*MONITOR_DEFAULTTOPRIMARY*/);
  83. +     if (mon != NULL)
  84. +     {
  85. +         moninfo.cbSize = sizeof(_MONITORINFO);
  86. +         if (pGetMonitorInfo(mon, &moninfo))
  87. +         {
  88. +         *spi_rect = moninfo.rcWork;
  89. +         return;
  90. +         }
  91. +     }
  92. +     }
  93. +     /* this is the old method... */
  94. +     SystemParametersInfo(SPI_GETWORKAREA, 0, spi_rect, 0);
  95. + }
  96.   
  97.   /*
  98.    * Set the size of the window to the given width and height in pixels.
  99. ***************
  100. *** 1143,1149 ****
  101.   
  102.       /* try to keep window completely on screen */
  103.       /* get size of the screen work area (excludes taskbar, appbars) */
  104. !     SystemParametersInfo(SPI_GETWORKAREA, 0, &workarea_rect, 0);
  105.   
  106.       /* get current posision of our window */
  107.       wndpl.length = sizeof(WINDOWPLACEMENT);
  108. --- 1201,1207 ----
  109.   
  110.       /* try to keep window completely on screen */
  111.       /* get size of the screen work area (excludes taskbar, appbars) */
  112. !     get_work_area(&workarea_rect);
  113.   
  114.       /* get current posision of our window */
  115.       wndpl.length = sizeof(WINDOWPLACEMENT);
  116. ***************
  117. *** 1184,1192 ****
  118.       if (win_ypos < workarea_rect.top)
  119.       win_ypos = workarea_rect.top;
  120.   
  121. !     /* set window position */
  122. !     SetWindowPos(s_hwnd, NULL, win_xpos, win_ypos, win_width, win_height,
  123. !          SWP_NOZORDER | SWP_NOACTIVATE);
  124.   
  125.   #ifdef FEAT_MENU
  126.       /* Menu may wrap differently now */
  127. --- 1242,1256 ----
  128.       if (win_ypos < workarea_rect.top)
  129.       win_ypos = workarea_rect.top;
  130.   
  131. !     wndpl.rcNormalPosition.left = win_xpos;
  132. !     wndpl.rcNormalPosition.right = win_xpos + win_width;
  133. !     wndpl.rcNormalPosition.top = win_ypos;
  134. !     wndpl.rcNormalPosition.bottom = win_ypos + win_height;
  135. !     /* set window position - we should use SetWindowPlacement rather than
  136. !      * SetWindowPos as the MSDN docs say the coord systems returned by
  137. !      * these two are not compatible. */
  138. !     SetWindowPlacement(s_hwnd, &wndpl);
  139.   
  140.   #ifdef FEAT_MENU
  141.       /* Menu may wrap differently now */
  142. *** ../vim61.381/src/version.c    Sun Mar  9 15:48:31 2003
  143. --- src/version.c    Sun Mar  9 16:17:15 2003
  144. ***************
  145. *** 613,614 ****
  146. --- 613,616 ----
  147.   {   /* Add new patch number below this line */
  148. + /**/
  149. +     382,
  150.   /**/
  151.  
  152. -- 
  153. hundred-and-one symptoms of being an internet addict:
  154. 2. You kiss your girlfriend's home page.
  155.  
  156.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  157. ///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
  158. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  159.  \\\     Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
  160.