Modify bindings for axis event detection.

dev
Scott Moreau 13 years ago
parent 210d079817
commit 6a3633d2bb
  1. 10
      src/compositor.c
  2. 7
      src/compositor.h
  3. 46
      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--;
}
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);
@ -1558,6 +1558,12 @@ notify_axis(struct wl_input_device *device,
weston_compositor_activity(compositor);
if (value)
weston_compositor_run_binding(compositor, wd,
time, 0, 0, axis, value);
else
return;
if (device->pointer_focus_resource)
wl_resource_post_event(device->pointer_focus_resource,
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)
weston_compositor_run_binding(compositor, wd,
time, key, 0, state);
time, key, 0, 0, state);
device->keyboard_grab->interface->key(device->keyboard_grab,
time, key, state);

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

@ -1092,7 +1092,7 @@ get_shell_surface_type(struct weston_surface *surface)
static void
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 *) device->pointer_focus;
@ -1115,7 +1115,7 @@ move_binding(struct wl_input_device *device, uint32_t time,
static void
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 *) device->pointer_focus;
@ -1163,7 +1163,7 @@ resize_binding(struct wl_input_device *device, uint32_t time,
static void
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_compositor *compositor = wd->compositor;
@ -1194,7 +1194,7 @@ zoom_binding(struct wl_input_device *device, uint32_t time,
static void
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;
@ -1278,7 +1278,7 @@ static const struct wl_pointer_grab_interface rotate_grab_interface = {
static void
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 *) device->pointer_focus;
@ -1389,7 +1389,7 @@ activate(struct weston_shell *base, struct weston_surface *es,
static void
click_to_activate_binding(struct wl_input_device *device,
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_compositor *compositor = data;
@ -1916,8 +1916,8 @@ static const struct wl_keyboard_grab_interface switcher_grab = {
static void
switcher_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 switcher *switcher;
@ -1937,7 +1937,7 @@ switcher_binding(struct wl_input_device *device, uint32_t time,
static void
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_output *output;
@ -1970,7 +1970,7 @@ backlight_binding(struct wl_input_device *device, uint32_t time,
static void
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 wl_shell *shell =
@ -2065,36 +2065,36 @@ shell_init(struct weston_compositor *ec)
if (launch_desktop_shell_process(shell) != 0)
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);
weston_compositor_add_binding(ec, 0, BTN_MIDDLE, MODIFIER_SUPER,
weston_compositor_add_binding(ec, 0, BTN_MIDDLE, 0, MODIFIER_SUPER,
resize_binding, shell);
weston_compositor_add_binding(ec, KEY_BACKSPACE, 0,
weston_compositor_add_binding(ec, KEY_BACKSPACE, 0, 0,
MODIFIER_CTRL | MODIFIER_ALT,
terminate_binding, ec);
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0,
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, 0,
click_to_activate_binding, ec);
weston_compositor_add_binding(ec, KEY_UP, 0, MODIFIER_SUPER,
weston_compositor_add_binding(ec, KEY_UP, 0, 0, MODIFIER_SUPER,
zoom_binding, shell);
weston_compositor_add_binding(ec, KEY_DOWN, 0, MODIFIER_SUPER,
weston_compositor_add_binding(ec, KEY_DOWN, 0, 0, MODIFIER_SUPER,
zoom_binding, shell);
weston_compositor_add_binding(ec, 0, BTN_LEFT,
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0,
MODIFIER_SUPER | MODIFIER_ALT,
rotate_binding, NULL);
weston_compositor_add_binding(ec, KEY_TAB, 0, MODIFIER_SUPER,
weston_compositor_add_binding(ec, KEY_TAB, 0, 0, MODIFIER_SUPER,
switcher_binding, ec);
/* 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);
weston_compositor_add_binding(ec, KEY_BRIGHTNESSDOWN, 0, 0,
weston_compositor_add_binding(ec, KEY_BRIGHTNESSDOWN, 0, 0, 0,
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);
weston_compositor_add_binding(ec, KEY_BRIGHTNESSUP, 0, 0,
weston_compositor_add_binding(ec, KEY_BRIGHTNESSUP, 0, 0, 0,
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);
ec->shell = &shell->shell;

@ -433,7 +433,7 @@ long_press_handler(void *data)
static void
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;
@ -446,7 +446,7 @@ menu_key_binding(struct wl_input_device *device, uint32_t time,
static void
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;
@ -534,15 +534,15 @@ shell_init(struct weston_compositor *compositor)
shell->long_press_source =
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);
weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0,
weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0, 0,
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);
weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0,
weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0,
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);
compositor->shell = &shell->shell;

@ -186,6 +186,7 @@ weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,
struct weston_binding {
uint32_t key;
uint32_t button;
uint32_t axis;
uint32_t modifier;
weston_binding_handler_t handler;
void *data;
@ -194,7 +195,7 @@ struct weston_binding {
WL_EXPORT struct weston_binding *
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)
{
struct weston_binding *binding;
@ -205,6 +206,7 @@ weston_compositor_add_binding(struct weston_compositor *compositor,
binding->key = key;
binding->button = button;
binding->axis = axis;
binding->modifier = modifier;
binding->handler = handler;
binding->data = data;
@ -272,16 +274,16 @@ install_binding_grab(struct wl_input_device *device,
WL_EXPORT void
weston_compositor_run_binding(struct weston_compositor *compositor,
struct weston_input_device *device,
uint32_t time,
uint32_t key, uint32_t button, int32_t state)
uint32_t time, uint32_t key,
uint32_t button, uint32_t axis, int32_t state)
{
struct weston_binding *b;
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->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
* install a keyboard grab, install one now to

Loading…
Cancel
Save