fix: window crash on tiling wayland WM

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

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

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

@ -97,6 +97,7 @@ enum {
OPT_MOUSE,
OPT_HID_KEYBOARD_DEPRECATED,
OPT_HID_MOUSE_DEPRECATED,
OPT_SYSTEM_RESIZE,
};
struct sc_option {
@ -877,6 +878,11 @@ static const struct sc_option options[] = {
.text = "Set the initial window height.\n"
"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[] = {
@ -2186,6 +2192,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
case OPT_ALWAYS_ON_TOP:
opts->always_on_top = true;
break;
case OPT_SYSTEM_RESIZE:
opts->system_resize = true;
break;
case 'v':
args->version = true;
break;

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

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

@ -699,6 +699,7 @@ scrcpy(struct scrcpy_options *options) {
.shortcut_mods = &options->shortcut_mods,
.window_title = window_title,
.always_on_top = options->always_on_top,
.system_resize = options->system_resize,
.window_x = options->window_x,
.window_y = options->window_y,
.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->maximized);
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)
@ -365,6 +367,7 @@ sc_screen_init(struct sc_screen *screen,
screen->req.x = params->window_x;
screen->req.y = params->window_y;
screen->req.system_resize = params->system_resize;
screen->req.width = params->window_width;
screen->req.height = params->window_height;
screen->req.fullscreen = params->fullscreen;

@ -38,6 +38,7 @@ struct sc_screen {
uint16_t width;
uint16_t height;
bool fullscreen;
bool system_resize;
bool start_fps_counter;
} req;
@ -79,6 +80,7 @@ struct sc_screen_params {
const char *window_title;
bool always_on_top;
bool system_resize;
int16_t window_x; // 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,
.window_title = window_title,
.always_on_top = options->always_on_top,
.system_resize = options->system_resize,
.window_x = options->window_x,
.window_y = options->window_y,
.window_width = options->window_width,

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

Loading…
Cancel
Save