diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-10-14 15:13:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-14 15:13:50 +0200 |
commit | 4a05fbf8ab364657763b1d1058bdf9b4c2727b76 (patch) | |
tree | c405121528d191ba74fe329fdb18093810d9b73c /include | |
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')
-rw-r--r-- | include/ipc.h | 3 | ||||
-rw-r--r-- | include/sway/config.h | 1 | ||||
-rw-r--r-- | include/sway/ipc-server.h | 1 | ||||
-rw-r--r-- | include/swaybar/bar.h | 37 | ||||
-rw-r--r-- | include/swaybar/config.h | 5 | ||||
-rw-r--r-- | include/swaybar/i3bar.h | 2 | ||||
-rw-r--r-- | include/swaybar/ipc.h | 4 | ||||
-rw-r--r-- | include/swaybar/status_line.h | 3 |
8 files changed, 44 insertions, 12 deletions
diff --git a/include/ipc.h b/include/ipc.h index a3f60e19..9063b933 100644 --- a/include/ipc.h +++ b/include/ipc.h | |||
@@ -30,6 +30,9 @@ enum ipc_command_type { | |||
30 | IPC_EVENT_BINDING = ((1<<31) | 5), | 30 | IPC_EVENT_BINDING = ((1<<31) | 5), |
31 | IPC_EVENT_SHUTDOWN = ((1<<31) | 6), | 31 | IPC_EVENT_SHUTDOWN = ((1<<31) | 6), |
32 | IPC_EVENT_TICK = ((1<<31) | 7), | 32 | IPC_EVENT_TICK = ((1<<31) | 7), |
33 | |||
34 | // sway-specific event types | ||
35 | IPC_EVENT_BAR_STATE_UPDATE = ((1<<31) | 20), | ||
33 | }; | 36 | }; |
34 | 37 | ||
35 | #endif | 38 | #endif |
diff --git a/include/sway/config.h b/include/sway/config.h index f21ecbb1..be5a00b5 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -191,6 +191,7 @@ struct bar_config { | |||
191 | * In "show" mode, it will always be shown on top of the active workspace. | 191 | * In "show" mode, it will always be shown on top of the active workspace. |
192 | */ | 192 | */ |
193 | char *hidden_state; | 193 | char *hidden_state; |
194 | bool visible_by_modifier; // only relevant in "hide" mode | ||
194 | /** | 195 | /** |
195 | * Id name used to identify the bar through IPC. | 196 | * Id name used to identify the bar through IPC. |
196 | * | 197 | * |
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h index 80180ec4..3c43f74d 100644 --- a/include/sway/ipc-server.h +++ b/include/sway/ipc-server.h | |||
@@ -15,6 +15,7 @@ void ipc_event_workspace(struct sway_workspace *old, | |||
15 | struct sway_workspace *new, const char *change); | 15 | struct sway_workspace *new, const char *change); |
16 | void ipc_event_window(struct sway_container *window, const char *change); | 16 | void ipc_event_window(struct sway_container *window, const char *change); |
17 | void ipc_event_barconfig_update(struct bar_config *bar); | 17 | void ipc_event_barconfig_update(struct bar_config *bar); |
18 | void ipc_event_bar_state_update(struct bar_config *bar); | ||
18 | void ipc_event_mode(const char *mode, bool pango); | 19 | void ipc_event_mode(const char *mode, bool pango); |
19 | void ipc_event_shutdown(const char *reason); | 20 | void ipc_event_shutdown(const char *reason); |
20 | void ipc_event_binding(struct sway_binding *binding); | 21 | void ipc_event_binding(struct sway_binding *binding); |
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 |
diff --git a/include/swaybar/config.h b/include/swaybar/config.h index d0336c27..5d40790a 100644 --- a/include/swaybar/config.h +++ b/include/swaybar/config.h | |||
@@ -13,7 +13,7 @@ struct box_colors { | |||
13 | }; | 13 | }; |
14 | 14 | ||
15 | struct config_output { | 15 | struct config_output { |
16 | struct wl_list link; | 16 | struct wl_list link; // swaybar_config::outputs |
17 | char *name; | 17 | char *name; |
18 | size_t index; | 18 | size_t index; |
19 | }; | 19 | }; |
@@ -31,7 +31,8 @@ struct swaybar_config { | |||
31 | char *font; | 31 | char *font; |
32 | char *sep_symbol; | 32 | char *sep_symbol; |
33 | char *mode; | 33 | char *mode; |
34 | bool mode_pango_markup; | 34 | char *hidden_state; |
35 | char *modifier; | ||
35 | bool strip_workspace_numbers; | 36 | bool strip_workspace_numbers; |
36 | bool binding_mode_indicator; | 37 | bool binding_mode_indicator; |
37 | bool wrap_scroll; | 38 | bool wrap_scroll; |
diff --git a/include/swaybar/i3bar.h b/include/swaybar/i3bar.h index 12d9b317..d4a48e07 100644 --- a/include/swaybar/i3bar.h +++ b/include/swaybar/i3bar.h | |||
@@ -5,7 +5,7 @@ | |||
5 | #include "status_line.h" | 5 | #include "status_line.h" |
6 | 6 | ||
7 | struct i3bar_block { | 7 | struct i3bar_block { |
8 | struct wl_list link; | 8 | struct wl_list link; // status_link::blocks |
9 | int ref_count; | 9 | int ref_count; |
10 | char *full_text, *short_text, *align; | 10 | char *full_text, *short_text, *align; |
11 | bool urgent; | 11 | bool urgent; |
diff --git a/include/swaybar/ipc.h b/include/swaybar/ipc.h index 8731dac2..d8cd0c76 100644 --- a/include/swaybar/ipc.h +++ b/include/swaybar/ipc.h | |||
@@ -3,9 +3,9 @@ | |||
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include "swaybar/bar.h" | 4 | #include "swaybar/bar.h" |
5 | 5 | ||
6 | bool ipc_initialize(struct swaybar *bar, const char *bar_id); | 6 | bool ipc_initialize(struct swaybar *bar); |
7 | bool handle_ipc_readable(struct swaybar *bar); | 7 | bool handle_ipc_readable(struct swaybar *bar); |
8 | void ipc_get_workspaces(struct swaybar *bar); | 8 | bool ipc_get_workspaces(struct swaybar *bar); |
9 | void ipc_send_workspace_command(struct swaybar *bar, const char *ws); | 9 | void ipc_send_workspace_command(struct swaybar *bar, const char *ws); |
10 | void ipc_execute_binding(struct swaybar *bar, struct swaybar_binding *bind); | 10 | void ipc_execute_binding(struct swaybar *bar, struct swaybar_binding *bind); |
11 | 11 | ||
diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h index ca88b0c5..5e7e8771 100644 --- a/include/swaybar/status_line.h +++ b/include/swaybar/status_line.h | |||
@@ -22,6 +22,9 @@ struct status_line { | |||
22 | const char *text; | 22 | const char *text; |
23 | struct wl_list blocks; // i3bar_block::link | 23 | struct wl_list blocks; // i3bar_block::link |
24 | 24 | ||
25 | int stop_signal; | ||
26 | int cont_signal; | ||
27 | |||
25 | bool click_events; | 28 | bool click_events; |
26 | bool clicked; | 29 | bool clicked; |
27 | char *buffer; | 30 | char *buffer; |