steamcompmgr: Add --force-windows-fullscreen

Useful for browsers or nested desktop environments.

Also adds GAMESCOPE_FORCE_WINDOWS_FULLSCREEN atom per-xwayland.
This commit is contained in:
Joshua Ashton 2023-01-11 19:14:12 +00:00
parent 041ee8dcd8
commit 201d5feb39
3 changed files with 19 additions and 1 deletions

View file

@ -84,6 +84,7 @@ const struct option *gamescope_options = (struct option[]){
{ "disable-xres", no_argument, nullptr, 'x' },
{ "fade-out-duration", required_argument, nullptr, 0 },
{ "force-orientation", required_argument, nullptr, 0 },
{ "force-windows-fullscreen", no_argument, nullptr, 0 },
{ "hdr-enabled", no_argument, nullptr, 0 },
{ "hdr-sdr-content-nits", required_argument, nullptr, 0 },
@ -120,6 +121,7 @@ const char usage[] =
" --xwayland-count create N xwayland servers\n"
" --prefer-vk-device prefer Vulkan device for compositing (ex: 1002:7300)\n"
" --force-orientation rotate the internal display (left, right, normal, upsidedown)\n"
" --force-windows-fullscreen force windows inside of gamescope to be the size of the nested display (fullscreen)\n"
" --hdr-enabled enable HDR output (needs Gamescope WSI layer enabled for support from clients)\n"
" If this is not set, and there is a HDR client, it will be tonemapped SDR.\n"
" --hdr-wide-gammut-for-sdr treat SDR sRGB content as having Rec.2020 primaries. Makes colors more vivid at cost of 'correctness'.\n"

View file

@ -2767,7 +2767,7 @@ determine_and_apply_focus(xwayland_ctx_t *ctx, std::vector<win*>& vecGlobalPossi
if (w->a.x != 0 || w->a.y != 0)
XMoveWindow(ctx->dpy, ctx->focus.focusWindow->id, 0, 0);
if ( window_is_fullscreen( ctx->focus.focusWindow ) )
if ( window_is_fullscreen( ctx->focus.focusWindow ) || ctx->force_windows_fullscreen )
{
bool bIsSteam = window_is_steam( ctx->focus.focusWindow );
int fs_width = ctx->root_width;
@ -4509,6 +4509,11 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
g_flLinearToNits = 400.0f;
hasRepaint = true;
}
if ( ev->atom == ctx->atoms.gamescopeForceWindowsFullscreen )
{
ctx->force_windows_fullscreen = !!get_prop( ctx, ctx->root, ctx->atoms.gamescopeForceWindowsFullscreen, 0 );
focusDirty = true;
}
for (int i = 0; i < DRM_SCREEN_TYPE_COUNT; i++)
{
if ( ev->atom == ctx->atoms.gamescopeColorLut3D[i] )
@ -5499,6 +5504,8 @@ void init_xwayland_ctx(gamescope_xwayland_server_t *xwayland_server)
ctx->atoms.gamescopeHDROutputFeedback = XInternAtom( ctx->dpy, "GAMESCOPE_HDR_OUTPUT_FEEDBACK", false );
ctx->atoms.gamescopeHDRSDRContentBrightness = XInternAtom( ctx->dpy, "GAMESCOPE_HDR_SDR_CONTENT_BRIGHTNESS", false );
ctx->atoms.gamescopeForceWindowsFullscreen = XInternAtom( ctx->dpy, "GAMESCOPE_FORCE_WINDOWS_FULLSCREEN", false );
ctx->atoms.gamescopeColorLut3D[DRM_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_3DLUT", false );
ctx->atoms.gamescopeColorLut3D[DRM_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_3DLUT_EXTERNAL", false );
@ -5638,6 +5645,7 @@ steamcompmgr_main(int argc, char **argv)
int o;
int opt_index = -1;
bool bForceWindowsFullscreen = false;
while ((o = getopt_long(argc, argv, gamescope_optstring, gamescope_options, &opt_index)) != -1)
{
const char *opt_name;
@ -5682,6 +5690,8 @@ steamcompmgr_main(int argc, char **argv)
sscanf(optarg, "%d,%d", &g_customCursorHotspotX, &g_customCursorHotspotY);
} else if (strcmp(opt_name, "fade-out-duration") == 0) {
g_FadeOutDuration = atoi(optarg);
} else if (strcmp(opt_name, "force-windows-fullscreen") == 0) {
bForceWindowsFullscreen = true;
} else if (strcmp(opt_name, "hdr-enabled") == 0) {
g_bHDREnabled = true;
} else if (strcmp(opt_name, "hdr-sdr-content-nits") == 0) {
@ -5784,6 +5794,8 @@ steamcompmgr_main(int argc, char **argv)
uint32_t serverId = static_cast<uint32_t>(i);
XChangeProperty(server->ctx->dpy, server->ctx->root, server->ctx->atoms.gamescopeXwaylandServerId, XA_CARDINAL, 32, PropModeReplace,
(unsigned char *)&serverId, 1 );
server->ctx->force_windows_fullscreen = bForceWindowsFullscreen;
}
}

View file

@ -65,6 +65,8 @@ struct xwayland_ctx_t
double accum_x = 0.0;
double accum_y = 0.0;
bool force_windows_fullscreen = false;
struct {
Atom steamAtom;
Atom gameAtom;
@ -179,6 +181,8 @@ struct xwayland_ctx_t
Atom gamescopeHDROutputFeedback;
Atom gamescopeHDRSDRContentBrightness;
Atom gamescopeForceWindowsFullscreen;
Atom gamescopeColorLut3D[DRM_SCREEN_TYPE_COUNT];
Atom gamescopeColorShaperLut[DRM_SCREEN_TYPE_COUNT];