aboutsummaryrefslogtreecommitdiffstats
path: root/include/swaybar
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-10-12 20:32:48 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-10-14 13:33:12 +0100
commitbcc61e5147fb57a3b4bfb9a2a33065a0cf6da67b (patch)
tree873a09eca473242c15299ea1053966e9d163f6c6 /include/swaybar
parentswaybar: streamline ipc handling (diff)
downloadsway-bcc61e5147fb57a3b4bfb9a2a33065a0cf6da67b.tar.gz
sway-bcc61e5147fb57a3b4bfb9a2a33065a0cf6da67b.tar.zst
sway-bcc61e5147fb57a3b4bfb9a2a33065a0cf6da67b.zip
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')
-rw-r--r--include/swaybar/bar.h18
-rw-r--r--include/swaybar/config.h1
2 files changed, 19 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 {
50 char *mode; 50 char *mode;
51 bool mode_pango_markup; 51 bool mode_pango_markup;
52 52
53 // only relevant when bar is in "hide" mode
54 bool visible_by_modifier;
55 bool visible_by_urgency;
56 bool visible;
57
53 struct wl_display *display; 58 struct wl_display *display;
54 struct wl_compositor *compositor; 59 struct wl_compositor *compositor;
55 struct zwlr_layer_shell_v1 *layer_shell; 60 struct zwlr_layer_shell_v1 *layer_shell;
@@ -104,6 +109,19 @@ bool bar_setup(struct swaybar *bar, const char *socket_path);
104void bar_run(struct swaybar *bar); 109void bar_run(struct swaybar *bar);
105void bar_teardown(struct swaybar *bar); 110void bar_teardown(struct swaybar *bar);
106 111
112/*
113 * Determines whether the bar should be visible and changes it to be so.
114 * If the current visibility of the bar is the different to what it should be,
115 * then it adds or destroys the layer surface as required,
116 * as well as sending the cont or stop signal to the status command.
117 * If the current visibility of the bar is already what it should be,
118 * then this function is a no-op, unless moving_layer is true, which occurs
119 * when the bar changes from "hide" to "dock" mode or vice versa, and the bar
120 * needs to be destroyed and re-added in order to change its layer.
121 *
122 * Returns true if the bar is now visible, otherwise false.
123 */
124bool determine_bar_visibility(struct swaybar *bar, bool moving_layer);
107void free_hotspots(struct wl_list *list); 125void free_hotspots(struct wl_list *list);
108void free_workspaces(struct wl_list *list); 126void free_workspaces(struct wl_list *list);
109 127
diff --git a/include/swaybar/config.h b/include/swaybar/config.h
index 68ee2087..10904bca 100644
--- a/include/swaybar/config.h
+++ b/include/swaybar/config.h
@@ -31,6 +31,7 @@ struct swaybar_config {
31 char *font; 31 char *font;
32 char *sep_symbol; 32 char *sep_symbol;
33 char *mode; 33 char *mode;
34 char *hidden_state;
34 bool strip_workspace_numbers; 35 bool strip_workspace_numbers;
35 bool binding_mode_indicator; 36 bool binding_mode_indicator;
36 bool wrap_scroll; 37 bool wrap_scroll;