Display and control your Android device
Remove black borders on double-click
Romain Vimontb858204786bb
diff --git a/README.md b/README.mdindex 337f12e1..195193d3 100644--- a/README.md+++ b/README.md@@ -188,22 +188,23 @@ To run without installing:## Shortcuts- | Action | Shortcut |- | -------------------------------------- |:---------------------------- |- | switch fullscreen mode | `Ctrl`+`f` |- | resize window to 1:1 (pixel-perfect) | `Ctrl`+`g` |- | resize window to remove black borders | `Ctrl`+`x` |- | click on `HOME` | `Ctrl`+`h` \| _Middle-click_ |- | click on `BACK` | `Ctrl`+`b` \| _Right-click¹_ |- | click on `APP_SWITCH` | `Ctrl`+`m` |- | click on `VOLUME_UP` | `Ctrl`+`+` |- | click on `VOLUME_DOWN` | `Ctrl`+`-` |- | click on `POWER` | `Ctrl`+`p` |- | turn screen on | _Right-click¹_ |- | paste computer clipboard to device | `Ctrl`+`v` |- | enable/disable FPS counter (on stdout) | `Ctrl`+`i` |--_¹Right-click turns the screen on if it was off, presses BACK otherwise._+ | Action | Shortcut |+ | -------------------------------------- |:---------------------------- |+ | switch fullscreen mode | `Ctrl`+`f` |+ | resize window to 1:1 (pixel-perfect) | `Ctrl`+`g` |+ | resize window to remove black borders | `Ctrl`+`x` \| _Double-click¹_ |+ | click on `HOME` | `Ctrl`+`h` \| _Middle-click_ |+ | click on `BACK` | `Ctrl`+`b` \| _Right-click²_ |+ | click on `APP_SWITCH` | `Ctrl`+`m` |+ | click on `VOLUME_UP` | `Ctrl`+`+` |+ | click on `VOLUME_DOWN` | `Ctrl`+`-` |+ | click on `POWER` | `Ctrl`+`p` |+ | turn screen on | _Right-click¹_ |+ | paste computer clipboard to device | `Ctrl`+`v` |+ | enable/disable FPS counter (on stdout) | `Ctrl`+`i` |++_¹Double-click on black borders to remove them._+_²Right-click turns the screen on if it was off, presses BACK otherwise._## Why _scrcpy_?diff --git a/app/src/inputmanager.c b/app/src/inputmanager.cindex 6a9243e2..4a1140d4 100644--- a/app/src/inputmanager.c+++ b/app/src/inputmanager.c@@ -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)) {diff --git a/app/src/main.c b/app/src/main.cindex 287c9d7d..b56b78a6 100644--- a/app/src/main.c+++ b/app/src/main.c@@ -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"