@@ -1429,7 +1429,7 @@ gui_mch_create_scrollbar(
14291429/*
14301430 * Find the scrollbar with the given hwnd.
14311431 */
1432- static scrollbar_T *
1432+ static scrollbar_T *
14331433gui_mswin_find_scrollbar (HWND hwnd )
14341434{
14351435 win_T * wp ;
@@ -5395,28 +5395,21 @@ gui_mch_set_shellsize(
53955395 int direction )
53965396{
53975397 RECT workarea_rect ;
5398+ RECT window_rect ;
53985399 int win_width , win_height ;
5399- WINDOWPLACEMENT wndpl ;
54005400
54015401 // Try to keep window completely on screen.
54025402 // Get position of the screen work area. This is the part that is not
54035403 // used by the taskbar or appbars.
54045404 get_work_area (& workarea_rect );
54055405
5406- // Get current position of our window. Note that the .left and .top are
5407- // relative to the work area.
5408- wndpl .length = sizeof (WINDOWPLACEMENT );
5409- GetWindowPlacement (s_hwnd , & wndpl );
5410-
54115406 // Resizing a maximized window looks very strange, unzoom it first.
54125407 // But don't do it when still starting up, it may have been requested in
54135408 // the shortcut.
5414- if (wndpl .showCmd == SW_SHOWMAXIMIZED && starting == 0 )
5415- {
5409+ if (IsZoomed (s_hwnd ) && starting == 0 )
54165410 ShowWindow (s_hwnd , SW_SHOWNORMAL );
5417- // Need to get the settings of the normal window.
5418- GetWindowPlacement (s_hwnd , & wndpl );
5419- }
5411+
5412+ GetWindowRect (s_hwnd , & window_rect );
54205413
54215414 // compute the size of the outside of the window
54225415 win_width = width + (GetSystemMetrics (SM_CXFRAME ) +
@@ -5432,34 +5425,24 @@ gui_mch_set_shellsize(
54325425 // The following should take care of keeping Vim on the same monitor, no
54335426 // matter if the secondary monitor is left or right of the primary
54345427 // monitor.
5435- wndpl . rcNormalPosition . right = wndpl . rcNormalPosition .left + win_width ;
5436- wndpl . rcNormalPosition . bottom = wndpl . rcNormalPosition .top + win_height ;
5428+ window_rect . right = window_rect .left + win_width ;
5429+ window_rect . bottom = window_rect .top + win_height ;
54375430
54385431 // If the window is going off the screen, move it on to the screen.
5439- if ((direction & RESIZE_HOR )
5440- && wndpl .rcNormalPosition .right > workarea_rect .right )
5441- OffsetRect (& wndpl .rcNormalPosition ,
5442- workarea_rect .right - wndpl .rcNormalPosition .right , 0 );
5443-
5444- if ((direction & RESIZE_HOR )
5445- && wndpl .rcNormalPosition .left < workarea_rect .left )
5446- OffsetRect (& wndpl .rcNormalPosition ,
5447- workarea_rect .left - wndpl .rcNormalPosition .left , 0 );
5448-
5449- if ((direction & RESIZE_VERT )
5450- && wndpl .rcNormalPosition .bottom > workarea_rect .bottom )
5451- OffsetRect (& wndpl .rcNormalPosition ,
5452- 0 , workarea_rect .bottom - wndpl .rcNormalPosition .bottom );
5453-
5454- if ((direction & RESIZE_VERT )
5455- && wndpl .rcNormalPosition .top < workarea_rect .top )
5456- OffsetRect (& wndpl .rcNormalPosition ,
5457- 0 , workarea_rect .top - wndpl .rcNormalPosition .top );
5458-
5459- // set window position - we should use SetWindowPlacement rather than
5460- // SetWindowPos as the MSDN docs say the coord systems returned by
5461- // these two are not compatible.
5462- SetWindowPlacement (s_hwnd , & wndpl );
5432+ if ((direction & RESIZE_HOR ) && window_rect .right > workarea_rect .right )
5433+ OffsetRect (& window_rect , workarea_rect .right - window_rect .right , 0 );
5434+
5435+ if ((direction & RESIZE_HOR ) && window_rect .left < workarea_rect .left )
5436+ OffsetRect (& window_rect , workarea_rect .left - window_rect .left , 0 );
5437+
5438+ if ((direction & RESIZE_VERT ) && window_rect .bottom > workarea_rect .bottom )
5439+ OffsetRect (& window_rect , 0 , workarea_rect .bottom - window_rect .bottom );
5440+
5441+ if ((direction & RESIZE_VERT ) && window_rect .top < workarea_rect .top )
5442+ OffsetRect (& window_rect , 0 , workarea_rect .top - window_rect .top );
5443+
5444+ MoveWindow (s_hwnd , window_rect .left , window_rect .top ,
5445+ win_width , win_height , TRUE);
54635446
54645447 SetActiveWindow (s_hwnd );
54655448 SetFocus (s_hwnd );
0 commit comments