Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply requested window size in OTG mode #3219

Merged
merged 4 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/usb/scrcpy_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ scrcpy_otg(struct scrcpy_options *options) {

const char *serial = options->serial;

if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1")) {
LOGW("Could not enable linear filtering");
}

// Minimal SDL initialization
if (SDL_Init(SDL_INIT_EVENTS)) {
LOGE("Could not initialize SDL: %s", SDL_GetError());
Expand Down Expand Up @@ -162,6 +166,8 @@ scrcpy_otg(struct scrcpy_options *options) {
.always_on_top = options->always_on_top,
.window_x = options->window_x,
.window_y = options->window_y,
.window_width = options->window_width,
.window_height = options->window_height,
.window_borderless = options->window_borderless,
};

Expand Down
12 changes: 9 additions & 3 deletions app/src/usb/screen_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ sc_screen_otg_init(struct sc_screen_otg *screen,
? params->window_x : (int) SDL_WINDOWPOS_UNDEFINED;
int y = params->window_y != SC_WINDOW_POSITION_UNDEFINED
? params->window_y : (int) SDL_WINDOWPOS_UNDEFINED;
int width = 256;
int height = 256;
int width = params->window_width ? params->window_width : 256;
int height = params->window_height ? params->window_height : 256;

uint32_t window_flags = 0;
uint32_t window_flags = SDL_WINDOW_ALLOW_HIGHDPI
| SDL_WINDOW_RESIZABLE;
if (params->always_on_top) {
window_flags |= SDL_WINDOW_ALWAYS_ON_TOP;
}
Expand All @@ -97,6 +98,11 @@ sc_screen_otg_init(struct sc_screen_otg *screen,
if (icon) {
SDL_SetWindowIcon(screen->window, icon);

if (!SDL_RenderSetLogicalSize(screen->renderer, icon->w, icon->h)) {
LOGW("Could not set renderer logical size: %s", SDL_GetError());
// don't fail
}

screen->texture = SDL_CreateTextureFromSurface(screen->renderer, icon);
scrcpy_icon_destroy(icon);
if (!screen->texture) {
Expand Down
2 changes: 2 additions & 0 deletions app/src/usb/screen_otg.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ 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
uint16_t window_width;
uint16_t window_height;
bool window_borderless;
};

Expand Down