aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-10-03 19:14:36 +0200
committeremersion <contact@emersion.fr>2017-10-03 19:14:36 +0200
commita40d38798c6fabf14a690fde7ab2367455da65c6 (patch)
treefb9325b32f8ce5a318287289e8d97c1475d21239
parent5f3c56de2805f11e84e0bb17edc30f455f0a3aaf (diff)
rootston: force move and resize
-rw-r--r--rootston/cursor.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/rootston/cursor.c b/rootston/cursor.c
index c24e6989..ef941730 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -1,3 +1,4 @@
+#include <stdbool.h>
#include <stdint.h>
#include <string.h>
// TODO: BSD et al
@@ -141,6 +142,18 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
event->orientation, event->delta);
}
+static bool is_logo_pressed(struct roots_input *input) {
+ struct roots_keyboard *keyboard;
+ wl_list_for_each(keyboard, &input->keyboards, link) {
+ uint32_t modifiers =
+ wlr_keyboard_get_modifiers(keyboard->device->keyboard);
+ if ((modifiers ^ WLR_MODIFIER_LOGO) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
static void do_cursor_button_press(struct roots_input *input,
struct wlr_cursor *cursor, struct wlr_input_device *device,
uint32_t time, uint32_t button, uint32_t state) {
@@ -148,9 +161,27 @@ static void do_cursor_button_press(struct roots_input *input,
struct wlr_surface *surface;
double sx, sy;
struct roots_view *view = view_at(desktop,
- input->cursor->x, input->cursor->y, &surface, &sx, &sy);
- uint32_t serial = wlr_seat_pointer_send_button(
- input->wl_seat, time, button, state);
+ input->cursor->x, input->cursor->y, &surface, &sx, &sy);
+
+ if (state == WLR_BUTTON_PRESSED && view && is_logo_pressed(input)) {
+ set_view_focus(input, desktop, view);
+
+ switch (button) {
+ case BTN_LEFT:
+ view_begin_move(input, cursor, view);
+ break;
+ case BTN_RIGHT:
+ view_begin_resize(input, cursor, view,
+ ROOTS_CURSOR_RESIZE_EDGE_RIGHT |
+ ROOTS_CURSOR_RESIZE_EDGE_BOTTOM);
+ break;
+ }
+ return;
+ }
+
+ uint32_t serial = wlr_seat_pointer_send_button(input->wl_seat, time, button,
+ state);
+
int i;
switch (state) {
case WLR_BUTTON_RELEASED: