Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad6b8847d4 | ||
|
|
fba89e6f73 | ||
|
|
4bf2b80c75 | ||
|
|
f983ec67fa |
-30
@@ -268,33 +268,3 @@ For more details, go read the code!
|
|||||||
|
|
||||||
If you find a bug, or have an awesome idea to implement, please discuss and
|
If you find a bug, or have an awesome idea to implement, please discuss and
|
||||||
contribute ;-)
|
contribute ;-)
|
||||||
|
|
||||||
|
|
||||||
### Debug the server
|
|
||||||
|
|
||||||
The server is pushed to the device by the client on startup.
|
|
||||||
|
|
||||||
To debug it, enable the server debugger during configuration:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
meson x -Dserver_debugger=true
|
|
||||||
# or, if x is already configured
|
|
||||||
meson configure x -Dserver_debugger=true
|
|
||||||
```
|
|
||||||
|
|
||||||
Then recompile.
|
|
||||||
|
|
||||||
When you start scrcpy, it will start a debugger on port 5005 on the device.
|
|
||||||
Redirect that port to the computer:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
adb forward tcp:5005 tcp:5005
|
|
||||||
```
|
|
||||||
|
|
||||||
In Android Studio, _Run_ > _Debug_ > _Edit configurations..._ On the left, click on
|
|
||||||
`+`, _Remote_, and fill the form:
|
|
||||||
|
|
||||||
- Host: `localhost`
|
|
||||||
- Port: `5005`
|
|
||||||
|
|
||||||
Then click on _Debug_.
|
|
||||||
|
|||||||
+3
-6
@@ -109,15 +109,12 @@ conf.set('DEFAULT_MAX_SIZE', '0') # 0: unlimited
|
|||||||
# overridden by option --bit-rate
|
# overridden by option --bit-rate
|
||||||
conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps
|
conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps
|
||||||
|
|
||||||
|
# enable High DPI support
|
||||||
|
conf.set('HIDPI_SUPPORT', get_option('hidpi_support'))
|
||||||
|
|
||||||
# disable console on Windows
|
# disable console on Windows
|
||||||
conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole'))
|
conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole'))
|
||||||
|
|
||||||
# run a server debugger and wait for a client to be attached
|
|
||||||
conf.set('SERVER_DEBUGGER', get_option('server_debugger'))
|
|
||||||
|
|
||||||
# enable a workaround for bug #15
|
|
||||||
conf.set('HIDPI_WORKAROUND', get_option('hidpi_workaround'))
|
|
||||||
|
|
||||||
configure_file(configuration: conf, output: 'config.h')
|
configure_file(configuration: conf, output: 'config.h')
|
||||||
|
|
||||||
src_dir = include_directories('src')
|
src_dir = include_directories('src')
|
||||||
|
|||||||
@@ -106,6 +106,29 @@ Print the version of scrcpy.
|
|||||||
.BI \-\-window\-title " text
|
.BI \-\-window\-title " text
|
||||||
Set a custom window title.
|
Set a custom window title.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BI \-\-window\-x " value
|
||||||
|
Set the initial window horizontal position.
|
||||||
|
|
||||||
|
Default is -1 (automatic).\n
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BI \-\-window\-y " value
|
||||||
|
Set the initial window vertical position.
|
||||||
|
|
||||||
|
Default is -1 (automatic).\n
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BI \-\-window\-width " value
|
||||||
|
Set the initial window width.
|
||||||
|
|
||||||
|
Default is 0 (automatic).\n
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BI \-\-window\-height " value
|
||||||
|
Set the initial window height.
|
||||||
|
|
||||||
|
Default is 0 (automatic).\n
|
||||||
|
|
||||||
.SH SHORTCUTS
|
.SH SHORTCUTS
|
||||||
|
|
||||||
|
|||||||
+113
-4
@@ -29,9 +29,14 @@ struct args {
|
|||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint16_t max_size;
|
uint16_t max_size;
|
||||||
uint32_t bit_rate;
|
uint32_t bit_rate;
|
||||||
|
int16_t window_x;
|
||||||
|
int16_t window_y;
|
||||||
|
uint16_t window_width;
|
||||||
|
uint16_t window_height;
|
||||||
bool always_on_top;
|
bool always_on_top;
|
||||||
bool turn_screen_off;
|
bool turn_screen_off;
|
||||||
bool render_expired_frames;
|
bool render_expired_frames;
|
||||||
|
bool window_borderless;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void usage(const char *arg0) {
|
static void usage(const char *arg0) {
|
||||||
@@ -115,9 +120,28 @@ 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"
|
||||||
|
" --window-x value\n"
|
||||||
|
" Set the initial window horizontal position.\n"
|
||||||
|
" Default is -1 (automatic).\n"
|
||||||
|
"\n"
|
||||||
|
" --window-y value\n"
|
||||||
|
" Set the initial window vertical position.\n"
|
||||||
|
" Default is -1 (automatic).\n"
|
||||||
|
"\n"
|
||||||
|
" --window-width value\n"
|
||||||
|
" Set the initial window width.\n"
|
||||||
|
" Default is -1 (automatic).\n"
|
||||||
|
"\n"
|
||||||
|
" --window-height value\n"
|
||||||
|
" Set the initial window width.\n"
|
||||||
|
" Default is -1 (automatic).\n"
|
||||||
|
"\n"
|
||||||
"Shortcuts:\n"
|
"Shortcuts:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" " CTRL_OR_CMD "+f\n"
|
" " CTRL_OR_CMD "+f\n"
|
||||||
@@ -258,6 +282,48 @@ parse_max_size(char *optarg, uint16_t *max_size) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
parse_window_position(char *optarg, int16_t *position) {
|
||||||
|
char *endptr;
|
||||||
|
if (*optarg == '\0') {
|
||||||
|
LOGE("Window position parameter is empty");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
long value = strtol(optarg, &endptr, 0);
|
||||||
|
if (*endptr != '\0') {
|
||||||
|
LOGE("Invalid window position: %s", optarg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (value < -1 || value > 0x7fff) {
|
||||||
|
LOGE("Window position must be between -1 and 32767: %ld", value);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*position = (int16_t) value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
parse_window_dimension(char *optarg, uint16_t *dimension) {
|
||||||
|
char *endptr;
|
||||||
|
if (*optarg == '\0') {
|
||||||
|
LOGE("Window dimension parameter is empty");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
long value = strtol(optarg, &endptr, 0);
|
||||||
|
if (*endptr != '\0') {
|
||||||
|
LOGE("Invalid window dimension: %s", optarg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (value & ~0xffff) {
|
||||||
|
LOGE("Window position must be between 0 and 65535: %ld", value);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dimension = (uint16_t) value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_port(char *optarg, uint16_t *port) {
|
parse_port(char *optarg, uint16_t *port) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
@@ -310,8 +376,13 @@ guess_record_format(const char *filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define OPT_RENDER_EXPIRED_FRAMES 1000
|
#define OPT_RENDER_EXPIRED_FRAMES 1000
|
||||||
#define OPT_WINDOW_TITLE 1001
|
#define OPT_PUSH_TARGET 1001
|
||||||
#define OPT_PUSH_TARGET 1002
|
#define OPT_WINDOW_TITLE 1002
|
||||||
|
#define OPT_WINDOW_X 1003
|
||||||
|
#define OPT_WINDOW_Y 1004
|
||||||
|
#define OPT_WINDOW_WIDTH 1005
|
||||||
|
#define OPT_WINDOW_HEIGHT 1006
|
||||||
|
#define OPT_WINDOW_BORDERLESS 1007
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_args(struct args *args, int argc, char *argv[]) {
|
parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
@@ -324,6 +395,8 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
{"max-size", required_argument, NULL, 'm'},
|
{"max-size", required_argument, NULL, 'm'},
|
||||||
{"no-control", no_argument, NULL, 'n'},
|
{"no-control", no_argument, NULL, 'n'},
|
||||||
{"no-display", no_argument, NULL, 'N'},
|
{"no-display", no_argument, NULL, 'N'},
|
||||||
|
{"window-borderless", no_argument, NULL,
|
||||||
|
OPT_WINDOW_BORDERLESS},
|
||||||
{"port", required_argument, NULL, 'p'},
|
{"port", required_argument, NULL, 'p'},
|
||||||
{"push-target", required_argument, NULL,
|
{"push-target", required_argument, NULL,
|
||||||
OPT_PUSH_TARGET},
|
OPT_PUSH_TARGET},
|
||||||
@@ -335,8 +408,11 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
{"show-touches", no_argument, NULL, 't'},
|
{"show-touches", no_argument, NULL, 't'},
|
||||||
{"turn-screen-off", no_argument, NULL, 'S'},
|
{"turn-screen-off", no_argument, NULL, 'S'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"window-title", required_argument, NULL,
|
{"window-title", required_argument, NULL, OPT_WINDOW_TITLE},
|
||||||
OPT_WINDOW_TITLE},
|
{"window-x", required_argument, NULL, OPT_WINDOW_X},
|
||||||
|
{"window-y", required_argument, NULL, OPT_WINDOW_Y},
|
||||||
|
{"window-width", required_argument, NULL, OPT_WINDOW_WIDTH},
|
||||||
|
{"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT},
|
||||||
{NULL, 0, NULL, 0 },
|
{NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
int c;
|
int c;
|
||||||
@@ -402,6 +478,29 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
case OPT_WINDOW_TITLE:
|
case OPT_WINDOW_TITLE:
|
||||||
args->window_title = optarg;
|
args->window_title = optarg;
|
||||||
break;
|
break;
|
||||||
|
case OPT_WINDOW_X:
|
||||||
|
if (!parse_window_position(optarg, &args->window_x)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OPT_WINDOW_Y:
|
||||||
|
if (!parse_window_position(optarg, &args->window_y)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OPT_WINDOW_WIDTH:
|
||||||
|
if (!parse_window_dimension(optarg, &args->window_width)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OPT_WINDOW_HEIGHT:
|
||||||
|
if (!parse_window_dimension(optarg, &args->window_height)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OPT_WINDOW_BORDERLESS:
|
||||||
|
args->window_borderless = true;
|
||||||
|
break;
|
||||||
case OPT_PUSH_TARGET:
|
case OPT_PUSH_TARGET:
|
||||||
args->push_target = optarg;
|
args->push_target = optarg;
|
||||||
break;
|
break;
|
||||||
@@ -470,11 +569,16 @@ main(int argc, char *argv[]) {
|
|||||||
.port = DEFAULT_LOCAL_PORT,
|
.port = DEFAULT_LOCAL_PORT,
|
||||||
.max_size = DEFAULT_MAX_SIZE,
|
.max_size = DEFAULT_MAX_SIZE,
|
||||||
.bit_rate = DEFAULT_BIT_RATE,
|
.bit_rate = DEFAULT_BIT_RATE,
|
||||||
|
.window_x = -1,
|
||||||
|
.window_y = -1,
|
||||||
|
.window_width = 0,
|
||||||
|
.window_height = 0,
|
||||||
.always_on_top = false,
|
.always_on_top = false,
|
||||||
.no_control = false,
|
.no_control = false,
|
||||||
.no_display = false,
|
.no_display = false,
|
||||||
.turn_screen_off = false,
|
.turn_screen_off = false,
|
||||||
.render_expired_frames = false,
|
.render_expired_frames = false,
|
||||||
|
.window_borderless = false,
|
||||||
};
|
};
|
||||||
if (!parse_args(&args, argc, argv)) {
|
if (!parse_args(&args, argc, argv)) {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -514,6 +618,10 @@ main(int argc, char *argv[]) {
|
|||||||
.record_format = args.record_format,
|
.record_format = args.record_format,
|
||||||
.max_size = args.max_size,
|
.max_size = args.max_size,
|
||||||
.bit_rate = args.bit_rate,
|
.bit_rate = args.bit_rate,
|
||||||
|
.window_x = args.window_x,
|
||||||
|
.window_y = args.window_y,
|
||||||
|
.window_width = args.window_width,
|
||||||
|
.window_height = args.window_height,
|
||||||
.show_touches = args.show_touches,
|
.show_touches = args.show_touches,
|
||||||
.fullscreen = args.fullscreen,
|
.fullscreen = args.fullscreen,
|
||||||
.always_on_top = args.always_on_top,
|
.always_on_top = args.always_on_top,
|
||||||
@@ -521,6 +629,7 @@ main(int argc, char *argv[]) {
|
|||||||
.display = !args.no_display,
|
.display = !args.no_display,
|
||||||
.turn_screen_off = args.turn_screen_off,
|
.turn_screen_off = args.turn_screen_off,
|
||||||
.render_expired_frames = args.render_expired_frames,
|
.render_expired_frames = args.render_expired_frames,
|
||||||
|
.window_borderless = args.window_borderless,
|
||||||
};
|
};
|
||||||
int res = scrcpy(&options) ? 0 : 1;
|
int res = scrcpy(&options) ? 0 : 1;
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -145,10 +145,8 @@ handle_event(SDL_Event *event, bool control) {
|
|||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
switch (event->window.event) {
|
switch (event->window.event) {
|
||||||
case SDL_WINDOWEVENT_EXPOSED:
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
screen_render(&screen);
|
|
||||||
break;
|
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
screen_window_resized(&screen);
|
screen_render(&screen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -392,7 +390,10 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
options->window_title ? options->window_title : device_name;
|
options->window_title ? options->window_title : device_name;
|
||||||
|
|
||||||
if (!screen_init_rendering(&screen, window_title, frame_size,
|
if (!screen_init_rendering(&screen, window_title, frame_size,
|
||||||
options->always_on_top)) {
|
options->always_on_top, options->window_x,
|
||||||
|
options->window_y, options->window_width,
|
||||||
|
options->window_height,
|
||||||
|
options->window_borderless)) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ struct scrcpy_options {
|
|||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint16_t max_size;
|
uint16_t max_size;
|
||||||
uint32_t bit_rate;
|
uint32_t bit_rate;
|
||||||
|
int16_t window_x;
|
||||||
|
int16_t window_y;
|
||||||
|
uint16_t window_width;
|
||||||
|
uint16_t window_height;
|
||||||
bool show_touches;
|
bool show_touches;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool always_on_top;
|
bool always_on_top;
|
||||||
@@ -24,6 +28,7 @@ struct scrcpy_options {
|
|||||||
bool display;
|
bool display;
|
||||||
bool turn_screen_off;
|
bool turn_screen_off;
|
||||||
bool render_expired_frames;
|
bool render_expired_frames;
|
||||||
|
bool window_borderless;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
+56
-89
@@ -117,9 +117,30 @@ get_optimal_window_size(const struct screen *screen, struct size frame_size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initially, there is no current size, so use the frame size as current size
|
// initially, there is no current size, so use the frame size as current size
|
||||||
|
// req_width and req_height, if not 0, are the sizes requested by the user
|
||||||
static inline struct size
|
static inline struct size
|
||||||
get_initial_optimal_size(struct size frame_size) {
|
get_initial_optimal_size(struct size frame_size, uint16_t req_width,
|
||||||
return get_optimal_size(frame_size, frame_size);
|
uint16_t req_height) {
|
||||||
|
struct size window_size;
|
||||||
|
if (!req_width && !req_height) {
|
||||||
|
window_size = get_optimal_size(frame_size, frame_size);
|
||||||
|
} else {
|
||||||
|
if (req_width) {
|
||||||
|
window_size.width = req_width;
|
||||||
|
} else {
|
||||||
|
// compute from the requested height
|
||||||
|
window_size.width = (uint32_t) req_height * frame_size.width
|
||||||
|
/ frame_size.height;
|
||||||
|
}
|
||||||
|
if (req_height) {
|
||||||
|
window_size.height = req_height;
|
||||||
|
} else {
|
||||||
|
// compute from the requested width
|
||||||
|
window_size.height = (uint32_t) req_width * frame_size.height
|
||||||
|
/ frame_size.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -134,57 +155,19 @@ create_texture(SDL_Renderer *renderer, struct size frame_size) {
|
|||||||
frame_size.width, frame_size.height);
|
frame_size.width, frame_size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HIDPI_WORKAROUND
|
|
||||||
static void
|
|
||||||
screen_get_sizes(struct screen *screen, struct screen_sizes *out) {
|
|
||||||
int ww, wh, dw, dh;
|
|
||||||
SDL_GetWindowSize(screen->window, &ww, &wh);
|
|
||||||
SDL_GL_GetDrawableSize(screen->window, &dw, &dh);
|
|
||||||
out->window.width = ww;
|
|
||||||
out->window.height = wh;
|
|
||||||
out->window.width = dw;
|
|
||||||
out->window.height = dh;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This may be called more than once to work around SDL bugs
|
|
||||||
static bool
|
|
||||||
screen_init_renderer_and_texture(struct screen *screen) {
|
|
||||||
screen->renderer = SDL_CreateRenderer(screen->window, -1,
|
|
||||||
SDL_RENDERER_ACCELERATED);
|
|
||||||
if (!screen->renderer) {
|
|
||||||
LOGC("Could not create renderer: %s", SDL_GetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_RenderSetLogicalSize(screen->renderer, screen->frame_size.width,
|
|
||||||
screen->frame_size.height)) {
|
|
||||||
LOGE("Could not set renderer logical size: %s", SDL_GetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
screen->texture = create_texture(screen->renderer, screen->frame_size);
|
|
||||||
if (!screen->texture) {
|
|
||||||
LOGC("Could not create texture: %s", SDL_GetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HIDPI_WORKAROUND
|
|
||||||
screen_get_sizes(screen, &screen->sizes);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
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,
|
||||||
|
uint16_t window_height, bool window_borderless) {
|
||||||
screen->frame_size = frame_size;
|
screen->frame_size = frame_size;
|
||||||
|
|
||||||
struct size window_size = get_initial_optimal_size(frame_size);
|
struct size window_size =
|
||||||
uint32_t window_flags = SDL_WINDOW_HIDDEN
|
get_initial_optimal_size(frame_size, window_width, window_height);
|
||||||
| SDL_WINDOW_RESIZABLE
|
uint32_t window_flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
|
||||||
| SDL_WINDOW_ALLOW_HIGHDPI;
|
#ifdef HIDPI_SUPPORT
|
||||||
|
window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
|
#endif
|
||||||
if (always_on_top) {
|
if (always_on_top) {
|
||||||
#ifdef SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP
|
#ifdef SCRCPY_SDL_HAS_WINDOW_ALWAYS_ON_TOP
|
||||||
window_flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
window_flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
||||||
@@ -193,9 +176,13 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
screen->window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_UNDEFINED,
|
int x = window_x != -1 ? window_x : SDL_WINDOWPOS_UNDEFINED;
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
int y = window_y != -1 ? window_y : SDL_WINDOWPOS_UNDEFINED;
|
||||||
|
screen->window = SDL_CreateWindow(window_title, x, y,
|
||||||
window_size.width, window_size.height,
|
window_size.width, window_size.height,
|
||||||
window_flags);
|
window_flags);
|
||||||
if (!screen->window) {
|
if (!screen->window) {
|
||||||
@@ -203,6 +190,21 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screen->renderer = SDL_CreateRenderer(screen->window, -1,
|
||||||
|
SDL_RENDERER_ACCELERATED);
|
||||||
|
if (!screen->renderer) {
|
||||||
|
LOGC("Could not create renderer: %s", SDL_GetError());
|
||||||
|
screen_destroy(screen);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SDL_RenderSetLogicalSize(screen->renderer, frame_size.width,
|
||||||
|
frame_size.height)) {
|
||||||
|
LOGE("Could not set renderer logical size: %s", SDL_GetError());
|
||||||
|
screen_destroy(screen);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Surface *icon = read_xpm(icon_xpm);
|
SDL_Surface *icon = read_xpm(icon_xpm);
|
||||||
if (icon) {
|
if (icon) {
|
||||||
SDL_SetWindowIcon(screen->window, icon);
|
SDL_SetWindowIcon(screen->window, icon);
|
||||||
@@ -213,7 +215,9 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|||||||
|
|
||||||
LOGI("Initial texture: %" PRIu16 "x%" PRIu16, frame_size.width,
|
LOGI("Initial texture: %" PRIu16 "x%" PRIu16, frame_size.width,
|
||||||
frame_size.height);
|
frame_size.height);
|
||||||
if (!screen_init_renderer_and_texture(screen)) {
|
screen->texture = create_texture(screen->renderer, frame_size);
|
||||||
|
if (!screen->texture) {
|
||||||
|
LOGC("Could not create texture: %s", SDL_GetError());
|
||||||
screen_destroy(screen);
|
screen_destroy(screen);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -302,43 +306,6 @@ screen_update_frame(struct screen *screen, struct video_buffer *vb) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HIDPI_WORKAROUND
|
|
||||||
// workaround for <https://github.com/Genymobile/scrcpy/issues/15>
|
|
||||||
static inline bool
|
|
||||||
screen_fix_hidpi(struct screen *screen) {
|
|
||||||
struct screen_sizes cur;
|
|
||||||
screen_get_sizes(screen, &cur);
|
|
||||||
|
|
||||||
struct screen_sizes *prev = &screen->sizes;
|
|
||||||
|
|
||||||
bool width_ratio_changed = cur.window.width * prev->drawable.width !=
|
|
||||||
cur.drawable.width * prev->window.width;
|
|
||||||
bool height_ratio_changed = cur.window.height * prev->drawable.height !=
|
|
||||||
cur.drawable.height * prev->window.height;
|
|
||||||
if (width_ratio_changed || height_ratio_changed) {
|
|
||||||
SDL_DestroyTexture(screen->texture);
|
|
||||||
SDL_DestroyRenderer(screen->renderer);
|
|
||||||
if (!screen_init_renderer_and_texture(screen)) {
|
|
||||||
screen->texture = NULL;
|
|
||||||
screen->renderer = NULL;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGI("Renderer reset after hidpi scaling changed");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
|
||||||
screen_window_resized(struct screen *screen) {
|
|
||||||
#ifdef HIDPI_WORKAROUND
|
|
||||||
screen_fix_hidpi(screen);
|
|
||||||
#endif
|
|
||||||
screen_render(screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_render(struct screen *screen) {
|
screen_render(struct screen *screen) {
|
||||||
SDL_RenderClear(screen->renderer);
|
SDL_RenderClear(screen->renderer);
|
||||||
|
|||||||
+3
-11
@@ -20,12 +20,6 @@ struct screen {
|
|||||||
bool has_frame;
|
bool has_frame;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool no_window;
|
bool no_window;
|
||||||
#ifdef HIDPI_WORKAROUND
|
|
||||||
struct screen_sizes {
|
|
||||||
struct size window;
|
|
||||||
struct size drawable;
|
|
||||||
} sizes;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCREEN_INITIALIZER { \
|
#define SCREEN_INITIALIZER { \
|
||||||
@@ -52,7 +46,9 @@ screen_init(struct screen *screen);
|
|||||||
// initialize screen, create window, renderer and texture (window is hidden)
|
// initialize screen, create window, renderer and texture (window is hidden)
|
||||||
bool
|
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,
|
||||||
|
uint16_t window_height, bool window_borderless);
|
||||||
|
|
||||||
// show the window
|
// show the window
|
||||||
void
|
void
|
||||||
@@ -66,10 +62,6 @@ screen_destroy(struct screen *screen);
|
|||||||
bool
|
bool
|
||||||
screen_update_frame(struct screen *screen, struct video_buffer *vb);
|
screen_update_frame(struct screen *screen, struct video_buffer *vb);
|
||||||
|
|
||||||
// update content after window resizing
|
|
||||||
void
|
|
||||||
screen_window_resized(struct screen *screen);
|
|
||||||
|
|
||||||
// render the texture to the renderer
|
// render the texture to the renderer
|
||||||
void
|
void
|
||||||
screen_render(struct screen *screen);
|
screen_render(struct screen *screen);
|
||||||
|
|||||||
@@ -124,11 +124,6 @@ execute_server(struct server *server, const struct server_params *params) {
|
|||||||
"shell",
|
"shell",
|
||||||
"CLASSPATH=/data/local/tmp/" SERVER_FILENAME,
|
"CLASSPATH=/data/local/tmp/" SERVER_FILENAME,
|
||||||
"app_process",
|
"app_process",
|
||||||
#ifdef SERVER_DEBUGGER
|
|
||||||
# define SERVER_DEBUGGER_PORT "5005"
|
|
||||||
"-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address="
|
|
||||||
SERVER_DEBUGGER_PORT,
|
|
||||||
#endif
|
|
||||||
"/", // unused
|
"/", // unused
|
||||||
"com.genymobile.scrcpy.Server",
|
"com.genymobile.scrcpy.Server",
|
||||||
max_size_string,
|
max_size_string,
|
||||||
@@ -138,17 +133,6 @@ execute_server(struct server *server, const struct server_params *params) {
|
|||||||
"true", // always send frame meta (packet boundaries + timestamp)
|
"true", // always send frame meta (packet boundaries + timestamp)
|
||||||
params->control ? "true" : "false",
|
params->control ? "true" : "false",
|
||||||
};
|
};
|
||||||
#ifdef SERVER_DEBUGGER
|
|
||||||
LOGI("Server debugger waiting for a client on device port "
|
|
||||||
SERVER_DEBUGGER_PORT "...");
|
|
||||||
// From the computer, run
|
|
||||||
// adb forward tcp:5005 tcp:5005
|
|
||||||
// Then, from Android Studio: Run > Debug > Edit configurations...
|
|
||||||
// On the left, click on '+', "Remote", with:
|
|
||||||
// Host: localhost
|
|
||||||
// Port: 5005
|
|
||||||
// Then click on "Debug"
|
|
||||||
#endif
|
|
||||||
return adb_execute(server->serial, cmd, sizeof(cmd) / sizeof(cmd[0]));
|
return adb_execute(server->serial, cmd, sizeof(cmd) / sizeof(cmd[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -4,5 +4,4 @@ option('crossbuild_windows', type: 'boolean', value: false, description: 'Build
|
|||||||
option('windows_noconsole', type: 'boolean', value: false, description: 'Disable console on Windows (pass -mwindows flag)')
|
option('windows_noconsole', type: 'boolean', value: false, description: 'Disable console on Windows (pass -mwindows flag)')
|
||||||
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
|
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
|
||||||
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
|
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
|
||||||
option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')
|
option('hidpi_support', type: 'boolean', value: true, description: 'Enable High DPI support')
|
||||||
option('hidpi_workaround', type: 'boolean', value: true, description: 'Enable a workaround for bug #15')
|
|
||||||
|
|||||||
Reference in New Issue
Block a user