fix: window crash on tiling wayland WM

pull/4761/head
liukairui 3 months ago
parent 79968a0ae6
commit 1cc415877e

@ -92,7 +92,8 @@ _scrcpy() {
--window-x= --window-x=
--window-y= --window-y=
--window-width= --window-width=
--window-height=" --window-height=
--system-resize"
_init_completion -s || return _init_completion -s || return

@ -96,6 +96,7 @@ arguments=(
'--window-y=[Set the initial window vertical position]' '--window-y=[Set the initial window vertical position]'
'--window-width=[Set the initial window width]' '--window-width=[Set the initial window width]'
'--window-height=[Set the initial window height]' '--window-height=[Set the initial window height]'
'--system-resize[Leave the window size to be completely managed by the desktop manager]'
) )
_arguments -s $arguments _arguments -s $arguments

@ -97,6 +97,7 @@ enum {
OPT_MOUSE, OPT_MOUSE,
OPT_HID_KEYBOARD_DEPRECATED, OPT_HID_KEYBOARD_DEPRECATED,
OPT_HID_MOUSE_DEPRECATED, OPT_HID_MOUSE_DEPRECATED,
OPT_SYSTEM_RESIZE,
}; };
struct sc_option { struct sc_option {
@ -877,6 +878,11 @@ static const struct sc_option options[] = {
.text = "Set the initial window height.\n" .text = "Set the initial window height.\n"
"Default is 0 (automatic).", "Default is 0 (automatic).",
}, },
{
.longopt_id = OPT_SYSTEM_RESIZE,
.longopt = "system-resize",
.text = "Leave the window size to be completely managed by the desktop manager",
},
}; };
static const struct sc_shortcut shortcuts[] = { static const struct sc_shortcut shortcuts[] = {
@ -2186,6 +2192,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
case OPT_ALWAYS_ON_TOP: case OPT_ALWAYS_ON_TOP:
opts->always_on_top = true; opts->always_on_top = true;
break; break;
case OPT_SYSTEM_RESIZE:
opts->system_resize = true;
break;
case 'v': case 'v':
args->version = true; args->version = true;
break; break;

@ -60,6 +60,7 @@ const struct scrcpy_options scrcpy_options_default = {
.show_touches = false, .show_touches = false,
.fullscreen = false, .fullscreen = false,
.always_on_top = false, .always_on_top = false,
.system_resize = false,
.control = true, .control = true,
.video_playback = true, .video_playback = true,
.audio_playback = true, .audio_playback = true,

@ -246,6 +246,7 @@ struct scrcpy_options {
bool show_touches; bool show_touches;
bool fullscreen; bool fullscreen;
bool always_on_top; bool always_on_top;
bool system_resize;
bool control; bool control;
bool video_playback; bool video_playback;
bool audio_playback; bool audio_playback;

@ -699,6 +699,7 @@ scrcpy(struct scrcpy_options *options) {
.shortcut_mods = &options->shortcut_mods, .shortcut_mods = &options->shortcut_mods,
.window_title = window_title, .window_title = window_title,
.always_on_top = options->always_on_top, .always_on_top = options->always_on_top,
.system_resize = options->system_resize,
.window_x = options->window_x, .window_x = options->window_x,
.window_y = options->window_y, .window_y = options->window_y,
.window_width = options->window_width, .window_width = options->window_width,

@ -57,7 +57,9 @@ set_window_size(struct sc_screen *screen, struct sc_size new_size) {
assert(!screen->fullscreen); assert(!screen->fullscreen);
assert(!screen->maximized); assert(!screen->maximized);
assert(!screen->minimized); assert(!screen->minimized);
SDL_SetWindowSize(screen->window, new_size.width, new_size.height); if(!(screen->req.system_resize)){
SDL_SetWindowSize(screen->window, new_size.width, new_size.height);
}
} }
// get the preferred display bounds (i.e. the screen bounds with some margins) // get the preferred display bounds (i.e. the screen bounds with some margins)
@ -365,6 +367,7 @@ sc_screen_init(struct sc_screen *screen,
screen->req.x = params->window_x; screen->req.x = params->window_x;
screen->req.y = params->window_y; screen->req.y = params->window_y;
screen->req.system_resize = params->system_resize;
screen->req.width = params->window_width; screen->req.width = params->window_width;
screen->req.height = params->window_height; screen->req.height = params->window_height;
screen->req.fullscreen = params->fullscreen; screen->req.fullscreen = params->fullscreen;

@ -38,6 +38,7 @@ struct sc_screen {
uint16_t width; uint16_t width;
uint16_t height; uint16_t height;
bool fullscreen; bool fullscreen;
bool system_resize;
bool start_fps_counter; bool start_fps_counter;
} req; } req;
@ -79,6 +80,7 @@ struct sc_screen_params {
const char *window_title; const char *window_title;
bool always_on_top; bool always_on_top;
bool system_resize;
int16_t window_x; // accepts SC_WINDOW_POSITION_UNDEFINED int16_t window_x; // accepts SC_WINDOW_POSITION_UNDEFINED
int16_t window_y; // accepts SC_WINDOW_POSITION_UNDEFINED int16_t window_y; // accepts SC_WINDOW_POSITION_UNDEFINED

@ -159,6 +159,7 @@ scrcpy_otg(struct scrcpy_options *options) {
.mouse = mouse, .mouse = mouse,
.window_title = window_title, .window_title = window_title,
.always_on_top = options->always_on_top, .always_on_top = options->always_on_top,
.system_resize = options->system_resize,
.window_x = options->window_x, .window_x = options->window_x,
.window_y = options->window_y, .window_y = options->window_y,
.window_width = options->window_width, .window_width = options->window_width,

@ -29,6 +29,7 @@ struct sc_screen_otg_params {
bool always_on_top; bool always_on_top;
int16_t window_x; // accepts SC_WINDOW_POSITION_UNDEFINED int16_t window_x; // accepts SC_WINDOW_POSITION_UNDEFINED
int16_t window_y; // accepts SC_WINDOW_POSITION_UNDEFINED int16_t window_y; // accepts SC_WINDOW_POSITION_UNDEFINED
bool system_resize;
uint16_t window_width; uint16_t window_width;
uint16_t window_height; uint16_t window_height;
bool window_borderless; bool window_borderless;

Loading…
Cancel
Save