2020-06-11 10:42:27 +00:00
|
|
|
// Wayland stuff
|
2019-11-21 05:16:53 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <wayland-server-core.h>
|
2021-04-01 21:58:33 +00:00
|
|
|
#include <atomic>
|
2019-11-21 05:16:53 +00:00
|
|
|
|
2020-04-02 02:13:58 +00:00
|
|
|
#define WLSERVER_BUTTON_COUNT 4
|
2020-09-18 21:59:26 +00:00
|
|
|
#define WLSERVER_TOUCH_COUNT 11 // Ten fingers + nose ought to be enough for anyone
|
2020-04-02 02:13:58 +00:00
|
|
|
|
2019-11-21 05:16:53 +00:00
|
|
|
struct wlserver_t {
|
2021-07-27 08:46:03 +00:00
|
|
|
struct wl_display *display;
|
|
|
|
struct wl_event_loop *event_loop;
|
2021-04-28 04:17:36 +00:00
|
|
|
char wl_display_name[32];
|
2019-11-21 05:16:53 +00:00
|
|
|
|
|
|
|
struct {
|
2020-01-17 09:57:39 +00:00
|
|
|
struct wlr_backend *multi_backend;
|
2021-02-01 09:24:39 +00:00
|
|
|
struct wlr_backend *noop_backend;
|
2020-01-17 09:57:39 +00:00
|
|
|
struct wlr_backend *libinput_backend;
|
|
|
|
|
2019-11-21 05:16:53 +00:00
|
|
|
struct wlr_renderer *renderer;
|
|
|
|
struct wlr_compositor *compositor;
|
2020-05-19 15:25:43 +00:00
|
|
|
struct wlr_xwayland_server *xwayland_server;
|
2019-11-21 05:16:53 +00:00
|
|
|
struct wlr_session *session;
|
|
|
|
struct wlr_seat *seat;
|
|
|
|
struct wlr_output *output;
|
2021-09-14 11:47:55 +00:00
|
|
|
|
2021-09-23 08:40:18 +00:00
|
|
|
// Used to simulate key events and set the keymap
|
2021-09-14 11:47:55 +00:00
|
|
|
struct wlr_input_device *virtual_keyboard_device;
|
2019-11-21 05:16:53 +00:00
|
|
|
} wlr;
|
2020-01-17 09:57:39 +00:00
|
|
|
|
|
|
|
struct wlr_surface *mouse_focus_surface;
|
|
|
|
double mouse_surface_cursorx;
|
|
|
|
double mouse_surface_cursory;
|
|
|
|
|
2020-04-02 02:13:58 +00:00
|
|
|
bool button_held[ WLSERVER_BUTTON_COUNT ];
|
2020-09-18 21:59:26 +00:00
|
|
|
bool touch_down[ WLSERVER_TOUCH_COUNT ];
|
2021-07-27 12:09:04 +00:00
|
|
|
|
|
|
|
struct wl_listener session_active;
|
2021-09-14 11:53:19 +00:00
|
|
|
struct wl_listener new_input_method;
|
2020-01-17 09:57:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlserver_keyboard {
|
|
|
|
struct wlr_input_device *device;
|
|
|
|
|
|
|
|
struct wl_listener modifiers;
|
|
|
|
struct wl_listener key;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlserver_pointer {
|
|
|
|
struct wlr_input_device *device;
|
|
|
|
|
|
|
|
struct wl_listener motion;
|
|
|
|
struct wl_listener button;
|
2021-09-13 19:29:17 +00:00
|
|
|
struct wl_listener axis;
|
|
|
|
struct wl_listener frame;
|
2020-01-17 09:57:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlserver_touch {
|
|
|
|
struct wlr_input_device *device;
|
|
|
|
|
|
|
|
struct wl_listener down;
|
|
|
|
struct wl_listener up;
|
|
|
|
struct wl_listener motion;
|
2019-11-21 05:16:53 +00:00
|
|
|
};
|
|
|
|
|
2021-06-18 08:44:13 +00:00
|
|
|
enum wlserver_touch_click_mode {
|
|
|
|
WLSERVER_TOUCH_CLICK_HOVER = 0,
|
|
|
|
WLSERVER_TOUCH_CLICK_LEFT = 1,
|
|
|
|
WLSERVER_TOUCH_CLICK_RIGHT = 2,
|
|
|
|
WLSERVER_TOUCH_CLICK_MIDDLE = 3,
|
|
|
|
WLSERVER_TOUCH_CLICK_PASSTHROUGH = 4,
|
|
|
|
};
|
|
|
|
|
2021-10-04 22:00:29 +00:00
|
|
|
extern enum wlserver_touch_click_mode g_nDefaultTouchClickMode;
|
2021-06-18 08:44:13 +00:00
|
|
|
extern enum wlserver_touch_click_mode g_nTouchClickMode;
|
2020-04-02 02:13:58 +00:00
|
|
|
|
2020-01-17 00:43:21 +00:00
|
|
|
void xwayland_surface_role_commit(struct wlr_surface *wlr_surface);
|
|
|
|
|
2021-09-14 14:59:46 +00:00
|
|
|
bool wlsession_init( void );
|
2021-07-27 09:24:04 +00:00
|
|
|
int wlsession_open_kms( const char *device_name );
|
|
|
|
|
2021-09-14 15:03:52 +00:00
|
|
|
bool wlserver_init( void );
|
2019-11-23 06:58:07 +00:00
|
|
|
|
2021-09-10 09:01:54 +00:00
|
|
|
void wlserver_run(void);
|
2019-11-23 07:42:02 +00:00
|
|
|
|
2019-12-31 01:50:22 +00:00
|
|
|
void wlserver_lock(void);
|
|
|
|
void wlserver_unlock(void);
|
|
|
|
|
2020-01-17 09:57:39 +00:00
|
|
|
void wlserver_keyboardfocus( struct wlr_surface *surface );
|
2020-01-18 23:10:14 +00:00
|
|
|
void wlserver_key( uint32_t key, bool press, uint32_t time );
|
2020-01-17 09:57:39 +00:00
|
|
|
|
2021-09-13 06:39:34 +00:00
|
|
|
void wlserver_mousefocus( struct wlr_surface *wlrsurface, int x = 0, int y = 0 );
|
2020-04-01 20:41:58 +00:00
|
|
|
void wlserver_mousemotion( int x, int y, uint32_t time );
|
2020-01-02 07:23:39 +00:00
|
|
|
void wlserver_mousebutton( int button, bool press, uint32_t time );
|
|
|
|
void wlserver_mousewheel( int x, int y, uint32_t time );
|
|
|
|
|
2020-01-23 05:50:01 +00:00
|
|
|
void wlserver_send_frame_done( struct wlr_surface *surf, const struct timespec *when );
|
|
|
|
|
2021-04-28 04:17:36 +00:00
|
|
|
const char *wlserver_get_nested_display_name( void );
|
|
|
|
const char *wlserver_get_wl_display_name( void );
|
2021-04-01 21:58:33 +00:00
|
|
|
|
|
|
|
struct wlserver_surface
|
|
|
|
{
|
|
|
|
std::atomic<struct wlr_surface *> wlr;
|
|
|
|
|
|
|
|
// owned by wlserver
|
2021-02-18 13:59:13 +00:00
|
|
|
long wl_id, x11_id;
|
|
|
|
bool overridden;
|
2021-04-01 21:58:33 +00:00
|
|
|
struct wl_list pending_link;
|
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
|
|
|
|
2021-02-18 13:59:13 +00:00
|
|
|
void wlserver_surface_init( struct wlserver_surface *surf, long x11_id );
|
2021-04-16 12:39:38 +00:00
|
|
|
void wlserver_surface_set_wl_id( struct wlserver_surface *surf, long id );
|
2021-04-01 21:58:33 +00:00
|
|
|
void wlserver_surface_finish( struct wlserver_surface *surf );
|