Skip to content

Commit 9081fc0

Browse files
PoloniumRainLibretroAdmin
authored andcommitted
GNOME X11: Fix title bar showing in fullscreen
1 parent b6a018b commit 9081fc0

6 files changed

Lines changed: 78 additions & 0 deletions

File tree

gfx/common/x11_common.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@ void x11_set_net_wm_fullscreen(Display *dpy, Window win)
141141
&xev);
142142
}
143143

144+
/* Set the fullscreen state on the window before it is shown.
145+
* On GNOME + X11 (Mutter), fullscreen works properly when the
146+
* window carries the fullscreen hint as it is being mapped */
147+
void x11_set_net_wm_fullscreen_hint(Display *dpy, Window win)
148+
{
149+
Atom states[1] = {0};
150+
151+
XA_NET_WM_STATE = XInternAtom(dpy, "_NET_WM_STATE", False);
152+
XA_NET_WM_STATE_FULLSCREEN = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
153+
states[0] = XA_NET_WM_STATE_FULLSCREEN;
154+
155+
XChangeProperty(dpy, win, XA_NET_WM_STATE, XA_ATOM, 32,
156+
PropModeReplace, (const unsigned char*)states,
157+
sizeof(states) / sizeof(*states));
158+
}
159+
144160
/* Try to be nice to tiling WMs if possible. */
145161

146162
void x11_move_window(Display *dpy, Window win, int x, int y,

gfx/common/x11_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern unsigned g_x11_screen;
3030

3131
void x11_show_mouse(void *data, bool state);
3232
void x11_set_net_wm_fullscreen(Display *dpy, Window win);
33+
void x11_set_net_wm_fullscreen_hint(Display *dpy, Window win);
3334
bool x11_suspend_screensaver(void *data, bool enable);
3435

3536
void x11_move_window(Display *dpy, Window win,

gfx/drivers/xvideo.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ static void *xv_init(const video_info_t *video,
603603
{
604604
unsigned i;
605605
int ret;
606+
XEvent event;
606607
XWindowAttributes target;
607608
char title[128] = {0};
608609
XSetWindowAttributes attributes = {0};
@@ -741,6 +742,13 @@ static void *xv_init(const video_info_t *video,
741742
XFree(visualinfo);
742743
XSetWindowBackground(g_x11_dpy, g_x11_win, 0);
743744

745+
if (video->fullscreen)
746+
{
747+
/* Give the window a fullscreen hint before it is shown.
748+
* This helps GNOME + X11 enter fullscreen properly */
749+
x11_set_net_wm_fullscreen_hint(g_x11_dpy, g_x11_win);
750+
}
751+
744752
if (video->fullscreen && video_disable_composition)
745753
{
746754
uint32_t value = 1;
@@ -765,7 +773,12 @@ static void *xv_init(const video_info_t *video,
765773

766774
if (video->fullscreen)
767775
{
776+
/* Ask for fullscreen again after the window is visible. Some
777+
* GNOME + X11 setups ignore the first request if it happens too
778+
* early, which causes RetroArch to only maximise the window */
779+
x11_event_queue_check(&event);
768780
x11_set_net_wm_fullscreen(g_x11_dpy, g_x11_win);
781+
XFlush(g_x11_dpy);
769782
x11_show_mouse(xv, false);
770783
}
771784

gfx/drivers_context/x_ctx.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,13 @@ static bool gfx_ctx_x_set_video_mode(void *data,
622622
x11_set_window_attr(g_x11_dpy, g_x11_win);
623623
x11_update_title(NULL);
624624

625+
if (fullscreen)
626+
{
627+
/* Give the window a fullscreen hint before it is shown.
628+
* This helps GNOME + X11 enter fullscreen properly */
629+
x11_set_net_wm_fullscreen_hint(g_x11_dpy, g_x11_win);
630+
}
631+
625632
if (fullscreen)
626633
x11_show_mouse(data, false);
627634

@@ -662,6 +669,15 @@ static bool gfx_ctx_x_set_video_mode(void *data,
662669

663670
x11_event_queue_check(&event);
664671

672+
if (fullscreen)
673+
{
674+
/* Ask for fullscreen again after the window is visible. Some
675+
* GNOME + X11 setups ignore the first request if it happens too
676+
* early, which causes RetroArch to only maximise the window */
677+
x11_set_net_wm_fullscreen(g_x11_dpy, g_x11_win);
678+
XFlush(g_x11_dpy);
679+
}
680+
665681
switch (x_api)
666682
{
667683
case GFX_CTX_OPENGL_API:

gfx/drivers_context/x_vk_ctx.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,13 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
389389
x11_set_window_attr(g_x11_dpy, g_x11_win);
390390
x11_update_title(NULL);
391391

392+
if (fullscreen)
393+
{
394+
/* Give the window a fullscreen hint before it is shown.
395+
* This helps GNOME + X11 enter fullscreen properly */
396+
x11_set_net_wm_fullscreen_hint(g_x11_dpy, g_x11_win);
397+
}
398+
392399
if (fullscreen)
393400
x11_show_mouse(data, false);
394401

@@ -429,6 +436,15 @@ static bool gfx_ctx_x_vk_set_video_mode(void *data,
429436

430437
x11_event_queue_check(&event);
431438

439+
if (fullscreen)
440+
{
441+
/* Ask for fullscreen again after the window is visible. Some
442+
* GNOME + X11 setups ignore the first request if it happens too
443+
* early, which causes RetroArch to only maximise the window */
444+
x11_set_net_wm_fullscreen(g_x11_dpy, g_x11_win);
445+
XFlush(g_x11_dpy);
446+
}
447+
432448
{
433449
bool quit, resize;
434450
unsigned width = 0, height = 0;

gfx/drivers_context/xegl_ctx.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,13 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
397397
x11_set_window_attr(g_x11_dpy, g_x11_win);
398398
x11_update_title(NULL);
399399

400+
if (fullscreen)
401+
{
402+
/* Give the window a fullscreen hint before it is shown.
403+
* This helps GNOME + X11 enter fullscreen properly */
404+
x11_set_net_wm_fullscreen_hint(g_x11_dpy, g_x11_win);
405+
}
406+
400407
if (fullscreen)
401408
x11_show_mouse(data, false);
402409

@@ -438,6 +445,15 @@ static bool gfx_ctx_xegl_set_video_mode(void *data,
438445
}
439446

440447
x11_event_queue_check(&event);
448+
449+
if (fullscreen)
450+
{
451+
/* Ask for fullscreen again after the window is visible. Some
452+
* GNOME + X11 setups ignore the first request if it happens too
453+
* early, which causes RetroArch to only maximise the window */
454+
x11_set_net_wm_fullscreen(g_x11_dpy, g_x11_win);
455+
XFlush(g_x11_dpy);
456+
}
441457
x11_install_quit_atom();
442458

443459
#ifdef HAVE_EGL

0 commit comments

Comments
 (0)