diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/pango.h | 16 | ||||
-rw-r--r-- | include/sway/config.h | 7 | ||||
-rw-r--r-- | include/swaybar/bar.h | 89 | ||||
-rw-r--r-- | include/swaybar/config.h | 43 | ||||
-rw-r--r-- | include/swaybar/event_loop.h | 4 | ||||
-rw-r--r-- | include/swaybar/ipc.h | 22 | ||||
-rw-r--r-- | include/swaybar/render.h | 22 |
7 files changed, 67 insertions, 136 deletions
diff --git a/include/pango.h b/include/pango.h new file mode 100644 index 00000000..f6325f28 --- /dev/null +++ b/include/pango.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _SWAY_PANGO_H | ||
2 | #define _SWAY_PANGO_H | ||
3 | #include <stdarg.h> | ||
4 | #include <stdbool.h> | ||
5 | #include <stdint.h> | ||
6 | #include <cairo/cairo.h> | ||
7 | #include <pango/pangocairo.h> | ||
8 | |||
9 | PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, | ||
10 | const char *text, int32_t scale, bool markup); | ||
11 | void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, | ||
12 | int32_t scale, bool markup, const char *fmt, ...); | ||
13 | void pango_printf(cairo_t *cairo, const char *font, | ||
14 | int32_t scale, bool markup, const char *fmt, ...); | ||
15 | |||
16 | #endif | ||
diff --git a/include/sway/config.h b/include/sway/config.h index 48a8b0ab..8c9e04de 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -1,17 +1,16 @@ | |||
1 | #ifndef _SWAY_CONFIG_H | 1 | #ifndef _SWAY_CONFIG_H |
2 | #define _SWAY_CONFIG_H | 2 | #define _SWAY_CONFIG_H |
3 | |||
4 | #define PID_WORKSPACE_TIMEOUT 60 | 3 | #define PID_WORKSPACE_TIMEOUT 60 |
5 | |||
6 | #include <libinput.h> | 4 | #include <libinput.h> |
7 | #include <stdint.h> | 5 | #include <stdint.h> |
8 | #include <string.h> | 6 | #include <string.h> |
7 | #include <time.h> | ||
9 | #include <wlr/types/wlr_box.h> | 8 | #include <wlr/types/wlr_box.h> |
10 | #include <xkbcommon/xkbcommon.h> | 9 | #include <xkbcommon/xkbcommon.h> |
11 | #include <time.h> | ||
12 | #include "list.h" | 10 | #include "list.h" |
13 | #include "layout.h" | 11 | #include "layout.h" |
14 | #include "container.h" | 12 | #include "container.h" |
13 | #include "wlr-layer-shell-unstable-v1-protocol.h" | ||
15 | 14 | ||
16 | /** | 15 | /** |
17 | * Describes a variable created via the `set` command. | 16 | * Describes a variable created via the `set` command. |
@@ -152,7 +151,7 @@ struct bar_config { | |||
152 | char *id; | 151 | char *id; |
153 | uint32_t modifier; | 152 | uint32_t modifier; |
154 | list_t *outputs; | 153 | list_t *outputs; |
155 | //enum desktop_shell_panel_position position; // TODO | 154 | char *position; |
156 | list_t *bindings; | 155 | list_t *bindings; |
157 | char *status_command; | 156 | char *status_command; |
158 | bool pango_markup; | 157 | bool pango_markup; |
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 | ||
8 | struct bar { | 7 | struct swaybar_config; |
9 | struct config *config; | 8 | struct swaybar_output; |
10 | struct status_line *status; | 9 | struct swaybar_workspace; |
11 | list_t *outputs; | 10 | |
12 | struct output *focused_output; | 11 | struct 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 | ||
21 | struct output { | 23 | struct 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 | ||
33 | struct 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 */ | 39 | void bar_setup(struct swaybar *bar, |
42 | extern struct bar swaybar; | 40 | const char *socket_path, |
41 | const char *bar_id); | ||
42 | void bar_run(struct swaybar *bar); | ||
43 | void bar_teardown(struct swaybar *bar); | ||
43 | 44 | ||
44 | /** True if sway needs to render */ | 45 | #endif |
45 | extern bool dirty; | ||
46 | |||
47 | /** | ||
48 | * Setup bar. | ||
49 | */ | ||
50 | void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id); | ||
51 | |||
52 | /** | ||
53 | * Create new output struct from name. | ||
54 | */ | ||
55 | struct output *new_output(const char *name); | ||
56 | |||
57 | /** | ||
58 | * Bar mainloop. | ||
59 | */ | ||
60 | void bar_run(struct bar *bar); | ||
61 | |||
62 | /** | ||
63 | * free workspace list. | ||
64 | */ | ||
65 | void free_workspaces(list_t *workspaces); | ||
66 | |||
67 | /** | ||
68 | * Teardown bar. | ||
69 | */ | ||
70 | void 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 | */ |
22 | struct config { | 20 | struct 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 | /** | 52 | struct swaybar_config *init_config(); |
67 | * Parse position top|bottom|left|right. | 53 | void free_config(struct swaybar_config *config); |
68 | */ | ||
69 | uint32_t parse_position(const char *position); | ||
70 | |||
71 | /** | ||
72 | * Parse font. | ||
73 | */ | ||
74 | char *parse_font(const char *font); | ||
75 | |||
76 | /** | ||
77 | * Initialize default sway config. | ||
78 | */ | ||
79 | struct config *init_config(); | ||
80 | |||
81 | /** | ||
82 | * Free config struct. | ||
83 | */ | ||
84 | void 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); | |||
23 | void event_loop_poll(); | 22 | void event_loop_poll(); |
24 | 23 | ||
25 | void init_event_loop(); | 24 | void 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" | 5 | void ipc_bar_init(struct swaybar *bar, const char *bar_id); |
5 | 6 | bool handle_ipc_event(struct swaybar *bar); | |
6 | /** | ||
7 | * Initialize ipc connection to sway and get sway state, outputs, bar_config. | ||
8 | */ | ||
9 | void ipc_bar_init(struct bar *bar, const char *bar_id); | ||
10 | |||
11 | /** | ||
12 | * Handle ipc event from sway. | ||
13 | */ | ||
14 | bool handle_ipc_event(struct bar *bar); | ||
15 | |||
16 | |||
17 | /** | ||
18 | * Send workspace command to sway | ||
19 | */ | ||
20 | void ipc_send_workspace_command(const char *workspace_name); | 7 | void 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" | 4 | struct swaybar; |
5 | #include "bar.h" | 5 | struct swaybar_output; |
6 | struct swaybar_config; | ||
6 | 7 | ||
7 | /** | 8 | void render_frame(struct swaybar *bar, struct swaybar_output *output); |
8 | * Render swaybar. | ||
9 | */ | ||
10 | void 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 | */ | ||
15 | void set_window_height(struct window *window, int height); | ||
16 | |||
17 | /** | ||
18 | * Compute the size of a workspace name | ||
19 | */ | ||
20 | void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height); | ||
21 | |||
22 | #endif /* _SWAYBAR_RENDER_H */ | ||