From 4a308c97f722985bec20313e2d9ee1517a87de39 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Mon, 7 Feb 2022 00:06:56 +0000 Subject: [PATCH] steamcompmgr: Handle being initially connected to external display --- src/main.cpp | 12 +++++++----- src/steamcompmgr.cpp | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8a526f9..48f63a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -212,10 +212,12 @@ static void handle_signal( int sig ) } } +int g_nPreferredOutputWidth = 0; +int g_nPreferredOutputHeight = 0; + int main(int argc, char **argv) { - int nPreferredOutputWidth = 0; - int nPreferredOutputHeight = 0; + static std::string optstring = build_optstring(gamescope_options); gamescope_optstring = optstring.c_str(); @@ -236,10 +238,10 @@ int main(int argc, char **argv) g_nNestedRefresh = atoi( optarg ); break; case 'W': - nPreferredOutputWidth = atoi( optarg ); + g_nPreferredOutputWidth = atoi( optarg ); break; case 'H': - nPreferredOutputHeight = atoi( optarg ); + g_nPreferredOutputHeight = atoi( optarg ); break; case 'o': g_nNestedUnfocusedRefresh = atoi( optarg ); @@ -358,7 +360,7 @@ int main(int argc, char **argv) return 1; } - if ( !initOutput( nPreferredOutputWidth, nPreferredOutputHeight, g_nNestedRefresh ) ) + if ( !initOutput( g_nPreferredOutputWidth, g_nPreferredOutputHeight, g_nNestedRefresh ) ) { fprintf( stderr, "Failed to initialize output\n" ); return 1; diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 429efb5..f2e739f 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -761,6 +761,12 @@ window_wants_no_focus_when_mouse_hidden( win *w ) return w && w->appID == 769; } +static bool +window_is_fullscreen( win *w ) +{ + return w && ( w->appID == 769 || w->isFullscreen ); +} + /** * Constructor for a cursor. It is hidden in the beginning (normally until moved by user). */ @@ -2259,11 +2265,11 @@ determine_and_apply_focus(xwayland_ctx_t *ctx, std::vector& vecGlobalPossi if (w->a.x != 0 || w->a.y != 0) XMoveWindow(ctx->dpy, ctx->focus.focusWindow->id, 0, 0); - if ( ctx->focus.focusWindow->isFullscreen && ( w->a.width != ctx->root_width || w->a.height != ctx->root_height || globalScaleRatio != 1.0f ) ) + if ( window_is_fullscreen( ctx->focus.focusWindow ) && ( w->a.width != ctx->root_width || w->a.height != ctx->root_height || globalScaleRatio != 1.0f ) ) { XResizeWindow(ctx->dpy, ctx->focus.focusWindow->id, ctx->root_width, ctx->root_height); } - else if (!ctx->focus.focusWindow->isFullscreen && ctx->focus.focusWindow->sizeHintsSpecified && + else if ( !window_is_fullscreen( ctx->focus.focusWindow ) && ctx->focus.focusWindow->sizeHintsSpecified && ((unsigned)ctx->focus.focusWindow->a.width != ctx->focus.focusWindow->requestedWidth || (unsigned)ctx->focus.focusWindow->a.height != ctx->focus.focusWindow->requestedHeight)) { @@ -4489,6 +4495,9 @@ void init_xwayland_ctx(gamescope_xwayland_server_t *xwayland_server) } } +extern int g_nPreferredOutputWidth; +extern int g_nPreferredOutputHeight; + void steamcompmgr_main(int argc, char **argv) { @@ -4568,8 +4577,8 @@ steamcompmgr_main(int argc, char **argv) alwaysComposite = true; } - currentOutputWidth = g_nOutputWidth; - currentOutputHeight = g_nOutputHeight; + currentOutputWidth = g_nPreferredOutputWidth; + currentOutputHeight = g_nPreferredOutputHeight; int vblankFD = vblank_init(); assert( vblankFD >= 0 );