From 5b75f1b218db312df0140b9f89d7c04649f554ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 4 Aug 2010 23:21:41 -0400 Subject: [PATCH] Implement server side move override --- compositor.c | 24 +++++++++++++++++------- compositor.h | 3 ++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/compositor.c b/compositor.c index 3af3566..da1a658 100644 --- a/compositor.c +++ b/compositor.c @@ -783,9 +783,15 @@ notify_button(struct wlsc_input_device *device, device->grab = WLSC_DEVICE_GRAB_NONE; } - wl_surface_post_event(&surface->base, &device->base, - WL_INPUT_DEVICE_BUTTON, - time, button, state); + if (state && button == BTN_LEFT && + device->grab == WLSC_DEVICE_GRAB_MOTION && + (device->modifier_state & MODIFIER_SUPER)) + shell_move(NULL, &compositor->shell, + &surface->base, device, time); + else + wl_surface_post_event(&surface->base, &device->base, + WL_INPUT_DEVICE_BUTTON, + time, button, state); wlsc_compositor_schedule_repaint(compositor); } @@ -795,11 +801,10 @@ void notify_key(struct wlsc_input_device *device, uint32_t time, uint32_t key, uint32_t state) { - struct wlsc_compositor *compositor = device->ec; uint32_t *k, *end; uint32_t modifier; - switch (key | compositor->modifier_state) { + switch (key | device->modifier_state) { case KEY_BACKSPACE | MODIFIER_CTRL | MODIFIER_ALT: kill(0, SIGTERM); return; @@ -816,15 +821,20 @@ notify_key(struct wlsc_input_device *device, modifier = MODIFIER_ALT; break; + case KEY_LEFTMETA: + case KEY_RIGHTMETA: + modifier = MODIFIER_SUPER; + break; + default: modifier = 0; break; } if (state) - compositor->modifier_state |= modifier; + device->modifier_state |= modifier; else - compositor->modifier_state &= ~modifier; + device->modifier_state &= ~modifier; end = device->keys.data + device->keys.size; for (k = device->keys.data; k < end; k++) { diff --git a/compositor.h b/compositor.h index 7b42eb7..f1ffbd9 100644 --- a/compositor.h +++ b/compositor.h @@ -82,6 +82,7 @@ struct wlsc_input_device { struct wlsc_surface *pointer_focus; struct wlsc_surface *keyboard_focus; struct wl_array keys; + uint32_t modifier_state; enum wlsc_grab_type grab; uint32_t grab_time; @@ -121,7 +122,6 @@ struct wlsc_compositor { struct timespec previous_swap; uint32_t current_frame; - uint32_t modifier_state; uint32_t focus; void (*present)(struct wlsc_compositor *c); @@ -129,6 +129,7 @@ struct wlsc_compositor { #define MODIFIER_CTRL (1 << 8) #define MODIFIER_ALT (1 << 9) +#define MODIFIER_SUPER (1 << 10) struct wlsc_vector { GLfloat f[4]; -- 2.7.4