aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ipc.h3
-rw-r--r--include/loop.h54
-rw-r--r--include/sway/config.h4
-rw-r--r--include/sway/input/seat.h11
-rw-r--r--include/sway/ipc-server.h1
-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
-rw-r--r--include/swaylock/swaylock.h4
12 files changed, 119 insertions, 40 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 {
30 IPC_EVENT_BINDING = ((1<<31) | 5), 30 IPC_EVENT_BINDING = ((1<<31) | 5),
31 IPC_EVENT_SHUTDOWN = ((1<<31) | 6), 31 IPC_EVENT_SHUTDOWN = ((1<<31) | 6),
32 IPC_EVENT_TICK = ((1<<31) | 7), 32 IPC_EVENT_TICK = ((1<<31) | 7),
33
34 // sway-specific event types
35 IPC_EVENT_BAR_STATE_UPDATE = ((1<<31) | 20),
33}; 36};
34 37
35#endif 38#endif
diff --git a/include/loop.h b/include/loop.h
new file mode 100644
index 00000000..2f608eda
--- /dev/null
+++ b/include/loop.h
@@ -0,0 +1,54 @@
1#ifndef _SWAY_LOOP_H
2#define _SWAY_LOOP_H
3#include <stdbool.h>
4
5/**
6 * This is an event loop system designed for sway clients, not sway itself.
7 *
8 * The loop consists of file descriptors and timers. Typically the Wayland
9 * display's file descriptor will be one of the fds in the loop.
10 */
11
12struct loop;
13struct loop_timer;
14
15/**
16 * Create an event loop.
17 */
18struct loop *loop_create(void);
19
20/**
21 * Destroy the event loop (eg. on program termination).
22 */
23void loop_destroy(struct loop *loop);
24
25/**
26 * Poll the event loop. This will block until one of the fds has data.
27 */
28void loop_poll(struct loop *loop);
29
30/**
31 * Add a file descriptor to the loop.
32 */
33void loop_add_fd(struct loop *loop, int fd, short mask,
34 void (*func)(int fd, short mask, void *data), void *data);
35
36/**
37 * Add a timer to the loop.
38 *
39 * When the timer expires, the timer will be removed from the loop and freed.
40 */
41struct loop_timer *loop_add_timer(struct loop *loop, int ms,
42 void (*callback)(void *data), void *data);
43
44/**
45 * Remove a file descriptor from the loop.
46 */
47bool loop_remove_fd(struct loop *loop, int fd);
48
49/**
50 * Remove a timer from the loop.
51 */
52bool loop_remove_timer(struct loop *loop, struct loop_timer *timer);
53
54#endif
diff --git a/include/sway/config.h b/include/sway/config.h
index bc02c0fd..be5a00b5 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -191,6 +191,7 @@ struct bar_config {
191 * In "show" mode, it will always be shown on top of the active workspace. 191 * In "show" mode, it will always be shown on top of the active workspace.
192 */ 192 */
193 char *hidden_state; 193 char *hidden_state;
194 bool visible_by_modifier; // only relevant in "hide" mode
194 /** 195 /**
195 * Id name used to identify the bar through IPC. 196 * Id name used to identify the bar through IPC.
196 * 197 *
@@ -389,7 +390,6 @@ struct sway_config {
389 bool show_marks; 390 bool show_marks;
390 bool tiling_drag; 391 bool tiling_drag;
391 392
392 bool edge_gaps;
393 bool smart_gaps; 393 bool smart_gaps;
394 int gaps_inner; 394 int gaps_inner;
395 int gaps_outer; 395 int gaps_outer;
@@ -531,6 +531,8 @@ void free_sway_binding(struct sway_binding *sb);
531 531
532void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); 532void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding);
533 533
534void load_swaybar(struct bar_config *bar);
535
534void load_swaybars(void); 536void load_swaybars(void);
535 537
536void terminate_swaybg(pid_t pid); 538void terminate_swaybg(pid_t pid);
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index ebb0cd43..be95567e 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -51,6 +51,7 @@ struct sway_seat {
51 51
52 bool has_focus; 52 bool has_focus;
53 struct wl_list focus_stack; // list of containers in focus order 53 struct wl_list focus_stack; // list of containers in focus order
54 struct sway_workspace *workspace;
54 55
55 // If the focused layer is set, views cannot receive keyboard focus 56 // If the focused layer is set, views cannot receive keyboard focus
56 struct wlr_layer_surface_v1 *focused_layer; 57 struct wlr_layer_surface_v1 *focused_layer;
@@ -112,8 +113,16 @@ void seat_set_focus_container(struct sway_seat *seat,
112void seat_set_focus_workspace(struct sway_seat *seat, 113void seat_set_focus_workspace(struct sway_seat *seat,
113 struct sway_workspace *ws); 114 struct sway_workspace *ws);
114 115
116/**
117 * Manipulate the focus stack without triggering any other behaviour.
118 *
119 * This can be used to set focus_inactive by calling the function a second time
120 * with the real focus.
121 */
122void seat_set_raw_focus(struct sway_seat *seat, struct sway_node *node);
123
115void seat_set_focus_warp(struct sway_seat *seat, 124void seat_set_focus_warp(struct sway_seat *seat,
116 struct sway_node *node, bool warp, bool notify); 125 struct sway_node *node, bool warp);
117 126
118void seat_set_focus_surface(struct sway_seat *seat, 127void seat_set_focus_surface(struct sway_seat *seat,
119 struct wlr_surface *surface, bool unfocus); 128 struct wlr_surface *surface, bool unfocus);
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,
15 struct sway_workspace *new, const char *change); 15 struct sway_workspace *new, const char *change);
16void ipc_event_window(struct sway_container *window, const char *change); 16void ipc_event_window(struct sway_container *window, const char *change);
17void ipc_event_barconfig_update(struct bar_config *bar); 17void ipc_event_barconfig_update(struct bar_config *bar);
18void ipc_event_bar_state_update(struct bar_config *bar);
18void ipc_event_mode(const char *mode, bool pango); 19void ipc_event_mode(const char *mode, bool pango);
19void ipc_event_shutdown(const char *reason); 20void ipc_event_shutdown(const char *reason);
20void ipc_event_binding(struct sway_binding *binding); 21void ipc_event_binding(struct sway_binding *binding);
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 @@
8struct swaybar_config; 8struct swaybar_config;
9struct swaybar_output; 9struct swaybar_output;
10struct swaybar_workspace; 10struct swaybar_workspace;
11struct loop;
11 12
12struct swaybar_pointer { 13struct swaybar_pointer {
13 struct wl_pointer *pointer; 14 struct wl_pointer *pointer;
@@ -37,7 +38,7 @@ enum hotspot_event_handling {
37}; 38};
38 39
39struct swaybar_hotspot { 40struct swaybar_hotspot {
40 struct wl_list link; 41 struct wl_list link; // swaybar_output::hotspots
41 int x, y, width, height; 42 int x, y, width, height;
42 enum hotspot_event_handling (*callback)(struct swaybar_output *output, 43 enum hotspot_event_handling (*callback)(struct swaybar_output *output,
43 int x, int y, enum x11_button button, void *data); 44 int x, int y, enum x11_button button, void *data);
@@ -46,6 +47,15 @@ struct swaybar_hotspot {
46}; 47};
47 48
48struct swaybar { 49struct swaybar {
50 char *id;
51 char *mode;
52 bool mode_pango_markup;
53
54 // only relevant when bar is in "hide" mode
55 bool visible_by_modifier;
56 bool visible_by_urgency;
57 bool visible;
58
49 struct wl_display *display; 59 struct wl_display *display;
50 struct wl_compositor *compositor; 60 struct wl_compositor *compositor;
51 struct zwlr_layer_shell_v1 *layer_shell; 61 struct zwlr_layer_shell_v1 *layer_shell;
@@ -57,14 +67,16 @@ struct swaybar {
57 struct swaybar_pointer pointer; 67 struct swaybar_pointer pointer;
58 struct status_line *status; 68 struct status_line *status;
59 69
70 struct loop *eventloop;
71
60 int ipc_event_socketfd; 72 int ipc_event_socketfd;
61 int ipc_socketfd; 73 int ipc_socketfd;
62 74
63 struct wl_list outputs; 75 struct wl_list outputs; // swaybar_output::link
64}; 76};
65 77
66struct swaybar_output { 78struct swaybar_output {
67 struct wl_list link; 79 struct wl_list link; // swaybar::outputs
68 struct swaybar *bar; 80 struct swaybar *bar;
69 struct wl_output *output; 81 struct wl_output *output;
70 struct zxdg_output_v1 *xdg_output; 82 struct zxdg_output_v1 *xdg_output;
@@ -72,8 +84,8 @@ struct swaybar_output {
72 struct zwlr_layer_surface_v1 *layer_surface; 84 struct zwlr_layer_surface_v1 *layer_surface;
73 uint32_t wl_name; 85 uint32_t wl_name;
74 86
75 struct wl_list workspaces; 87 struct wl_list workspaces; // swaybar_workspace::link
76 struct wl_list hotspots; 88 struct wl_list hotspots; // swaybar_hotspot::link
77 89
78 char *name; 90 char *name;
79 bool focused; 91 bool focused;
@@ -88,7 +100,7 @@ struct swaybar_output {
88}; 100};
89 101
90struct swaybar_workspace { 102struct swaybar_workspace {
91 struct wl_list link; 103 struct wl_list link; // swaybar_output::workspaces
92 int num; 104 int num;
93 char *name; 105 char *name;
94 bool focused; 106 bool focused;
@@ -96,10 +108,24 @@ struct swaybar_workspace {
96 bool urgent; 108 bool urgent;
97}; 109};
98 110
99bool bar_setup(struct swaybar *bar, const char *socket_path, const char *bar_id); 111bool bar_setup(struct swaybar *bar, const char *socket_path);
100void bar_run(struct swaybar *bar); 112void bar_run(struct swaybar *bar);
101void bar_teardown(struct swaybar *bar); 113void bar_teardown(struct swaybar *bar);
102 114
115/*
116 * Determines whether the bar should be visible and changes it to be so.
117 * If the current visibility of the bar is the different to what it should be,
118 * then it adds or destroys the layer surface as required,
119 * as well as sending the cont or stop signal to the status command.
120 * If the current visibility of the bar is already what it should be,
121 * then this function is a no-op, unless moving_layer is true, which occurs
122 * when the bar changes from "hide" to "dock" mode or vice versa, and the bar
123 * needs to be destroyed and re-added in order to change its layer.
124 *
125 * Returns true if the bar is now visible, otherwise false.
126 */
127bool determine_bar_visibility(struct swaybar *bar, bool moving_layer);
128void free_hotspots(struct wl_list *list);
103void free_workspaces(struct wl_list *list); 129void free_workspaces(struct wl_list *list);
104 130
105#endif 131#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 {
13}; 13};
14 14
15struct config_output { 15struct config_output {
16 struct wl_list link; 16 struct wl_list link; // swaybar_config::outputs
17 char *name; 17 char *name;
18 size_t index; 18 size_t index;
19}; 19};
@@ -31,7 +31,8 @@ struct swaybar_config {
31 char *font; 31 char *font;
32 char *sep_symbol; 32 char *sep_symbol;
33 char *mode; 33 char *mode;
34 bool mode_pango_markup; 34 char *hidden_state;
35 char *modifier;
35 bool strip_workspace_numbers; 36 bool strip_workspace_numbers;
36 bool binding_mode_indicator; 37 bool binding_mode_indicator;
37 bool wrap_scroll; 38 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 @@
1#ifndef _SWAYBAR_EVENT_LOOP_H
2#define _SWAYBAR_EVENT_LOOP_H
3#include <stdbool.h>
4#include <time.h>
5
6void add_event(int fd, short mask,
7 void(*cb)(int fd, short mask, void *data),
8 void *data);
9
10// Not guaranteed to notify cb immediately
11void add_timer(timer_t timer,
12 void(*cb)(timer_t timer, void *data),
13 void *data);
14
15// Returns false if nothing exists, true otherwise
16bool remove_event(int fd);
17
18// Returns false if nothing exists, true otherwise
19bool remove_timer(timer_t timer);
20
21// Blocks and returns after sending callbacks
22void event_loop_poll(void);
23
24void init_event_loop(void);
25
26#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 @@
5#include "status_line.h" 5#include "status_line.h"
6 6
7struct i3bar_block { 7struct i3bar_block {
8 struct wl_list link; 8 struct wl_list link; // status_link::blocks
9 int ref_count; 9 int ref_count;
10 char *full_text, *short_text, *align; 10 char *full_text, *short_text, *align;
11 bool urgent; 11 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 @@
3#include <stdbool.h> 3#include <stdbool.h>
4#include "swaybar/bar.h" 4#include "swaybar/bar.h"
5 5
6bool ipc_initialize(struct swaybar *bar, const char *bar_id); 6bool ipc_initialize(struct swaybar *bar);
7bool handle_ipc_readable(struct swaybar *bar); 7bool handle_ipc_readable(struct swaybar *bar);
8void ipc_get_workspaces(struct swaybar *bar); 8bool ipc_get_workspaces(struct swaybar *bar);
9void ipc_send_workspace_command(struct swaybar *bar, const char *ws); 9void ipc_send_workspace_command(struct swaybar *bar, const char *ws);
10void ipc_execute_binding(struct swaybar *bar, struct swaybar_binding *bind); 10void ipc_execute_binding(struct swaybar *bar, struct swaybar_binding *bind);
11 11
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 {
14}; 14};
15 15
16struct status_line { 16struct status_line {
17 struct swaybar *bar;
18
17 pid_t pid; 19 pid_t pid;
18 int read_fd, write_fd; 20 int read_fd, write_fd;
19 FILE *read, *write; 21 FILE *read, *write;
@@ -22,6 +24,9 @@ struct status_line {
22 const char *text; 24 const char *text;
23 struct wl_list blocks; // i3bar_block::link 25 struct wl_list blocks; // i3bar_block::link
24 26
27 int stop_signal;
28 int cont_signal;
29
25 bool click_events; 30 bool click_events;
26 bool clicked; 31 bool clicked;
27 char *buffer; 32 char *buffer;
diff --git a/include/swaylock/swaylock.h b/include/swaylock/swaylock.h
index fbdd42a8..25b41a71 100644
--- a/include/swaylock/swaylock.h
+++ b/include/swaylock/swaylock.h
@@ -54,6 +54,10 @@ struct swaylock_password {
54}; 54};
55 55
56struct swaylock_state { 56struct swaylock_state {
57 struct loop *eventloop;
58 struct loop_timer *clear_indicator_timer; // clears the indicator
59 struct loop_timer *clear_password_timer; // clears the password buffer
60 struct loop_timer *verify_password_timer;
57 struct wl_display *display; 61 struct wl_display *display;
58 struct wl_compositor *compositor; 62 struct wl_compositor *compositor;
59 struct zwlr_layer_shell_v1 *layer_shell; 63 struct zwlr_layer_shell_v1 *layer_shell;