Add option to disable window decoration

Add --window-borderless parameter.

Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
Diego Fernando Díaz A 2019-08-29 00:25:17 -05:00 committed by Romain Vimont
parent fba89e6f73
commit ad6b8847d4
5 changed files with 20 additions and 3 deletions

View File

@ -36,6 +36,7 @@ struct args {
bool always_on_top;
bool turn_screen_off;
bool render_expired_frames;
bool window_borderless;
};
static void usage(const char *arg0) {
@ -119,6 +120,9 @@ static void usage(const char *arg0) {
" -v, --version\n"
" Print the version of scrcpy.\n"
"\n"
" --window_borderless\n"
" Disable window decorations (display borderless window).\n"
"\n"
" --window-title text\n"
" Set a custom window title.\n"
"\n"
@ -378,6 +382,7 @@ guess_record_format(const char *filename) {
#define OPT_WINDOW_Y 1004
#define OPT_WINDOW_WIDTH 1005
#define OPT_WINDOW_HEIGHT 1006
#define OPT_WINDOW_BORDERLESS 1007
static bool
parse_args(struct args *args, int argc, char *argv[]) {
@ -390,6 +395,8 @@ parse_args(struct args *args, int argc, char *argv[]) {
{"max-size", required_argument, NULL, 'm'},
{"no-control", no_argument, NULL, 'n'},
{"no-display", no_argument, NULL, 'N'},
{"window-borderless", no_argument, NULL,
OPT_WINDOW_BORDERLESS},
{"port", required_argument, NULL, 'p'},
{"push-target", required_argument, NULL,
OPT_PUSH_TARGET},
@ -491,6 +498,9 @@ parse_args(struct args *args, int argc, char *argv[]) {
return false;
}
break;
case OPT_WINDOW_BORDERLESS:
args->window_borderless = true;
break;
case OPT_PUSH_TARGET:
args->push_target = optarg;
break;
@ -568,6 +578,7 @@ main(int argc, char *argv[]) {
.no_display = false,
.turn_screen_off = false,
.render_expired_frames = false,
.window_borderless = false,
};
if (!parse_args(&args, argc, argv)) {
return 1;
@ -618,6 +629,7 @@ main(int argc, char *argv[]) {
.display = !args.no_display,
.turn_screen_off = args.turn_screen_off,
.render_expired_frames = args.render_expired_frames,
.window_borderless = args.window_borderless,
};
int res = scrcpy(&options) ? 0 : 1;

View File

@ -392,7 +392,8 @@ scrcpy(const struct scrcpy_options *options) {
if (!screen_init_rendering(&screen, window_title, frame_size,
options->always_on_top, options->window_x,
options->window_y, options->window_width,
options->window_height)) {
options->window_height,
options->window_borderless)) {
goto end;
}

View File

@ -28,6 +28,7 @@ struct scrcpy_options {
bool display;
bool turn_screen_off;
bool render_expired_frames;
bool window_borderless;
};
bool

View File

@ -159,7 +159,7 @@ bool
screen_init_rendering(struct screen *screen, const char *window_title,
struct size frame_size, bool always_on_top,
int16_t window_x, int16_t window_y, uint16_t window_width,
uint16_t window_height) {
uint16_t window_height, bool window_borderless) {
screen->frame_size = frame_size;
struct size window_size =
@ -176,6 +176,9 @@ screen_init_rendering(struct screen *screen, const char *window_title,
"(compile with SDL >= 2.0.5 to enable it)");
#endif
}
if (window_borderless) {
window_flags |= SDL_WINDOW_BORDERLESS;
}
int x = window_x != -1 ? window_x : SDL_WINDOWPOS_UNDEFINED;
int y = window_y != -1 ? window_y : SDL_WINDOWPOS_UNDEFINED;

View File

@ -48,7 +48,7 @@ bool
screen_init_rendering(struct screen *screen, const char *window_title,
struct size frame_size, bool always_on_top,
int16_t window_x, int16_t window_y, uint16_t window_width,
uint16_t window_height);
uint16_t window_height, bool window_borderless);
// show the window
void