aboutsummaryrefslogtreecommitdiffstats
path: root/include/swaybar
diff options
context:
space:
mode:
Diffstat (limited to 'include/swaybar')
-rw-r--r--include/swaybar/bar.h89
-rw-r--r--include/swaybar/config.h43
-rw-r--r--include/swaybar/event_loop.h4
-rw-r--r--include/swaybar/ipc.h22
-rw-r--r--include/swaybar/render.h22
5 files changed, 48 insertions, 132 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h
index 50d36e76..3ae8c0b3 100644
--- a/include/swaybar/bar.h
+++ b/include/swaybar/bar.h
@@ -1,72 +1,45 @@
1#ifndef _SWAYBAR_BAR_H 1#ifndef _SWAYBAR_BAR_H
2#define _SWAYBAR_BAR_H 2#define _SWAYBAR_BAR_H
3 3#include <wayland-client.h>
4#include "client/registry.h" 4#include "pool-buffer.h"
5#include "client/window.h"
6#include "list.h" 5#include "list.h"
7 6
8struct bar { 7struct swaybar_config;
9 struct config *config; 8struct swaybar_output;
10 struct status_line *status; 9struct swaybar_workspace;
11 list_t *outputs; 10
12 struct output *focused_output; 11struct swaybar {
12 struct wl_display *display;
13 struct wl_compositor *compositor;
14 struct zwlr_layer_shell_v1 *layer_shell;
15 struct wl_shm *shm;
13 16
14 int ipc_event_socketfd; 17 struct swaybar_config *config;
15 int ipc_socketfd; 18 struct swaybar_output *focused_output;
16 int status_read_fd; 19
17 int status_write_fd; 20 struct wl_list outputs;
18 pid_t status_command_pid;
19}; 21};
20 22
21struct output { 23struct swaybar_output {
22 struct window *window; 24 struct wl_list link;
23 struct registry *registry; 25 struct swaybar *bar;
24 list_t *workspaces; 26 struct wl_output *output;
25#ifdef ENABLE_TRAY 27 struct wl_surface *surface;
26 list_t *items; 28 struct zwlr_layer_surface_v1 *layer_surface;
27#endif 29
28 char *name; 30 char *name;
29 int idx; 31 int idx;
30 bool focused; 32 bool focused;
31};
32 33
33struct workspace { 34 uint32_t width, height;
34 int num; 35 struct pool_buffer buffers[2];
35 char *name; 36 struct pool_buffer *current_buffer;
36 bool focused;
37 bool visible;
38 bool urgent;
39}; 37};
40 38
41/** Global bar state */ 39void bar_setup(struct swaybar *bar,
42extern struct bar swaybar; 40 const char *socket_path,
41 const char *bar_id);
42void bar_run(struct swaybar *bar);
43void bar_teardown(struct swaybar *bar);
43 44
44/** True if sway needs to render */ 45#endif
45extern bool dirty;
46
47/**
48 * Setup bar.
49 */
50void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id);
51
52/**
53 * Create new output struct from name.
54 */
55struct output *new_output(const char *name);
56
57/**
58 * Bar mainloop.
59 */
60void bar_run(struct bar *bar);
61
62/**
63 * free workspace list.
64 */
65void free_workspaces(list_t *workspaces);
66
67/**
68 * Teardown bar.
69 */
70void bar_teardown(struct bar *bar);
71
72#endif /* _SWAYBAR_BAR_H */
diff --git a/include/swaybar/config.h b/include/swaybar/config.h
index 651f0ee3..1bfe4843 100644
--- a/include/swaybar/config.h
+++ b/include/swaybar/config.h
@@ -1,9 +1,7 @@
1#ifndef _SWAYBAR_CONFIG_H 1#ifndef _SWAYBAR_CONFIG_H
2#define _SWAYBAR_CONFIG_H 2#define _SWAYBAR_CONFIG_H
3
4#include <stdint.h>
5#include <stdbool.h> 3#include <stdbool.h>
6 4#include <stdint.h>
7#include "list.h" 5#include "list.h"
8#include "util.h" 6#include "util.h"
9 7
@@ -19,10 +17,10 @@ struct box_colors {
19/** 17/**
20 * Swaybar config. 18 * Swaybar config.
21 */ 19 */
22struct config { 20struct swaybar_config {
23 char *status_command; 21 char *status_command;
24 bool pango_markup; 22 bool pango_markup;
25 uint32_t position; 23 uint32_t position; // zwlr_layer_surface_v1_anchor
26 char *font; 24 char *font;
27 char *sep_symbol; 25 char *sep_symbol;
28 char *mode; 26 char *mode;
@@ -32,18 +30,6 @@ struct config {
32 bool workspace_buttons; 30 bool workspace_buttons;
33 bool all_outputs; 31 bool all_outputs;
34 list_t *outputs; 32 list_t *outputs;
35
36#ifdef ENABLE_TRAY
37 // Tray
38 char *tray_output;
39 char *icon_theme;
40
41 uint32_t tray_padding;
42 uint32_t activate_button;
43 uint32_t context_button;
44 uint32_t secondary_button;
45#endif
46
47 int height; 33 int height;
48 34
49 struct { 35 struct {
@@ -63,24 +49,7 @@ struct config {
63 } colors; 49 } colors;
64}; 50};
65 51
66/** 52struct swaybar_config *init_config();
67 * Parse position top|bottom|left|right. 53void free_config(struct swaybar_config *config);
68 */
69uint32_t parse_position(const char *position);
70
71/**
72 * Parse font.
73 */
74char *parse_font(const char *font);
75
76/**
77 * Initialize default sway config.
78 */
79struct config *init_config();
80
81/**
82 * Free config struct.
83 */
84void free_config(struct config *config);
85 54
86#endif /* _SWAYBAR_CONFIG_H */ 55#endif
diff --git a/include/swaybar/event_loop.h b/include/swaybar/event_loop.h
index a0cde07f..99f6ed36 100644
--- a/include/swaybar/event_loop.h
+++ b/include/swaybar/event_loop.h
@@ -1,6 +1,5 @@
1#ifndef _SWAYBAR_EVENT_LOOP_H 1#ifndef _SWAYBAR_EVENT_LOOP_H
2#define _SWAYBAR_EVENT_LOOP_H 2#define _SWAYBAR_EVENT_LOOP_H
3
4#include <stdbool.h> 3#include <stdbool.h>
5#include <time.h> 4#include <time.h>
6 5
@@ -23,4 +22,5 @@ bool remove_timer(timer_t timer);
23void event_loop_poll(); 22void event_loop_poll();
24 23
25void init_event_loop(); 24void init_event_loop();
26#endif /*_SWAYBAR_EVENT_LOOP_H */ 25
26#endif
diff --git a/include/swaybar/ipc.h b/include/swaybar/ipc.h
index c11931d0..57a1b925 100644
--- a/include/swaybar/ipc.h
+++ b/include/swaybar/ipc.h
@@ -1,23 +1,9 @@
1#ifndef _SWAYBAR_IPC_H 1#ifndef _SWAYBAR_IPC_H
2#define _SWAYBAR_IPC_H 2#define _SWAYBAR_IPC_H
3#include "swaybar/bar.h"
3 4
4#include "bar.h" 5void ipc_bar_init(struct swaybar *bar, const char *bar_id);
5 6bool handle_ipc_event(struct swaybar *bar);
6/**
7 * Initialize ipc connection to sway and get sway state, outputs, bar_config.
8 */
9void ipc_bar_init(struct bar *bar, const char *bar_id);
10
11/**
12 * Handle ipc event from sway.
13 */
14bool handle_ipc_event(struct bar *bar);
15
16
17/**
18 * Send workspace command to sway
19 */
20void ipc_send_workspace_command(const char *workspace_name); 7void ipc_send_workspace_command(const char *workspace_name);
21 8
22#endif /* _SWAYBAR_IPC_H */ 9#endif
23
diff --git a/include/swaybar/render.h b/include/swaybar/render.h
index 114f43f4..071e2298 100644
--- a/include/swaybar/render.h
+++ b/include/swaybar/render.h
@@ -1,22 +1,10 @@
1#ifndef _SWAYBAR_RENDER_H 1#ifndef _SWAYBAR_RENDER_H
2#define _SWAYBAR_RENDER_H 2#define _SWAYBAR_RENDER_H
3 3
4#include "config.h" 4struct swaybar;
5#include "bar.h" 5struct swaybar_output;
6struct swaybar_config;
6 7
7/** 8void render_frame(struct swaybar *bar, struct swaybar_output *output);
8 * Render swaybar.
9 */
10void render(struct output *output, struct config *config, struct status_line *line);
11 9
12/** 10#endif
13 * Set window height and modify internal spacing accordingly.
14 */
15void set_window_height(struct window *window, int height);
16
17/**
18 * Compute the size of a workspace name
19 */
20void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height);
21
22#endif /* _SWAYBAR_RENDER_H */