Skip to content

Display and control your Android device

Use is_icon flag to compute content rectangle

Romain Vimonte4d91f0cc3b8
diff --git a/app/src/screen.c b/app/src/screen.c
index 437c7ebe..ffff7575 100644
--- a/app/src/screen.c
+++ b/app/src/screen.c
@@ -158,17 +158,9 @@ sc_screen_is_relative_mode(struct sc_screen *screen) {
static void
compute_content_rect(struct sc_size render_size, struct sc_size content_size,
- bool can_upscale, SDL_FRect *rect) {
- if (is_optimal_size(render_size, content_size)) {
- rect->x = 0;
- rect->y = 0;
- rect->w = render_size.width;
- rect->h = render_size.height;
- return;
- }
-
- if (!can_upscale && content_size.width <= render_size.width
- && content_size.height <= render_size.height) {
+ bool is_icon, SDL_FRect *rect) {
+ if (is_icon && content_size.width <= render_size.width
+ && content_size.height <= render_size.height) {
// Center without upscaling
rect->x = (render_size.width - content_size.width) / 2.f;
rect->y = (render_size.height - content_size.height) / 2.f;
@@ -177,6 +169,14 @@ compute_content_rect(struct sc_size render_size, struct sc_size content_size,
return;
}
+ if (is_optimal_size(render_size, content_size)) {
+ rect->x = 0;
+ rect->y = 0;
+ rect->w = render_size.width;
+ rect->h = render_size.height;
+ return;
+ }
+
bool keep_width = (uint32_t) content_size.width * render_size.height
> (uint32_t) content_size.height * render_size.width;
if (keep_width) {
@@ -197,11 +197,11 @@ compute_content_rect(struct sc_size render_size, struct sc_size content_size,
static void
sc_screen_update_content_rect(struct sc_screen *screen) {
// Only upscale video frames, not icon
- bool can_upscale = screen->video && !screen->disconnected;
+ bool is_icon = !screen->video || screen->disconnected;
struct sc_size render_size =
sc_sdl_get_render_output_size(screen->renderer);
- compute_content_rect(render_size, screen->content_size, can_upscale,
+ compute_content_rect(render_size, screen->content_size, is_icon,
&screen->rect);
}