Add 16:9 defaults for -W/-w

This commit is contained in:
Simon Ser 2021-07-20 13:03:37 +02:00
parent 84dd1e6542
commit 97ae60154d
2 changed files with 26 additions and 6 deletions

View file

@ -52,8 +52,8 @@ gamescope -w 1920 -h 1080 -W 3440 -H 1440 -b -- %command%
## Options ## 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 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. Defaults to the values specified in `-W` and `-H`. * `-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. * `-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. * `-o`: set a frame-rate limit for the game when unfocused. Specified in frames per second. Defaults to unlimited.
* `-n`: use integer scaling. * `-n`: use integer scaling.

View file

@ -25,8 +25,8 @@ int g_nNestedHeight = 0;
int g_nNestedRefresh = 0; int g_nNestedRefresh = 0;
int g_nNestedUnfocusedRefresh = 0; int g_nNestedUnfocusedRefresh = 0;
uint32_t g_nOutputWidth = 1280; uint32_t g_nOutputWidth = 0;
uint32_t g_nOutputHeight = 720; uint32_t g_nOutputHeight = 0;
int g_nOutputRefresh = 60; int g_nOutputRefresh = 60;
bool g_bFullscreen = false; 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; cap_t caps;
caps = cap_get_proc(); caps = cap_get_proc();
cap_flag_value_t nicecapvalue = CAP_CLEAR; 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_nNestedHeight == 0 )
{
if ( g_nNestedWidth != 0 )
{
fprintf( stderr, "Cannot specify -w without -h\n" );
return 1;
}
g_nNestedWidth = g_nOutputWidth;
g_nNestedHeight = g_nOutputHeight; g_nNestedHeight = g_nOutputHeight;
}
if ( g_nNestedWidth == 0 )
g_nNestedWidth = g_nNestedHeight * 16 / 9;
wlserver_init(argc, argv, g_bIsNested == true ); wlserver_init(argc, argv, g_bIsNested == true );