diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-10-12 20:32:48 +0100 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-10-14 13:33:12 +0100 |
commit | bcc61e5147fb57a3b4bfb9a2a33065a0cf6da67b (patch) | |
tree | 873a09eca473242c15299ea1053966e9d163f6c6 /include/swaybar/bar.h | |
parent | 55ca16f2d83f4d7e14635ac4de3eb67ee2a0787e (diff) |
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.
Diffstat (limited to 'include/swaybar/bar.h')
-rw-r--r-- | include/swaybar/bar.h | 18 |
1 files changed, 18 insertions, 0 deletions
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); |