floating/tiling move + floating resize cleaned and fixed

This commit is contained in:
taiyu 2015-08-22 18:01:38 -07:00
parent 232940f813
commit e139de0857
6 changed files with 454 additions and 136 deletions

View file

@ -17,6 +17,7 @@ void press_key(keycode key);
// unsets a key as pressed // unsets a key as pressed
void release_key(keycode key); void release_key(keycode key);
/* Pointer state */ /* Pointer state */
enum pointer_values { enum pointer_values {
@ -27,9 +28,40 @@ enum pointer_values {
M_SCROLL_DOWN = 276, M_SCROLL_DOWN = 276,
}; };
enum pointer_mode {
// Target
M_FLOATING = 1 << 0,
M_TILING = 1 << 1,
// Action
M_DRAGGING = 1 << 2,
M_RESIZING = 1 << 3,
};
extern struct pointer_state { extern struct pointer_state {
bool l_held; // mouse clicks
bool r_held; bool l_held : 1;
bool r_held : 1;
// scroll wheel
bool s_held : 1;
bool s_up : 1;
bool s_down :1;
// pointer position
struct mouse_origin{
int x, y;
} origin;
struct {
int x, y;
} delta;
// view pointer is over
swayc_t *view;
// Pointer mode
int mode;
// OLD
struct pointer_floating { struct pointer_floating {
bool drag; bool drag;
bool resize; bool resize;
@ -53,6 +85,16 @@ extern struct pointer_state {
} lock; } lock;
} pointer_state; } pointer_state;
// on button release unset mode depending on the button.
// on button press set mode conditionally depending on the button
void pointer_mode_set(uint32_t button, bool condition);
// Update mode in mouse motion
void pointer_mode_update(void);
// Reset mode on any keypress;
void pointer_mode_reset(void);
void start_floating(swayc_t *view); void start_floating(swayc_t *view);
void reset_floating(swayc_t *view); void reset_floating(swayc_t *view);
void input_init(void); void input_init(void);

View file

@ -19,10 +19,12 @@ void add_floating(swayc_t *ws, swayc_t *child);
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
swayc_t *replace_child(swayc_t *child, swayc_t *new_child); swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
swayc_t *remove_child(swayc_t *child); swayc_t *remove_child(swayc_t *child);
void swap_container(swayc_t *a, swayc_t *b);
void move_container(swayc_t* container,swayc_t* root,enum movement_direction direction); void move_container(swayc_t* container,swayc_t* root,enum movement_direction direction);
// Layout // Layout
void update_geometry(swayc_t *view);
void arrange_windows(swayc_t *container, double width, double height); void arrange_windows(swayc_t *container, double width, double height);
swayc_t *get_focused_container(swayc_t *parent); swayc_t *get_focused_container(swayc_t *parent);

View file

@ -17,10 +17,8 @@
#include "input_state.h" #include "input_state.h"
#include "resize.h" #include "resize.h"
struct wlc_origin mouse_origin;
static bool pointer_test(swayc_t *view, void *_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 // Determine the output that the view is under
swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT); swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT);
if (origin->x >= view->x && origin->y >= view->y if (origin->x >= view->x && origin->y >= view->y
@ -55,7 +53,7 @@ swayc_t *container_under_pointer(void) {
i = len = lookup->floating->length; i = len = lookup->floating->length;
bool got_floating = false; bool got_floating = false;
while (--i > -1) { 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]; lookup = lookup->floating->items[i];
got_floating = true; got_floating = true;
break; break;
@ -68,7 +66,7 @@ swayc_t *container_under_pointer(void) {
// search children // search children
len = lookup->children->length; len = lookup->children->length;
for (i = 0; i < len; ++i) { 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]; lookup = lookup->children->items[i];
break; break;
} }
@ -281,10 +279,9 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
return false; return false;
} }
// Revert floating container back to original position on keypress // reset pointer mode on keypress
if (state == WLC_KEY_STATE_PRESSED && if (state == WLC_KEY_STATE_PRESSED && pointer_state.mode) {
(pointer_state.floating.drag || pointer_state.floating.resize)) { pointer_mode_reset();
reset_floating(get_focused_view(&root_container));
} }
struct sway_mode *mode = config->current_mode; 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 bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) {
static struct wlc_origin prev_pos; // Update pointer origin
static wlc_handle prev_handle = 0; pointer_state.delta.x = origin->x - pointer_state.origin.x;
mouse_origin = *origin; pointer_state.delta.y = origin->y - pointer_state.origin.y;
bool changed_floating = false; pointer_state.origin.x = origin->x;
bool changed_tiling = false; pointer_state.origin.y = origin->y;
if (!swayc_active_workspace()) {
return false;
}
// 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; // Update view under pointer
view->parent->children->items[i] = init_view; swayc_t *prev_view = pointer_state.view;
pointer_state.view = container_under_pointer();
swayc_t *temp = view->parent; // If pointer is in a mode, update it
view->parent = init_view->parent; if (pointer_state.mode) {
init_view->parent = temp; pointer_mode_update();
arrange_windows(&root_container, -1, -1);
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);
} }
break;
}
}
}
}
} 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; 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, 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) { 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); 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 // dont change focus if fullscreen
if (swayc_is_fullscreen(focused)) { if (swayc_is_fullscreen(focused)) {
return false; return SEND_CLICK;
} }
// Finally send click
return SEND_CLICK;
/* OLD */
if (state == WLC_BUTTON_STATE_PRESSED) { if (state == WLC_BUTTON_STATE_PRESSED) {
sway_log(L_DEBUG, "Mouse button %u pressed", button); sway_log(L_DEBUG, "Mouse button %u pressed", button);
if (button == M_LEFT_CLICK) { 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) { 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) { if (modifiers->mods & config->floating_mod) {
pointer_state.floating.drag = pointer_state.l_held; pointer_state.floating.drag = pointer_state.l_held;
pointer_state.floating.resize = pointer_state.r_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}; pointer_state.lock = (struct pointer_lock){false ,false ,false ,false, false, false, false, false};
} }
} }
/* OLD */
return false; return false;
} }

View file

@ -50,6 +50,224 @@ void release_key(keycode key) {
struct pointer_state pointer_state; struct pointer_state pointer_state;
// Pointer mode values
static struct mode_state {
// Initial view state
struct {
double x, y, w, h;
swayc_t *ptr;
} view;
// Initial pointer state
struct {
int x, y;
} coor;
} initial;
static struct {
enum { LEFT=1, RIGHT=0 } lr;
enum { TOP=1, BOTTOM=0 } tb;
} 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 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);
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) {
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;
// Setup locking information
int midway_x = view->x + view->width/2;
int midway_y = view->y + view->height/2;
lock.lr = pointer_state.origin.x > midway_x;
lock.tb = pointer_state.origin.y > midway_y;
if (view->is_floating) {
pointer_state.mode = M_RESIZING | M_FLOATING;
pointer_mode_set_floating();
} else {
pointer_state.mode = M_RESIZING | M_TILING;
}
}
// Mode set/update/reset
void pointer_mode_set(uint32_t button, bool condition) {
// switch on drag/resize mode
switch (pointer_state.mode & (M_DRAGGING | M_RESIZING)) {
case M_DRAGGING:
// end drag mode when left click is unpressed
if (!pointer_state.l_held) {
pointer_state.mode = 0;
}
break;
case M_RESIZING:
// end resize mode when right click is unpressed
if (!pointer_state.r_held) {
pointer_state.mode = 0;
}
break;
// No mode case
default:
// return if failed condition, or no view
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) {
pointer_mode_set_left();
}
break;
// Start resize mode
case M_RIGHT_CLICK:
// if button release dont do anyhting
if (pointer_state.r_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) {
pointer_state.mode = 0;
return;
}
int dx = pointer_state.origin.x - initial.coor.x;
int dy = pointer_state.origin.y - initial.coor.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;
changed = true;
}
if (initial.view.y + dy != view->y) {
view->y = initial.view.y + dy;
changed = true;
}
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;
}
}
} 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 (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;
}
}
} 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;
}
}
}
break;
case M_TILING | M_DRAGGING:
// swap current view under pointer with dragged view
if (pointer_state.view && pointer_state.view != initial.view.ptr) {
// Swap them around
swap_container(pointer_state.view, initial.view.ptr);
update_geometry(pointer_state.view);
update_geometry(initial.view.ptr);
// Set focus back to initial view
set_focused_container(initial.view.ptr);
}
break;
case M_TILING | M_RESIZING:
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();
break;
case M_TILING | M_DRAGGING:
case M_TILING | M_RESIZING:
default:
return;
}
}
static struct wlc_geometry saved_floating; static struct wlc_geometry saved_floating;
void start_floating(swayc_t *view) { void start_floating(swayc_t *view) {
@ -72,3 +290,4 @@ void reset_floating(swayc_t *view) {
pointer_state.floating = (struct pointer_floating){0, 0}; pointer_state.floating = (struct pointer_floating){0, 0};
pointer_state.lock = (struct pointer_lock){0, 0, 0, 0, 0, 0, 0, 0}; pointer_state.lock = (struct pointer_lock){0, 0, 0, 0, 0, 0, 0, 0};
} }

View file

@ -20,7 +20,8 @@ void init_layout(void) {
root_container.handle = -1; root_container.handle = -1;
} }
static int index_child(swayc_t *parent, swayc_t *child) { static int index_child(swayc_t *child) {
swayc_t *parent = child->parent;
int i; int i;
for (i = 0; i < parent->children->length; ++i) { for (i = 0; i < parent->children->length; ++i) {
if (parent->children->items[i] == child) { if (parent->children->items[i] == child) {
@ -54,7 +55,7 @@ void add_floating(swayc_t *ws, swayc_t *child) {
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child) { swayc_t *add_sibling(swayc_t *sibling, swayc_t *child) {
swayc_t *parent = sibling->parent; swayc_t *parent = sibling->parent;
int i = index_child(parent, sibling); int i = index_child(sibling);
if (i == parent->children->length) { if (i == parent->children->length) {
--i; --i;
} }
@ -68,17 +69,65 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) {
if (parent == NULL) { if (parent == NULL) {
return NULL; return NULL;
} }
int i = index_child(parent, child); int i = index_child(child);
parent->children->items[i] = new_child; parent->children->items[i] = new_child;
new_child->parent = child->parent; new_child->parent = child->parent;
// Set parent for new child
if (child->parent->focused == child) { if (child->parent->focused == child) {
child->parent->focused = new_child; child->parent->focused = new_child;
} }
child->parent = NULL; child->parent = NULL;
// Set geometry for new child
new_child->x = child->x;
new_child->y = child->y;
new_child->width = child->width;
new_child->height = child->height;
// set child geometry to 0
child->x = 0;
child->y = 0;
child->width = 0;
child->height = 0;
return parent; return parent;
} }
void swap_container(swayc_t *a, swayc_t *b) {
//TODO doesnt handle floating <-> tiling swap
if (!sway_assert(a&&b, "%s: parameters must be non null",__func__) ||
!sway_assert(a->parent && b->parent, "%s: containers must have parents",__func__)) {
return;
}
size_t a_index = index_child(a);
size_t b_index = index_child(b);
swayc_t *a_parent = a->parent;
swayc_t *b_parent = b->parent;
// Swap the pointers
a_parent->children->items[a_index] = b;
b_parent->children->items[b_index] = a;
a->parent = b_parent;
b->parent = a_parent;
if (a_parent->focused == a) {
a_parent->focused = b;
}
// dont want to double switch
if (b_parent->focused == b && a_parent != b_parent) {
b_parent->focused = a;
}
// and their geometry
double x = a->x;
double y = a->y;
double w = a->width;
double h = a->height;
a->x = b->x;
a->y = b->y;
a->width = b->width;
a->height = b->height;
b->x = x;
b->y = y;
b->width = w;
b->height = h;
}
swayc_t *remove_child(swayc_t *child) { swayc_t *remove_child(swayc_t *child) {
int i; int i;
swayc_t *parent = child->parent; swayc_t *parent = child->parent;
@ -154,6 +203,30 @@ void move_container(swayc_t *container,swayc_t* root,enum movement_direction dir
} }
void update_geometry(swayc_t *container) {
if (container->type != C_VIEW) {
return;
}
struct wlc_geometry geometry = {
.origin = {
.x = container->x + container->gaps / 2,
.y = container->y + container->gaps / 2
},
.size = {
.w = container->width - container->gaps,
.h = container->height - container->gaps
}
};
if (swayc_is_fullscreen(container)) {
swayc_t *parent = swayc_parent_by_type(container, C_OUTPUT);
geometry.origin.x = 0;
geometry.origin.y = 0;
geometry.size.w = parent->width;
geometry.size.h = parent->height;
}
wlc_view_set_geometry(container->handle, 0, &geometry);
return;
}
void arrange_windows(swayc_t *container, double width, double height) { void arrange_windows(swayc_t *container, double width, double height) {
int i; int i;
@ -196,31 +269,11 @@ void arrange_windows(swayc_t *container, double width, double height) {
return; return;
case C_VIEW: case C_VIEW:
{ {
struct wlc_geometry geometry = {
.origin = {
.x = container->x + container->gaps / 2,
.y = container->y + container->gaps / 2
},
.size = {
.w = width - container->gaps,
.h = height - container->gaps
}
};
if (swayc_is_fullscreen(container)) {
swayc_t *parent = swayc_parent_by_type(container, C_OUTPUT);
geometry.origin.x = 0;
geometry.origin.y = 0;
geometry.size.w = parent->width;
geometry.size.h = parent->height;
wlc_view_set_geometry(container->handle, 0, &geometry);
wlc_view_bring_to_front(container->handle);
} else {
wlc_view_set_geometry(container->handle, 0, &geometry);
container->width = width; container->width = width;
container->height = height; container->height = height;
} update_geometry(container);
sway_log(L_DEBUG, "Set view to %d x %d @ %d, %d", geometry.size.w, geometry.size.h, sway_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f", container->width,
geometry.origin.x, geometry.origin.y); container->height, container->x, container->y);
} }
return; return;
default: default:

View file

@ -10,8 +10,8 @@ bool mouse_resize_tiled(struct wlc_origin prev_pos) {
swayc_t *view = container_under_pointer(); swayc_t *view = container_under_pointer();
bool valid = true; bool valid = true;
bool changed_tiling = false; bool changed_tiling = false;
double dx = mouse_origin.x - prev_pos.x; double dx = pointer_state.origin.x - prev_pos.x;
double dy = mouse_origin.y - prev_pos.y; double dy = pointer_state.origin.y - prev_pos.y;
if (view != pointer_state.tiling.init_view) { if (view != pointer_state.tiling.init_view) {
changed_tiling = true; changed_tiling = true;
valid = false; valid = false;
@ -32,7 +32,7 @@ bool mouse_resize_tiled(struct wlc_origin prev_pos) {
} }
} }
if ((dx < 0 || mouse_origin.x < pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_left) { if ((dx < 0 || pointer_state.origin.x < pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_left) {
changed_tiling = true; changed_tiling = true;
valid = false; valid = false;
} else if (dx > 0 && pointer_state.lock.temp_left) { } else if (dx > 0 && pointer_state.lock.temp_left) {
@ -40,7 +40,7 @@ bool mouse_resize_tiled(struct wlc_origin prev_pos) {
pointer_state.tiling.lock_pos.x = 0; pointer_state.tiling.lock_pos.x = 0;
} }
if ((dx > 0 || mouse_origin.x > pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_right) { if ((dx > 0 || pointer_state.origin.x > pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_right) {
changed_tiling = true; changed_tiling = true;
valid = false; valid = false;
} else if (dx < 0 && pointer_state.lock.temp_right) { } else if (dx < 0 && pointer_state.lock.temp_right) {
@ -48,7 +48,7 @@ bool mouse_resize_tiled(struct wlc_origin prev_pos) {
pointer_state.tiling.lock_pos.x = 0; pointer_state.tiling.lock_pos.x = 0;
} }
if ((dy < 0 || mouse_origin.y < pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_up) { if ((dy < 0 || pointer_state.origin.y < pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_up) {
changed_tiling = true; changed_tiling = true;
valid = false; valid = false;
} else if (dy > 0 && pointer_state.lock.temp_up) { } else if (dy > 0 && pointer_state.lock.temp_up) {
@ -56,7 +56,7 @@ bool mouse_resize_tiled(struct wlc_origin prev_pos) {
pointer_state.tiling.lock_pos.y = 0; pointer_state.tiling.lock_pos.y = 0;
} }
if ((dy > 0 || mouse_origin.y > pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_down) { if ((dy > 0 || pointer_state.origin.y > pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_down) {
changed_tiling = true; changed_tiling = true;
valid = false; valid = false;
} else if (dy < 0 && pointer_state.lock.temp_down) { } else if (dy < 0 && pointer_state.lock.temp_down) {
@ -190,8 +190,8 @@ bool resize_floating(struct wlc_origin prev_pos) {
bool changed = false; bool changed = false;
swayc_t *view = container_under_pointer(); swayc_t *view = container_under_pointer();
uint32_t edge = 0; uint32_t edge = 0;
int dx = mouse_origin.x - prev_pos.x; int dx = pointer_state.origin.x - prev_pos.x;
int dy = mouse_origin.y - prev_pos.y; int dy = pointer_state.origin.y - prev_pos.y;
// Move and resize the view based on the dx/dy and mouse position // Move and resize the view based on the dx/dy and mouse position
int midway_x = view->x + view->width/2; int midway_x = view->x + view->width/2;
@ -203,14 +203,14 @@ bool resize_floating(struct wlc_origin prev_pos) {
view->width += dx; view->width += dx;
edge += WLC_RESIZE_EDGE_RIGHT; edge += WLC_RESIZE_EDGE_RIGHT;
} }
} else if (mouse_origin.x < midway_x && !pointer_state.lock.left) { } else if (pointer_state.origin.x < midway_x && !pointer_state.lock.left) {
changed = true; changed = true;
view->x += dx; view->x += dx;
view->width -= dx; view->width -= dx;
edge += WLC_RESIZE_EDGE_LEFT; edge += WLC_RESIZE_EDGE_LEFT;
} }
} else if (dx > 0) { } else if (dx > 0) {
if (mouse_origin.x > midway_x && !pointer_state.lock.right) { if (pointer_state.origin.x > midway_x && !pointer_state.lock.right) {
changed = true; changed = true;
view->width += dx; view->width += dx;
edge += WLC_RESIZE_EDGE_RIGHT; edge += WLC_RESIZE_EDGE_RIGHT;
@ -231,14 +231,14 @@ bool resize_floating(struct wlc_origin prev_pos) {
view->height += dy; view->height += dy;
edge += WLC_RESIZE_EDGE_BOTTOM; edge += WLC_RESIZE_EDGE_BOTTOM;
} }
} else if (mouse_origin.y < midway_y && !pointer_state.lock.top) { } else if (pointer_state.origin.y < midway_y && !pointer_state.lock.top) {
changed = true; changed = true;
view->y += dy; view->y += dy;
view->height -= dy; view->height -= dy;
edge += WLC_RESIZE_EDGE_TOP; edge += WLC_RESIZE_EDGE_TOP;
} }
} else if (dy > 0) { } else if (dy > 0) {
if (mouse_origin.y > midway_y && !pointer_state.lock.bottom) { if (pointer_state.origin.y > midway_y && !pointer_state.lock.bottom) {
changed = true; changed = true;
view->height += dy; view->height += dy;
edge += WLC_RESIZE_EDGE_BOTTOM; edge += WLC_RESIZE_EDGE_BOTTOM;