mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 21:44:20 +01:00
In relative mouse mode, the mouse pointer must be "captured" from the computer. Toggle (disable/enable) relative mouse mode using any of the hardcoded capture keys: - left-Alt - left-Super - right-Super These capture keys do not conflict with shortcuts, since a shortcut is always a combination of the MOD key and some other key, while the capture key triggers an action only if it is pressed and released alone. The relative mouse mode is also automatically enabled on any click in the window, and automatically disabled on focus lost (it is possible to lose focus even without the mouse).
156 lines
4.2 KiB
C
156 lines
4.2 KiB
C
#ifndef SCREEN_H
|
|
#define SCREEN_H
|
|
|
|
#include "common.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <SDL2/SDL.h>
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include "controller.h"
|
|
#include "coords.h"
|
|
#include "fps_counter.h"
|
|
#include "input_manager.h"
|
|
#include "opengl.h"
|
|
#include "trait/key_processor.h"
|
|
#include "trait/frame_sink.h"
|
|
#include "trait/mouse_processor.h"
|
|
#include "video_buffer.h"
|
|
|
|
struct screen {
|
|
struct sc_frame_sink frame_sink; // frame sink trait
|
|
|
|
#ifndef NDEBUG
|
|
bool open; // track the open/close state to assert correct behavior
|
|
#endif
|
|
|
|
struct input_manager im;
|
|
struct sc_video_buffer vb;
|
|
struct fps_counter fps_counter;
|
|
|
|
SDL_Window *window;
|
|
SDL_Renderer *renderer;
|
|
SDL_Texture *texture;
|
|
struct sc_opengl gl;
|
|
struct sc_size frame_size;
|
|
struct sc_size content_size; // rotated frame_size
|
|
|
|
bool resize_pending; // resize requested while fullscreen or maximized
|
|
// The content size the last time the window was not maximized or
|
|
// fullscreen (meaningful only when resize_pending is true)
|
|
struct sc_size windowed_content_size;
|
|
|
|
// client rotation: 0, 1, 2 or 3 (x90 degrees counterclockwise)
|
|
unsigned rotation;
|
|
// rectangle of the content (excluding black borders)
|
|
struct SDL_Rect rect;
|
|
bool has_frame;
|
|
bool fullscreen;
|
|
bool maximized;
|
|
bool mipmaps;
|
|
|
|
bool event_failed; // in case SDL_PushEvent() returned an error
|
|
|
|
bool mouse_captured; // only relevant in relative mouse mode
|
|
// To enable/disable mouse capture, a mouse capture key (LALT, LGUI or
|
|
// RGUI) must be pressed. This variable tracks the pressed capture key.
|
|
SDL_Keycode mouse_capture_key_pressed;
|
|
|
|
AVFrame *frame;
|
|
};
|
|
|
|
struct screen_params {
|
|
struct controller *controller;
|
|
struct sc_key_processor *kp;
|
|
struct sc_mouse_processor *mp;
|
|
|
|
bool control;
|
|
bool forward_all_clicks;
|
|
bool legacy_paste;
|
|
bool clipboard_autosync;
|
|
const struct sc_shortcut_mods *shortcut_mods;
|
|
|
|
const char *window_title;
|
|
struct sc_size frame_size;
|
|
bool always_on_top;
|
|
|
|
int16_t window_x;
|
|
int16_t window_y;
|
|
uint16_t window_width; // accepts SC_WINDOW_POSITION_UNDEFINED
|
|
uint16_t window_height; // accepts SC_WINDOW_POSITION_UNDEFINED
|
|
|
|
bool window_borderless;
|
|
|
|
uint8_t rotation;
|
|
bool mipmaps;
|
|
|
|
bool fullscreen;
|
|
|
|
sc_tick buffering_time;
|
|
};
|
|
|
|
// initialize screen, create window, renderer and texture (window is hidden)
|
|
bool
|
|
screen_init(struct screen *screen, const struct screen_params *params);
|
|
|
|
// request to interrupt any inner thread
|
|
// must be called before screen_join()
|
|
void
|
|
screen_interrupt(struct screen *screen);
|
|
|
|
// join any inner thread
|
|
void
|
|
screen_join(struct screen *screen);
|
|
|
|
// destroy window, renderer and texture (if any)
|
|
void
|
|
screen_destroy(struct screen *screen);
|
|
|
|
// hide the window
|
|
//
|
|
// It is used to hide the window immediately on closing without waiting for
|
|
// screen_destroy()
|
|
void
|
|
screen_hide_window(struct screen *screen);
|
|
|
|
// switch the fullscreen mode
|
|
void
|
|
screen_switch_fullscreen(struct screen *screen);
|
|
|
|
// resize window to optimal size (remove black borders)
|
|
void
|
|
screen_resize_to_fit(struct screen *screen);
|
|
|
|
// resize window to 1:1 (pixel-perfect)
|
|
void
|
|
screen_resize_to_pixel_perfect(struct screen *screen);
|
|
|
|
// set the display rotation (0, 1, 2 or 3, x90 degrees counterclockwise)
|
|
void
|
|
screen_set_rotation(struct screen *screen, unsigned rotation);
|
|
|
|
// react to SDL events
|
|
bool
|
|
screen_handle_event(struct screen *screen, SDL_Event *event);
|
|
|
|
// convert point from window coordinates to frame coordinates
|
|
// x and y are expressed in pixels
|
|
struct sc_point
|
|
screen_convert_window_to_frame_coords(struct screen *screen,
|
|
int32_t x, int32_t y);
|
|
|
|
// convert point from drawable coordinates to frame coordinates
|
|
// x and y are expressed in pixels
|
|
struct sc_point
|
|
screen_convert_drawable_to_frame_coords(struct screen *screen,
|
|
int32_t x, int32_t y);
|
|
|
|
// Convert coordinates from window to drawable.
|
|
// Events are expressed in window coordinates, but content is expressed in
|
|
// drawable coordinates. They are the same if HiDPI scaling is 1, but differ
|
|
// otherwise.
|
|
void
|
|
screen_hidpi_scale_coords(struct screen *screen, int32_t *x, int32_t *y);
|
|
|
|
#endif
|