From e139de0857a1ba015fa324dcc662a39eca88761b Mon Sep 17 00:00:00 2001 From: taiyu Date: Sat, 22 Aug 2015 18:01:38 -0700 Subject: floating/tiling move + floating resize cleaned and fixed --- sway/handlers.c | 190 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 96 insertions(+), 94 deletions(-) (limited to 'sway/handlers.c') diff --git a/sway/handlers.c b/sway/handlers.c index cb42196f..7d1e4cde 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -17,10 +17,8 @@ #include "input_state.h" #include "resize.h" -struct wlc_origin mouse_origin; - static bool pointer_test(swayc_t *view, void *_origin) { - const struct wlc_origin *origin = _origin; + const struct mouse_origin *origin = _origin; // Determine the output that the view is under swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT); if (origin->x >= view->x && origin->y >= view->y @@ -55,7 +53,7 @@ swayc_t *container_under_pointer(void) { i = len = lookup->floating->length; bool got_floating = false; while (--i > -1) { - if (pointer_test(lookup->floating->items[i], &mouse_origin)) { + if (pointer_test(lookup->floating->items[i], &pointer_state.origin)) { lookup = lookup->floating->items[i]; got_floating = true; break; @@ -68,7 +66,7 @@ swayc_t *container_under_pointer(void) { // search children len = lookup->children->length; for (i = 0; i < len; ++i) { - if (pointer_test(lookup->children->items[i], &mouse_origin)) { + if (pointer_test(lookup->children->items[i], &pointer_state.origin)) { lookup = lookup->children->items[i]; break; } @@ -281,10 +279,9 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier return false; } - // Revert floating container back to original position on keypress - if (state == WLC_KEY_STATE_PRESSED && - (pointer_state.floating.drag || pointer_state.floating.resize)) { - reset_floating(get_focused_view(&root_container)); + // reset pointer mode on keypress + if (state == WLC_KEY_STATE_PRESSED && pointer_state.mode) { + pointer_mode_reset(); } struct sway_mode *mode = config->current_mode; @@ -334,83 +331,25 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier } static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) { - static struct wlc_origin prev_pos; - static wlc_handle prev_handle = 0; - mouse_origin = *origin; - bool changed_floating = false; - bool changed_tiling = false; - if (!swayc_active_workspace()) { - return false; + // Update pointer origin + pointer_state.delta.x = origin->x - pointer_state.origin.x; + pointer_state.delta.y = origin->y - pointer_state.origin.y; + pointer_state.origin.x = origin->x; + pointer_state.origin.y = origin->y; + + // Update view under pointer + swayc_t *prev_view = pointer_state.view; + pointer_state.view = container_under_pointer(); + + // If pointer is in a mode, update it + if (pointer_state.mode) { + pointer_mode_update(); } - // Do checks to determine if proper keys are being held - swayc_t *view = container_under_pointer(); - if (pointer_state.floating.drag && view) { - if (view->is_floating) { - int dx = mouse_origin.x - prev_pos.x; - int dy = mouse_origin.y - prev_pos.y; - view->x += dx; - view->y += dy; - struct wlc_geometry geometry = { - .origin = { - .x = view->x, - .y = view->y - }, - .size = { - .w = view->width, - .h = view->height - } - }; - wlc_view_set_geometry(view->handle, 0, &geometry); - changed_floating = true; - } else { - swayc_t *init_view = pointer_state.tiling.init_view; - if (view != init_view && view->type == C_VIEW) { - changed_tiling = true; - int i, j; - for (i = 0; i < view->parent->children->length; i++) { - if (view->parent->children->items[i] == view) { - for (j = 0; j < init_view->parent->children->length; j++) { - if (init_view->parent->children->items[j] == init_view) { - double temp_w = view->width; - double temp_h = view->height; - view->width = init_view->width; - view->height = init_view->height; - init_view->width = temp_w; - init_view->height = temp_h; - - init_view->parent->children->items[j] = view; - view->parent->children->items[i] = init_view; - - swayc_t *temp = view->parent; - view->parent = init_view->parent; - init_view->parent = temp; - - arrange_windows(&root_container, -1, -1); - break; - } - } - break; - } - } - } + // Otherwise change focus if config is set an + else if (prev_view != pointer_state.view && config->focus_follows_mouse) { + if (pointer_state.view && pointer_state.view->type == C_VIEW) { + set_focused_container(pointer_state.view); } - } else if (pointer_state.floating.resize && view) { - changed_floating = resize_floating(prev_pos); - } else if (pointer_state.tiling.resize && view) { - changed_tiling = mouse_resize_tiled(prev_pos); - } - if (config->focus_follows_mouse && prev_handle != handle) { - // Dont change focus if fullscreen - swayc_t *focused = get_focused_view(view); - if (!swayc_is_fullscreen(focused) - && !(pointer_state.l_held || pointer_state.r_held)) { - set_focused_container(container_under_pointer()); - } - } - prev_handle = handle; - prev_pos = mouse_origin; - if (changed_tiling || changed_floating) { - return true; } return false; } @@ -418,11 +357,82 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) { + enum { DONT_SEND_CLICK = true, SEND_CLICK = false }; + + // Update pointer_state + switch (button) { + case M_LEFT_CLICK: + pointer_state.l_held = state == WLC_BUTTON_STATE_PRESSED; + break; + + case M_RIGHT_CLICK: + pointer_state.r_held = state == WLC_BUTTON_STATE_PRESSED; + break; + + case M_SCROLL_CLICK: + pointer_state.s_held = state == WLC_BUTTON_STATE_PRESSED; + break; + + case M_SCROLL_UP: + pointer_state.s_up = state == WLC_BUTTON_STATE_PRESSED; + break; + + case M_SCROLL_DOWN: + pointer_state.s_down = state == WLC_BUTTON_STATE_PRESSED; + break; + } + + // Update pointer origin + pointer_state.origin.x = origin->x; + pointer_state.origin.y = origin->y; + + // Update view pointer is on + pointer_state.view = container_under_pointer(); + + // set pointer mode + pointer_mode_set(button, + (modifiers->mods & config->floating_mod) == config->floating_mod); + + // Return if mode has been set + if (pointer_state.mode) { + return DONT_SEND_CLICK; + } + + // Always send mouse release + if (state == WLC_BUTTON_STATE_RELEASED) { + return SEND_CLICK; + } + + // get focused window and check if to change focus on mouse click swayc_t *focused = get_focused_container(&root_container); + + // Check whether to change focus + swayc_t *pointer = pointer_state.view; + if (pointer && focused != pointer) { + set_focused_container(pointer_state.view); + // Send to front if floating + if (pointer->is_floating) { + int i; + for (i = 0; i < pointer->parent->floating->length; i++) { + if (pointer->parent->floating->items[i] == pointer) { + list_del(pointer->parent->floating, i); + list_add(pointer->parent->floating, pointer); + break; + } + } + wlc_view_bring_to_front(view); + } + } + // dont change focus if fullscreen if (swayc_is_fullscreen(focused)) { - return false; + return SEND_CLICK; } + + // Finally send click + return SEND_CLICK; + + /* OLD */ if (state == WLC_BUTTON_STATE_PRESSED) { sway_log(L_DEBUG, "Mouse button %u pressed", button); if (button == M_LEFT_CLICK) { @@ -443,15 +453,6 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w } if (pointer->is_floating) { - int i; - for (i = 0; i < pointer->parent->floating->length; i++) { - if (pointer->parent->floating->items[i] == pointer) { - list_del(pointer->parent->floating, i); - list_add(pointer->parent->floating, pointer); - break; - } - } - arrange_windows(pointer->parent, -1, -1); if (modifiers->mods & config->floating_mod) { pointer_state.floating.drag = pointer_state.l_held; pointer_state.floating.resize = pointer_state.r_held; @@ -484,6 +485,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w pointer_state.lock = (struct pointer_lock){false ,false ,false ,false, false, false, false, false}; } } + /* OLD */ return false; } -- cgit v1.2.3 From 42d5d9a17779710e83f4ebb2d7e8c893ad91dfe6 Mon Sep 17 00:00:00 2001 From: taiyu Date: Sat, 22 Aug 2015 21:03:45 -0700 Subject: mouse tile resize mode done --- include/input_state.h | 46 +++------ include/resize.h | 2 +- sway/handlers.c | 102 +++++++------------- sway/input_state.c | 230 +++++++++++++++++++++++--------------------- sway/resize.c | 261 -------------------------------------------------- 5 files changed, 165 insertions(+), 476 deletions(-) (limited to 'sway/handlers.c') diff --git a/include/input_state.h b/include/input_state.h index 3a246e0c..747a3563 100644 --- a/include/input_state.h +++ b/include/input_state.h @@ -37,52 +37,34 @@ enum pointer_mode { M_RESIZING = 1 << 3, }; +struct pointer_button_state { + bool held; + // state at the point it was pressed + int x, y; + swayc_t *view; +}; + extern struct pointer_state { // mouse clicks - bool l_held : 1; - bool r_held : 1; - - // scroll wheel - bool s_held : 1; - bool s_up : 1; - bool s_down :1; + struct pointer_button_state left; + struct pointer_button_state right; + struct pointer_button_state scroll; // pointer position struct mouse_origin{ int x, y; } origin; + + // change in pointer position struct { int x, y; } delta; - // view pointer is over + // view pointer is currently over swayc_t *view; // Pointer mode int mode; - - // OLD - struct pointer_floating { - bool drag; - bool resize; - } floating; - struct pointer_tiling { - bool resize; - swayc_t *init_view; - struct wlc_origin lock_pos; - } tiling; - struct pointer_lock { - // Lock movement for certain edges - bool left; - bool right; - bool top; - bool bottom; - // Lock movement in certain directions - bool temp_left; - bool temp_right; - bool temp_up; - bool temp_down; - } lock; } pointer_state; // on button release unset mode depending on the button. @@ -95,8 +77,6 @@ void pointer_mode_update(void); // Reset mode on any keypress; void pointer_mode_reset(void); -void start_floating(swayc_t *view); -void reset_floating(swayc_t *view); void input_init(void); #endif diff --git a/include/resize.h b/include/resize.h index 4ace1815..04209983 100644 --- a/include/resize.h +++ b/include/resize.h @@ -1,8 +1,8 @@ #ifndef _SWAY_RESIZE_H #define _SWAY_RESIZE_H +#include bool mouse_resize_tiled(struct wlc_origin prev_pos); -bool resize_floating(struct wlc_origin prev_pos); bool resize_tiled(int amount, bool use_width); #endif diff --git a/sway/handlers.c b/sway/handlers.c index 7d1e4cde..896caa10 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -359,36 +359,54 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) { enum { DONT_SEND_CLICK = true, SEND_CLICK = false }; + // Update view pointer is on + pointer_state.view = container_under_pointer(); + + // Update pointer origin + pointer_state.origin.x = origin->x; + pointer_state.origin.y = origin->y; + // Update pointer_state switch (button) { case M_LEFT_CLICK: - pointer_state.l_held = state == WLC_BUTTON_STATE_PRESSED; + if (state == WLC_BUTTON_STATE_PRESSED) { + pointer_state.left.held = true; + pointer_state.left.x = origin->x; + pointer_state.left.y = origin->y; + pointer_state.left.view = pointer_state.view; + } else { + pointer_state.left.held = false; + } break; case M_RIGHT_CLICK: - pointer_state.r_held = state == WLC_BUTTON_STATE_PRESSED; + if (state == WLC_BUTTON_STATE_PRESSED) { + pointer_state.right.held = true; + pointer_state.right.x = origin->x; + pointer_state.right.y = origin->y; + pointer_state.right.view = pointer_state.view; + } else { + pointer_state.right.held = false; + } break; case M_SCROLL_CLICK: - pointer_state.s_held = state == WLC_BUTTON_STATE_PRESSED; + if (state == WLC_BUTTON_STATE_PRESSED) { + pointer_state.scroll.held = true; + pointer_state.scroll.x = origin->x; + pointer_state.scroll.y = origin->y; + pointer_state.scroll.view = pointer_state.view; + } else { + pointer_state.scroll.held = false; + } break; + //TODO scrolling behavior case M_SCROLL_UP: - pointer_state.s_up = state == WLC_BUTTON_STATE_PRESSED; - break; - case M_SCROLL_DOWN: - pointer_state.s_down = state == WLC_BUTTON_STATE_PRESSED; break; } - // Update pointer origin - pointer_state.origin.x = origin->x; - pointer_state.origin.y = origin->y; - - // Update view pointer is on - pointer_state.view = container_under_pointer(); - // set pointer mode pointer_mode_set(button, (modifiers->mods & config->floating_mod) == config->floating_mod); @@ -431,62 +449,6 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w // Finally send click return SEND_CLICK; - - /* OLD */ - if (state == WLC_BUTTON_STATE_PRESSED) { - sway_log(L_DEBUG, "Mouse button %u pressed", button); - if (button == M_LEFT_CLICK) { - pointer_state.l_held = true; - } - if (button == M_RIGHT_CLICK) { - pointer_state.r_held = true; - } - swayc_t *pointer = container_under_pointer(); - if (pointer) { - set_focused_container(pointer); - int midway_x = pointer->x + pointer->width/2; - int midway_y = pointer->y + pointer->height/2; - pointer_state.lock.bottom = origin->y < midway_y; - pointer_state.lock.top = !pointer_state.lock.bottom; - pointer_state.lock.right = origin->x < midway_x; - pointer_state.lock.left = !pointer_state.lock.right; - } - - if (pointer->is_floating) { - if (modifiers->mods & config->floating_mod) { - pointer_state.floating.drag = pointer_state.l_held; - pointer_state.floating.resize = pointer_state.r_held; - start_floating(pointer); - } - // Dont want pointer sent to window while dragging or resizing - return (pointer_state.floating.drag || pointer_state.floating.resize); - } else { - if (modifiers->mods & config->floating_mod) { - pointer_state.floating.drag = pointer_state.l_held; - pointer_state.tiling.resize = pointer_state.r_held; - pointer_state.tiling.init_view = pointer; - // Dont want pointer sent when resizing - return (pointer_state.tiling.resize); - } - } - return (pointer && pointer != focused); - } else { - sway_log(L_DEBUG, "Mouse button %u released", button); - if (button == M_LEFT_CLICK) { - pointer_state.l_held = false; - pointer_state.floating.drag = false; - pointer_state.tiling.init_view = NULL; - } - if (button == M_RIGHT_CLICK) { - pointer_state.r_held = false; - pointer_state.floating.resize = false; - pointer_state.tiling.resize = false; - pointer_state.tiling.init_view = NULL; - pointer_state.lock = (struct pointer_lock){false ,false ,false ,false, false, false, false, false}; - } - } - /* OLD */ - return false; } static void handle_wlc_ready(void) { diff --git a/sway/input_state.c b/sway/input_state.c index 3db78167..a63fc01c 100644 --- a/sway/input_state.c +++ b/sway/input_state.c @@ -48,75 +48,81 @@ void release_key(keycode key) { } } +// Pointer state and mode + struct pointer_state pointer_state; -// Pointer mode values static struct mode_state { - // Initial view state + // initial view state + double x, y, w, h; + swayc_t *ptr; + // containers resized with tiling resize struct { - double x, y, w, h; + double x, w; swayc_t *ptr; - } view; - // Initial pointer state + } lr; struct { - int x, y; - } coor; + double y, h; + swayc_t *ptr; + } tb; } initial; static struct { - enum { LEFT=1, RIGHT=0 } lr; - enum { TOP=1, BOTTOM=0 } tb; + bool left; + bool top; } lock; // Floating set/unset -static void pointer_mode_set_floating(void) { - initial.view.x = initial.view.ptr->x; - initial.view.y = initial.view.ptr->y; - initial.view.w = initial.view.ptr->width; - initial.view.h = initial.view.ptr->height; - // setup initial cooridinates - initial.coor.x = pointer_state.origin.x; - initial.coor.y = pointer_state.origin.y; +static void set_initial_view(swayc_t *view) { + initial.ptr = view; + initial.x = view->x; + initial.y = view->y; + initial.w = view->width; + initial.h = view->height; } -static void pointer_mode_reset_floating(void) { - initial.view.ptr->x = initial.view.x; - initial.view.ptr->y = initial.view.y; - initial.view.ptr->width = initial.view.w; - initial.view.ptr->height = initial.view.h; - arrange_windows(initial.view.ptr, -1, -1); +static void reset_initial_view(void) { + initial.ptr->x = initial.x; + initial.ptr->y = initial.y; + initial.ptr->width = initial.w; + initial.ptr->height = initial.h; + arrange_windows(initial.ptr, -1, -1); pointer_state.mode = 0; } // Mode set left/right click static void pointer_mode_set_left(void) { - swayc_t *view = pointer_state.view; - initial.view.ptr = view; - if (view->is_floating) { + set_initial_view(pointer_state.left.view); + if (initial.ptr->is_floating) { pointer_state.mode = M_DRAGGING | M_FLOATING; - pointer_mode_set_floating(); } else { pointer_state.mode = M_DRAGGING | M_TILING; } } static void pointer_mode_set_right(void) { - swayc_t *view = pointer_state.view; - initial.view.ptr = view; + set_initial_view(pointer_state.right.view); // Setup locking information - int midway_x = view->x + view->width/2; - int midway_y = view->y + view->height/2; + int midway_x = initial.ptr->x + initial.ptr->width/2; + int midway_y = initial.ptr->y + initial.ptr->height/2; - lock.lr = pointer_state.origin.x > midway_x; - lock.tb = pointer_state.origin.y > midway_y; + lock.left = pointer_state.origin.x > midway_x; + lock.top = pointer_state.origin.y > midway_y; - if (view->is_floating) { + if (initial.ptr->is_floating) { pointer_state.mode = M_RESIZING | M_FLOATING; - pointer_mode_set_floating(); } else { pointer_state.mode = M_RESIZING | M_TILING; + if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) { + initial.lr.x = initial.lr.ptr->x; + initial.lr.w = initial.lr.ptr->width; + } + if ((initial.tb.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) { + initial.tb.y = initial.tb.ptr->y; + initial.tb.h = initial.tb.ptr->height; + } } } @@ -127,14 +133,14 @@ void pointer_mode_set(uint32_t button, bool condition) { switch (pointer_state.mode & (M_DRAGGING | M_RESIZING)) { case M_DRAGGING: // end drag mode when left click is unpressed - if (!pointer_state.l_held) { + if (!pointer_state.left.held) { pointer_state.mode = 0; } break; case M_RESIZING: // end resize mode when right click is unpressed - if (!pointer_state.r_held) { + if (!pointer_state.right.held) { pointer_state.mode = 0; } break; @@ -145,12 +151,13 @@ void pointer_mode_set(uint32_t button, bool condition) { if (!condition || !pointer_state.view) { break; } + // Set mode depending on current button press switch (button) { // Start dragging mode case M_LEFT_CLICK: // if button release dont do anything - if (pointer_state.l_held) { + if (pointer_state.left.held) { pointer_mode_set_left(); } break; @@ -158,106 +165,131 @@ void pointer_mode_set(uint32_t button, bool condition) { // Start resize mode case M_RIGHT_CLICK: // if button release dont do anyhting - if (pointer_state.r_held) { + if (pointer_state.right.held) { pointer_mode_set_right(); } break; - - case M_SCROLL_UP: - case M_SCROLL_DOWN: - //TODO add scrolling behavior here - ; } } } void pointer_mode_update(void) { - swayc_t *view = initial.view.ptr; - if (view->type != C_VIEW) { + if (initial.ptr->type != C_VIEW) { pointer_state.mode = 0; return; } - int dx = pointer_state.origin.x - initial.coor.x; - int dy = pointer_state.origin.y - initial.coor.y; + int dx = pointer_state.origin.x; + int dy = pointer_state.origin.y; bool changed = false; switch (pointer_state.mode) { case M_FLOATING | M_DRAGGING: // Update position - if (initial.view.x + dx != view->x) { - view->x = initial.view.x + dx; + dx -= pointer_state.left.x; + dy -= pointer_state.left.y; + if (initial.x + dx != initial.ptr->x) { + initial.ptr->x = initial.x + dx; changed = true; } - if (initial.view.y + dy != view->y) { - view->y = initial.view.y + dy; + if (initial.y + dy != initial.ptr->y) { + initial.ptr->y = initial.y + dy; changed = true; } + update_geometry(initial.ptr); break; case M_FLOATING | M_RESIZING: - if (lock.lr) { - if (initial.view.w + dx > min_sane_w) { - if (initial.view.w + dx != view->width) { - view->width = initial.view.w + dx; - changed = true; - } + dx -= pointer_state.right.x; + dy -= pointer_state.right.y; + initial.ptr = pointer_state.right.view; + if (lock.left) { + if (initial.w + dx > min_sane_w) { + initial.ptr->width = initial.w + dx; } } else { //lock.right - if (initial.view.w - dx > min_sane_w) { - if (initial.view.w - dx != view->width) { - view->width = initial.view.w - dx; - view->x = initial.view.x + dx; - changed = true; - } + if (initial.w - dx > min_sane_w) { + initial.ptr->width = initial.w - dx; + initial.ptr->x = initial.x + dx; } } - if (lock.tb) { - if (initial.view.h + dy > min_sane_h) { - if (initial.view.y - dy != view->height) { - view->height = initial.view.h + dy; - changed = true; - } + if (lock.top) { + if (initial.h + dy > min_sane_h) { + initial.ptr->height = initial.h + dy; } } else { //lock.bottom - if (initial.view.h - dy > min_sane_h) { - if (initial.view.h - dy != view->height) { - view->height = initial.view.h - dy; - view->y = initial.view.y + dy; - changed = true; - } + if (initial.h - dy > min_sane_h) { + initial.ptr->height = initial.h - dy; + initial.ptr->y = initial.y + dy; } } + update_geometry(initial.ptr); break; case M_TILING | M_DRAGGING: // swap current view under pointer with dragged view - if (pointer_state.view && pointer_state.view != initial.view.ptr) { + if (pointer_state.view && pointer_state.view != initial.ptr) { // Swap them around - swap_container(pointer_state.view, initial.view.ptr); + swap_container(pointer_state.view, initial.ptr); update_geometry(pointer_state.view); - update_geometry(initial.view.ptr); + update_geometry(initial.ptr); // Set focus back to initial view - set_focused_container(initial.view.ptr); + set_focused_container(initial.ptr); } break; case M_TILING | M_RESIZING: - - - + dx -= pointer_state.right.x; + dy -= pointer_state.right.y; + // resize if we can + if (initial.lr.ptr) { + if (lock.left) { + // Check whether its fine to resize + if (initial.w + dx > min_sane_w && initial.lr.w - dx > min_sane_w) { + initial.ptr->width = initial.w + dx; + initial.lr.ptr->width = initial.lr.w - dx; + initial.lr.ptr->x = initial.lr.x + dx; + } + } else { //lock.right + if (initial.w - dx > min_sane_w && initial.lr.w + dx > min_sane_w) { + initial.ptr->width = initial.w - dx; + initial.ptr->x = initial.x + dx; + initial.lr.ptr->width = initial.lr.w + dx; + } + changed = true; + } + arrange_windows(initial.lr.ptr->parent, -1, -1); + } + if (initial.tb.ptr) { + if (lock.top) { + if (initial.h + dy > min_sane_h && initial.tb.h - dy > min_sane_h) { + initial.ptr->height = initial.h + dy; + initial.tb.ptr->height = initial.tb.h - dy; + initial.tb.ptr->y = initial.tb.y + dy; + } + } else { //lock.bottom + if (initial.h - dy > min_sane_h && initial.tb.h + dy > min_sane_h) { + initial.ptr->height = initial.h - dy; + initial.ptr->y = initial.y + dy; + initial.tb.ptr->height = initial.tb.h + dy; + } + changed = true; + } + arrange_windows(initial.tb.ptr->parent, -1, -1); + } + if (changed) { + arrange_windows(initial.ptr->parent, -1, -1); + } + changed = false; default: return; } - if (changed) { - update_geometry(view); - } } void pointer_mode_reset(void) { switch (pointer_state.mode) { case M_FLOATING | M_DRAGGING: case M_FLOATING | M_RESIZING: - pointer_mode_reset_floating(); + reset_initial_view(); break; case M_TILING | M_DRAGGING: @@ -267,27 +299,3 @@ void pointer_mode_reset(void) { } } - -static struct wlc_geometry saved_floating; - -void start_floating(swayc_t *view) { - if (view->is_floating) { - saved_floating.origin.x = view->x; - saved_floating.origin.y = view->y; - saved_floating.size.w = view->width; - saved_floating.size.h = view->height; - } -} - -void reset_floating(swayc_t *view) { - if (view->is_floating) { - view->x = saved_floating.origin.x; - view->y = saved_floating.origin.y; - view->width = saved_floating.size.w; - view->height = saved_floating.size.h; - arrange_windows(view->parent, -1, -1); - } - pointer_state.floating = (struct pointer_floating){0, 0}; - pointer_state.lock = (struct pointer_lock){0, 0, 0, 0, 0, 0, 0, 0}; -} - diff --git a/sway/resize.c b/sway/resize.c index 31cd66e8..22d520af 100644 --- a/sway/resize.c +++ b/sway/resize.c @@ -6,267 +6,6 @@ #include "input_state.h" #include "handlers.h" -bool mouse_resize_tiled(struct wlc_origin prev_pos) { - swayc_t *view = container_under_pointer(); - bool valid = true; - bool changed_tiling = false; - double dx = pointer_state.origin.x - prev_pos.x; - double dy = pointer_state.origin.y - prev_pos.y; - if (view != pointer_state.tiling.init_view) { - changed_tiling = true; - valid = false; - if (view->type != C_WORKSPACE) { - if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_LEFT) == view) { - pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20; - pointer_state.lock.temp_left = true; - } else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_RIGHT) == view) { - pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20; - pointer_state.lock.temp_right = true; - } else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_UP) == view) { - pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20; - pointer_state.lock.temp_up = true; - } else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_DOWN) == view) { - pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20; - pointer_state.lock.temp_down = true; - } - } - } - - if ((dx < 0 || pointer_state.origin.x < pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_left) { - changed_tiling = true; - valid = false; - } else if (dx > 0 && pointer_state.lock.temp_left) { - pointer_state.lock.temp_left = false; - pointer_state.tiling.lock_pos.x = 0; - } - - if ((dx > 0 || pointer_state.origin.x > pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_right) { - changed_tiling = true; - valid = false; - } else if (dx < 0 && pointer_state.lock.temp_right) { - pointer_state.lock.temp_right = false; - pointer_state.tiling.lock_pos.x = 0; - } - - if ((dy < 0 || pointer_state.origin.y < pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_up) { - changed_tiling = true; - valid = false; - } else if (dy > 0 && pointer_state.lock.temp_up) { - pointer_state.lock.temp_up = false; - pointer_state.tiling.lock_pos.y = 0; - } - - if ((dy > 0 || pointer_state.origin.y > pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_down) { - changed_tiling = true; - valid = false; - } else if (dy < 0 && pointer_state.lock.temp_down) { - pointer_state.lock.temp_down = false; - pointer_state.tiling.lock_pos.y = 0; - } - - if (!view->is_floating && valid) { - // Handle layout resizes -- Find the biggest parent container then apply resizes to that - // and its bordering siblings - swayc_t *parent = view; - if (!pointer_state.lock.bottom) { - while (parent->type != C_WORKSPACE) { - // TODO: Absolute value is a bad hack here to compensate for rounding. Find a better - // way of doing this. - if (fabs(parent->parent->y + parent->parent->height - (view->y + view->height)) <= 1) { - parent = parent->parent; - } else { - break; - } - } - if (parent->parent->children->length > 1 && parent->parent->layout == L_VERT) { - swayc_t *sibling = get_swayc_in_direction(parent, MOVE_DOWN); - if (sibling) { - if ((parent->height > min_sane_h || dy > 0) && (sibling->height > min_sane_h || dy < 0)) { - recursive_resize(parent, dy, WLC_RESIZE_EDGE_BOTTOM); - recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP); - changed_tiling = true; - } else { - if (parent->height < min_sane_h) { - //pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20; - pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20; - pointer_state.lock.temp_up = true; - } else if (sibling->height < min_sane_h) { - pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20; - pointer_state.lock.temp_down = true; - } - } - } - } - } else if (!pointer_state.lock.top) { - while (parent->type != C_WORKSPACE) { - if (fabs(parent->parent->y - view->y) <= 1) { - parent = parent->parent; - } else { - break; - } - } - if (parent->parent->children->length > 1 && parent->parent->layout == L_VERT) { - swayc_t *sibling = get_swayc_in_direction(parent, MOVE_UP); - if (sibling) { - if ((parent->height > min_sane_h || dy < 0) && (sibling->height > min_sane_h || dy > 0)) { - recursive_resize(parent, -1 * dy, WLC_RESIZE_EDGE_TOP); - recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM); - changed_tiling = true; - } else { - if (parent->height < min_sane_h) { - //pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20; - pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20; - pointer_state.lock.temp_down = true; - } else if (sibling->height < min_sane_h) { - pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20; - pointer_state.lock.temp_up = true; - } - } - } - } - } - - parent = view; - if (!pointer_state.lock.right) { - while (parent->type != C_WORKSPACE) { - if (fabs(parent->parent->x + parent->parent->width - (view->x + view->width)) <= 1) { - parent = parent->parent; - } else { - sway_log(L_DEBUG, "view: %f vs parent: %f", view->x + view->width, parent->parent->x + parent->parent->width); - break; - } - } - if (parent->parent->children->length > 1 && parent->parent->layout == L_HORIZ) { - swayc_t *sibling = get_swayc_in_direction(parent, MOVE_RIGHT); - if (sibling) { - if ((parent->width > min_sane_w || dx > 0) && (sibling->width > min_sane_w || dx < 0)) { - recursive_resize(parent, dx, WLC_RESIZE_EDGE_RIGHT); - recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT); - changed_tiling = true; - } else { - if (parent->width < min_sane_w) { - pointer_state.lock.temp_left = true; - pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20; - } else if (sibling->width < min_sane_w) { - pointer_state.lock.temp_right = true; - pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20; - } - } - } - } - } else if (!pointer_state.lock.left) { - while (parent->type != C_WORKSPACE) { - if (fabs(parent->parent->x - view->x) <= 1 && parent->parent) { - parent = parent->parent; - } else { - break; - } - } - if (parent->parent->children->length > 1 && parent->parent->layout == L_HORIZ) { - swayc_t *sibling = get_swayc_in_direction(parent, MOVE_LEFT); - if (sibling) { - if ((parent->width > min_sane_w || dx < 0) && (sibling->width > min_sane_w || dx > 0)) { - recursive_resize(parent, -1 * dx, WLC_RESIZE_EDGE_LEFT); - recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT); - changed_tiling = true; - } else { - if (parent->width < min_sane_w) { - pointer_state.lock.temp_right = true; - pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20; - } else if (sibling->width < min_sane_w) { - pointer_state.lock.temp_left = true; - pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20; - } - } - } - } - } - arrange_windows(swayc_active_workspace(), -1, -1); - } - return changed_tiling; -} - -bool resize_floating(struct wlc_origin prev_pos) { - bool changed = false; - swayc_t *view = container_under_pointer(); - uint32_t edge = 0; - int dx = pointer_state.origin.x - prev_pos.x; - int dy = pointer_state.origin.y - prev_pos.y; - - // Move and resize the view based on the dx/dy and mouse position - int midway_x = view->x + view->width/2; - int midway_y = view->y + view->height/2; - if (dx < 0) { - if (!pointer_state.lock.right) { - if (view->width > min_sane_w) { - changed = true; - view->width += dx; - edge += WLC_RESIZE_EDGE_RIGHT; - } - } else if (pointer_state.origin.x < midway_x && !pointer_state.lock.left) { - changed = true; - view->x += dx; - view->width -= dx; - edge += WLC_RESIZE_EDGE_LEFT; - } - } else if (dx > 0) { - if (pointer_state.origin.x > midway_x && !pointer_state.lock.right) { - changed = true; - view->width += dx; - edge += WLC_RESIZE_EDGE_RIGHT; - } else if (!pointer_state.lock.left) { - if (view->width > min_sane_w) { - changed = true; - view->x += dx; - view->width -= dx; - edge += WLC_RESIZE_EDGE_LEFT; - } - } - } - - if (dy < 0) { - if (!pointer_state.lock.bottom) { - if (view->height > min_sane_h) { - changed = true; - view->height += dy; - edge += WLC_RESIZE_EDGE_BOTTOM; - } - } else if (pointer_state.origin.y < midway_y && !pointer_state.lock.top) { - changed = true; - view->y += dy; - view->height -= dy; - edge += WLC_RESIZE_EDGE_TOP; - } - } else if (dy > 0) { - if (pointer_state.origin.y > midway_y && !pointer_state.lock.bottom) { - changed = true; - view->height += dy; - edge += WLC_RESIZE_EDGE_BOTTOM; - } else if (!pointer_state.lock.top) { - if (view->height > min_sane_h) { - changed = true; - view->y += dy; - view->height -= dy; - edge += WLC_RESIZE_EDGE_TOP; - } - } - } - if (changed) { - struct wlc_geometry geometry = { - .origin = { - .x = view->x, - .y = view->y - }, - .size = { - .w = view->width, - .h = view->height - } - }; - wlc_view_set_geometry(view->handle, edge, &geometry); - } - return changed; -} - bool resize_tiled(int amount, bool use_width) { swayc_t *parent = get_focused_view(swayc_active_workspace()); swayc_t *focused = parent; -- cgit v1.2.3 From f1e38be09f00688b90751a45e9365cfd906f8d39 Mon Sep 17 00:00:00 2001 From: taiyu Date: Sat, 22 Aug 2015 21:16:46 -0700 Subject: no mode for fullscreen --- sway/handlers.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sway/handlers.c') diff --git a/sway/handlers.c b/sway/handlers.c index 896caa10..d26ce5f3 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -407,6 +407,14 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w break; } + // get focused window and check if to change focus on mouse click + swayc_t *focused = get_focused_container(&root_container); + + // dont change focus or mode if fullscreen + if (swayc_is_fullscreen(focused)) { + return SEND_CLICK; + } + // set pointer mode pointer_mode_set(button, (modifiers->mods & config->floating_mod) == config->floating_mod); @@ -421,9 +429,6 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w return SEND_CLICK; } - // get focused window and check if to change focus on mouse click - swayc_t *focused = get_focused_container(&root_container); - // Check whether to change focus swayc_t *pointer = pointer_state.view; if (pointer && focused != pointer) { @@ -442,11 +447,6 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w } } - // dont change focus if fullscreen - if (swayc_is_fullscreen(focused)) { - return SEND_CLICK; - } - // Finally send click return SEND_CLICK; } -- cgit v1.2.3 From d72cc925416847adaf2636cea0773ef6d9a46461 Mon Sep 17 00:00:00 2001 From: taiyu Date: Sun, 23 Aug 2015 07:59:18 -0700 Subject: style --- include/input_state.h | 8 ++-- sway/handlers.c | 25 ++++++++----- sway/input_state.c | 101 +++++++++++++++++++++++++++----------------------- 3 files changed, 74 insertions(+), 60 deletions(-) (limited to 'sway/handlers.c') diff --git a/include/input_state.h b/include/input_state.h index 747a3563..4ab93cd6 100644 --- a/include/input_state.h +++ b/include/input_state.h @@ -30,11 +30,11 @@ enum pointer_values { enum pointer_mode { // Target - M_FLOATING = 1 << 0, - M_TILING = 1 << 1, + M_FLOATING = 1, + M_TILING = 2, // Action - M_DRAGGING = 1 << 2, - M_RESIZING = 1 << 3, + M_DRAGGING = 4, + M_RESIZING = 8, }; struct pointer_button_state { diff --git a/sway/handlers.c b/sway/handlers.c index d26ce5f3..0bb4f613 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -17,6 +17,12 @@ #include "input_state.h" #include "resize.h" +// Event should be sent to client +#define EVENT_PASSTHROUGH false + +// Event handled by sway and should not be sent to client +#define EVENT_HANDLED true + static bool pointer_test(swayc_t *view, void *_origin) { const struct mouse_origin *origin = _origin; // Determine the output that the view is under @@ -276,7 +282,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier uint32_t key, uint32_t sym, enum wlc_key_state state) { if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { - return false; + return EVENT_PASSTHROUGH; } // reset pointer mode on keypress @@ -289,7 +295,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier if (sym < 70000 /* bullshit made up number */) { if (!isalnum(sym) && sym != ' ' && sym != XKB_KEY_Escape && sym != XKB_KEY_Tab) { // God fucking dammit - return false; + return EVENT_PASSTHROUGH; } } @@ -320,14 +326,14 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier if (match) { if (state == WLC_KEY_STATE_PRESSED) { handle_command(config, binding->command); - return true; + return EVENT_HANDLED; } else if (state == WLC_KEY_STATE_RELEASED) { // TODO: --released } } } } - return false; + return EVENT_PASSTHROUGH; } static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) { @@ -351,13 +357,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct set_focused_container(pointer_state.view); } } - return false; + return EVENT_PASSTHROUGH; } static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) { - enum { DONT_SEND_CLICK = true, SEND_CLICK = false }; // Update view pointer is on pointer_state.view = container_under_pointer(); @@ -412,7 +417,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w // dont change focus or mode if fullscreen if (swayc_is_fullscreen(focused)) { - return SEND_CLICK; + return EVENT_PASSTHROUGH; } // set pointer mode @@ -421,12 +426,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w // Return if mode has been set if (pointer_state.mode) { - return DONT_SEND_CLICK; + return EVENT_HANDLED; } // Always send mouse release if (state == WLC_BUTTON_STATE_RELEASED) { - return SEND_CLICK; + return EVENT_PASSTHROUGH; } // Check whether to change focus @@ -448,7 +453,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w } // Finally send click - return SEND_CLICK; + return EVENT_PASSTHROUGH; } static void handle_wlc_ready(void) { diff --git a/sway/input_state.c b/sway/input_state.c index 8450fe7a..acf90d75 100644 --- a/sway/input_state.c +++ b/sway/input_state.c @@ -56,23 +56,24 @@ static struct mode_state { // initial view state double x, y, w, h; swayc_t *ptr; - // containers resized with tiling resize + // Containers used for resizing horizontally struct { - double x, w; + double w; swayc_t *ptr; struct { - double x, w; + double w; swayc_t *ptr; - } sib; - } lr; + } parent; + } horiz; + // Containers used for resizing vertically struct { - double y, h; + double h; swayc_t *ptr; struct { - double y, h; + double h; swayc_t *ptr; - } sib; - } tb; + } parent; + } vert; } initial; static struct { @@ -92,23 +93,19 @@ static void set_initial_view(swayc_t *view) { static void set_initial_sibling(void) { bool reset = true; - if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) { - initial.lr.x = initial.lr.ptr->x; - initial.lr.w = initial.lr.ptr->width; - initial.lr.sib.ptr = get_swayc_in_direction(initial.lr.ptr, lock.left ? MOVE_LEFT : MOVE_RIGHT); - initial.lr.sib.x = initial.lr.sib.ptr->x; - initial.lr.sib.w = initial.lr.sib.ptr->width; + if ((initial.horiz.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) { + initial.horiz.w = initial.horiz.ptr->width; + initial.horiz.parent.ptr = get_swayc_in_direction(initial.horiz.ptr, lock.left ? MOVE_LEFT : MOVE_RIGHT); + initial.horiz.parent.w = initial.horiz.parent.ptr->width; reset = false; } - if ((initial.tb.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) { - initial.tb.y = initial.tb.ptr->y; - initial.tb.h = initial.tb.ptr->height; - initial.tb.sib.ptr = get_swayc_in_direction(initial.tb.ptr, lock.top ? MOVE_UP : MOVE_DOWN); - initial.tb.sib.y = initial.tb.sib.ptr->y; - initial.tb.sib.h = initial.tb.sib.ptr->height; + if ((initial.vert.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) { + initial.vert.h = initial.vert.ptr->height; + initial.vert.parent.ptr = get_swayc_in_direction(initial.vert.ptr, lock.top ? MOVE_UP : MOVE_DOWN); + initial.vert.parent.h = initial.vert.parent.ptr->height; reset = false; } - // If nothing changes just undo the mode + // If nothing will change just undo the mode if (reset) { pointer_state.mode = 0; } @@ -123,6 +120,16 @@ static void reset_initial_view(void) { pointer_state.mode = 0; } +static void reset_initial_sibling(void) { + initial.horiz.ptr->width = initial.horiz.w; + initial.horiz.parent.ptr->width = initial.horiz.parent.w; + initial.vert.ptr->height = initial.vert.h; + initial.vert.parent.ptr->height = initial.vert.parent.h; + arrange_windows(initial.horiz.ptr->parent, -1, -1); + arrange_windows(initial.vert.ptr->parent, -1, -1); + pointer_state.mode = 0; +} + // Mode set left/right click static void pointer_mode_set_left(void) { @@ -228,7 +235,7 @@ void pointer_mode_update(void) { if (initial.w + dx > min_sane_w) { initial.ptr->width = initial.w + dx; } - } else { //lock.right + } else { // lock.right if (initial.w - dx > min_sane_w) { initial.ptr->width = initial.w - dx; initial.ptr->x = initial.x + dx; @@ -238,7 +245,7 @@ void pointer_mode_update(void) { if (initial.h + dy > min_sane_h) { initial.ptr->height = initial.h + dy; } - } else { //lock.bottom + } else { // lock.bottom if (initial.h - dy > min_sane_h) { initial.ptr->height = initial.h - dy; initial.ptr->y = initial.y + dy; @@ -264,34 +271,34 @@ void pointer_mode_update(void) { dx -= pointer_state.right.x; dy -= pointer_state.right.y; // resize if we can - if (initial.lr.ptr) { + if (initial.horiz.ptr) { if (lock.left) { // Check whether its fine to resize - if (initial.w + dx > min_sane_w && initial.lr.w - dx > min_sane_w) { - initial.lr.ptr->width = initial.lr.w - dx; - initial.lr.sib.ptr->width = initial.lr.sib.w + dx; + if (initial.w + dx > min_sane_w && initial.horiz.w - dx > min_sane_w) { + initial.horiz.ptr->width = initial.horiz.w - dx; + initial.horiz.parent.ptr->width = initial.horiz.parent.w + dx; } - } else { //lock.right - if (initial.w - dx > min_sane_w && initial.lr.w + dx > min_sane_w) { - initial.lr.ptr->width = initial.lr.w + dx; - initial.lr.sib.ptr->width = initial.lr.sib.w - dx; + } else { // lock.right + if (initial.w - dx > min_sane_w && initial.horiz.w + dx > min_sane_w) { + initial.horiz.ptr->width = initial.horiz.w + dx; + initial.horiz.parent.ptr->width = initial.horiz.parent.w - dx; } } - arrange_windows(initial.lr.ptr->parent, -1, -1); + arrange_windows(initial.horiz.ptr->parent, -1, -1); } - if (initial.tb.ptr) { + if (initial.vert.ptr) { if (lock.top) { - if (initial.h + dy > min_sane_h && initial.tb.h - dy > min_sane_h) { - initial.tb.ptr->height = initial.tb.h - dy; - initial.tb.sib.ptr->height = initial.tb.sib.h + dy; + if (initial.h + dy > min_sane_h && initial.vert.h - dy > min_sane_h) { + initial.vert.ptr->height = initial.vert.h - dy; + initial.vert.parent.ptr->height = initial.vert.parent.h + dy; } - } else { //lock.bottom - if (initial.h - dy > min_sane_h && initial.tb.h + dy > min_sane_h) { - initial.tb.ptr->height = initial.tb.h + dy; - initial.tb.sib.ptr->height = initial.tb.sib.h - dy; + } else { // lock.bottom + if (initial.h - dy > min_sane_h && initial.vert.h + dy > min_sane_h) { + initial.vert.ptr->height = initial.vert.h + dy; + initial.vert.parent.ptr->height = initial.vert.parent.h - dy; } } - arrange_windows(initial.tb.ptr->parent, -1, -1); + arrange_windows(initial.vert.ptr->parent, -1, -1); } default: return; @@ -300,15 +307,17 @@ void pointer_mode_update(void) { void pointer_mode_reset(void) { switch (pointer_state.mode) { - case M_FLOATING | M_DRAGGING: case M_FLOATING | M_RESIZING: + case M_FLOATING | M_DRAGGING: reset_initial_view(); break; - case M_TILING | M_DRAGGING: case M_TILING | M_RESIZING: + (void) reset_initial_sibling; + break; + + case M_TILING | M_DRAGGING: default: - return; + break; } } - -- cgit v1.2.3