]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2005: MS-Windows: Missing fullscreen support for GUI version v9.1.2005
authorMao-Yining <101858210+mao-yining@users.noreply.github.com>
Sun, 21 Dec 2025 19:31:24 +0000 (19:31 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 21 Dec 2025 19:33:53 +0000 (19:33 +0000)
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 <cb@256bit.org>
runtime/doc/gui_w32.txt
runtime/doc/options.txt
runtime/doc/tags
runtime/doc/version9.txt
src/gui.c
src/gui_w32.c
src/option.h
src/proto/gui_w32.pro
src/testdir/test_gui.vim
src/version.c

index 6dc53a0446aabe8e794e738062db2551af6339b3..475b12e962c006439fd9496862a33033261ecfc9 100644 (file)
@@ -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 <expr> <F11> &go =~# 's' ? ":se go-=s<CR>" : ":se go+=s<CR>"
+
+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:
index a8dbab912b0fa750786bf69d8840880fd1feb05c..5130a28318f8ac2564e13a415609e324f089f07e 100644 (file)
@@ -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'*
index 05e967c4e6fd63b6c37a194c99379ea855a77947..6a00cc789b401430d80c83750230f387cdf87300 100644 (file)
@@ -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*
index 1071613fea08d7df78a463320c743086f3a1fc8a..f1cfd09797d36b8cd813aeb02bfc877d77113e57 100644 (file)
@@ -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.
 
index dd81d4c999ae39f5b4db7c2449ce0f2e5105ed93..1470facf9c5f7e6943d26f3de30791afb8f4600e 100644 (file)
--- 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
index 290223c44e843abd21ca53cede958eac108bda59..6e12b9458dab1feca5d64d10af3ac9cc8b7388e8 100644 (file)
@@ -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.
  */
index 55dbf8a566a58bf93b190b25b7598e4e8f7c767a..f5c36ad89bd213fd22cae227a9f81feff4680005 100644 (file)
@@ -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
index 83cb7721f0fdfbcb08b745bfbf8a741625f2e3df..a93df3672c3c9569ab11fbe6a9bab91353a665e8 100644 (file)
@@ -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);
index 1b7096b5d1ca3b50a07cbfba5567d7eea5a59b5c..7635245b3176188f49a687e7932542a15d7df594 100644 (file)
@@ -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)
 
index a0cbb675e2282fb74b0d7d19ac7b41040155076b..2d4b1df977ed7fddd7bb0bdc8f05338e917f29e8 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2005,
 /**/
     2004,
 /**/