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 9fd7a80a89
commit 59bc5bc1f5
5 changed files with 18 additions and 3 deletions

View file

@ -107,6 +107,9 @@ static void usage(const char *arg0) {
" -v, --version\n" " -v, --version\n"
" Print the version of scrcpy.\n" " Print the version of scrcpy.\n"
"\n" "\n"
" --window-borderless\n"
" Disable window decorations (display borderless window).\n"
"\n"
" --window-title text\n" " --window-title text\n"
" Set a custom window title.\n" " Set a custom window title.\n"
"\n" "\n"
@ -370,6 +373,7 @@ guess_record_format(const char *filename) {
#define OPT_WINDOW_Y 1008 #define OPT_WINDOW_Y 1008
#define OPT_WINDOW_WIDTH 1009 #define OPT_WINDOW_WIDTH 1009
#define OPT_WINDOW_HEIGHT 1010 #define OPT_WINDOW_HEIGHT 1010
#define OPT_WINDOW_BORDERLESS 1011
static bool static bool
parse_args(struct args *args, int argc, char *argv[]) { parse_args(struct args *args, int argc, char *argv[]) {
@ -398,6 +402,8 @@ parse_args(struct args *args, int argc, char *argv[]) {
{"window-y", required_argument, NULL, OPT_WINDOW_Y}, {"window-y", required_argument, NULL, OPT_WINDOW_Y},
{"window-width", required_argument, NULL, OPT_WINDOW_WIDTH}, {"window-width", required_argument, NULL, OPT_WINDOW_WIDTH},
{"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT}, {"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT},
{"window-borderless", no_argument, NULL,
OPT_WINDOW_BORDERLESS},
{NULL, 0, NULL, 0 }, {NULL, 0, NULL, 0 },
}; };
@ -495,6 +501,9 @@ parse_args(struct args *args, int argc, char *argv[]) {
return false; return false;
} }
break; break;
case OPT_WINDOW_BORDERLESS:
opts->window_borderless = true;
break;
case OPT_PUSH_TARGET: case OPT_PUSH_TARGET:
opts->push_target = optarg; opts->push_target = optarg;
break; break;

View file

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

View file

@ -30,6 +30,7 @@ struct scrcpy_options {
bool turn_screen_off; bool turn_screen_off;
bool render_expired_frames; bool render_expired_frames;
bool prefer_text; bool prefer_text;
bool window_borderless;
}; };
#define SCRCPY_OPTIONS_DEFAULT { \ #define SCRCPY_OPTIONS_DEFAULT { \
@ -54,6 +55,7 @@ struct scrcpy_options {
.turn_screen_off = false, \ .turn_screen_off = false, \
.render_expired_frames = false, \ .render_expired_frames = false, \
.prefer_text = false, \ .prefer_text = false, \
.window_borderless = false, \
} }
bool bool

View file

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

View file

@ -57,7 +57,7 @@ bool
screen_init_rendering(struct screen *screen, const char *window_title, screen_init_rendering(struct screen *screen, const char *window_title,
struct size frame_size, bool always_on_top, struct size frame_size, bool always_on_top,
int16_t window_x, int16_t window_y, uint16_t window_width, 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 // show the window
void void