From 6d57f03028b4b32b4377d869be8de9a7e6aa55ee Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Mon, 22 Feb 2016 17:27:17 +0100 Subject: Make single bar handle multiple outputs --- include/bar/bar.h | 11 ++++++++--- include/bar/config.h | 3 +++ include/bar/ipc.h | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/bar/bar.h b/include/bar/bar.h index 89496da6..c20efc55 100644 --- a/include/bar/bar.h +++ b/include/bar/bar.h @@ -8,8 +8,7 @@ struct bar { struct config *config; struct status_line *status; - struct output *output; - /* list_t *outputs; */ + list_t *outputs; int ipc_event_socketfd; int ipc_socketfd; @@ -22,6 +21,7 @@ struct output { struct registry *registry; list_t *workspaces; char *name; + int idx; }; struct workspace { @@ -35,7 +35,12 @@ struct workspace { /** * Setup bar. */ -void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id, int desired_output); +void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id); + +/** + * Create new output struct from name. + */ +struct output *new_output(const char *name); /** * Bar mainloop. diff --git a/include/bar/config.h b/include/bar/config.h index 508b9c42..dfad0ba4 100644 --- a/include/bar/config.h +++ b/include/bar/config.h @@ -4,6 +4,8 @@ #include #include +#include "list.h" + /** * Colors for a box with background, border and text colors. */ @@ -25,6 +27,7 @@ struct config { bool strip_workspace_numbers; bool binding_mode_indicator; bool workspace_buttons; + list_t *outputs; int height; diff --git a/include/bar/ipc.h b/include/bar/ipc.h index c3f661f8..741c067b 100644 --- a/include/bar/ipc.h +++ b/include/bar/ipc.h @@ -6,7 +6,7 @@ /** * Initialize ipc connection to sway and get sway state, outputs, bar_config. */ -void ipc_bar_init(struct bar *bar, int outputi, const char *bar_id); +void ipc_bar_init(struct bar *bar, const char *bar_id); /** * Handle ipc event from sway. -- cgit v1.2.3 From bad4e22f3be658f8688f308e54a48b65c071a952 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Tue, 23 Feb 2016 14:25:09 +0100 Subject: Make sway spawn only one bar per bar config --- include/config.h | 4 ++-- include/container.h | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/config.h b/include/config.h index 655d0a9c..0b19580c 100644 --- a/include/config.h +++ b/include/config.h @@ -125,6 +125,7 @@ struct bar_config { bool strip_workspace_numbers; bool binding_mode_indicator; bool verbose; + pid_t pid; struct { char background[10]; char statusline[10]; @@ -226,8 +227,7 @@ int sway_mouse_binding_cmp_qsort(const void *a, const void *b); int sway_mouse_binding_cmp_buttons(const void *a, const void *b); void free_sway_mouse_binding(struct sway_mouse_binding *smb); -void load_swaybars(swayc_t *output, int output_idx); -void terminate_swaybars(list_t *pids); +void load_swaybars(swayc_t *output); void terminate_swaybg(pid_t pid); /** diff --git a/include/container.h b/include/container.h index d5126e74..a96beab9 100644 --- a/include/container.h +++ b/include/container.h @@ -82,9 +82,7 @@ struct sway_container { char *class; char *app_id; - // Used by output containers to keep track of swaybar/swaybg child - // processes. - list_t *bar_pids; + // Used by output containers to keep track of swaybg child processes. pid_t bg_pid; int gaps; -- cgit v1.2.3 From e4c1176b726ab9391a3c9eb69670c09ffe3e4f0a Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Tue, 23 Feb 2016 15:06:04 +0100 Subject: Differentiate between all or no outputs --- include/bar/config.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/bar/config.h b/include/bar/config.h index dfad0ba4..fc938c38 100644 --- a/include/bar/config.h +++ b/include/bar/config.h @@ -27,6 +27,7 @@ struct config { bool strip_workspace_numbers; bool binding_mode_indicator; bool workspace_buttons; + bool all_outputs; list_t *outputs; int height; -- cgit v1.2.3 From e15a8a03769736f588f68ae5e1cc24611ed334ae Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Wed, 24 Feb 2016 18:52:57 +0100 Subject: Improve how swaybars are spawned --- include/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/config.h b/include/config.h index 0b19580c..8907e019 100644 --- a/include/config.h +++ b/include/config.h @@ -227,7 +227,7 @@ int sway_mouse_binding_cmp_qsort(const void *a, const void *b); int sway_mouse_binding_cmp_buttons(const void *a, const void *b); void free_sway_mouse_binding(struct sway_mouse_binding *smb); -void load_swaybars(swayc_t *output); +void load_swaybars(); void terminate_swaybg(pid_t pid); /** -- cgit v1.2.3 From 67bbcceba1433e41b5edfca32532b7d55a39a395 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Wed, 24 Feb 2016 18:53:09 +0100 Subject: Free config before exiting sway. Apart from freeing the sway_config struct, this also terminates the swaybars spawned by sway, since they are linked by PID to the bar config structs. --- include/config.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/config.h b/include/config.h index 8907e019..d77872ee 100644 --- a/include/config.h +++ b/include/config.h @@ -192,6 +192,10 @@ bool load_config(const char *file); /** Reads the config from the given FILE. */ bool read_config(FILE *file, bool is_active); +/** + * Free config struct + */ +void free_config(struct sway_config *config); /** * Does variable replacement for a string based on the config's currently loaded variables. */ -- cgit v1.2.3