Skip to content

Commit 49e0f83

Browse files
mao-yiningchrisbra
authored andcommitted
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 <cb@256bit.org>
1 parent bd686d8 commit 49e0f83

10 files changed

Lines changed: 133 additions & 7 deletions

File tree

runtime/doc/gui_w32.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*gui_w32.txt* For Vim version 9.1. Last change: 2025 Nov 09
1+
*gui_w32.txt* For Vim version 9.1. Last change: 2025 Dec 21
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -504,4 +504,25 @@ To use the system's default title bar colors, set highlighting groups to
504504
hi TitleBar guibg=NONE guifg=NONE
505505
hi TitleBarNC guibg=NONE guifg=NONE
506506
<
507+
508+
Full Screen *gui-w32-fullscreen*
509+
510+
To enable fullscreen mode in the Windows GUI version of Vim, add the 's' flag
511+
to the 'guioptions' setting.
512+
513+
For convenience, you can define a command or mapping to toggle fullscreen mode:
514+
>
515+
command! ToggleFullscreen {
516+
if &guioptions =~# 's'
517+
set guioptions-=s
518+
else
519+
set guioptions+=s
520+
endif
521+
}
522+
523+
map <expr> <F11> &go =~# 's' ? ":se go-=s<CR>" : ":se go+=s<CR>"
524+
525+
The fullscreen mode will occupy the entire screen area while hiding window
526+
decorations such as the title bar and borders.
527+
507528
vim:tw=78:sw=4:ts=8:noet:ft=help:norl:

runtime/doc/options.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*options.txt* For Vim version 9.1. Last change: 2025 Dec 18
1+
*options.txt* For Vim version 9.1. Last change: 2025 Dec 21
22

33

44
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|.
45724572
*'go-T'*
45734573
'T' Include Toolbar. Currently only in Win32, GTK+, Motif and
45744574
Photon GUIs.
4575+
*'go-s'*
4576+
's' Enable fullscreen mode. Currently only supported in the
4577+
MS-Windows GUI version. When set, the window will occupy the
4578+
entire screen and remove window decorations. Define custom
4579+
mappings to toggle this mode conveniently. For detailed usage
4580+
instructions, see |gui-w32-fullscreen|.
45754581
*'go-r'*
45764582
'r' Right-hand scrollbar is always present.
45774583
*'go-R'*

runtime/doc/tags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ $quote eval.txt /*$quote*
377377
'go-m' options.txt /*'go-m'*
378378
'go-p' options.txt /*'go-p'*
379379
'go-r' options.txt /*'go-r'*
380+
'go-s' options.txt /*'go-s'*
380381
'go-t' options.txt /*'go-t'*
381382
'go-v' options.txt /*'go-v'*
382383
'gp' options.txt /*'gp'*
@@ -8249,6 +8250,7 @@ gui-vert-scroll gui.txt /*gui-vert-scroll*
82498250
gui-w32 gui_w32.txt /*gui-w32*
82508251
gui-w32-cmdargs gui_w32.txt /*gui-w32-cmdargs*
82518252
gui-w32-dialogs gui_w32.txt /*gui-w32-dialogs*
8253+
gui-w32-fullscreen gui_w32.txt /*gui-w32-fullscreen*
82528254
gui-w32-printing gui_w32.txt /*gui-w32-printing*
82538255
gui-w32-start gui_w32.txt /*gui-w32-start*
82548256
gui-w32-title-bar gui_w32.txt /*gui-w32-title-bar*

runtime/doc/version9.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*version9.txt* For Vim version 9.1. Last change: 2025 Dec 15
1+
*version9.txt* For Vim version 9.1. Last change: 2025 Dec 21
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -41724,6 +41724,8 @@ Options: ~
4172441724
(see also the below platform specific change).
4172541725
- 'guioptions': Support darkmode on MS-Windows for menu and title bar using
4172641726
|'go-d'| (see also the below platform specific change).
41727+
- 'guioptions': New value |'go-s'| to support fullscreen on MS-Windows GUI
41728+
(see also the below platform specific change).
4172741729
- 'completepopup': Add more values to style popup windows.
4172841730

4172941731
Ex commands: ~
@@ -41768,6 +41770,7 @@ Platform specific ~
4176841770
- MS-Windows: Vim no longer searches the current directory for
4176941771
executables when running external commands; prefix a relative or absolute
4177041772
path if you want the old behavior |$NoDefaultCurrentDirectoryInExePath|.
41773+
- MS-Windows: New value |'go-s'| to support fullscreen on MS-Windows GUI
4177141774

4177241775
- macOS: increase default scheduler priority to TASK_DEFAULT_APPLICATION.
4177341776

src/gui.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ gui_start(char_u *arg UNUSED)
158158
gui_gtk_init_socket_server();
159159
#endif
160160

161+
#ifdef FEAT_GUI_MSWIN
162+
// Enable fullscreen mode
163+
if (vim_strchr(p_go, GO_FULLSCREEN) != NULL)
164+
gui_mch_set_fullscreen(TRUE);
165+
#endif
166+
161167
vim_free(old_term);
162168

163169
// If the GUI started successfully, trigger the GUIEnter event, otherwise
@@ -3498,6 +3504,9 @@ gui_init_which_components(char_u *oldval UNUSED)
34983504
#ifdef FEAT_GUI_MSWIN
34993505
static int prev_titlebar = FALSE;
35003506
int using_titlebar = FALSE;
3507+
3508+
static int prev_fullscreen = FALSE;
3509+
int using_fullscreen = FALSE;
35013510
#endif
35023511
#if defined(FEAT_MENU)
35033512
static int prev_tearoff = -1;
@@ -3572,6 +3581,9 @@ gui_init_which_components(char_u *oldval UNUSED)
35723581
case GO_TITLEBAR:
35733582
using_titlebar = TRUE;
35743583
break;
3584+
case GO_FULLSCREEN:
3585+
using_fullscreen = TRUE;
3586+
break;
35753587
#endif
35763588
#ifdef FEAT_TOOLBAR
35773589
case GO_TOOLBAR:
@@ -3600,6 +3612,12 @@ gui_init_which_components(char_u *oldval UNUSED)
36003612
gui_mch_set_titlebar_colors();
36013613
prev_titlebar = using_titlebar;
36023614
}
3615+
3616+
if (using_fullscreen != prev_fullscreen)
3617+
{
3618+
gui_mch_set_fullscreen(using_fullscreen);
3619+
prev_fullscreen = using_fullscreen;
3620+
}
36033621
#endif
36043622

36053623
#ifdef FEAT_GUI_DARKTHEME

src/gui_w32.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ static HINSTANCE hLibDwm = NULL;
421421
static HRESULT (WINAPI *pDwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD);
422422
static void dyn_dwm_load(void);
423423

424+
static int fullscreen_on = FALSE;
425+
424426
#ifdef FEAT_GUI_DARKTHEME
425427

426428
static HINSTANCE hUxThemeLib = NULL;
@@ -3170,6 +3172,76 @@ dyn_uxtheme_load(void)
31703172

31713173
#endif // FEAT_GUI_DARKTHEME
31723174

3175+
/*
3176+
* When flag is true, set fullscreen on.
3177+
* When flag is false, set fullscreen off.
3178+
*/
3179+
void
3180+
gui_mch_set_fullscreen(int flag)
3181+
{
3182+
static RECT normal_rect;
3183+
static LONG_PTR normal_style, normal_exstyle;
3184+
HMONITOR mon;
3185+
MONITORINFO moninfo;
3186+
RECT rc;
3187+
3188+
if (!full_screen) // Windows not set yet.
3189+
return;
3190+
3191+
if (flag)
3192+
{
3193+
if (fullscreen_on)
3194+
return;
3195+
3196+
// Enter fullscreen mode
3197+
GetWindowRect(s_hwnd, &rc);
3198+
3199+
moninfo.cbSize = sizeof(MONITORINFO);
3200+
mon = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST);
3201+
if (mon == NULL || !GetMonitorInfo(mon, &moninfo))
3202+
return;
3203+
3204+
// Save current window state
3205+
GetWindowRect(s_hwnd, &normal_rect);
3206+
normal_style = GetWindowLongPtr(s_hwnd, GWL_STYLE);
3207+
normal_exstyle = GetWindowLongPtr(s_hwnd, GWL_EXSTYLE);
3208+
3209+
// Set fullscreen styles
3210+
SetWindowLongPtr(s_hwnd, GWL_STYLE,
3211+
normal_style & ~(WS_CAPTION | WS_THICKFRAME));
3212+
SetWindowLongPtr(s_hwnd, GWL_EXSTYLE,
3213+
normal_exstyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE |
3214+
WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
3215+
SetWindowPos(s_hwnd, NULL,
3216+
moninfo.rcMonitor.left,
3217+
moninfo.rcMonitor.top,
3218+
moninfo.rcMonitor.right - moninfo.rcMonitor.left,
3219+
moninfo.rcMonitor.bottom - moninfo.rcMonitor.top,
3220+
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
3221+
3222+
fullscreen_on = TRUE;
3223+
}
3224+
else
3225+
{
3226+
if (!fullscreen_on)
3227+
return;
3228+
3229+
// Exit fullscreen mode
3230+
SetWindowLongPtr(s_hwnd, GWL_STYLE, normal_style);
3231+
SetWindowLongPtr(s_hwnd, GWL_EXSTYLE, normal_exstyle);
3232+
3233+
// Restore original window position and size
3234+
SetWindowPos(s_hwnd, NULL,
3235+
normal_rect.left,
3236+
normal_rect.top,
3237+
normal_rect.right - normal_rect.left,
3238+
normal_rect.bottom - normal_rect.top,
3239+
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
3240+
3241+
fullscreen_on = FALSE;
3242+
}
3243+
}
3244+
31733245
/*
31743246
* ":simalt" command.
31753247
*/

src/option.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,14 @@ typedef enum {
303303
#define GO_ASELPLUS 'P' // autoselectPlus
304304
#define GO_RIGHT 'r' // use right scrollbar
305305
#define GO_VRIGHT 'R' // right scrollbar with vert split
306+
#define GO_FULLSCREEN 's' // enter fullscreen
306307
#define GO_TEAROFF 't' // add tear-off menu items
307308
#define GO_TOOLBAR 'T' // add toolbar
308309
#define GO_FOOTER 'F' // add footer
309310
#define GO_VERTICAL 'v' // arrange dialog buttons vertically
310311
#define GO_KEEPWINSIZE 'k' // keep GUI window size
311312
// all possible flags for 'go'
312-
#define GO_ALL "!aAbcCdefFghilLmMpPrRtTvk"
313+
#define GO_ALL "!aAbcCdefFghilLmMpPrRstTvk"
313314

314315
// flags for 'comments' option
315316
#define COM_NEST 'n' // comments strings nest

src/proto/gui_w32.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ int gui_mch_showing_tabline(void);
4444
void gui_mch_update_tabline(void);
4545
void gui_mch_set_curtab(int nr);
4646
void gui_mch_set_dark_theme(int dark);
47+
void gui_mch_set_fullscreen(int flag);
4748
void ex_simalt(exarg_T *eap);
4849
void gui_mch_find_dialog(exarg_T *eap);
4950
void gui_mch_replace_dialog(exarg_T *eap);

src/testdir/test_gui.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ func Test_set_guioptions()
664664
set guioptions&
665665
call assert_equal('egmrLtT', &guioptions)
666666

667-
set guioptions+=C
667+
set guioptions+=s
668668
exec 'sleep' . duration
669-
call assert_equal('egmrLtTC', &guioptions)
670-
set guioptions-=C
669+
call assert_equal('egmrLtTs', &guioptions)
670+
set guioptions-=s
671671
exec 'sleep' . duration
672672
call assert_equal('egmrLtT', &guioptions)
673673

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
2005,
737739
/**/
738740
2004,
739741
/**/

0 commit comments

Comments
 (0)