From 40493dff608cda7f0f37c166a2d8fef92581acf0 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 24 Jun 2024 23:00:33 +0200 Subject: [PATCH] Fix "resize to fit" when all clicks are forwarded To resize the window to fit the device screen, it is possible to double-click in the "black bars". This feature was mistakenly disabled when --forward-all-clicks was set. Instead, disable it only if mouse relative mode is enabled (AOA or UHID), because in that case the mouse cursor is on the device. --- app/src/input_manager.c | 73 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/app/src/input_manager.c b/app/src/input_manager.c index 1e46b30e56..f5f7992a9e 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -720,49 +720,48 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im, bool control = im->controller; bool paused = im->screen->paused; bool down = event->type == SDL_MOUSEBUTTONDOWN; - if (!im->forward_all_clicks) { - if (control && !paused) { - enum sc_action action = down ? SC_ACTION_DOWN : SC_ACTION_UP; + if (control && !paused && !im->forward_all_clicks) { + enum sc_action action = down ? SC_ACTION_DOWN : SC_ACTION_UP; - if (im->kp && event->button == SDL_BUTTON_X1) { - action_app_switch(im, action); - return; - } - if (event->button == SDL_BUTTON_X2 && down) { - if (event->clicks < 2) { - expand_notification_panel(im); - } else { - expand_settings_panel(im); - } - return; - } - if (im->kp && event->button == SDL_BUTTON_RIGHT) { - press_back_or_turn_screen_on(im, action); - return; - } - if (im->kp && event->button == SDL_BUTTON_MIDDLE) { - action_home(im, action); - return; + if (im->kp && event->button == SDL_BUTTON_X1) { + action_app_switch(im, action); + return; + } + if (event->button == SDL_BUTTON_X2 && down) { + if (event->clicks < 2) { + expand_notification_panel(im); + } else { + expand_settings_panel(im); } + return; + } + if (im->kp && event->button == SDL_BUTTON_RIGHT) { + press_back_or_turn_screen_on(im, action); + return; } + if (im->kp && event->button == SDL_BUTTON_MIDDLE) { + action_home(im, action); + return; + } + } - // double-click on black borders resize to fit the device screen - bool video = im->screen->video; - if (video && event->button == SDL_BUTTON_LEFT && event->clicks == 2) { - int32_t x = event->x; - int32_t y = event->y; - sc_screen_hidpi_scale_coords(im->screen, &x, &y); - SDL_Rect *r = &im->screen->rect; - bool outside = x < r->x || x >= r->x + r->w - || y < r->y || y >= r->y + r->h; - if (outside) { - if (down) { - sc_screen_resize_to_fit(im->screen); - } - return; + // double-click on black borders resizes to fit the device screen + bool video = im->screen->video; + bool mouse_relative_mode = im->mp && im->mp->relative_mode; + if (video && !mouse_relative_mode && event->button == SDL_BUTTON_LEFT + && event->clicks == 2) { + int32_t x = event->x; + int32_t y = event->y; + sc_screen_hidpi_scale_coords(im->screen, &x, &y); + SDL_Rect *r = &im->screen->rect; + bool outside = x < r->x || x >= r->x + r->w + || y < r->y || y >= r->y + r->h; + if (outside) { + if (down) { + sc_screen_resize_to_fit(im->screen); } + return; } - // otherwise, send the click event to the device } if (!im->mp || paused) {