mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-04 13:29:51 -05:00
wayland-server: Add touch grab support
Touch grabs allow the compositor to be placed into a mode where touch events temporarily bypass their default behavior and perform other operations. Wayland already supports keyboard and pointer grabs, but was lacking corresponding touch support. The default touch grab handlers here contain the client event delivery code that was previously called directly in weston. Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
This commit is contained in:
parent
33b7637b45
commit
4ce294d641
2 changed files with 101 additions and 0 deletions
|
|
@ -559,6 +559,55 @@ static const struct wl_pointer_grab_interface
|
||||||
default_grab_button
|
default_grab_button
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void default_grab_touch_down(struct wl_touch_grab *grab,
|
||||||
|
uint32_t time,
|
||||||
|
int touch_id,
|
||||||
|
wl_fixed_t sx,
|
||||||
|
wl_fixed_t sy)
|
||||||
|
{
|
||||||
|
struct wl_touch *touch = grab->touch;
|
||||||
|
uint32_t serial;
|
||||||
|
|
||||||
|
if (touch->focus_resource && touch->focus) {
|
||||||
|
serial = wl_display_next_serial(touch->focus_resource->client->display);
|
||||||
|
wl_touch_send_down(touch->focus_resource, serial, time,
|
||||||
|
&touch->focus->resource, touch_id, sx, sy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void default_grab_touch_up(struct wl_touch_grab *grab,
|
||||||
|
uint32_t time,
|
||||||
|
int touch_id)
|
||||||
|
{
|
||||||
|
struct wl_touch *touch = grab->touch;
|
||||||
|
uint32_t serial;
|
||||||
|
|
||||||
|
if (touch->focus_resource) {
|
||||||
|
serial = wl_display_next_serial(touch->focus_resource->client->display);
|
||||||
|
wl_touch_send_up(touch->focus_resource, serial, time, touch_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void default_grab_touch_motion(struct wl_touch_grab *grab,
|
||||||
|
uint32_t time,
|
||||||
|
int touch_id,
|
||||||
|
wl_fixed_t sx,
|
||||||
|
wl_fixed_t sy)
|
||||||
|
{
|
||||||
|
struct wl_touch *touch = grab->touch;
|
||||||
|
|
||||||
|
if (touch->focus_resource) {
|
||||||
|
wl_touch_send_motion(touch->focus_resource, time,
|
||||||
|
touch_id, sx, sy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct wl_touch_grab_interface default_touch_grab_interface = {
|
||||||
|
default_grab_touch_down,
|
||||||
|
default_grab_touch_up,
|
||||||
|
default_grab_touch_motion
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
default_grab_key(struct wl_keyboard_grab *grab,
|
default_grab_key(struct wl_keyboard_grab *grab,
|
||||||
uint32_t time, uint32_t key, uint32_t state)
|
uint32_t time, uint32_t key, uint32_t state)
|
||||||
|
|
@ -678,6 +727,10 @@ wl_touch_init(struct wl_touch *touch)
|
||||||
memset(touch, 0, sizeof *touch);
|
memset(touch, 0, sizeof *touch);
|
||||||
wl_list_init(&touch->resource_list);
|
wl_list_init(&touch->resource_list);
|
||||||
touch->focus_listener.notify = lose_touch_focus;
|
touch->focus_listener.notify = lose_touch_focus;
|
||||||
|
touch->default_grab.interface = &default_touch_grab_interface;
|
||||||
|
touch->default_grab.touch = touch;
|
||||||
|
touch->grab = &touch->default_grab;
|
||||||
|
wl_signal_init(&touch->focus_signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
|
|
@ -902,6 +955,19 @@ wl_pointer_end_grab(struct wl_pointer *pointer)
|
||||||
pointer->current_x, pointer->current_y);
|
pointer->current_x, pointer->current_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
wl_touch_start_grab(struct wl_touch *touch, struct wl_touch_grab *grab)
|
||||||
|
{
|
||||||
|
touch->grab = grab;
|
||||||
|
grab->touch = touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
wl_touch_end_grab(struct wl_touch *touch)
|
||||||
|
{
|
||||||
|
touch->grab = &touch->default_grab;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
registry_bind(struct wl_client *client,
|
registry_bind(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t name,
|
struct wl_resource *resource, uint32_t name,
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,29 @@ struct wl_keyboard_grab {
|
||||||
uint32_t key;
|
uint32_t key;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wl_touch_grab;
|
||||||
|
struct wl_touch_grab_interface {
|
||||||
|
void (*down)(struct wl_touch_grab *grab,
|
||||||
|
uint32_t time,
|
||||||
|
int touch_id,
|
||||||
|
wl_fixed_t sx,
|
||||||
|
wl_fixed_t sy);
|
||||||
|
void (*up)(struct wl_touch_grab *grab,
|
||||||
|
uint32_t time,
|
||||||
|
int touch_id);
|
||||||
|
void (*motion)(struct wl_touch_grab *grab,
|
||||||
|
uint32_t time,
|
||||||
|
int touch_id,
|
||||||
|
wl_fixed_t sx,
|
||||||
|
wl_fixed_t sy);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wl_touch_grab {
|
||||||
|
const struct wl_touch_grab_interface *interface;
|
||||||
|
struct wl_touch *touch;
|
||||||
|
struct wl_surface *focus;
|
||||||
|
};
|
||||||
|
|
||||||
struct wl_data_offer {
|
struct wl_data_offer {
|
||||||
struct wl_resource resource;
|
struct wl_resource resource;
|
||||||
struct wl_data_source *source;
|
struct wl_data_source *source;
|
||||||
|
|
@ -301,6 +324,13 @@ struct wl_touch {
|
||||||
struct wl_resource *focus_resource;
|
struct wl_resource *focus_resource;
|
||||||
struct wl_listener focus_listener;
|
struct wl_listener focus_listener;
|
||||||
uint32_t focus_serial;
|
uint32_t focus_serial;
|
||||||
|
struct wl_signal focus_signal;
|
||||||
|
|
||||||
|
struct wl_touch_grab *grab;
|
||||||
|
struct wl_touch_grab default_grab;
|
||||||
|
wl_fixed_t grab_x, grab_y;
|
||||||
|
uint32_t grab_serial;
|
||||||
|
uint32_t grab_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_seat {
|
struct wl_seat {
|
||||||
|
|
@ -410,6 +440,11 @@ void
|
||||||
wl_touch_init(struct wl_touch *touch);
|
wl_touch_init(struct wl_touch *touch);
|
||||||
void
|
void
|
||||||
wl_touch_release(struct wl_touch *touch);
|
wl_touch_release(struct wl_touch *touch);
|
||||||
|
void
|
||||||
|
wl_touch_start_grab(struct wl_touch *device,
|
||||||
|
struct wl_touch_grab *grab);
|
||||||
|
void
|
||||||
|
wl_touch_end_grab(struct wl_touch *touch);
|
||||||
|
|
||||||
void
|
void
|
||||||
wl_data_device_set_keyboard_focus(struct wl_seat *seat);
|
wl_data_device_set_keyboard_focus(struct wl_seat *seat);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue