Remove black borders on double-click

Resize the window to fit the device screen on click on black borders
(same as Ctrl+x).

Suggested-by: Guillaume Roche <groche@genymobile.com>
This commit is contained in:
Romain Vimont
2018-03-13 08:32:48 +01:00
parent 1038bad385
commit b858204786
3 changed files with 27 additions and 15 deletions

View File

@@ -235,6 +235,16 @@ void input_manager_process_mouse_button(struct input_manager *input_manager,
action_home(input_manager->controller);
return;
}
// double-click on black borders resize to fit the device screen
if (event->button == SDL_BUTTON_LEFT && event->clicks == 2) {
SDL_bool outside_device_screen =
event->x < 0 || event->x >= input_manager->screen->frame_size.width ||
event->y < 0 || event->y >= input_manager->screen->frame_size.height;
if (outside_device_screen) {
screen_resize_to_fit(input_manager->screen);
}
return;
}
};
struct control_event control_event;
if (mouse_button_from_sdl_to_android(event, input_manager->screen->frame_size, &control_event)) {

View File

@@ -57,6 +57,7 @@ static void usage(const char *arg0) {
" resize window to 1:1 (pixel-perfect)\n"
"\n"
" Ctrl+x\n"
" Double-click on black borders\n"
" resize window to remove black borders\n"
"\n"
" Ctrl+h\n"