diff options
Diffstat (limited to 'include/swaybar/bar.h')
-rw-r--r-- | include/swaybar/bar.h | 110 |
1 files changed, 60 insertions, 50 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 50d36e76..0037190b 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h | |||
@@ -1,36 +1,71 @@ | |||
1 | #ifndef _SWAYBAR_BAR_H | 1 | #ifndef _SWAYBAR_BAR_H |
2 | #define _SWAYBAR_BAR_H | 2 | #define _SWAYBAR_BAR_H |
3 | #include <wayland-client.h> | ||
4 | #include "pool-buffer.h" | ||
3 | 5 | ||
4 | #include "client/registry.h" | 6 | struct swaybar_config; |
5 | #include "client/window.h" | 7 | struct swaybar_output; |
6 | #include "list.h" | 8 | struct swaybar_workspace; |
7 | 9 | ||
8 | struct bar { | 10 | struct swaybar_pointer { |
9 | struct config *config; | 11 | struct wl_pointer *pointer; |
12 | struct wl_cursor_theme *cursor_theme; | ||
13 | struct wl_cursor_image *cursor_image; | ||
14 | struct wl_surface *cursor_surface; | ||
15 | struct swaybar_output *current; | ||
16 | int x, y; | ||
17 | }; | ||
18 | |||
19 | struct swaybar_hotspot { | ||
20 | struct wl_list link; | ||
21 | int x, y, width, height; | ||
22 | void (*callback)(struct swaybar_output *output, | ||
23 | int x, int y, uint32_t button, void *data); | ||
24 | void (*destroy)(void *data); | ||
25 | void *data; | ||
26 | }; | ||
27 | |||
28 | struct swaybar { | ||
29 | struct wl_display *display; | ||
30 | struct wl_compositor *compositor; | ||
31 | struct zwlr_layer_shell_v1 *layer_shell; | ||
32 | struct wl_shm *shm; | ||
33 | struct wl_seat *seat; | ||
34 | |||
35 | struct swaybar_config *config; | ||
36 | struct swaybar_output *focused_output; | ||
37 | struct swaybar_pointer pointer; | ||
10 | struct status_line *status; | 38 | struct status_line *status; |
11 | list_t *outputs; | ||
12 | struct output *focused_output; | ||
13 | 39 | ||
14 | int ipc_event_socketfd; | 40 | int ipc_event_socketfd; |
15 | int ipc_socketfd; | 41 | int ipc_socketfd; |
16 | int status_read_fd; | 42 | |
17 | int status_write_fd; | 43 | struct wl_list outputs; |
18 | pid_t status_command_pid; | ||
19 | }; | 44 | }; |
20 | 45 | ||
21 | struct output { | 46 | struct swaybar_output { |
22 | struct window *window; | 47 | struct wl_list link; |
23 | struct registry *registry; | 48 | struct swaybar *bar; |
24 | list_t *workspaces; | 49 | struct wl_output *output; |
25 | #ifdef ENABLE_TRAY | 50 | struct wl_surface *surface; |
26 | list_t *items; | 51 | struct zwlr_layer_surface_v1 *layer_surface; |
27 | #endif | 52 | uint32_t wl_name; |
53 | |||
54 | struct wl_list workspaces; | ||
55 | struct wl_list hotspots; | ||
56 | |||
28 | char *name; | 57 | char *name; |
29 | int idx; | 58 | size_t index; |
30 | bool focused; | 59 | bool focused; |
60 | |||
61 | uint32_t width, height; | ||
62 | int32_t scale; | ||
63 | struct pool_buffer buffers[2]; | ||
64 | struct pool_buffer *current_buffer; | ||
31 | }; | 65 | }; |
32 | 66 | ||
33 | struct workspace { | 67 | struct swaybar_workspace { |
68 | struct wl_list link; | ||
34 | int num; | 69 | int num; |
35 | char *name; | 70 | char *name; |
36 | bool focused; | 71 | bool focused; |
@@ -38,35 +73,10 @@ struct workspace { | |||
38 | bool urgent; | 73 | bool urgent; |
39 | }; | 74 | }; |
40 | 75 | ||
41 | /** Global bar state */ | 76 | void bar_setup(struct swaybar *bar, |
42 | extern struct bar swaybar; | 77 | const char *socket_path, |
43 | 78 | const char *bar_id); | |
44 | /** True if sway needs to render */ | 79 | void bar_run(struct swaybar *bar); |
45 | extern bool dirty; | 80 | void bar_teardown(struct swaybar *bar); |
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 | 81 | ||
57 | /** | 82 | #endif |
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 */ | ||