You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
580 lines
16 KiB
580 lines
16 KiB
12 years ago
|
/*
|
||
10 years ago
|
* Copyright © 2011-2012 Intel Corporation
|
||
12 years ago
|
*
|
||
10 years ago
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||
|
* a copy of this software and associated documentation files (the
|
||
|
* "Software"), to deal in the Software without restriction, including
|
||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||
|
* the following conditions:
|
||
12 years ago
|
*
|
||
10 years ago
|
* The above copyright notice and this permission notice (including the
|
||
|
* next paragraph) shall be included in all copies or substantial
|
||
|
* portions of the Software.
|
||
|
*
|
||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
|
* SOFTWARE.
|
||
12 years ago
|
*/
|
||
|
|
||
12 years ago
|
#include "config.h"
|
||
|
|
||
12 years ago
|
#include <stdlib.h>
|
||
10 years ago
|
#include <linux/input.h>
|
||
12 years ago
|
|
||
|
#include "compositor.h"
|
||
10 years ago
|
#include "shared/helpers.h"
|
||
12 years ago
|
|
||
|
struct weston_binding {
|
||
|
uint32_t key;
|
||
|
uint32_t button;
|
||
|
uint32_t axis;
|
||
|
uint32_t modifier;
|
||
|
void *handler;
|
||
|
void *data;
|
||
|
struct wl_list link;
|
||
|
};
|
||
|
|
||
|
static struct weston_binding *
|
||
|
weston_compositor_add_binding(struct weston_compositor *compositor,
|
||
|
uint32_t key, uint32_t button, uint32_t axis,
|
||
|
uint32_t modifier, void *handler, void *data)
|
||
|
{
|
||
|
struct weston_binding *binding;
|
||
|
|
||
|
binding = malloc(sizeof *binding);
|
||
|
if (binding == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
binding->key = key;
|
||
|
binding->button = button;
|
||
|
binding->axis = axis;
|
||
|
binding->modifier = modifier;
|
||
|
binding->handler = handler;
|
||
|
binding->data = data;
|
||
|
|
||
|
return binding;
|
||
|
}
|
||
|
|
||
|
WL_EXPORT struct weston_binding *
|
||
|
weston_compositor_add_key_binding(struct weston_compositor *compositor,
|
||
|
uint32_t key, uint32_t modifier,
|
||
|
weston_key_binding_handler_t handler,
|
||
|
void *data)
|
||
|
{
|
||
|
struct weston_binding *binding;
|
||
|
|
||
|
binding = weston_compositor_add_binding(compositor, key, 0, 0,
|
||
|
modifier, handler, data);
|
||
|
if (binding == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
wl_list_insert(compositor->key_binding_list.prev, &binding->link);
|
||
|
|
||
|
return binding;
|
||
|
}
|
||
|
|
||
11 years ago
|
WL_EXPORT struct weston_binding *
|
||
|
weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
|
||
|
uint32_t modifier,
|
||
|
weston_modifier_binding_handler_t handler,
|
||
|
void *data)
|
||
|
{
|
||
|
struct weston_binding *binding;
|
||
|
|
||
|
binding = weston_compositor_add_binding(compositor, 0, 0, 0,
|
||
|
modifier, handler, data);
|
||
|
if (binding == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
wl_list_insert(compositor->modifier_binding_list.prev, &binding->link);
|
||
|
|
||
|
return binding;
|
||
|
}
|
||
|
|
||
12 years ago
|
WL_EXPORT struct weston_binding *
|
||
|
weston_compositor_add_button_binding(struct weston_compositor *compositor,
|
||
|
uint32_t button, uint32_t modifier,
|
||
|
weston_button_binding_handler_t handler,
|
||
|
void *data)
|
||
|
{
|
||
|
struct weston_binding *binding;
|
||
|
|
||
|
binding = weston_compositor_add_binding(compositor, 0, button, 0,
|
||
|
modifier, handler, data);
|
||
|
if (binding == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
wl_list_insert(compositor->button_binding_list.prev, &binding->link);
|
||
|
|
||
|
return binding;
|
||
|
}
|
||
|
|
||
11 years ago
|
WL_EXPORT struct weston_binding *
|
||
|
weston_compositor_add_touch_binding(struct weston_compositor *compositor,
|
||
|
uint32_t modifier,
|
||
|
weston_touch_binding_handler_t handler,
|
||
|
void *data)
|
||
|
{
|
||
|
struct weston_binding *binding;
|
||
|
|
||
|
binding = weston_compositor_add_binding(compositor, 0, 0, 0,
|
||
|
modifier, handler, data);
|
||
|
if (binding == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
wl_list_insert(compositor->touch_binding_list.prev, &binding->link);
|
||
|
|
||
|
return binding;
|
||
|
}
|
||
|
|
||
12 years ago
|
WL_EXPORT struct weston_binding *
|
||
|
weston_compositor_add_axis_binding(struct weston_compositor *compositor,
|
||
|
uint32_t axis, uint32_t modifier,
|
||
|
weston_axis_binding_handler_t handler,
|
||
|
void *data)
|
||
|
{
|
||
|
struct weston_binding *binding;
|
||
|
|
||
|
binding = weston_compositor_add_binding(compositor, 0, 0, axis,
|
||
|
modifier, handler, data);
|
||
|
if (binding == NULL)
|
||
|
return NULL;
|
||
|
|
||
|
wl_list_insert(compositor->axis_binding_list.prev, &binding->link);
|
||
|
|
||
|
return binding;
|
||
|
}
|
||
|
|
||
|
WL_EXPORT struct weston_binding *
|
||
|
weston_compositor_add_debug_binding(struct weston_compositor *compositor,
|
||
|
uint32_t key,
|
||
|
weston_key_binding_handler_t handler,
|
||
|
void *data)
|
||
|
{
|
||
|
struct weston_binding *binding;
|
||
|
|
||
|
binding = weston_compositor_add_binding(compositor, key, 0, 0, 0,
|
||
|
handler, data);
|
||
|
|
||
|
wl_list_insert(compositor->debug_binding_list.prev, &binding->link);
|
||
|
|
||
|
return binding;
|
||
|
}
|
||
|
|
||
|
WL_EXPORT void
|
||
|
weston_binding_destroy(struct weston_binding *binding)
|
||
|
{
|
||
|
wl_list_remove(&binding->link);
|
||
|
free(binding);
|
||
|
}
|
||
|
|
||
10 years ago
|
void
|
||
12 years ago
|
weston_binding_list_destroy_all(struct wl_list *list)
|
||
|
{
|
||
|
struct weston_binding *binding, *tmp;
|
||
|
|
||
|
wl_list_for_each_safe(binding, tmp, list, link)
|
||
|
weston_binding_destroy(binding);
|
||
|
}
|
||
|
|
||
|
struct binding_keyboard_grab {
|
||
|
uint32_t key;
|
||
12 years ago
|
struct weston_keyboard_grab grab;
|
||
12 years ago
|
};
|
||
|
|
||
|
static void
|
||
12 years ago
|
binding_key(struct weston_keyboard_grab *grab,
|
||
12 years ago
|
uint32_t time, uint32_t key, uint32_t state_w)
|
||
|
{
|
||
|
struct binding_keyboard_grab *b =
|
||
|
container_of(grab, struct binding_keyboard_grab, grab);
|
||
|
struct wl_resource *resource;
|
||
|
enum wl_keyboard_key_state state = state_w;
|
||
|
uint32_t serial;
|
||
12 years ago
|
struct weston_keyboard *keyboard = grab->keyboard;
|
||
12 years ago
|
struct wl_display *display = keyboard->seat->compositor->wl_display;
|
||
12 years ago
|
|
||
|
if (key == b->key) {
|
||
|
if (state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||
12 years ago
|
weston_keyboard_end_grab(grab->keyboard);
|
||
12 years ago
|
if (keyboard->input_method_resource)
|
||
12 years ago
|
keyboard->grab = &keyboard->input_method_grab;
|
||
12 years ago
|
free(b);
|
||
10 years ago
|
} else {
|
||
|
/* Don't send the key press event for the binding key */
|
||
|
return;
|
||
12 years ago
|
}
|
||
10 years ago
|
}
|
||
|
if (!wl_list_empty(&keyboard->focus_resource_list)) {
|
||
12 years ago
|
serial = wl_display_next_serial(display);
|
||
11 years ago
|
wl_resource_for_each(resource, &keyboard->focus_resource_list) {
|
||
|
wl_keyboard_send_key(resource,
|
||
|
serial,
|
||
|
time,
|
||
|
key,
|
||
|
state);
|
||
|
}
|
||
12 years ago
|
}
|
||
|
}
|
||
|
|
||
|
static void
|
||
12 years ago
|
binding_modifiers(struct weston_keyboard_grab *grab, uint32_t serial,
|
||
12 years ago
|
uint32_t mods_depressed, uint32_t mods_latched,
|
||
|
uint32_t mods_locked, uint32_t group)
|
||
|
{
|
||
|
struct wl_resource *resource;
|
||
|
|
||
11 years ago
|
wl_resource_for_each(resource, &grab->keyboard->focus_resource_list) {
|
||
|
wl_keyboard_send_modifiers(resource, serial, mods_depressed,
|
||
|
mods_latched, mods_locked, group);
|
||
|
}
|
||
12 years ago
|
}
|
||
|
|
||
11 years ago
|
static void
|
||
|
binding_cancel(struct weston_keyboard_grab *grab)
|
||
|
{
|
||
|
struct binding_keyboard_grab *binding_grab =
|
||
|
container_of(grab, struct binding_keyboard_grab, grab);
|
||
|
|
||
|
weston_keyboard_end_grab(grab->keyboard);
|
||
|
free(binding_grab);
|
||
|
}
|
||
|
|
||
12 years ago
|
static const struct weston_keyboard_grab_interface binding_grab = {
|
||
12 years ago
|
binding_key,
|
||
|
binding_modifiers,
|
||
11 years ago
|
binding_cancel,
|
||
12 years ago
|
};
|
||
|
|
||
|
static void
|
||
10 years ago
|
install_binding_grab(struct weston_keyboard *keyboard, uint32_t time,
|
||
|
uint32_t key, struct weston_surface *focus)
|
||
12 years ago
|
{
|
||
|
struct binding_keyboard_grab *grab;
|
||
|
|
||
|
grab = malloc(sizeof *grab);
|
||
|
grab->key = key;
|
||
|
grab->grab.interface = &binding_grab;
|
||
10 years ago
|
weston_keyboard_start_grab(keyboard, &grab->grab);
|
||
10 years ago
|
|
||
|
/* Notify the surface which had the focus before this binding
|
||
|
* triggered that we stole a keypress from under it, by forcing
|
||
|
* a wl_keyboard leave/enter pair. The enter event will contain
|
||
|
* the pressed key in the keys array, so the client will know
|
||
|
* the exact state of the keyboard.
|
||
|
* If the old focus surface is different than the new one it
|
||
|
* means it was changed in the binding handler, so it received
|
||
|
* the enter event already. */
|
||
10 years ago
|
if (focus && keyboard->focus == focus) {
|
||
|
weston_keyboard_set_focus(keyboard, NULL);
|
||
|
weston_keyboard_set_focus(keyboard, focus);
|
||
10 years ago
|
}
|
||
12 years ago
|
}
|
||
|
|
||
10 years ago
|
void
|
||
12 years ago
|
weston_compositor_run_key_binding(struct weston_compositor *compositor,
|
||
10 years ago
|
struct weston_keyboard *keyboard,
|
||
12 years ago
|
uint32_t time, uint32_t key,
|
||
|
enum wl_keyboard_key_state state)
|
||
|
{
|
||
10 years ago
|
struct weston_binding *b, *tmp;
|
||
10 years ago
|
struct weston_surface *focus;
|
||
10 years ago
|
struct weston_seat *seat = keyboard->seat;
|
||
12 years ago
|
|
||
|
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
||
10 years ago
|
return;
|
||
12 years ago
|
|
||
11 years ago
|
/* Invalidate all active modifier bindings. */
|
||
|
wl_list_for_each(b, &compositor->modifier_binding_list, link)
|
||
|
b->key = key;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(b, tmp, &compositor->key_binding_list, link) {
|
||
12 years ago
|
if (b->key == key && b->modifier == seat->modifier_state) {
|
||
|
weston_key_binding_handler_t handler = b->handler;
|
||
10 years ago
|
focus = keyboard->focus;
|
||
|
handler(keyboard, time, key, b->data);
|
||
12 years ago
|
|
||
|
/* If this was a key binding and it didn't
|
||
|
* install a keyboard grab, install one now to
|
||
10 years ago
|
* swallow the key press. */
|
||
10 years ago
|
if (keyboard->grab ==
|
||
|
&keyboard->default_grab)
|
||
|
install_binding_grab(keyboard,
|
||
10 years ago
|
time,
|
||
|
key,
|
||
|
focus);
|
||
12 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
10 years ago
|
void
|
||
11 years ago
|
weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
|
||
10 years ago
|
struct weston_keyboard *keyboard,
|
||
11 years ago
|
enum weston_keyboard_modifier modifier,
|
||
|
enum wl_keyboard_key_state state)
|
||
|
{
|
||
10 years ago
|
struct weston_binding *b, *tmp;
|
||
11 years ago
|
|
||
10 years ago
|
if (keyboard->grab != &keyboard->default_grab)
|
||
11 years ago
|
return;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(b, tmp, &compositor->modifier_binding_list, link) {
|
||
11 years ago
|
weston_modifier_binding_handler_t handler = b->handler;
|
||
|
|
||
|
if (b->modifier != modifier)
|
||
|
continue;
|
||
|
|
||
|
/* Prime the modifier binding. */
|
||
|
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||
|
b->key = 0;
|
||
|
continue;
|
||
|
}
|
||
|
/* Ignore the binding if a key was pressed in between. */
|
||
|
else if (b->key != 0) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
10 years ago
|
handler(keyboard, modifier, b->data);
|
||
11 years ago
|
}
|
||
|
}
|
||
|
|
||
10 years ago
|
void
|
||
12 years ago
|
weston_compositor_run_button_binding(struct weston_compositor *compositor,
|
||
10 years ago
|
struct weston_pointer *pointer,
|
||
12 years ago
|
uint32_t time, uint32_t button,
|
||
|
enum wl_pointer_button_state state)
|
||
|
{
|
||
10 years ago
|
struct weston_binding *b, *tmp;
|
||
12 years ago
|
|
||
|
if (state == WL_POINTER_BUTTON_STATE_RELEASED)
|
||
|
return;
|
||
|
|
||
11 years ago
|
/* Invalidate all active modifier bindings. */
|
||
|
wl_list_for_each(b, &compositor->modifier_binding_list, link)
|
||
|
b->key = button;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(b, tmp, &compositor->button_binding_list, link) {
|
||
10 years ago
|
if (b->button == button &&
|
||
|
b->modifier == pointer->seat->modifier_state) {
|
||
12 years ago
|
weston_button_binding_handler_t handler = b->handler;
|
||
10 years ago
|
handler(pointer, time, button, b->data);
|
||
12 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
10 years ago
|
void
|
||
11 years ago
|
weston_compositor_run_touch_binding(struct weston_compositor *compositor,
|
||
10 years ago
|
struct weston_touch *touch, uint32_t time,
|
||
11 years ago
|
int touch_type)
|
||
|
{
|
||
10 years ago
|
struct weston_binding *b, *tmp;
|
||
11 years ago
|
|
||
10 years ago
|
if (touch->num_tp != 1 || touch_type != WL_TOUCH_DOWN)
|
||
11 years ago
|
return;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(b, tmp, &compositor->touch_binding_list, link) {
|
||
10 years ago
|
if (b->modifier == touch->seat->modifier_state) {
|
||
11 years ago
|
weston_touch_binding_handler_t handler = b->handler;
|
||
10 years ago
|
handler(touch, time, b->data);
|
||
11 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
10 years ago
|
int
|
||
12 years ago
|
weston_compositor_run_axis_binding(struct weston_compositor *compositor,
|
||
10 years ago
|
struct weston_pointer *pointer,
|
||
9 years ago
|
uint32_t time,
|
||
|
struct weston_pointer_axis_event *event)
|
||
12 years ago
|
{
|
||
10 years ago
|
struct weston_binding *b, *tmp;
|
||
12 years ago
|
|
||
11 years ago
|
/* Invalidate all active modifier bindings. */
|
||
|
wl_list_for_each(b, &compositor->modifier_binding_list, link)
|
||
9 years ago
|
b->key = event->axis;
|
||
11 years ago
|
|
||
10 years ago
|
wl_list_for_each_safe(b, tmp, &compositor->axis_binding_list, link) {
|
||
9 years ago
|
if (b->axis == event->axis &&
|
||
10 years ago
|
b->modifier == pointer->seat->modifier_state) {
|
||
12 years ago
|
weston_axis_binding_handler_t handler = b->handler;
|
||
9 years ago
|
handler(pointer, time, event, b->data);
|
||
12 years ago
|
return 1;
|
||
12 years ago
|
}
|
||
|
}
|
||
12 years ago
|
|
||
|
return 0;
|
||
12 years ago
|
}
|
||
|
|
||
10 years ago
|
int
|
||
12 years ago
|
weston_compositor_run_debug_binding(struct weston_compositor *compositor,
|
||
10 years ago
|
struct weston_keyboard *keyboard,
|
||
12 years ago
|
uint32_t time, uint32_t key,
|
||
|
enum wl_keyboard_key_state state)
|
||
|
{
|
||
|
weston_key_binding_handler_t handler;
|
||
10 years ago
|
struct weston_binding *binding, *tmp;
|
||
12 years ago
|
int count = 0;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(binding, tmp, &compositor->debug_binding_list, link) {
|
||
12 years ago
|
if (key != binding->key)
|
||
|
continue;
|
||
|
|
||
|
count++;
|
||
|
handler = binding->handler;
|
||
10 years ago
|
handler(keyboard, time, key, binding->data);
|
||
12 years ago
|
}
|
||
|
|
||
|
return count;
|
||
|
}
|
||
10 years ago
|
|
||
|
struct debug_binding_grab {
|
||
|
struct weston_keyboard_grab grab;
|
||
|
struct weston_seat *seat;
|
||
|
uint32_t key[2];
|
||
|
int key_released[2];
|
||
|
};
|
||
|
|
||
|
static void
|
||
|
debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
|
||
|
uint32_t key, uint32_t state)
|
||
|
{
|
||
|
struct debug_binding_grab *db = (struct debug_binding_grab *) grab;
|
||
|
struct weston_compositor *ec = db->seat->compositor;
|
||
|
struct wl_display *display = ec->wl_display;
|
||
|
struct wl_resource *resource;
|
||
|
uint32_t serial;
|
||
|
int send = 0, terminate = 0;
|
||
|
int check_binding = 1;
|
||
|
int i;
|
||
|
struct wl_list *resource_list;
|
||
|
|
||
|
if (state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||
|
/* Do not run bindings on key releases */
|
||
|
check_binding = 0;
|
||
|
|
||
|
for (i = 0; i < 2; i++)
|
||
|
if (key == db->key[i])
|
||
|
db->key_released[i] = 1;
|
||
|
|
||
|
if (db->key_released[0] && db->key_released[1]) {
|
||
|
/* All key releases been swalled so end the grab */
|
||
|
terminate = 1;
|
||
|
} else if (key != db->key[0] && key != db->key[1]) {
|
||
|
/* Should not swallow release of other keys */
|
||
|
send = 1;
|
||
|
}
|
||
|
} else if (key == db->key[0] && !db->key_released[0]) {
|
||
|
/* Do not check bindings for the first press of the binding
|
||
|
* key. This allows it to be used as a debug shortcut.
|
||
|
* We still need to swallow this event. */
|
||
|
check_binding = 0;
|
||
|
} else if (db->key[1]) {
|
||
|
/* If we already ran a binding don't process another one since
|
||
|
* we can't keep track of all the binding keys that were
|
||
|
* pressed in order to swallow the release events. */
|
||
|
send = 1;
|
||
|
check_binding = 0;
|
||
|
}
|
||
|
|
||
|
if (check_binding) {
|
||
10 years ago
|
if (weston_compositor_run_debug_binding(ec, grab->keyboard,
|
||
|
time, key, state)) {
|
||
10 years ago
|
/* We ran a binding so swallow the press and keep the
|
||
|
* grab to swallow the released too. */
|
||
|
send = 0;
|
||
|
terminate = 0;
|
||
|
db->key[1] = key;
|
||
|
} else {
|
||
|
/* Terminate the grab since the key pressed is not a
|
||
|
* debug binding key. */
|
||
|
send = 1;
|
||
|
terminate = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (send) {
|
||
|
serial = wl_display_next_serial(display);
|
||
|
resource_list = &grab->keyboard->focus_resource_list;
|
||
|
wl_resource_for_each(resource, resource_list) {
|
||
|
wl_keyboard_send_key(resource, serial, time, key, state);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (terminate) {
|
||
|
weston_keyboard_end_grab(grab->keyboard);
|
||
|
if (grab->keyboard->input_method_resource)
|
||
|
grab->keyboard->grab = &grab->keyboard->input_method_grab;
|
||
|
free(db);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
debug_binding_modifiers(struct weston_keyboard_grab *grab, uint32_t serial,
|
||
|
uint32_t mods_depressed, uint32_t mods_latched,
|
||
|
uint32_t mods_locked, uint32_t group)
|
||
|
{
|
||
|
struct wl_resource *resource;
|
||
|
struct wl_list *resource_list;
|
||
|
|
||
|
resource_list = &grab->keyboard->focus_resource_list;
|
||
|
|
||
|
wl_resource_for_each(resource, resource_list) {
|
||
|
wl_keyboard_send_modifiers(resource, serial, mods_depressed,
|
||
|
mods_latched, mods_locked, group);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
debug_binding_cancel(struct weston_keyboard_grab *grab)
|
||
|
{
|
||
|
struct debug_binding_grab *db = (struct debug_binding_grab *) grab;
|
||
|
|
||
|
weston_keyboard_end_grab(grab->keyboard);
|
||
|
free(db);
|
||
|
}
|
||
|
|
||
|
struct weston_keyboard_grab_interface debug_binding_keyboard_grab = {
|
||
|
debug_binding_key,
|
||
|
debug_binding_modifiers,
|
||
|
debug_binding_cancel,
|
||
|
};
|
||
|
|
||
|
static void
|
||
10 years ago
|
debug_binding(struct weston_keyboard *keyboard, uint32_t time,
|
||
|
uint32_t key, void *data)
|
||
10 years ago
|
{
|
||
|
struct debug_binding_grab *grab;
|
||
|
|
||
|
grab = calloc(1, sizeof *grab);
|
||
|
if (!grab)
|
||
|
return;
|
||
|
|
||
10 years ago
|
grab->seat = keyboard->seat;
|
||
10 years ago
|
grab->key[0] = key;
|
||
|
grab->grab.interface = &debug_binding_keyboard_grab;
|
||
10 years ago
|
weston_keyboard_start_grab(keyboard, &grab->grab);
|
||
10 years ago
|
}
|
||
|
|
||
|
/** Install the trigger binding for debug bindings.
|
||
|
*
|
||
|
* \param compositor The compositor.
|
||
|
* \param mod The modifier.
|
||
|
*
|
||
|
* This will add a key binding for modifier+SHIFT+SPACE that will trigger
|
||
|
* debug key bindings.
|
||
|
*/
|
||
|
WL_EXPORT void
|
||
|
weston_install_debug_key_binding(struct weston_compositor *compositor,
|
||
|
uint32_t mod)
|
||
|
{
|
||
|
weston_compositor_add_key_binding(compositor, KEY_SPACE,
|
||
|
mod | MODIFIER_SHIFT,
|
||
|
debug_binding, NULL);
|
||
|
}
|