Split bindings into separate key/button/axis bindings
Rather than attempting to have the one handler prototype everywhere. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
committed by
Kristian Høgsberg
parent
878f0b77a8
commit
325fc2d53a
@@ -1727,12 +1727,10 @@ vt_func(struct weston_compositor *compositor, int event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
switch_vt_binding(struct wl_seat *seat, uint32_t time,
|
switch_vt_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data)
|
||||||
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
|
||||||
{
|
{
|
||||||
struct drm_compositor *ec = data;
|
struct drm_compositor *ec = data;
|
||||||
|
|
||||||
if (state)
|
|
||||||
tty_activate_vt(ec->tty, key - KEY_F1 + 1);
|
tty_activate_vt(ec->tty, key - KEY_F1 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1810,7 +1808,7 @@ drm_compositor_create(struct wl_display *display,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (key = KEY_F1; key < KEY_F9; key++)
|
for (key = KEY_F1; key < KEY_F9; key++)
|
||||||
weston_compositor_add_binding(&ec->base, key, 0, 0,
|
weston_compositor_add_key_binding(&ec->base, key,
|
||||||
MODIFIER_CTRL | MODIFIER_ALT,
|
MODIFIER_CTRL | MODIFIER_ALT,
|
||||||
switch_vt_binding, ec);
|
switch_vt_binding, ec);
|
||||||
|
|
||||||
|
|||||||
+10
-7
@@ -1694,7 +1694,7 @@ notify_button(struct wl_seat *seat, uint32_t time, int32_t button,
|
|||||||
seat->pointer->button_count--;
|
seat->pointer->button_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
weston_compositor_run_binding(compositor, ws, time, 0, button, 0,
|
weston_compositor_run_button_binding(compositor, ws, time, button,
|
||||||
state);
|
state);
|
||||||
|
|
||||||
seat->pointer->grab->interface->button(seat->pointer->grab, time,
|
seat->pointer->grab->interface->button(seat->pointer->grab, time,
|
||||||
@@ -1721,8 +1721,7 @@ notify_axis(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
|||||||
weston_compositor_activity(compositor);
|
weston_compositor_activity(compositor);
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
weston_compositor_run_binding(compositor, ws,
|
weston_compositor_run_axis_binding(compositor, ws, time, axis,
|
||||||
time, 0, 0, axis,
|
|
||||||
wl_fixed_to_int(value));
|
wl_fixed_to_int(value));
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@@ -1830,8 +1829,8 @@ notify_key(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (grab == &seat->keyboard->default_grab)
|
if (grab == &seat->keyboard->default_grab)
|
||||||
weston_compositor_run_binding(compositor, ws,
|
weston_compositor_run_key_binding(compositor, ws, time, key,
|
||||||
time, key, 0, 0, state);
|
state);
|
||||||
|
|
||||||
grab->interface->key(grab, time, key, state);
|
grab->interface->key(grab, time, key, state);
|
||||||
if (mods)
|
if (mods)
|
||||||
@@ -2835,7 +2834,9 @@ weston_compositor_init(struct weston_compositor *ec, struct wl_display *display)
|
|||||||
wl_list_init(&ec->layer_list);
|
wl_list_init(&ec->layer_list);
|
||||||
wl_list_init(&ec->seat_list);
|
wl_list_init(&ec->seat_list);
|
||||||
wl_list_init(&ec->output_list);
|
wl_list_init(&ec->output_list);
|
||||||
wl_list_init(&ec->binding_list);
|
wl_list_init(&ec->key_binding_list);
|
||||||
|
wl_list_init(&ec->button_binding_list);
|
||||||
|
wl_list_init(&ec->axis_binding_list);
|
||||||
wl_list_init(&ec->animation_list);
|
wl_list_init(&ec->animation_list);
|
||||||
weston_spring_init(&ec->fade.spring, 30.0, 1.0, 1.0);
|
weston_spring_init(&ec->fade.spring, 30.0, 1.0, 1.0);
|
||||||
ec->fade.animation.frame = fade_frame;
|
ec->fade.animation.frame = fade_frame;
|
||||||
@@ -2884,7 +2885,9 @@ weston_compositor_shutdown(struct weston_compositor *ec)
|
|||||||
wl_list_for_each_safe(output, next, &ec->output_list, link)
|
wl_list_for_each_safe(output, next, &ec->output_list, link)
|
||||||
output->destroy(output);
|
output->destroy(output);
|
||||||
|
|
||||||
weston_binding_list_destroy_all(&ec->binding_list);
|
weston_binding_list_destroy_all(&ec->key_binding_list);
|
||||||
|
weston_binding_list_destroy_all(&ec->button_binding_list);
|
||||||
|
weston_binding_list_destroy_all(&ec->axis_binding_list);
|
||||||
|
|
||||||
wl_array_release(&ec->vertices);
|
wl_array_release(&ec->vertices);
|
||||||
wl_array_release(&ec->indices);
|
wl_array_release(&ec->indices);
|
||||||
|
|||||||
+41
-11
@@ -268,7 +268,9 @@ struct weston_compositor {
|
|||||||
struct wl_list seat_list;
|
struct wl_list seat_list;
|
||||||
struct wl_list layer_list;
|
struct wl_list layer_list;
|
||||||
struct wl_list surface_list;
|
struct wl_list surface_list;
|
||||||
struct wl_list binding_list;
|
struct wl_list key_binding_list;
|
||||||
|
struct wl_list button_binding_list;
|
||||||
|
struct wl_list axis_binding_list;
|
||||||
struct wl_list animation_list;
|
struct wl_list animation_list;
|
||||||
struct {
|
struct {
|
||||||
struct weston_spring spring;
|
struct weston_spring spring;
|
||||||
@@ -525,16 +527,35 @@ weston_compositor_update_drag_surfaces(struct weston_compositor *compositor);
|
|||||||
|
|
||||||
|
|
||||||
struct weston_binding;
|
struct weston_binding;
|
||||||
typedef void (*weston_binding_handler_t)(struct wl_seat *seat,
|
typedef void (*weston_key_binding_handler_t)(struct wl_seat *seat,
|
||||||
uint32_t time, uint32_t key,
|
uint32_t time, uint32_t key,
|
||||||
|
void *data);
|
||||||
|
struct weston_binding *
|
||||||
|
weston_compositor_add_key_binding(struct weston_compositor *compositor,
|
||||||
|
uint32_t key,
|
||||||
|
enum weston_keyboard_modifier modifier,
|
||||||
|
weston_key_binding_handler_t binding,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
typedef void (*weston_button_binding_handler_t)(struct wl_seat *seat,
|
||||||
|
uint32_t time, uint32_t button,
|
||||||
|
void *data);
|
||||||
|
struct weston_binding *
|
||||||
|
weston_compositor_add_button_binding(struct weston_compositor *compositor,
|
||||||
uint32_t button,
|
uint32_t button,
|
||||||
uint32_t axis,
|
enum weston_keyboard_modifier modifier,
|
||||||
|
weston_button_binding_handler_t binding,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
typedef void (*weston_axis_binding_handler_t)(struct wl_seat *seat,
|
||||||
|
uint32_t time, uint32_t axis,
|
||||||
int32_t value, void *data);
|
int32_t value, void *data);
|
||||||
struct weston_binding *
|
struct weston_binding *
|
||||||
weston_compositor_add_binding(struct weston_compositor *compositor,
|
weston_compositor_add_axis_binding(struct weston_compositor *compositor,
|
||||||
uint32_t key, uint32_t button, uint32_t axis,
|
uint32_t axis,
|
||||||
enum weston_keyboard_modifier modifier,
|
enum weston_keyboard_modifier modifier,
|
||||||
weston_binding_handler_t binding, void *data);
|
weston_axis_binding_handler_t binding,
|
||||||
|
void *data);
|
||||||
void
|
void
|
||||||
weston_binding_destroy(struct weston_binding *binding);
|
weston_binding_destroy(struct weston_binding *binding);
|
||||||
|
|
||||||
@@ -542,11 +563,20 @@ void
|
|||||||
weston_binding_list_destroy_all(struct wl_list *list);
|
weston_binding_list_destroy_all(struct wl_list *list);
|
||||||
|
|
||||||
void
|
void
|
||||||
weston_compositor_run_binding(struct weston_compositor *compositor,
|
weston_compositor_run_key_binding(struct weston_compositor *compositor,
|
||||||
struct weston_seat *seat,
|
struct weston_seat *seat, uint32_t time,
|
||||||
uint32_t time,
|
uint32_t key,
|
||||||
uint32_t key, uint32_t button, uint32_t axis,
|
enum wl_keyboard_key_state state);
|
||||||
int32_t value);
|
void
|
||||||
|
weston_compositor_run_button_binding(struct weston_compositor *compositor,
|
||||||
|
struct weston_seat *seat, uint32_t time,
|
||||||
|
uint32_t button,
|
||||||
|
enum wl_pointer_button_state value);
|
||||||
|
void
|
||||||
|
weston_compositor_run_axis_binding(struct weston_compositor *compositor,
|
||||||
|
struct weston_seat *seat, uint32_t time,
|
||||||
|
uint32_t axis, int32_t value);
|
||||||
|
|
||||||
int
|
int
|
||||||
weston_environment_get_fd(const char *env);
|
weston_environment_get_fd(const char *env);
|
||||||
|
|
||||||
|
|||||||
+5
-8
@@ -199,9 +199,8 @@ screenshooter_sigchld(struct weston_process *process, int status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
screenshooter_binding(struct wl_seat *seat, uint32_t time,
|
screenshooter_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||||
uint32_t key, uint32_t button, uint32_t axis,
|
void *data)
|
||||||
int32_t state, void *data)
|
|
||||||
{
|
{
|
||||||
struct screenshooter *shooter = data;
|
struct screenshooter *shooter = data;
|
||||||
const char *screenshooter_exe = LIBEXECDIR "/weston-screenshooter";
|
const char *screenshooter_exe = LIBEXECDIR "/weston-screenshooter";
|
||||||
@@ -390,9 +389,7 @@ weston_recorder_destroy(struct weston_recorder *recorder)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
recorder_binding(struct wl_seat *seat, uint32_t time,
|
recorder_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data)
|
||||||
uint32_t key, uint32_t button, uint32_t axis,
|
|
||||||
int32_t state, void *data)
|
|
||||||
{
|
{
|
||||||
struct weston_seat *ws = (struct weston_seat *) seat;
|
struct weston_seat *ws = (struct weston_seat *) seat;
|
||||||
struct weston_compositor *ec = ws->compositor;
|
struct weston_compositor *ec = ws->compositor;
|
||||||
@@ -448,9 +445,9 @@ screenshooter_create(struct weston_compositor *ec)
|
|||||||
shooter->global = wl_display_add_global(ec->wl_display,
|
shooter->global = wl_display_add_global(ec->wl_display,
|
||||||
&screenshooter_interface,
|
&screenshooter_interface,
|
||||||
shooter, bind_shooter);
|
shooter, bind_shooter);
|
||||||
weston_compositor_add_binding(ec, KEY_S, 0, 0, MODIFIER_SUPER,
|
weston_compositor_add_key_binding(ec, KEY_S, MODIFIER_SUPER,
|
||||||
screenshooter_binding, shooter);
|
screenshooter_binding, shooter);
|
||||||
weston_compositor_add_binding(ec, KEY_R, 0, 0, MODIFIER_SUPER,
|
weston_compositor_add_key_binding(ec, KEY_R, MODIFIER_SUPER,
|
||||||
recorder_binding, shooter);
|
recorder_binding, shooter);
|
||||||
|
|
||||||
shooter->destroy_listener.notify = screenshooter_destroy;
|
shooter->destroy_listener.notify = screenshooter_destroy;
|
||||||
|
|||||||
+60
-63
@@ -1541,9 +1541,7 @@ get_shell_surface_type(struct weston_surface *surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
move_binding(struct wl_seat *seat, uint32_t time,
|
move_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
|
||||||
uint32_t key, uint32_t button, uint32_t axis, int32_t value,
|
|
||||||
void *data)
|
|
||||||
{
|
{
|
||||||
struct weston_surface *surface =
|
struct weston_surface *surface =
|
||||||
(struct weston_surface *) seat->pointer->focus;
|
(struct weston_surface *) seat->pointer->focus;
|
||||||
@@ -1570,9 +1568,7 @@ move_binding(struct wl_seat *seat, uint32_t time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
resize_binding(struct wl_seat *seat, uint32_t time,
|
resize_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
|
||||||
uint32_t key, uint32_t button, uint32_t axis, int32_t value,
|
|
||||||
void *data)
|
|
||||||
{
|
{
|
||||||
struct weston_surface *surface =
|
struct weston_surface *surface =
|
||||||
(struct weston_surface *) seat->pointer->focus;
|
(struct weston_surface *) seat->pointer->focus;
|
||||||
@@ -1620,8 +1616,7 @@ resize_binding(struct wl_seat *seat, uint32_t time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
surface_opacity_binding(struct wl_seat *seat, uint32_t time,
|
surface_opacity_binding(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
||||||
uint32_t key, uint32_t button, uint32_t axis,
|
|
||||||
int32_t value, void *data)
|
int32_t value, void *data)
|
||||||
{
|
{
|
||||||
float step = 0.05;
|
float step = 0.05;
|
||||||
@@ -1656,9 +1651,8 @@ surface_opacity_binding(struct wl_seat *seat, uint32_t time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zoom_binding(struct wl_seat *seat, uint32_t time,
|
do_zoom(struct wl_seat *seat, uint32_t time, uint32_t key, uint32_t axis,
|
||||||
uint32_t key, uint32_t button, uint32_t axis, int32_t value,
|
int32_t value)
|
||||||
void *data)
|
|
||||||
{
|
{
|
||||||
struct weston_seat *ws = (struct weston_seat *) seat;
|
struct weston_seat *ws = (struct weston_seat *) seat;
|
||||||
struct weston_compositor *compositor = ws->compositor;
|
struct weston_compositor *compositor = ws->compositor;
|
||||||
@@ -1670,9 +1664,9 @@ zoom_binding(struct wl_seat *seat, uint32_t time,
|
|||||||
wl_fixed_to_double(seat->pointer->x),
|
wl_fixed_to_double(seat->pointer->x),
|
||||||
wl_fixed_to_double(seat->pointer->y),
|
wl_fixed_to_double(seat->pointer->y),
|
||||||
NULL)) {
|
NULL)) {
|
||||||
if (key == KEY_PAGEUP && value)
|
if (key == KEY_PAGEUP)
|
||||||
increment = output->zoom.increment;
|
increment = output->zoom.increment;
|
||||||
else if (key == KEY_PAGEDOWN && value)
|
else if (key == KEY_PAGEDOWN)
|
||||||
increment = -output->zoom.increment;
|
increment = -output->zoom.increment;
|
||||||
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
|
||||||
increment = output->zoom.increment * value;
|
increment = output->zoom.increment * value;
|
||||||
@@ -1701,12 +1695,25 @@ zoom_binding(struct wl_seat *seat, uint32_t time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
terminate_binding(struct wl_seat *seat, uint32_t time,
|
zoom_axis_binding(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
||||||
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
int32_t value, void *data)
|
||||||
|
{
|
||||||
|
do_zoom(seat, time, 0, axis, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
zoom_key_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
do_zoom(seat, time, key, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
terminate_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||||
|
void *data)
|
||||||
{
|
{
|
||||||
struct weston_compositor *compositor = data;
|
struct weston_compositor *compositor = data;
|
||||||
|
|
||||||
if (state)
|
|
||||||
wl_display_terminate(compositor->wl_display);
|
wl_display_terminate(compositor->wl_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1807,8 +1814,7 @@ static const struct wl_pointer_grab_interface rotate_grab_interface = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rotate_binding(struct wl_seat *seat, uint32_t time,
|
rotate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
|
||||||
uint32_t key, uint32_t button, uint32_t axis, int32_t value,
|
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct weston_surface *base_surface =
|
struct weston_surface *base_surface =
|
||||||
@@ -1936,16 +1942,13 @@ is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
click_to_activate_binding(struct wl_seat *seat,
|
click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
|
||||||
uint32_t time, uint32_t key,
|
|
||||||
uint32_t button, uint32_t axis, int32_t state_w,
|
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct weston_seat *ws = (struct weston_seat *) seat;
|
struct weston_seat *ws = (struct weston_seat *) seat;
|
||||||
struct desktop_shell *shell = data;
|
struct desktop_shell *shell = data;
|
||||||
struct weston_surface *focus;
|
struct weston_surface *focus;
|
||||||
struct weston_surface *upper;
|
struct weston_surface *upper;
|
||||||
enum wl_pointer_button_state state = state_w;
|
|
||||||
|
|
||||||
focus = (struct weston_surface *) seat->pointer->focus;
|
focus = (struct weston_surface *) seat->pointer->focus;
|
||||||
if (!focus)
|
if (!focus)
|
||||||
@@ -1954,8 +1957,7 @@ click_to_activate_binding(struct wl_seat *seat,
|
|||||||
if (is_black_surface(focus, &upper))
|
if (is_black_surface(focus, &upper))
|
||||||
focus = upper;
|
focus = upper;
|
||||||
|
|
||||||
if (state == WL_POINTER_BUTTON_STATE_PRESSED &&
|
if (seat->pointer->grab == &seat->pointer->default_grab)
|
||||||
seat->pointer->grab == &seat->pointer->default_grab)
|
|
||||||
activate(shell, focus, ws);
|
activate(shell, focus, ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2511,9 +2513,8 @@ static const struct wl_keyboard_grab_interface switcher_grab = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
switcher_binding(struct wl_seat *seat, uint32_t time,
|
switcher_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||||
uint32_t key, uint32_t button, uint32_t axis,
|
void *data)
|
||||||
int32_t value, void *data)
|
|
||||||
{
|
{
|
||||||
struct desktop_shell *shell = data;
|
struct desktop_shell *shell = data;
|
||||||
struct switcher *switcher;
|
struct switcher *switcher;
|
||||||
@@ -2531,8 +2532,8 @@ switcher_binding(struct wl_seat *seat, uint32_t time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
backlight_binding(struct wl_seat *seat, uint32_t time,
|
backlight_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||||
uint32_t key, uint32_t button, uint32_t axis, int32_t state, void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct weston_compositor *compositor = data;
|
struct weston_compositor *compositor = data;
|
||||||
struct weston_output *output;
|
struct weston_output *output;
|
||||||
@@ -2564,9 +2565,8 @@ backlight_binding(struct wl_seat *seat, uint32_t time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
debug_repaint_binding(struct wl_seat *seat, uint32_t time,
|
debug_repaint_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||||
uint32_t key, uint32_t button, uint32_t axis,
|
void *data)
|
||||||
int32_t value, void *data)
|
|
||||||
{
|
{
|
||||||
struct desktop_shell *shell = data;
|
struct desktop_shell *shell = data;
|
||||||
struct weston_compositor *compositor = shell->compositor;
|
struct weston_compositor *compositor = shell->compositor;
|
||||||
@@ -2599,21 +2599,18 @@ debug_repaint_binding(struct wl_seat *seat, uint32_t time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
force_kill_binding(struct wl_seat *seat, uint32_t time,
|
force_kill_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||||
uint32_t key, uint32_t button, uint32_t axis,
|
void *data)
|
||||||
int32_t value, void *data)
|
|
||||||
{
|
{
|
||||||
struct wl_client *client;
|
struct wl_client *client;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
gid_t gid;
|
gid_t gid;
|
||||||
|
|
||||||
if (value == 1) {
|
|
||||||
client = seat->keyboard->focus->resource.client;
|
client = seat->keyboard->focus->resource.client;
|
||||||
wl_client_get_credentials(client, &pid, &uid, &gid);
|
wl_client_get_credentials(client, &pid, &uid, &gid);
|
||||||
|
|
||||||
kill(pid, SIGKILL);
|
kill(pid, SIGKILL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2638,44 +2635,44 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
|
|||||||
uint32_t mod;
|
uint32_t mod;
|
||||||
|
|
||||||
/* fixed bindings */
|
/* fixed bindings */
|
||||||
weston_compositor_add_binding(ec, KEY_BACKSPACE, 0, 0,
|
weston_compositor_add_key_binding(ec, KEY_BACKSPACE,
|
||||||
MODIFIER_CTRL | MODIFIER_ALT,
|
MODIFIER_CTRL | MODIFIER_ALT,
|
||||||
terminate_binding, ec);
|
terminate_binding, ec);
|
||||||
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, 0,
|
weston_compositor_add_button_binding(ec, BTN_LEFT, 0,
|
||||||
click_to_activate_binding, shell);
|
click_to_activate_binding,
|
||||||
weston_compositor_add_binding(ec, 0, 0,
|
shell);
|
||||||
WL_POINTER_AXIS_VERTICAL_SCROLL,
|
weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL,
|
||||||
MODIFIER_SUPER | MODIFIER_ALT,
|
MODIFIER_SUPER | MODIFIER_ALT,
|
||||||
surface_opacity_binding, NULL);
|
surface_opacity_binding, NULL);
|
||||||
weston_compositor_add_binding(ec, 0, 0,
|
weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL,
|
||||||
WL_POINTER_AXIS_VERTICAL_SCROLL,
|
MODIFIER_SUPER, zoom_axis_binding,
|
||||||
MODIFIER_SUPER, zoom_binding, NULL);
|
NULL);
|
||||||
|
|
||||||
/* configurable bindings */
|
/* configurable bindings */
|
||||||
mod = shell->binding_modifier;
|
mod = shell->binding_modifier;
|
||||||
weston_compositor_add_binding(ec, KEY_PAGEUP, 0, 0, mod,
|
weston_compositor_add_key_binding(ec, KEY_PAGEUP, mod,
|
||||||
zoom_binding, NULL);
|
zoom_key_binding, NULL);
|
||||||
weston_compositor_add_binding(ec, KEY_PAGEDOWN, 0, 0, mod,
|
weston_compositor_add_key_binding(ec, KEY_PAGEDOWN, mod,
|
||||||
zoom_binding, NULL);
|
zoom_key_binding, NULL);
|
||||||
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, mod,
|
weston_compositor_add_button_binding(ec, BTN_LEFT, mod, move_binding,
|
||||||
move_binding, shell);
|
shell);
|
||||||
weston_compositor_add_binding(ec, 0, BTN_MIDDLE, 0, mod,
|
weston_compositor_add_button_binding(ec, BTN_MIDDLE, mod,
|
||||||
resize_binding, shell);
|
resize_binding, shell);
|
||||||
weston_compositor_add_binding(ec, 0, BTN_RIGHT, 0, mod,
|
weston_compositor_add_button_binding(ec, BTN_RIGHT, mod,
|
||||||
rotate_binding, NULL);
|
rotate_binding, NULL);
|
||||||
weston_compositor_add_binding(ec, KEY_TAB, 0, 0, mod,
|
weston_compositor_add_key_binding(ec, KEY_TAB, mod, switcher_binding,
|
||||||
switcher_binding, shell);
|
shell);
|
||||||
weston_compositor_add_binding(ec, KEY_F9, 0, 0, mod,
|
weston_compositor_add_key_binding(ec, KEY_F9, mod, backlight_binding,
|
||||||
|
ec);
|
||||||
|
weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSDOWN, 0,
|
||||||
backlight_binding, ec);
|
backlight_binding, ec);
|
||||||
weston_compositor_add_binding(ec, KEY_BRIGHTNESSDOWN, 0, 0, 0,
|
weston_compositor_add_key_binding(ec, KEY_F10, mod, backlight_binding,
|
||||||
|
ec);
|
||||||
|
weston_compositor_add_key_binding(ec, KEY_BRIGHTNESSUP, 0,
|
||||||
backlight_binding, ec);
|
backlight_binding, ec);
|
||||||
weston_compositor_add_binding(ec, KEY_F10, 0, 0, mod,
|
weston_compositor_add_key_binding(ec, KEY_SPACE, mod,
|
||||||
backlight_binding, ec);
|
|
||||||
weston_compositor_add_binding(ec, KEY_BRIGHTNESSUP, 0, 0, 0,
|
|
||||||
backlight_binding, ec);
|
|
||||||
weston_compositor_add_binding(ec, KEY_SPACE, 0, 0, mod,
|
|
||||||
debug_repaint_binding, shell);
|
debug_repaint_binding, shell);
|
||||||
weston_compositor_add_binding(ec, KEY_K, 0, 0, mod,
|
weston_compositor_add_key_binding(ec, KEY_K, mod,
|
||||||
force_kill_binding, shell);
|
force_kill_binding, shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -447,31 +447,29 @@ long_press_handler(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
menu_key_binding(struct wl_seat *seat, uint32_t time,
|
menu_key_binding(struct wl_seat *seat, uint32_t time, uint32_t key, 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;
|
||||||
|
|
||||||
if (shell->state == STATE_LOCKED)
|
if (shell->state == STATE_LOCKED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (state)
|
|
||||||
toggle_switcher(shell);
|
toggle_switcher(shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
home_key_binding(struct wl_seat *seat, uint32_t time,
|
home_key_binding(struct wl_seat *seat, uint32_t time, uint32_t key, 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;
|
||||||
|
|
||||||
if (shell->state == STATE_LOCKED)
|
if (shell->state == STATE_LOCKED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (state) {
|
if (1) {
|
||||||
wl_event_source_timer_update(shell->long_press_source, 500);
|
wl_event_source_timer_update(shell->long_press_source, 500);
|
||||||
shell->long_press_active = 1;
|
shell->long_press_active = 1;
|
||||||
} else if (shell->long_press_active) {
|
} else if (shell->long_press_active) {
|
||||||
|
/* This code has never been run ... */
|
||||||
wl_event_source_timer_update(shell->long_press_source, 0);
|
wl_event_source_timer_update(shell->long_press_source, 0);
|
||||||
shell->long_press_active = 0;
|
shell->long_press_active = 0;
|
||||||
|
|
||||||
@@ -561,15 +559,17 @@ 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, 0,
|
weston_compositor_add_key_binding(compositor, KEY_LEFTMETA, 0,
|
||||||
home_key_binding, shell);
|
home_key_binding, shell);
|
||||||
weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0, 0,
|
weston_compositor_add_key_binding(compositor, KEY_RIGHTMETA, 0,
|
||||||
home_key_binding, shell);
|
home_key_binding, shell);
|
||||||
weston_compositor_add_binding(compositor, KEY_LEFTMETA, 0, 0,
|
weston_compositor_add_key_binding(compositor, KEY_LEFTMETA,
|
||||||
MODIFIER_SUPER, home_key_binding, shell);
|
MODIFIER_SUPER, home_key_binding,
|
||||||
weston_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0,
|
shell);
|
||||||
MODIFIER_SUPER, home_key_binding, shell);
|
weston_compositor_add_key_binding(compositor, KEY_RIGHTMETA,
|
||||||
weston_compositor_add_binding(compositor, KEY_COMPOSE, 0, 0, 0,
|
MODIFIER_SUPER, home_key_binding,
|
||||||
|
shell);
|
||||||
|
weston_compositor_add_key_binding(compositor, KEY_COMPOSE, 0,
|
||||||
menu_key_binding, shell);
|
menu_key_binding, shell);
|
||||||
|
|
||||||
weston_layer_init(&shell->homescreen_layer,
|
weston_layer_init(&shell->homescreen_layer,
|
||||||
|
|||||||
+103
-14
@@ -199,15 +199,15 @@ struct weston_binding {
|
|||||||
uint32_t button;
|
uint32_t button;
|
||||||
uint32_t axis;
|
uint32_t axis;
|
||||||
uint32_t modifier;
|
uint32_t modifier;
|
||||||
weston_binding_handler_t handler;
|
void *handler;
|
||||||
void *data;
|
void *data;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
WL_EXPORT struct weston_binding *
|
static 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 axis, uint32_t modifier,
|
uint32_t key, uint32_t button, uint32_t axis,
|
||||||
weston_binding_handler_t handler, void *data)
|
uint32_t modifier, void *handler, void *data)
|
||||||
{
|
{
|
||||||
struct weston_binding *binding;
|
struct weston_binding *binding;
|
||||||
|
|
||||||
@@ -221,7 +221,60 @@ weston_compositor_add_binding(struct weston_compositor *compositor,
|
|||||||
binding->modifier = modifier;
|
binding->modifier = modifier;
|
||||||
binding->handler = handler;
|
binding->handler = handler;
|
||||||
binding->data = data;
|
binding->data = data;
|
||||||
wl_list_insert(compositor->binding_list.prev, &binding->link);
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
return binding;
|
||||||
}
|
}
|
||||||
@@ -304,30 +357,66 @@ install_binding_grab(struct wl_seat *seat,
|
|||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
weston_compositor_run_binding(struct weston_compositor *compositor,
|
weston_compositor_run_key_binding(struct weston_compositor *compositor,
|
||||||
struct weston_seat *seat,
|
struct weston_seat *seat,
|
||||||
uint32_t time, uint32_t key,
|
uint32_t time, uint32_t key,
|
||||||
uint32_t button, uint32_t axis, int32_t value)
|
enum wl_keyboard_key_state state)
|
||||||
{
|
{
|
||||||
struct weston_binding *b;
|
struct weston_binding *b;
|
||||||
|
|
||||||
wl_list_for_each(b, &compositor->binding_list, link) {
|
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
||||||
if (b->key == key && b->button == button && b->axis == axis &&
|
return;
|
||||||
b->modifier == seat->modifier_state && value) {
|
|
||||||
b->handler(&seat->seat,
|
wl_list_for_each(b, &compositor->key_binding_list, link) {
|
||||||
time, key, button, axis, value, b->data);
|
if (b->key == key && b->modifier == seat->modifier_state) {
|
||||||
|
weston_key_binding_handler_t handler = b->handler;
|
||||||
|
handler(&seat->seat, time, key, 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
|
||||||
* swallow the key release. */
|
* swallow the key release. */
|
||||||
if (b->key &&
|
if (seat->seat.keyboard->grab ==
|
||||||
seat->seat.keyboard->grab ==
|
|
||||||
&seat->seat.keyboard->default_grab)
|
&seat->seat.keyboard->default_grab)
|
||||||
install_binding_grab(&seat->seat, time, key);
|
install_binding_grab(&seat->seat, time, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
weston_compositor_run_button_binding(struct weston_compositor *compositor,
|
||||||
|
struct weston_seat *seat,
|
||||||
|
uint32_t time, uint32_t button,
|
||||||
|
enum wl_pointer_button_state state)
|
||||||
|
{
|
||||||
|
struct weston_binding *b;
|
||||||
|
|
||||||
|
if (state == WL_POINTER_BUTTON_STATE_RELEASED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wl_list_for_each(b, &compositor->button_binding_list, link) {
|
||||||
|
if (b->button == button && b->modifier == seat->modifier_state) {
|
||||||
|
weston_button_binding_handler_t handler = b->handler;
|
||||||
|
handler(&seat->seat, time, button, b->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
weston_compositor_run_axis_binding(struct weston_compositor *compositor,
|
||||||
|
struct weston_seat *seat,
|
||||||
|
uint32_t time, uint32_t axis,
|
||||||
|
int32_t value)
|
||||||
|
{
|
||||||
|
struct weston_binding *b;
|
||||||
|
|
||||||
|
wl_list_for_each(b, &compositor->axis_binding_list, link) {
|
||||||
|
if (b->axis == axis && b->modifier == seat->modifier_state) {
|
||||||
|
weston_axis_binding_handler_t handler = b->handler;
|
||||||
|
handler(&seat->seat, time, axis, value, b->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WL_EXPORT int
|
WL_EXPORT int
|
||||||
weston_environment_get_fd(const char *env)
|
weston_environment_get_fd(const char *env)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user