From 97f7d47413967e2b6f405c4fa303850b7c56f57a Mon Sep 17 00:00:00 2001 From: wil Date: Sat, 10 Dec 2016 16:44:43 +0100 Subject: Added Awesome/Monad type "auto" layouts --- include/sway/container.h | 17 +++++++++++++++++ include/sway/layout.h | 3 +++ 2 files changed, 20 insertions(+) (limited to 'include') diff --git a/include/sway/container.h b/include/sway/container.h index 2bedd136..1d0fb265 100644 --- a/include/sway/container.h +++ b/include/sway/container.h @@ -37,6 +37,13 @@ enum swayc_layouts { L_STACKED, L_TABBED, L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */ + + /* Awesome/Monad style auto layouts */ + L_AUTO_LEFT, + L_AUTO_RIGHT, + L_AUTO_TOP, + L_AUTO_BOTTOM, + // Keep last L_LAYOUTS, }; @@ -144,6 +151,16 @@ struct sway_container { struct wlc_geometry title_bar_geometry; struct wlc_geometry actual_geometry; int border_thickness; + + /** + * Number of master views in auto layouts. + */ + uint32_t nb_master; + + /** + * Number of slave groups (e.g. columns) in auto layouts. + */ + uint32_t nb_slave_groups; }; enum visibility_mask { diff --git a/include/sway/layout.h b/include/sway/layout.h index b982365c..38096947 100644 --- a/include/sway/layout.h +++ b/include/sway/layout.h @@ -75,4 +75,7 @@ void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, .. */ enum swayc_layouts default_layout(swayc_t *output); +inline bool is_auto_layout(enum swayc_layouts layout) { + return (layout >= L_AUTO_LEFT) && (layout <= L_AUTO_BOTTOM); +} #endif -- cgit v1.2.3 From 0ff9fe9a7a18a5130b7c5e979ba980409f91b5f1 Mon Sep 17 00:00:00 2001 From: wil Date: Thu, 22 Dec 2016 18:46:00 +0100 Subject: introduce next/prev as a direction for focus/move commands. --- include/sway/focus.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/sway/focus.h b/include/sway/focus.h index b532edc2..30c9e108 100644 --- a/include/sway/focus.h +++ b/include/sway/focus.h @@ -6,7 +6,9 @@ enum movement_direction { MOVE_UP, MOVE_DOWN, MOVE_PARENT, - MOVE_CHILD + MOVE_CHILD, + MOVE_NEXT, + MOVE_PREV }; #include "container.h" @@ -40,4 +42,3 @@ extern bool suspend_workspace_cleanup; bool move_focus(enum movement_direction direction); #endif - -- cgit v1.2.3 From a0aa8d9780c6c8b0138800e3b2c2c0053174a2c5 Mon Sep 17 00:00:00 2001 From: wil Date: Thu, 29 Dec 2016 20:26:35 +0100 Subject: cleanup in auto layouts - added L_AUTO_FIRST/LAST instead of using explicit layouts. - when switching between auto layout that don't share the same major axis, invert the width/height of their child views to preserve their relative proportions. --- include/sway/container.h | 3 +++ include/sway/layout.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/sway/container.h b/include/sway/container.h index 1d0fb265..f0574b1b 100644 --- a/include/sway/container.h +++ b/include/sway/container.h @@ -44,6 +44,9 @@ enum swayc_layouts { L_AUTO_TOP, L_AUTO_BOTTOM, + L_AUTO_FIRST = L_AUTO_LEFT, + L_AUTO_LAST = L_AUTO_BOTTOM, + // Keep last L_LAYOUTS, }; diff --git a/include/sway/layout.h b/include/sway/layout.h index 38096947..a771a72e 100644 --- a/include/sway/layout.h +++ b/include/sway/layout.h @@ -76,6 +76,6 @@ void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, .. enum swayc_layouts default_layout(swayc_t *output); inline bool is_auto_layout(enum swayc_layouts layout) { - return (layout >= L_AUTO_LEFT) && (layout <= L_AUTO_BOTTOM); + return (layout >= L_AUTO_FIRST) && (layout <= L_AUTO_LAST); } #endif -- cgit v1.2.3 From 1b87193c3d63c8d884b5a45451a000d9b930521e Mon Sep 17 00:00:00 2001 From: wil Date: Thu, 29 Dec 2016 20:30:32 +0100 Subject: Added "layout promote" command. --- include/list.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/list.h b/include/list.h index f478b6bb..7eead4ac 100644 --- a/include/list.h +++ b/include/list.h @@ -22,4 +22,6 @@ void list_qsort(list_t *list, int compare(const void *left, const void *right)); int list_seq_find(list_t *list, int compare(const void *item, const void *cmp_to), const void *cmp_to); // stable sort since qsort is not guaranteed to be stable void list_stable_sort(list_t *list, int compare(const void *a, const void *b)); +// swap two elements in a list +void list_swap(list_t *list, int src, int dest); #endif -- cgit v1.2.3 From c01b89839874239bee7948fad004b19a19917432 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 1 Jan 2017 12:36:47 -0500 Subject: Fix inline is_auto_layout --- include/sway/layout.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/sway/layout.h b/include/sway/layout.h index a771a72e..d7fe748d 100644 --- a/include/sway/layout.h +++ b/include/sway/layout.h @@ -75,7 +75,6 @@ void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, .. */ enum swayc_layouts default_layout(swayc_t *output); -inline bool is_auto_layout(enum swayc_layouts layout) { - return (layout >= L_AUTO_FIRST) && (layout <= L_AUTO_LAST); -} +bool is_auto_layout(enum swayc_layouts layout); + #endif -- cgit v1.2.3 From a62048f15d9381e3040bd45965233e59a041eab7 Mon Sep 17 00:00:00 2001 From: wil Date: Sun, 1 Jan 2017 19:53:53 +0100 Subject: changed "layout promote" command to "move first" This is more consistent with other Sway semantics. --- include/sway/focus.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/sway/focus.h b/include/sway/focus.h index 30c9e108..652cdccc 100644 --- a/include/sway/focus.h +++ b/include/sway/focus.h @@ -8,7 +8,8 @@ enum movement_direction { MOVE_PARENT, MOVE_CHILD, MOVE_NEXT, - MOVE_PREV + MOVE_PREV, + MOVE_FIRST }; #include "container.h" -- cgit v1.2.3 From 97f70987d70315c683fd1e16c731b396679f6b96 Mon Sep 17 00:00:00 2001 From: wil Date: Sun, 1 Jan 2017 21:52:49 +0100 Subject: [fix] cleanups suggested by Sway community --- include/sway/container.h | 4 ++-- include/sway/layout.h | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/sway/container.h b/include/sway/container.h index f0574b1b..ff65628c 100644 --- a/include/sway/container.h +++ b/include/sway/container.h @@ -158,12 +158,12 @@ struct sway_container { /** * Number of master views in auto layouts. */ - uint32_t nb_master; + size_t nb_master; /** * Number of slave groups (e.g. columns) in auto layouts. */ - uint32_t nb_slave_groups; + size_t nb_slave_groups; }; enum visibility_mask { diff --git a/include/sway/layout.h b/include/sway/layout.h index a771a72e..8cc513d8 100644 --- a/include/sway/layout.h +++ b/include/sway/layout.h @@ -75,7 +75,5 @@ void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, .. */ enum swayc_layouts default_layout(swayc_t *output); -inline bool is_auto_layout(enum swayc_layouts layout) { - return (layout >= L_AUTO_FIRST) && (layout <= L_AUTO_LAST); -} +bool is_auto_layout(enum swayc_layouts layout); #endif -- cgit v1.2.3 From bd415029ba72425c97647b55fce19213e7909cbc Mon Sep 17 00:00:00 2001 From: wil Date: Sat, 7 Jan 2017 17:41:15 +0100 Subject: Moved auto_* layout functions from resize.c to layout.c --- include/sway/layout.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/sway/layout.h b/include/sway/layout.h index d7fe748d..c51fece9 100644 --- a/include/sway/layout.h +++ b/include/sway/layout.h @@ -76,5 +76,9 @@ void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, .. enum swayc_layouts default_layout(swayc_t *output); bool is_auto_layout(enum swayc_layouts layout); +int auto_group_start_index(swayc_t *container, int index); +int auto_group_end_index(swayc_t *container, int index); +size_t auto_group_count(swayc_t *container); +size_t auto_group_index(swayc_t *container, int index); #endif -- cgit v1.2.3 From 1f47c58d63130b8de59cb81422a4339bc0273273 Mon Sep 17 00:00:00 2001 From: wil Date: Sat, 7 Jan 2017 20:26:46 +0100 Subject: simplification of apply_auto_layout Achieved by introducing auto_group_bounds function that produces the start/end indexes of a group inside an auto layot container. --- include/sway/layout.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/sway/layout.h b/include/sway/layout.h index c51fece9..fbedcdb3 100644 --- a/include/sway/layout.h +++ b/include/sway/layout.h @@ -76,9 +76,10 @@ void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, .. enum swayc_layouts default_layout(swayc_t *output); bool is_auto_layout(enum swayc_layouts layout); -int auto_group_start_index(swayc_t *container, int index); -int auto_group_end_index(swayc_t *container, int index); -size_t auto_group_count(swayc_t *container); -size_t auto_group_index(swayc_t *container, int index); +int auto_group_start_index(const swayc_t *container, int index); +int auto_group_end_index(const swayc_t *container, int index); +size_t auto_group_count(const swayc_t *container); +size_t auto_group_index(const swayc_t *container, int index); +bool auto_group_bounds(const swayc_t *container, size_t group_index, int *start, int *end); #endif -- cgit v1.2.3