mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
server: Implement wl_keyboard_grab_interface.
This commit is contained in:
parent
8134e06742
commit
ab3b5cd71c
2 changed files with 59 additions and 0 deletions
|
|
@ -484,6 +484,24 @@ static const struct wl_pointer_grab_interface
|
|||
default_grab_button
|
||||
};
|
||||
|
||||
static void
|
||||
default_grab_key(struct wl_keyboard_grab *grab,
|
||||
uint32_t time, uint32_t key, int32_t state)
|
||||
{
|
||||
struct wl_input_device *device = grab->input_device;
|
||||
struct wl_resource *resource;
|
||||
|
||||
resource = device->keyboard_focus_resource;
|
||||
if (resource)
|
||||
wl_resource_post_event(resource, WL_INPUT_DEVICE_KEY,
|
||||
time, key, state);
|
||||
}
|
||||
|
||||
static const struct wl_keyboard_grab_interface
|
||||
default_keyboard_grab_interface = {
|
||||
default_grab_key
|
||||
};
|
||||
|
||||
WL_EXPORT void
|
||||
wl_input_device_init(struct wl_input_device *device)
|
||||
{
|
||||
|
|
@ -497,6 +515,10 @@ wl_input_device_init(struct wl_input_device *device)
|
|||
device->default_pointer_grab.input_device = device;
|
||||
device->pointer_grab = &device->default_pointer_grab;
|
||||
|
||||
device->default_keyboard_grab.interface = &default_keyboard_grab_interface;
|
||||
device->default_keyboard_grab.input_device = device;
|
||||
device->keyboard_grab = &device->default_keyboard_grab;
|
||||
|
||||
wl_list_init(&device->drag_resource_list);
|
||||
device->selection_data_source = NULL;
|
||||
wl_list_init(&device->selection_listener_list);
|
||||
|
|
@ -603,6 +625,21 @@ wl_input_device_set_keyboard_focus(struct wl_input_device *device,
|
|||
device->keyboard_focus_time = time;
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
wl_input_device_start_keyboard_grab(struct wl_input_device *device,
|
||||
struct wl_keyboard_grab *grab, uint32_t time)
|
||||
{
|
||||
device->keyboard_grab = grab;
|
||||
grab->input_device = device;
|
||||
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
wl_input_device_end_keyboard_grab(struct wl_input_device *device, uint32_t time)
|
||||
{
|
||||
device->keyboard_grab = &device->default_keyboard_grab;
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
wl_input_device_start_pointer_grab(struct wl_input_device *device,
|
||||
struct wl_pointer_grab *grab, uint32_t time)
|
||||
|
|
|
|||
|
|
@ -164,6 +164,19 @@ struct wl_pointer_grab {
|
|||
int32_t x, y;
|
||||
};
|
||||
|
||||
struct wl_keyboard_grab;
|
||||
struct wl_keyboard_grab_interface {
|
||||
void (*key)(struct wl_keyboard_grab *grab,
|
||||
uint32_t time, uint32_t key, int32_t state);
|
||||
};
|
||||
|
||||
struct wl_keyboard_grab {
|
||||
const struct wl_keyboard_grab_interface *interface;
|
||||
struct wl_input_device *input_device;
|
||||
struct wl_surface *focus;
|
||||
uint32_t key;
|
||||
};
|
||||
|
||||
struct wl_data_offer {
|
||||
struct wl_resource resource;
|
||||
struct wl_data_source *source;
|
||||
|
|
@ -202,10 +215,13 @@ struct wl_input_device {
|
|||
|
||||
struct wl_pointer_grab *pointer_grab;
|
||||
struct wl_pointer_grab default_pointer_grab;
|
||||
struct wl_keyboard_grab *keyboard_grab;
|
||||
struct wl_keyboard_grab default_keyboard_grab;
|
||||
uint32_t button_count;
|
||||
uint32_t grab_time;
|
||||
int32_t grab_x, grab_y;
|
||||
uint32_t grab_button;
|
||||
uint32_t grab_key;
|
||||
struct wl_listener grab_listener;
|
||||
|
||||
struct wl_list drag_resource_list;
|
||||
|
|
@ -282,6 +298,12 @@ wl_data_device_set_keyboard_focus(struct wl_input_device *device);
|
|||
int
|
||||
wl_data_device_manager_init(struct wl_display *display);
|
||||
|
||||
void
|
||||
wl_input_device_start_keyboard_grab(struct wl_input_device *device,
|
||||
struct wl_keyboard_grab *grab, uint32_t time);
|
||||
void
|
||||
wl_input_device_end_keyboard_grab(struct wl_input_device *device, uint32_t time);
|
||||
|
||||
void
|
||||
wl_input_device_start_pointer_grab(struct wl_input_device *device,
|
||||
struct wl_pointer_grab *grab, uint32_t time);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue