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 --- include/input_state.h | 46 ++++++++++++++++++++++++++++++++++++++++++++-- include/layout.h | 2 ++ 2 files changed, 46 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/input_state.h b/include/input_state.h index 04fde42d..3a246e0c 100644 --- a/include/input_state.h +++ b/include/input_state.h @@ -17,6 +17,7 @@ void press_key(keycode key); // unsets a key as pressed void release_key(keycode key); + /* Pointer state */ enum pointer_values { @@ -27,9 +28,40 @@ enum pointer_values { 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 { - bool l_held; - bool r_held; + // mouse clicks + 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 { bool drag; bool resize; @@ -53,6 +85,16 @@ extern struct pointer_state { } lock; } 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 reset_floating(swayc_t *view); void input_init(void); diff --git a/include/layout.h b/include/layout.h index f8aebe0a..8f269607 100644 --- a/include/layout.h +++ b/include/layout.h @@ -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 *replace_child(swayc_t *child, swayc_t *new_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); // Layout +void update_geometry(swayc_t *view); void arrange_windows(swayc_t *container, double width, double height); swayc_t *get_focused_container(swayc_t *parent); -- 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 +- 2 files changed, 14 insertions(+), 34 deletions(-) (limited to 'include') 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 -- cgit v1.2.3 From f24b78898a7a7fc98f896f6d1d374c602ee30952 Mon Sep 17 00:00:00 2001 From: taiyu Date: Sat, 22 Aug 2015 21:54:39 -0700 Subject: dont swap view with workspace... --- include/resize.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/resize.h b/include/resize.h index 04209983..8d205d3b 100644 --- a/include/resize.h +++ b/include/resize.h @@ -2,7 +2,6 @@ #define _SWAY_RESIZE_H #include -bool mouse_resize_tiled(struct wlc_origin prev_pos); bool resize_tiled(int amount, bool use_width); #endif -- 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 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') 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 { -- cgit v1.2.3