aboutsummaryrefslogtreecommitdiff
path: root/include/swaybar
diff options
context:
space:
mode:
Diffstat (limited to 'include/swaybar')
-rw-r--r--include/swaybar/bar.h40
-rw-r--r--include/swaybar/config.h5
-rw-r--r--include/swaybar/event_loop.h26
-rw-r--r--include/swaybar/i3bar.h2
-rw-r--r--include/swaybar/ipc.h4
-rw-r--r--include/swaybar/status_line.h5
6 files changed, 44 insertions, 38 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h
index de234111..58e2dee6 100644
--- a/include/swaybar/bar.h
+++ b/include/swaybar/bar.h
@@ -8,6 +8,7 @@
struct swaybar_config;
struct swaybar_output;
struct swaybar_workspace;
+struct loop;
struct swaybar_pointer {
struct wl_pointer *pointer;
@@ -37,7 +38,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 +47,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;
@@ -57,14 +67,16 @@ struct swaybar {
struct swaybar_pointer pointer;
struct status_line *status;
+ struct loop *eventloop;
+
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 +84,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 +100,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 +108,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/event_loop.h b/include/swaybar/event_loop.h
deleted file mode 100644
index 47be5b79..00000000
--- a/include/swaybar/event_loop.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _SWAYBAR_EVENT_LOOP_H
-#define _SWAYBAR_EVENT_LOOP_H
-#include <stdbool.h>
-#include <time.h>
-
-void add_event(int fd, short mask,
- void(*cb)(int fd, short mask, void *data),
- void *data);
-
-// Not guaranteed to notify cb immediately
-void add_timer(timer_t timer,
- void(*cb)(timer_t timer, void *data),
- void *data);
-
-// Returns false if nothing exists, true otherwise
-bool remove_event(int fd);
-
-// Returns false if nothing exists, true otherwise
-bool remove_timer(timer_t timer);
-
-// Blocks and returns after sending callbacks
-void event_loop_poll(void);
-
-void init_event_loop(void);
-
-#endif
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..957a808e 100644
--- a/include/swaybar/status_line.h
+++ b/include/swaybar/status_line.h
@@ -14,6 +14,8 @@ enum status_protocol {
};
struct status_line {
+ struct swaybar *bar;
+
pid_t pid;
int read_fd, write_fd;
FILE *read, *write;
@@ -22,6 +24,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;