Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 51 additions & 31 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3533,6 +3533,42 @@ static bool is_good_override_candidate( steamcompmgr_win_t *override, steamcompm
static void
handle_desktop_window(steamcompmgr_win_t *w);

static void
resize_window_to_desired_geometry( xwayland_ctx_t *ctx, steamcompmgr_win_t *w )
{
if ( win_has_game_id( w ) )
{
if ( window_is_fullscreen( w ) || ctx->force_windows_fullscreen )
{
bool bIsSteam = window_is_steam( w );
int fs_width = ctx->root_width;
int fs_height = ctx->root_height;
if ( bIsSteam && g_nSteamMaxHeight && ctx->root_height > g_nSteamMaxHeight )
{
float steam_height_scale = g_nSteamMaxHeight / (float)ctx->root_height;
fs_height = g_nSteamMaxHeight;
fs_width = ctx->root_width * steam_height_scale;
}

if ( w->GetGeometry().nWidth != fs_width || w->GetGeometry().nHeight != fs_height || globalScaleRatio != 1.0f )
XResizeWindow( ctx->dpy, w->xwayland().id, fs_width, fs_height );
}
else
{
if ( w->sizeHintsSpecified &&
((unsigned)w->GetGeometry().nWidth != w->requestedWidth ||
(unsigned)w->GetGeometry().nHeight != w->requestedHeight))
{
XResizeWindow( ctx->dpy, w->xwayland().id, w->requestedWidth, w->requestedHeight );
}
}
}
else
{
handle_desktop_window( w );
}
}

static bool
pick_primary_focus_and_override(
focus_t *out,
Expand Down Expand Up @@ -4044,37 +4080,7 @@ void xwayland_ctx_t::DetermineAndApplyFocus( const std::vector< steamcompmgr_win
w->placed = true;
}

if ( win_has_game_id( w ) )
{
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;
int fs_height = ctx->root_height;
if ( bIsSteam && g_nSteamMaxHeight && ctx->root_height > g_nSteamMaxHeight )
{
float steam_height_scale = g_nSteamMaxHeight / (float)ctx->root_height;
fs_height = g_nSteamMaxHeight;
fs_width = ctx->root_width * steam_height_scale;
}

if ( w->GetGeometry().nWidth != fs_width || w->GetGeometry().nHeight != fs_height || globalScaleRatio != 1.0f )
XResizeWindow(ctx->dpy, ctx->focus.focusWindow->xwayland().id, fs_width, fs_height);
}
else
{
if (ctx->focus.focusWindow->sizeHintsSpecified &&
((unsigned)ctx->focus.focusWindow->GetGeometry().nWidth != ctx->focus.focusWindow->requestedWidth ||
(unsigned)ctx->focus.focusWindow->GetGeometry().nHeight != ctx->focus.focusWindow->requestedHeight))
{
XResizeWindow(ctx->dpy, ctx->focus.focusWindow->xwayland().id, ctx->focus.focusWindow->requestedWidth, ctx->focus.focusWindow->requestedHeight);
}
}
}
else
{
handle_desktop_window( w );
}
resize_window_to_desired_geometry( ctx, w );

Window root_return = None, parent_return = None;
Window *children = NULL;
Expand Down Expand Up @@ -5562,9 +5568,12 @@ handle_net_wm_state(xwayland_ctx_t *ctx, steamcompmgr_win_t *w, XClientMessageEv
{
uint32_t action = (uint32_t)ev->data.l[0];
Atom *props = (Atom *)&ev->data.l[1];
bool fullscreenChanged = false;
for (size_t i = 0; i < 2; i++) {
if (props[i] == ctx->atoms.netWMStateFullscreenAtom) {
bool wasFullscreen = w->isFullscreen;
update_net_wm_state(action, &w->isFullscreen);
fullscreenChanged |= w->isFullscreen != wasFullscreen;
MakeFocusDirty();
} else if (props[i] == ctx->atoms.netWMStateSkipTaskbarAtom) {
update_net_wm_state(action, &w->skipTaskbar);
Expand All @@ -5576,6 +5585,17 @@ handle_net_wm_state(xwayland_ctx_t *ctx, steamcompmgr_win_t *w, XClientMessageEv
xwm_log.debugf("Unhandled NET_WM_STATE property change: %s", XGetAtomName(ctx->dpy, props[i]));
}
}

if (fullscreenChanged)
resize_window_to_desired_geometry( ctx, w );

Atom atoms[3];
int count = 0;
if (w->isFullscreen) atoms[count++] = ctx->atoms.netWMStateFullscreenAtom;
if (w->skipTaskbar) atoms[count++] = ctx->atoms.netWMStateSkipTaskbarAtom;
if (w->skipPager) atoms[count++] = ctx->atoms.netWMStateSkipPagerAtom;
XChangeProperty(ctx->dpy, w->xwayland().id, ctx->atoms.netWMStateAtom,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does firefox care about _NET_WM_STATE_SKIP_TASKBAR and _NET_WM_STATE_SKIP_PAGER?

This code unconditionally calls XChangeProperty(), even if none of these 3 properties has actually changed. It would probably be better and safer to first call XGetWindowProperty() and to change only the properties we care about, leaving the others (including those that gamescope doesn't handle) unchanged.

XA_ATOM, 32, PropModeReplace, (unsigned char*)atoms, count);
}

bool g_bLowLatency = false;
Expand Down