Modify bindings for axis event detection.

Scott Moreau 13 years ago
parent 210d079817
commit 6a3633d2bb
  1. 10
      src/compositor.c
  2. 7
      src/compositor.h
  3. 76
      src/shell.c
  4. 14
      src/tablet-shell.c
  5. 12
      src/util.c

@ -1543,7 +1543,7 @@ notify_button(struct wl_input_device *device,
device->button_count--; device->button_count--;
} }
weston_compositor_run_binding(compositor, wd, time, 0, button, state); weston_compositor_run_binding(compositor, wd, time, 0, button, 0, state);
device->pointer_grab->interface->button(device->pointer_grab, time, button, state); device->pointer_grab->interface->button(device->pointer_grab, time, button, state);
@ -1558,6 +1558,12 @@ notify_axis(struct wl_input_device *device,
weston_compositor_activity(compositor); weston_compositor_activity(compositor);
if (value)
weston_compositor_run_binding(compositor, wd,
time, 0, 0, axis, value);
else
return;
if (device->pointer_focus_resource) if (device->pointer_focus_resource)
wl_resource_post_event(device->pointer_focus_resource, wl_resource_post_event(device->pointer_focus_resource,
WL_INPUT_DEVICE_AXIS, time, axis, value); WL_INPUT_DEVICE_AXIS, time, axis, value);
@ -1626,7 +1632,7 @@ notify_key(struct wl_input_device *device,
if (device->keyboard_grab == &device->default_keyboard_grab) if (device->keyboard_grab == &device->default_keyboard_grab)
weston_compositor_run_binding(compositor, wd, weston_compositor_run_binding(compositor, wd,
time, key, 0, state); time, key, 0, 0, state);
device->keyboard_grab->interface->key(device->keyboard_grab, device->keyboard_grab->interface->key(device->keyboard_grab,
time, key, state); time, key, state);

@ -420,10 +420,11 @@ struct weston_binding;
typedef void (*weston_binding_handler_t)(struct wl_input_device *device, typedef void (*weston_binding_handler_t)(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t time, uint32_t key,
uint32_t button, uint32_t button,
uint32_t state, void *data); uint32_t axis,
int32_t state, void *data);
struct weston_binding * struct weston_binding *
weston_compositor_add_binding(struct weston_compositor *compositor, weston_compositor_add_binding(struct weston_compositor *compositor,
uint32_t key, uint32_t button, uint32_t modifier, uint32_t key, uint32_t button, uint32_t axis, uint32_t modifier,
weston_binding_handler_t binding, void *data); weston_binding_handler_t binding, void *data);
void void
weston_binding_destroy(struct weston_binding *binding); weston_binding_destroy(struct weston_binding *binding);
@ -435,7 +436,7 @@ void
weston_compositor_run_binding(struct weston_compositor *compositor, weston_compositor_run_binding(struct weston_compositor *compositor,
struct weston_input_device *device, struct weston_input_device *device,
uint32_t time, uint32_t time,
uint32_t key, uint32_t button, int32_t state); uint32_t key, uint32_t button, uint32_t axis, int32_t state);
struct wl_list * struct wl_list *
weston_compositor_top(struct weston_compositor *compositor); weston_compositor_top(struct weston_compositor *compositor);

@ -1092,7 +1092,7 @@ get_shell_surface_type(struct weston_surface *surface)
static void static void
move_binding(struct wl_input_device *device, uint32_t time, move_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct weston_surface *surface = struct weston_surface *surface =
(struct weston_surface *) device->pointer_focus; (struct weston_surface *) device->pointer_focus;
@ -1115,7 +1115,7 @@ move_binding(struct wl_input_device *device, uint32_t time,
static void static void
resize_binding(struct wl_input_device *device, uint32_t time, resize_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct weston_surface *surface = struct weston_surface *surface =
(struct weston_surface *) device->pointer_focus; (struct weston_surface *) device->pointer_focus;
@ -1163,7 +1163,7 @@ resize_binding(struct wl_input_device *device, uint32_t time,
static void static void
zoom_binding(struct wl_input_device *device, uint32_t time, zoom_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct weston_input_device *wd = (struct weston_input_device *) device; struct weston_input_device *wd = (struct weston_input_device *) device;
struct weston_compositor *compositor = wd->compositor; struct weston_compositor *compositor = wd->compositor;
@ -1194,7 +1194,7 @@ zoom_binding(struct wl_input_device *device, uint32_t time,
static void static void
terminate_binding(struct wl_input_device *device, uint32_t time, terminate_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;
@ -1278,7 +1278,7 @@ static const struct wl_pointer_grab_interface rotate_grab_interface = {
static void static void
rotate_binding(struct wl_input_device *device, uint32_t time, rotate_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct weston_surface *base_surface = struct weston_surface *base_surface =
(struct weston_surface *) device->pointer_focus; (struct weston_surface *) device->pointer_focus;
@ -1389,7 +1389,7 @@ activate(struct weston_shell *base, struct weston_surface *es,
static void static void
click_to_activate_binding(struct wl_input_device *device, click_to_activate_binding(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t time, uint32_t key,
uint32_t button, uint32_t state, void *data) uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct weston_input_device *wd = (struct weston_input_device *) device; struct weston_input_device *wd = (struct weston_input_device *) device;
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;
@ -1916,8 +1916,8 @@ static const struct wl_keyboard_grab_interface switcher_grab = {
static void static void
switcher_binding(struct wl_input_device *device, uint32_t time, switcher_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t key, uint32_t button, uint32_t axis,
uint32_t state, void *data) int32_t state, void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;
struct switcher *switcher; struct switcher *switcher;
@ -1937,7 +1937,7 @@ switcher_binding(struct wl_input_device *device, uint32_t time,
static void static void
backlight_binding(struct wl_input_device *device, uint32_t time, backlight_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;
struct weston_output *output; struct weston_output *output;
@ -1970,7 +1970,7 @@ backlight_binding(struct wl_input_device *device, uint32_t time,
static void static void
debug_repaint_binding(struct wl_input_device *device, uint32_t time, debug_repaint_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct weston_compositor *compositor = data; struct weston_compositor *compositor = data;
struct wl_shell *shell = struct wl_shell *shell =
@ -2065,37 +2065,37 @@ shell_init(struct weston_compositor *ec)
if (launch_desktop_shell_process(shell) != 0) if (launch_desktop_shell_process(shell) != 0)
return -1; return -1;
weston_compositor_add_binding(ec, 0, BTN_LEFT, MODIFIER_SUPER, weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, MODIFIER_SUPER,
move_binding, shell); move_binding, shell);
weston_compositor_add_binding(ec, 0, BTN_MIDDLE, MODIFIER_SUPER, weston_compositor_add_binding(ec, 0, BTN_MIDDLE, 0, MODIFIER_SUPER,
resize_binding, shell); resize_binding, shell);
weston_compositor_add_binding(ec, KEY_BACKSPACE, 0, weston_compositor_add_binding(ec, KEY_BACKSPACE, 0, 0,
MODIFIER_CTRL | MODIFIER_ALT, MODIFIER_CTRL | MODIFIER_ALT,
terminate_binding, ec); terminate_binding, ec);
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, 0,
click_to_activate_binding, ec);
weston_compositor_add_binding(ec, KEY_UP, 0, 0, MODIFIER_SUPER,
zoom_binding, shell);
weston_compositor_add_binding(ec, KEY_DOWN, 0, 0, MODIFIER_SUPER,
zoom_binding, shell);
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, weston_compositor_add_binding(ec, 0, BTN_LEFT, 0,
click_to_activate_binding, ec); MODIFIER_SUPER | MODIFIER_ALT,
weston_compositor_add_binding(ec, KEY_UP, 0, MODIFIER_SUPER, rotate_binding, NULL);
zoom_binding, shell); weston_compositor_add_binding(ec, KEY_TAB, 0, 0, MODIFIER_SUPER,
weston_compositor_add_binding(ec, KEY_DOWN, 0, MODIFIER_SUPER, switcher_binding, ec);
zoom_binding, shell);
weston_compositor_add_binding(ec, 0, BTN_LEFT,
MODIFIER_SUPER | MODIFIER_ALT,
rotate_binding, NULL);
weston_compositor_add_binding(ec, KEY_TAB, 0, MODIFIER_SUPER,
switcher_binding, ec);
/* brightness */ /* brightness */
weston_compositor_add_binding(ec, KEY_F9, 0, MODIFIER_CTRL, weston_compositor_add_binding(ec, KEY_F9, 0, 0, MODIFIER_CTRL,
backlight_binding, ec); backlight_binding, ec);
weston_compositor_add_binding(ec, KEY_BRIGHTNESSDOWN, 0, 0, weston_compositor_add_binding(ec, KEY_BRIGHTNESSDOWN, 0, 0, 0,
backlight_binding, ec); backlight_binding, ec);
weston_compositor_add_binding(ec, KEY_F10, 0, MODIFIER_CTRL, weston_compositor_add_binding(ec, KEY_F10, 0, 0, MODIFIER_CTRL,
backlight_binding, ec); backlight_binding, ec);
weston_compositor_add_binding(ec, KEY_BRIGHTNESSUP, 0, 0, weston_compositor_add_binding(ec, KEY_BRIGHTNESSUP, 0, 0, 0,
backlight_binding, ec); backlight_binding, ec);
weston_compositor_add_binding(ec, KEY_SPACE, 0, MODIFIER_SUPER, weston_compositor_add_binding(ec, KEY_SPACE, 0, 0, MODIFIER_SUPER,
debug_repaint_binding, ec); debug_repaint_binding, ec);
ec->shell = &shell->shell; ec->shell = &shell->shell;

@ -433,7 +433,7 @@ long_press_handler(void *data)
static void static void
menu_key_binding(struct wl_input_device *device, uint32_t time, menu_key_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct tablet_shell *shell = data; struct tablet_shell *shell = data;
@ -446,7 +446,7 @@ menu_key_binding(struct wl_input_device *device, uint32_t time,
static void static void
home_key_binding(struct wl_input_device *device, uint32_t time, home_key_binding(struct wl_input_device *device, uint32_t time,
uint32_t key, uint32_t button, uint32_t state, void *data) uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
{ {
struct tablet_shell *shell = data; struct tablet_shell *shell = data;
@ -534,15 +534,15 @@ shell_init(struct weston_compositor *compositor)
shell->long_press_source = shell->long_press_source =
wl_event_loop_add_timer(loop, long_press_handler, shell); wl_event_loop_add_timer(loop, long_press_handler, shell);
weston_compositor_add_binding(compositor, KEY_LEFTMETA, 0, 0, weston_compositor_add_binding(compositor, KEY_LEFTMETA, 0, 0, 0,
home_key_binding, shell); home_key_binding, shell);
weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0, weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0, 0,
home_key_binding, shell); home_key_binding, shell);
weston_compositor_add_binding(compositor, KEY_LEFTMETA, 0, weston_compositor_add_binding(compositor, KEY_LEFTMETA, 0, 0,
MODIFIER_SUPER, home_key_binding, shell); MODIFIER_SUPER, home_key_binding, shell);
weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0,
MODIFIER_SUPER, home_key_binding, shell); MODIFIER_SUPER, home_key_binding, shell);
weston_compositor_add_binding(compositor, KEY_COMPOSE, 0, 0, weston_compositor_add_binding(compositor, KEY_COMPOSE, 0, 0, 0,
menu_key_binding, shell); menu_key_binding, shell);
compositor->shell = &shell->shell; compositor->shell = &shell->shell;

@ -186,6 +186,7 @@ weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,
struct weston_binding { struct weston_binding {
uint32_t key; uint32_t key;
uint32_t button; uint32_t button;
uint32_t axis;
uint32_t modifier; uint32_t modifier;
weston_binding_handler_t handler; weston_binding_handler_t handler;
void *data; void *data;
@ -194,7 +195,7 @@ struct weston_binding {
WL_EXPORT struct weston_binding * WL_EXPORT struct weston_binding *
weston_compositor_add_binding(struct weston_compositor *compositor, weston_compositor_add_binding(struct weston_compositor *compositor,
uint32_t key, uint32_t button, uint32_t modifier, uint32_t key, uint32_t button, uint32_t axis, uint32_t modifier,
weston_binding_handler_t handler, void *data) weston_binding_handler_t handler, void *data)
{ {
struct weston_binding *binding; struct weston_binding *binding;
@ -205,6 +206,7 @@ weston_compositor_add_binding(struct weston_compositor *compositor,
binding->key = key; binding->key = key;
binding->button = button; binding->button = button;
binding->axis = axis;
binding->modifier = modifier; binding->modifier = modifier;
binding->handler = handler; binding->handler = handler;
binding->data = data; binding->data = data;
@ -272,16 +274,16 @@ install_binding_grab(struct wl_input_device *device,
WL_EXPORT void WL_EXPORT void
weston_compositor_run_binding(struct weston_compositor *compositor, weston_compositor_run_binding(struct weston_compositor *compositor,
struct weston_input_device *device, struct weston_input_device *device,
uint32_t time, uint32_t time, uint32_t key,
uint32_t key, uint32_t button, int32_t state) uint32_t button, uint32_t axis, int32_t state)
{ {
struct weston_binding *b; struct weston_binding *b;
wl_list_for_each(b, &compositor->binding_list, link) { wl_list_for_each(b, &compositor->binding_list, link) {
if (b->key == key && b->button == button && if (b->key == key && b->button == button && b->axis == axis &&
b->modifier == device->modifier_state && state) { b->modifier == device->modifier_state && state) {
b->handler(&device->input_device, b->handler(&device->input_device,
time, key, button, state, b->data); time, key, button, axis, state, b->data);
/* If this was a key binding and it didn't /* If this was a key binding and it didn't
* install a keyboard grab, install one now to * install a keyboard grab, install one now to

Loading…
Cancel
Save