diff --git a/compositor/compositor.c b/compositor/compositor.c index a87c658f..befdbc75 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -1286,14 +1286,6 @@ notify_button(struct wl_input_device *device, else wlsc_compositor_idle_release(compositor); - if (state && surface && device->grab == NULL) { - compositor->shell->activate(compositor->shell, - surface, wd, time); - wl_input_device_start_grab(device, - &device->implicit_grab, - button, time); - } - wl_list_for_each(b, &compositor->binding_list, link) { if (b->button == button && b->modifier == wd->modifier_state && state) { @@ -1303,6 +1295,12 @@ notify_button(struct wl_input_device *device, } } + if (state && surface && device->grab == NULL) { + wl_input_device_start_grab(device, + &device->implicit_grab, + button, time); + } + if (device->grab) device->grab->interface->button(device->grab, time, button, state); @@ -1326,6 +1324,21 @@ terminate_binding(struct wl_input_device *device, uint32_t time, wl_display_terminate(compositor->wl_display); } +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) +{ + struct wlsc_input_device *wd = (struct wlsc_input_device *) device; + struct wlsc_compositor *compositor = data; + struct wlsc_surface *focus; + + focus = (struct wlsc_surface *) device->pointer_focus; + if (state && focus && device->grab == NULL) + compositor->shell->activate(compositor->shell, + focus, wd, time); +} + WL_EXPORT struct wlsc_binding * wlsc_compositor_add_binding(struct wlsc_compositor *compositor, uint32_t key, uint32_t button, uint32_t modifier, @@ -1906,6 +1919,9 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display) MODIFIER_CTRL | MODIFIER_ALT, terminate_binding, ec); + wlsc_compositor_add_binding(ec, 0, BTN_LEFT, 0, + click_to_activate_binding, ec); + screenshooter_create(ec); wlsc_data_device_manager_init(ec);