diff --git a/README.md b/README.md index 83a706f..eb898af 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ gamescope -w 1920 -h 1080 -W 3440 -H 1440 -b -- %command% ## Options -* `-W`, `-H`: set the resolution used by gamescope. Resizing the gamescope window will update these settings. Defaults to 1280x720. -* `-w`, `-h`: set the resolution used by the game. Defaults to the values specified in `-W` and `-H`. +* `-W`, `-H`: set the resolution used by gamescope. Resizing the gamescope window will update these settings. Ignored in embedded mode. If `-H` is specified but `-W` isn't, a 16:9 aspect ratio is assumed. Defaults to 1280x720. +* `-w`, `-h`: set the resolution used by the game. If `-h` is specified but `-w` isn't, a 16:9 aspect ratio is assumed. Defaults to the values specified in `-W` and `-H`. * `-r`: set a frame-rate limit for the game. Specified in frames per second. Defaults to unlimited. * `-o`: set a frame-rate limit for the game when unfocused. Specified in frames per second. Defaults to unlimited. * `-n`: use integer scaling. diff --git a/src/main.cpp b/src/main.cpp index 395b2c1..dbcce10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,8 +25,8 @@ int g_nNestedHeight = 0; int g_nNestedRefresh = 0; int g_nNestedUnfocusedRefresh = 0; -uint32_t g_nOutputWidth = 1280; -uint32_t g_nOutputHeight = 720; +uint32_t g_nOutputWidth = 0; +uint32_t g_nOutputHeight = 0; int g_nOutputRefresh = 60; bool g_bFullscreen = false; @@ -115,6 +115,18 @@ int main(int argc, char **argv) } } + if ( g_nOutputHeight == 0 ) + { + if ( g_nOutputWidth != 0 ) + { + fprintf( stderr, "Cannot specify -W without -H\n" ); + return 1; + } + g_nOutputHeight = 720; + } + if ( g_nOutputWidth == 0 ) + g_nOutputWidth = g_nOutputHeight * 16 / 9; + cap_t caps; caps = cap_get_proc(); cap_flag_value_t nicecapvalue = CAP_CLEAR; @@ -199,10 +211,18 @@ int main(int argc, char **argv) } } - if ( g_nNestedWidth == 0 ) - g_nNestedWidth = g_nOutputWidth; if ( g_nNestedHeight == 0 ) + { + if ( g_nNestedWidth != 0 ) + { + fprintf( stderr, "Cannot specify -w without -h\n" ); + return 1; + } + g_nNestedWidth = g_nOutputWidth; g_nNestedHeight = g_nOutputHeight; + } + if ( g_nNestedWidth == 0 ) + g_nNestedWidth = g_nNestedHeight * 16 / 9; wlserver_init(argc, argv, g_bIsNested == true );