From d0b54e932b59baa71b54d842b249400db74ce79b Mon Sep 17 00:00:00 2001 From: Ian Fan Date: Sun, 30 Sep 2018 15:09:09 +0100 Subject: swaybar: save id upon startup This adds an id property to the bar, which will be used to filter barconfig_update events --- include/swaybar/bar.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/swaybar/bar.h') diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index de234111..d29db31e 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -46,6 +46,8 @@ struct swaybar_hotspot { }; struct swaybar { + char *id; + struct wl_display *display; struct wl_compositor *compositor; struct zwlr_layer_shell_v1 *layer_shell; @@ -96,7 +98,7 @@ struct swaybar_workspace { bool urgent; }; -bool bar_setup(struct swaybar *bar, const char *socket_path, const char *bar_id); +bool bar_setup(struct swaybar *bar, const char *socket_path); void bar_run(struct swaybar *bar); void bar_teardown(struct swaybar *bar); -- cgit v1.2.3 From 18eaf452245d47461070894b4324d2afa47b0b05 Mon Sep 17 00:00:00 2001 From: Ian Fan Date: Sat, 6 Oct 2018 19:02:12 +0100 Subject: swaybar: annotate wl_list properties in definitions --- include/swaybar/bar.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include/swaybar/bar.h') diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index d29db31e..3c1a236d 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -37,7 +37,7 @@ enum hotspot_event_handling { }; struct swaybar_hotspot { - struct wl_list link; + struct wl_list link; // swaybar_output::hotspots int x, y, width, height; enum hotspot_event_handling (*callback)(struct swaybar_output *output, int x, int y, enum x11_button button, void *data); @@ -62,11 +62,11 @@ struct swaybar { int ipc_event_socketfd; int ipc_socketfd; - struct wl_list outputs; + struct wl_list outputs; // swaybar_output::link }; struct swaybar_output { - struct wl_list link; + struct wl_list link; // swaybar::outputs struct swaybar *bar; struct wl_output *output; struct zxdg_output_v1 *xdg_output; @@ -74,8 +74,8 @@ struct swaybar_output { struct zwlr_layer_surface_v1 *layer_surface; uint32_t wl_name; - struct wl_list workspaces; - struct wl_list hotspots; + struct wl_list workspaces; // swaybar_workspace::link + struct wl_list hotspots; // swaybar_hotspot::link char *name; bool focused; @@ -90,7 +90,7 @@ struct swaybar_output { }; struct swaybar_workspace { - struct wl_list link; + struct wl_list link; // swaybar_output::workspaces int num; char *name; bool focused; -- cgit v1.2.3 From 19f0bf38640f4da609782442c901366617aa27fa Mon Sep 17 00:00:00 2001 From: Ian Fan Date: Fri, 12 Oct 2018 20:18:04 +0100 Subject: swaybar: add free_hotspots helper function --- include/swaybar/bar.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/swaybar/bar.h') diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 3c1a236d..72e0ca75 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -102,6 +102,7 @@ bool bar_setup(struct swaybar *bar, const char *socket_path); void bar_run(struct swaybar *bar); void bar_teardown(struct swaybar *bar); +void free_hotspots(struct wl_list *list); void free_workspaces(struct wl_list *list); #endif -- cgit v1.2.3 From fed11d1c7b388e999414dd8cec4b8982ba5ce950 Mon Sep 17 00:00:00 2001 From: Ian Fan Date: Fri, 12 Oct 2018 20:23:01 +0100 Subject: swaybar: move mode & mode_pango_markup to bar struct This distinguishes the binding mode from the distinct config mode, as well as removing mode_pango_markup from the config struct where it should not be present. --- include/swaybar/bar.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/swaybar/bar.h') diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 72e0ca75..593f4f6d 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -47,6 +47,8 @@ struct swaybar_hotspot { struct swaybar { char *id; + char *mode; + bool mode_pango_markup; struct wl_display *display; struct wl_compositor *compositor; -- cgit v1.2.3 From bcc61e5147fb57a3b4bfb9a2a33065a0cf6da67b Mon Sep 17 00:00:00 2001 From: Ian Fan Date: Fri, 12 Oct 2018 20:32:48 +0100 Subject: swaybar: handle mode/hidden_state changes As well as adding the hidden_state property to the bar config struct, this commit handles barconfig_update events when the mode or hidden_state changes, and uses a new function determine_bar_visibility to hide or show the bar as required, using, respectively, destroy_layer_surface, which is also newly added, and add_layer_surface, which has been changed to allow dynamically adding the surface. --- include/swaybar/bar.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/swaybar/bar.h') diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 593f4f6d..9ff3fe7b 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -50,6 +50,11 @@ struct swaybar { char *mode; bool mode_pango_markup; + // only relevant when bar is in "hide" mode + bool visible_by_modifier; + bool visible_by_urgency; + bool visible; + struct wl_display *display; struct wl_compositor *compositor; struct zwlr_layer_shell_v1 *layer_shell; @@ -104,6 +109,19 @@ bool bar_setup(struct swaybar *bar, const char *socket_path); void bar_run(struct swaybar *bar); void bar_teardown(struct swaybar *bar); +/* + * Determines whether the bar should be visible and changes it to be so. + * If the current visibility of the bar is the different to what it should be, + * then it adds or destroys the layer surface as required, + * as well as sending the cont or stop signal to the status command. + * If the current visibility of the bar is already what it should be, + * then this function is a no-op, unless moving_layer is true, which occurs + * when the bar changes from "hide" to "dock" mode or vice versa, and the bar + * needs to be destroyed and re-added in order to change its layer. + * + * Returns true if the bar is now visible, otherwise false. + */ +bool determine_bar_visibility(struct swaybar *bar, bool moving_layer); void free_hotspots(struct wl_list *list); void free_workspaces(struct wl_list *list); -- cgit v1.2.3