diff options
author | 2018-10-14 15:13:50 +0200 | |
---|---|---|
committer | 2018-10-14 15:13:50 +0200 | |
commit | 4a05fbf8ab364657763b1d1058bdf9b4c2727b76 (patch) | |
tree | c405121528d191ba74fe329fdb18093810d9b73c /include/swaybar/bar.h | |
parent | Merge pull request #2808 from RedSoxFan/bar-subcommands (diff) | |
parent | swaybar: add documentation for hide/hidden_state subcommands (diff) | |
download | sway-4a05fbf8ab364657763b1d1058bdf9b4c2727b76.tar.gz sway-4a05fbf8ab364657763b1d1058bdf9b4c2727b76.tar.zst sway-4a05fbf8ab364657763b1d1058bdf9b4c2727b76.zip |
Merge pull request #2751 from ianyfan/swaybar
Bar mode/hidden_state events
Diffstat (limited to 'include/swaybar/bar.h')
-rw-r--r-- | include/swaybar/bar.h | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index de234111..9ff3fe7b 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h | |||
@@ -37,7 +37,7 @@ enum hotspot_event_handling { | |||
37 | }; | 37 | }; |
38 | 38 | ||
39 | struct swaybar_hotspot { | 39 | struct swaybar_hotspot { |
40 | struct wl_list link; | 40 | struct wl_list link; // swaybar_output::hotspots |
41 | int x, y, width, height; | 41 | int x, y, width, height; |
42 | enum hotspot_event_handling (*callback)(struct swaybar_output *output, | 42 | enum hotspot_event_handling (*callback)(struct swaybar_output *output, |
43 | int x, int y, enum x11_button button, void *data); | 43 | int x, int y, enum x11_button button, void *data); |
@@ -46,6 +46,15 @@ struct swaybar_hotspot { | |||
46 | }; | 46 | }; |
47 | 47 | ||
48 | struct swaybar { | 48 | struct swaybar { |
49 | char *id; | ||
50 | char *mode; | ||
51 | bool mode_pango_markup; | ||
52 | |||
53 | // only relevant when bar is in "hide" mode | ||
54 | bool visible_by_modifier; | ||
55 | bool visible_by_urgency; | ||
56 | bool visible; | ||
57 | |||
49 | struct wl_display *display; | 58 | struct wl_display *display; |
50 | struct wl_compositor *compositor; | 59 | struct wl_compositor *compositor; |
51 | struct zwlr_layer_shell_v1 *layer_shell; | 60 | struct zwlr_layer_shell_v1 *layer_shell; |
@@ -60,11 +69,11 @@ struct swaybar { | |||
60 | int ipc_event_socketfd; | 69 | int ipc_event_socketfd; |
61 | int ipc_socketfd; | 70 | int ipc_socketfd; |
62 | 71 | ||
63 | struct wl_list outputs; | 72 | struct wl_list outputs; // swaybar_output::link |
64 | }; | 73 | }; |
65 | 74 | ||
66 | struct swaybar_output { | 75 | struct swaybar_output { |
67 | struct wl_list link; | 76 | struct wl_list link; // swaybar::outputs |
68 | struct swaybar *bar; | 77 | struct swaybar *bar; |
69 | struct wl_output *output; | 78 | struct wl_output *output; |
70 | struct zxdg_output_v1 *xdg_output; | 79 | struct zxdg_output_v1 *xdg_output; |
@@ -72,8 +81,8 @@ struct swaybar_output { | |||
72 | struct zwlr_layer_surface_v1 *layer_surface; | 81 | struct zwlr_layer_surface_v1 *layer_surface; |
73 | uint32_t wl_name; | 82 | uint32_t wl_name; |
74 | 83 | ||
75 | struct wl_list workspaces; | 84 | struct wl_list workspaces; // swaybar_workspace::link |
76 | struct wl_list hotspots; | 85 | struct wl_list hotspots; // swaybar_hotspot::link |
77 | 86 | ||
78 | char *name; | 87 | char *name; |
79 | bool focused; | 88 | bool focused; |
@@ -88,7 +97,7 @@ struct swaybar_output { | |||
88 | }; | 97 | }; |
89 | 98 | ||
90 | struct swaybar_workspace { | 99 | struct swaybar_workspace { |
91 | struct wl_list link; | 100 | struct wl_list link; // swaybar_output::workspaces |
92 | int num; | 101 | int num; |
93 | char *name; | 102 | char *name; |
94 | bool focused; | 103 | bool focused; |
@@ -96,10 +105,24 @@ struct swaybar_workspace { | |||
96 | bool urgent; | 105 | bool urgent; |
97 | }; | 106 | }; |
98 | 107 | ||
99 | bool bar_setup(struct swaybar *bar, const char *socket_path, const char *bar_id); | 108 | bool bar_setup(struct swaybar *bar, const char *socket_path); |
100 | void bar_run(struct swaybar *bar); | 109 | void bar_run(struct swaybar *bar); |
101 | void bar_teardown(struct swaybar *bar); | 110 | void bar_teardown(struct swaybar *bar); |
102 | 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); | ||
125 | void free_hotspots(struct wl_list *list); | ||
103 | void free_workspaces(struct wl_list *list); | 126 | void free_workspaces(struct wl_list *list); |
104 | 127 | ||
105 | #endif | 128 | #endif |