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 | abde9d6627483256ccfd20bdeeaa52d7790b0426 (diff) | |
parent | 85dd36e92b2fb3d4b5fefa36927abf8f35f84c5c (diff) | |
download | sway-4a05fbf8ab364657763b1d1058bdf9b4c2727b76.tar.xz |
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 { IPC_EVENT_BINDING = ((1<<31) | 5), IPC_EVENT_SHUTDOWN = ((1<<31) | 6), IPC_EVENT_TICK = ((1<<31) | 7), + + // sway-specific event types + IPC_EVENT_BAR_STATE_UPDATE = ((1<<31) | 20), }; #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 { * In "show" mode, it will always be shown on top of the active workspace. */ char *hidden_state; + bool visible_by_modifier; // only relevant in "hide" mode /** * Id name used to identify the bar through IPC. * 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, struct sway_workspace *new, const char *change); void ipc_event_window(struct sway_container *window, const char *change); void ipc_event_barconfig_update(struct bar_config *bar); +void ipc_event_bar_state_update(struct bar_config *bar); void ipc_event_mode(const char *mode, bool pango); void ipc_event_shutdown(const char *reason); 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 { }; struct swaybar_hotspot { - struct wl_list link; + struct wl_list link; // swaybar_output::hotspots int x, y, width, height; enum hotspot_event_handling (*callback)(struct swaybar_output *output, int x, int y, enum x11_button button, void *data); @@ -46,6 +46,15 @@ struct swaybar_hotspot { }; struct swaybar { + char *id; + 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; @@ -60,11 +69,11 @@ struct swaybar { int ipc_event_socketfd; int ipc_socketfd; - struct wl_list outputs; + struct wl_list outputs; // swaybar_output::link }; struct swaybar_output { - struct wl_list link; + struct wl_list link; // swaybar::outputs struct swaybar *bar; struct wl_output *output; struct zxdg_output_v1 *xdg_output; @@ -72,8 +81,8 @@ struct swaybar_output { struct zwlr_layer_surface_v1 *layer_surface; uint32_t wl_name; - struct wl_list workspaces; - struct wl_list hotspots; + struct wl_list workspaces; // swaybar_workspace::link + struct wl_list hotspots; // swaybar_hotspot::link char *name; bool focused; @@ -88,7 +97,7 @@ struct swaybar_output { }; struct swaybar_workspace { - struct wl_list link; + struct wl_list link; // swaybar_output::workspaces int num; char *name; bool focused; @@ -96,10 +105,24 @@ struct swaybar_workspace { bool urgent; }; -bool bar_setup(struct swaybar *bar, const char *socket_path, const char *bar_id); +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); #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 { }; struct config_output { - struct wl_list link; + struct wl_list link; // swaybar_config::outputs char *name; size_t index; }; @@ -31,7 +31,8 @@ struct swaybar_config { char *font; char *sep_symbol; char *mode; - bool mode_pango_markup; + char *hidden_state; + char *modifier; bool strip_workspace_numbers; bool binding_mode_indicator; 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 @@ #include "status_line.h" struct i3bar_block { - struct wl_list link; + struct wl_list link; // status_link::blocks int ref_count; char *full_text, *short_text, *align; 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 @@ #include <stdbool.h> #include "swaybar/bar.h" -bool ipc_initialize(struct swaybar *bar, const char *bar_id); +bool ipc_initialize(struct swaybar *bar); bool handle_ipc_readable(struct swaybar *bar); -void ipc_get_workspaces(struct swaybar *bar); +bool ipc_get_workspaces(struct swaybar *bar); void ipc_send_workspace_command(struct swaybar *bar, const char *ws); void ipc_execute_binding(struct swaybar *bar, struct swaybar_binding *bind); 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 { const char *text; struct wl_list blocks; // i3bar_block::link + int stop_signal; + int cont_signal; + bool click_events; bool clicked; char *buffer; |