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.
This commit is contained in:
Romain Vimont 2024-06-24 23:00:33 +02:00
parent 09ce0307fe
commit 40493dff60

View File

@ -720,49 +720,48 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
bool control = im->controller; bool control = im->controller;
bool paused = im->screen->paused; bool paused = im->screen->paused;
bool down = event->type == SDL_MOUSEBUTTONDOWN; bool down = event->type == SDL_MOUSEBUTTONDOWN;
if (!im->forward_all_clicks) { if (control && !paused && !im->forward_all_clicks) {
if (control && !paused) { enum sc_action action = down ? SC_ACTION_DOWN : SC_ACTION_UP;
enum sc_action action = down ? SC_ACTION_DOWN : SC_ACTION_UP;
if (im->kp && event->button == SDL_BUTTON_X1) { if (im->kp && event->button == SDL_BUTTON_X1) {
action_app_switch(im, action); action_app_switch(im, action);
return; 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 (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 // double-click on black borders resizes to fit the device screen
bool video = im->screen->video; bool video = im->screen->video;
if (video && event->button == SDL_BUTTON_LEFT && event->clicks == 2) { bool mouse_relative_mode = im->mp && im->mp->relative_mode;
int32_t x = event->x; if (video && !mouse_relative_mode && event->button == SDL_BUTTON_LEFT
int32_t y = event->y; && event->clicks == 2) {
sc_screen_hidpi_scale_coords(im->screen, &x, &y); int32_t x = event->x;
SDL_Rect *r = &im->screen->rect; int32_t y = event->y;
bool outside = x < r->x || x >= r->x + r->w sc_screen_hidpi_scale_coords(im->screen, &x, &y);
|| y < r->y || y >= r->y + r->h; SDL_Rect *r = &im->screen->rect;
if (outside) { bool outside = x < r->x || x >= r->x + r->w
if (down) { || y < r->y || y >= r->y + r->h;
sc_screen_resize_to_fit(im->screen); if (outside) {
} if (down) {
return; sc_screen_resize_to_fit(im->screen);
} }
return;
} }
// otherwise, send the click event to the device
} }
if (!im->mp || paused) { if (!im->mp || paused) {