mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-02 22:29:25 +00:00
rename recapture
This commit is contained in:
parent
62ff6df278
commit
058322b6cb
2 changed files with 15 additions and 16 deletions
|
@ -366,7 +366,7 @@ screen_init(struct screen *screen, const struct screen_params *params) {
|
||||||
screen->maximized = false;
|
screen->maximized = false;
|
||||||
screen->event_failed = false;
|
screen->event_failed = false;
|
||||||
screen->mouse_captured = false;
|
screen->mouse_captured = false;
|
||||||
screen->uncapture_key_pressed = 0;
|
screen->mouse_capture_key_pressed = 0;
|
||||||
|
|
||||||
static const struct sc_video_buffer_callbacks cbs = {
|
static const struct sc_video_buffer_callbacks cbs = {
|
||||||
.on_new_frame = sc_video_buffer_on_new_frame,
|
.on_new_frame = sc_video_buffer_on_new_frame,
|
||||||
|
@ -755,7 +755,7 @@ screen_resize_to_pixel_perfect(struct screen *screen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
screen_is_uncapture_key(SDL_Keycode key) {
|
screen_is_mouse_capture_key(SDL_Keycode key) {
|
||||||
return key == SDLK_LALT || key == SDLK_LGUI || key == SDLK_RGUI;
|
return key == SDLK_LALT || key == SDLK_LGUI || key == SDLK_RGUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,14 +811,14 @@ screen_handle_event(struct screen *screen, SDL_Event *event) {
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (screen->im.mp->relative_mode) {
|
if (screen->im.mp->relative_mode) {
|
||||||
SDL_Keycode key = event->key.keysym.sym;
|
SDL_Keycode key = event->key.keysym.sym;
|
||||||
if (screen_is_uncapture_key(key)) {
|
if (screen_is_mouse_capture_key(key)) {
|
||||||
if (!screen->uncapture_key_pressed) {
|
if (!screen->mouse_capture_key_pressed) {
|
||||||
screen->uncapture_key_pressed = key;
|
screen->mouse_capture_key_pressed = key;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Another uncapture key has been pressed, cancel mouse
|
// Another mouse capture key has been pressed, cancel
|
||||||
// uncapture
|
// mouse (un)capture
|
||||||
screen->uncapture_key_pressed = 0;
|
screen->mouse_capture_key_pressed = 0;
|
||||||
// Do not return, the event must be forwarded to the
|
// Do not return, the event must be forwarded to the
|
||||||
// input manager
|
// input manager
|
||||||
}
|
}
|
||||||
|
@ -828,11 +828,10 @@ screen_handle_event(struct screen *screen, SDL_Event *event) {
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
if (screen->im.mp->relative_mode) {
|
if (screen->im.mp->relative_mode) {
|
||||||
SDL_Keycode key = event->key.keysym.sym;
|
SDL_Keycode key = event->key.keysym.sym;
|
||||||
SDL_Keycode uncapture_key_pressed =
|
SDL_Keycode cap = screen->mouse_capture_key_pressed;
|
||||||
screen->uncapture_key_pressed;
|
screen->mouse_capture_key_pressed = 0;
|
||||||
screen->uncapture_key_pressed = 0;
|
if (key == cap) {
|
||||||
if (key == uncapture_key_pressed) {
|
// A mouse capture key has been pressed then released:
|
||||||
// An uncapture key has been pressed then released:
|
|
||||||
// toggle the capture mouse mode
|
// toggle the capture mouse mode
|
||||||
screen_capture_mouse(screen, !screen->mouse_captured);
|
screen_capture_mouse(screen, !screen->mouse_captured);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -52,9 +52,9 @@ struct screen {
|
||||||
bool event_failed; // in case SDL_PushEvent() returned an error
|
bool event_failed; // in case SDL_PushEvent() returned an error
|
||||||
|
|
||||||
bool mouse_captured; // only relevant in relative mouse mode
|
bool mouse_captured; // only relevant in relative mouse mode
|
||||||
// To disable mouse capture, an uncapture key (LALT, LGUI or RGUI) must be
|
// To enable/disable mouse capture, a mouse capture key (LALT, LGUI or
|
||||||
// pressed. This variable tracks the pressed mod key.
|
// RGUI) must be pressed. This variable tracks the pressed capture key.
|
||||||
SDL_Keycode uncapture_key_pressed;
|
SDL_Keycode mouse_capture_key_pressed;
|
||||||
|
|
||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue