From: Mao-Yining <101858210+mao-yining@users.noreply.github.com> Date: Sun, 21 Dec 2025 19:31:24 +0000 (+0000) Subject: patch 9.1.2005: MS-Windows: Missing fullscreen support for GUI version X-Git-Tag: v9.1.2005^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49e0f833dd285df9ab7bdeb8c4a629d8252e6247;p=thirdparty%2Fvim.git patch 9.1.2005: MS-Windows: Missing fullscreen support for GUI version Problem: MS-Windows: Missing fullscreen support for GUI version Solution: Add "s" flag to guioptions (Mao-Yining) - Implement fullscreen mode controlled by the 'go-s' flag in 'guioptions' - Update documentation with usage examples and platform-specific details See :help 'go-s' and :help gui-w32-fullscreen for complete documentation. closes: #18836 Signed-off-by: Mao-Yining <101858210+mao-yining@users.noreply.github.com> Signed-off-by: Christian Brabandt --- diff --git a/runtime/doc/gui_w32.txt b/runtime/doc/gui_w32.txt index 6dc53a0446..475b12e962 100644 --- a/runtime/doc/gui_w32.txt +++ b/runtime/doc/gui_w32.txt @@ -1,4 +1,4 @@ -*gui_w32.txt* For Vim version 9.1. Last change: 2025 Nov 09 +*gui_w32.txt* For Vim version 9.1. Last change: 2025 Dec 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -504,4 +504,25 @@ To use the system's default title bar colors, set highlighting groups to hi TitleBar guibg=NONE guifg=NONE hi TitleBarNC guibg=NONE guifg=NONE < + +Full Screen *gui-w32-fullscreen* + +To enable fullscreen mode in the Windows GUI version of Vim, add the 's' flag +to the 'guioptions' setting. + +For convenience, you can define a command or mapping to toggle fullscreen mode: +> + command! ToggleFullscreen { + if &guioptions =~# 's' + set guioptions-=s + else + set guioptions+=s + endif + } + + map &go =~# 's' ? ":se go-=s" : ":se go+=s" + +The fullscreen mode will occupy the entire screen area while hiding window +decorations such as the title bar and borders. + vim:tw=78:sw=4:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index a8dbab912b..5130a28318 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 9.1. Last change: 2025 Dec 18 +*options.txt* For Vim version 9.1. Last change: 2025 Dec 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -4572,6 +4572,12 @@ A jump table for the options with a short description can be found at |Q_op|. *'go-T'* 'T' Include Toolbar. Currently only in Win32, GTK+, Motif and Photon GUIs. + *'go-s'* + 's' Enable fullscreen mode. Currently only supported in the + MS-Windows GUI version. When set, the window will occupy the + entire screen and remove window decorations. Define custom + mappings to toggle this mode conveniently. For detailed usage + instructions, see |gui-w32-fullscreen|. *'go-r'* 'r' Right-hand scrollbar is always present. *'go-R'* diff --git a/runtime/doc/tags b/runtime/doc/tags index 05e967c4e6..6a00cc789b 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -377,6 +377,7 @@ $quote eval.txt /*$quote* 'go-m' options.txt /*'go-m'* 'go-p' options.txt /*'go-p'* 'go-r' options.txt /*'go-r'* +'go-s' options.txt /*'go-s'* 'go-t' options.txt /*'go-t'* 'go-v' options.txt /*'go-v'* 'gp' options.txt /*'gp'* @@ -8249,6 +8250,7 @@ gui-vert-scroll gui.txt /*gui-vert-scroll* gui-w32 gui_w32.txt /*gui-w32* gui-w32-cmdargs gui_w32.txt /*gui-w32-cmdargs* gui-w32-dialogs gui_w32.txt /*gui-w32-dialogs* +gui-w32-fullscreen gui_w32.txt /*gui-w32-fullscreen* gui-w32-printing gui_w32.txt /*gui-w32-printing* gui-w32-start gui_w32.txt /*gui-w32-start* gui-w32-title-bar gui_w32.txt /*gui-w32-title-bar* diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt index 1071613fea..f1cfd09797 100644 --- a/runtime/doc/version9.txt +++ b/runtime/doc/version9.txt @@ -1,4 +1,4 @@ -*version9.txt* For Vim version 9.1. Last change: 2025 Dec 15 +*version9.txt* For Vim version 9.1. Last change: 2025 Dec 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -41724,6 +41724,8 @@ Options: ~ (see also the below platform specific change). - 'guioptions': Support darkmode on MS-Windows for menu and title bar using |'go-d'| (see also the below platform specific change). +- 'guioptions': New value |'go-s'| to support fullscreen on MS-Windows GUI + (see also the below platform specific change). - 'completepopup': Add more values to style popup windows. Ex commands: ~ @@ -41768,6 +41770,7 @@ Platform specific ~ - MS-Windows: Vim no longer searches the current directory for executables when running external commands; prefix a relative or absolute path if you want the old behavior |$NoDefaultCurrentDirectoryInExePath|. +- MS-Windows: New value |'go-s'| to support fullscreen on MS-Windows GUI - macOS: increase default scheduler priority to TASK_DEFAULT_APPLICATION. diff --git a/src/gui.c b/src/gui.c index dd81d4c999..1470facf9c 100644 --- a/src/gui.c +++ b/src/gui.c @@ -158,6 +158,12 @@ gui_start(char_u *arg UNUSED) gui_gtk_init_socket_server(); #endif +#ifdef FEAT_GUI_MSWIN + // Enable fullscreen mode + if (vim_strchr(p_go, GO_FULLSCREEN) != NULL) + gui_mch_set_fullscreen(TRUE); +#endif + vim_free(old_term); // If the GUI started successfully, trigger the GUIEnter event, otherwise @@ -3498,6 +3504,9 @@ gui_init_which_components(char_u *oldval UNUSED) #ifdef FEAT_GUI_MSWIN static int prev_titlebar = FALSE; int using_titlebar = FALSE; + + static int prev_fullscreen = FALSE; + int using_fullscreen = FALSE; #endif #if defined(FEAT_MENU) static int prev_tearoff = -1; @@ -3572,6 +3581,9 @@ gui_init_which_components(char_u *oldval UNUSED) case GO_TITLEBAR: using_titlebar = TRUE; break; + case GO_FULLSCREEN: + using_fullscreen = TRUE; + break; #endif #ifdef FEAT_TOOLBAR case GO_TOOLBAR: @@ -3600,6 +3612,12 @@ gui_init_which_components(char_u *oldval UNUSED) gui_mch_set_titlebar_colors(); prev_titlebar = using_titlebar; } + + if (using_fullscreen != prev_fullscreen) + { + gui_mch_set_fullscreen(using_fullscreen); + prev_fullscreen = using_fullscreen; + } #endif #ifdef FEAT_GUI_DARKTHEME diff --git a/src/gui_w32.c b/src/gui_w32.c index 290223c44e..6e12b9458d 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -421,6 +421,8 @@ static HINSTANCE hLibDwm = NULL; static HRESULT (WINAPI *pDwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD); static void dyn_dwm_load(void); +static int fullscreen_on = FALSE; + #ifdef FEAT_GUI_DARKTHEME static HINSTANCE hUxThemeLib = NULL; @@ -3170,6 +3172,76 @@ dyn_uxtheme_load(void) #endif // FEAT_GUI_DARKTHEME +/* + * When flag is true, set fullscreen on. + * When flag is false, set fullscreen off. + */ + void +gui_mch_set_fullscreen(int flag) +{ + static RECT normal_rect; + static LONG_PTR normal_style, normal_exstyle; + HMONITOR mon; + MONITORINFO moninfo; + RECT rc; + + if (!full_screen) // Windows not set yet. + return; + + if (flag) + { + if (fullscreen_on) + return; + + // Enter fullscreen mode + GetWindowRect(s_hwnd, &rc); + + moninfo.cbSize = sizeof(MONITORINFO); + mon = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST); + if (mon == NULL || !GetMonitorInfo(mon, &moninfo)) + return; + + // Save current window state + GetWindowRect(s_hwnd, &normal_rect); + normal_style = GetWindowLongPtr(s_hwnd, GWL_STYLE); + normal_exstyle = GetWindowLongPtr(s_hwnd, GWL_EXSTYLE); + + // Set fullscreen styles + SetWindowLongPtr(s_hwnd, GWL_STYLE, + normal_style & ~(WS_CAPTION | WS_THICKFRAME)); + SetWindowLongPtr(s_hwnd, GWL_EXSTYLE, + normal_exstyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | + WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); + SetWindowPos(s_hwnd, NULL, + moninfo.rcMonitor.left, + moninfo.rcMonitor.top, + moninfo.rcMonitor.right - moninfo.rcMonitor.left, + moninfo.rcMonitor.bottom - moninfo.rcMonitor.top, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); + + fullscreen_on = TRUE; + } + else + { + if (!fullscreen_on) + return; + + // Exit fullscreen mode + SetWindowLongPtr(s_hwnd, GWL_STYLE, normal_style); + SetWindowLongPtr(s_hwnd, GWL_EXSTYLE, normal_exstyle); + + // Restore original window position and size + SetWindowPos(s_hwnd, NULL, + normal_rect.left, + normal_rect.top, + normal_rect.right - normal_rect.left, + normal_rect.bottom - normal_rect.top, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); + + fullscreen_on = FALSE; + } +} + /* * ":simalt" command. */ diff --git a/src/option.h b/src/option.h index 55dbf8a566..f5c36ad89b 100644 --- a/src/option.h +++ b/src/option.h @@ -303,13 +303,14 @@ typedef enum { #define GO_ASELPLUS 'P' // autoselectPlus #define GO_RIGHT 'r' // use right scrollbar #define GO_VRIGHT 'R' // right scrollbar with vert split +#define GO_FULLSCREEN 's' // enter fullscreen #define GO_TEAROFF 't' // add tear-off menu items #define GO_TOOLBAR 'T' // add toolbar #define GO_FOOTER 'F' // add footer #define GO_VERTICAL 'v' // arrange dialog buttons vertically #define GO_KEEPWINSIZE 'k' // keep GUI window size // all possible flags for 'go' -#define GO_ALL "!aAbcCdefFghilLmMpPrRtTvk" +#define GO_ALL "!aAbcCdefFghilLmMpPrRstTvk" // flags for 'comments' option #define COM_NEST 'n' // comments strings nest diff --git a/src/proto/gui_w32.pro b/src/proto/gui_w32.pro index 83cb7721f0..a93df3672c 100644 --- a/src/proto/gui_w32.pro +++ b/src/proto/gui_w32.pro @@ -44,6 +44,7 @@ int gui_mch_showing_tabline(void); void gui_mch_update_tabline(void); void gui_mch_set_curtab(int nr); void gui_mch_set_dark_theme(int dark); +void gui_mch_set_fullscreen(int flag); void ex_simalt(exarg_T *eap); void gui_mch_find_dialog(exarg_T *eap); void gui_mch_replace_dialog(exarg_T *eap); diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index 1b7096b5d1..7635245b31 100644 --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -664,10 +664,10 @@ func Test_set_guioptions() set guioptions& call assert_equal('egmrLtT', &guioptions) - set guioptions+=C + set guioptions+=s exec 'sleep' . duration - call assert_equal('egmrLtTC', &guioptions) - set guioptions-=C + call assert_equal('egmrLtTs', &guioptions) + set guioptions-=s exec 'sleep' . duration call assert_equal('egmrLtT', &guioptions) diff --git a/src/version.c b/src/version.c index a0cbb675e2..2d4b1df977 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2005, /**/ 2004, /**/