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 | swaybar: streamline ipc handling (diff) | |
download | sway-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/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 { | |||
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); | |||
104 | void bar_run(struct swaybar *bar); | 109 | void bar_run(struct swaybar *bar); |
105 | void bar_teardown(struct swaybar *bar); | 110 | void 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 | */ | ||
124 | bool determine_bar_visibility(struct swaybar *bar, bool moving_layer); | ||
107 | void free_hotspots(struct wl_list *list); | 125 | void free_hotspots(struct wl_list *list); |
108 | void free_workspaces(struct wl_list *list); | 126 | void free_workspaces(struct wl_list *list); |
109 | 127 | ||