diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/ipc.h | 3 | ||||
| -rw-r--r-- | include/loop.h | 54 | ||||
| -rw-r--r-- | include/sway/config.h | 4 | ||||
| -rw-r--r-- | include/sway/input/seat.h | 11 | ||||
| -rw-r--r-- | include/sway/ipc-server.h | 1 | ||||
| -rw-r--r-- | include/swaybar/bar.h | 40 | ||||
| -rw-r--r-- | include/swaybar/config.h | 5 | ||||
| -rw-r--r-- | include/swaybar/event_loop.h | 26 | ||||
| -rw-r--r-- | include/swaybar/i3bar.h | 2 | ||||
| -rw-r--r-- | include/swaybar/ipc.h | 4 | ||||
| -rw-r--r-- | include/swaybar/status_line.h | 5 | ||||
| -rw-r--r-- | include/swaylock/swaylock.h | 4 | 
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 {  	IPC_EVENT_BINDING = ((1<<31) | 5),  	IPC_EVENT_SHUTDOWN = ((1<<31) | 6),  	IPC_EVENT_TICK = ((1<<31) | 7), + +	// sway-specific event types +	IPC_EVENT_BAR_STATE_UPDATE = ((1<<31) | 20),  };  #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 @@ +#ifndef _SWAY_LOOP_H +#define _SWAY_LOOP_H +#include <stdbool.h> + +/** + * This is an event loop system designed for sway clients, not sway itself. + * + * The loop consists of file descriptors and timers. Typically the Wayland + * display's file descriptor will be one of the fds in the loop. + */ + +struct loop; +struct loop_timer; + +/** + * Create an event loop. + */ +struct loop *loop_create(void); + +/** + * Destroy the event loop (eg. on program termination). + */ +void loop_destroy(struct loop *loop); + +/** + * Poll the event loop. This will block until one of the fds has data. + */ +void loop_poll(struct loop *loop); + +/** + * Add a file descriptor to the loop. + */ +void loop_add_fd(struct loop *loop, int fd, short mask, +		void (*func)(int fd, short mask, void *data), void *data); + +/** + * Add a timer to the loop. + * + * When the timer expires, the timer will be removed from the loop and freed. + */ +struct loop_timer *loop_add_timer(struct loop *loop, int ms, +		void (*callback)(void *data), void *data); + +/** + * Remove a file descriptor from the loop. + */ +bool loop_remove_fd(struct loop *loop, int fd); + +/** + * Remove a timer from the loop. + */ +bool loop_remove_timer(struct loop *loop, struct loop_timer *timer); + +#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 {  	 * In "show" mode, it will always be shown on top of the active workspace.  	 */  	char *hidden_state; +	bool visible_by_modifier; // only relevant in "hide" mode  	/**  	 * Id name used to identify the bar through IPC.  	 * @@ -389,7 +390,6 @@ struct sway_config {  	bool show_marks;  	bool tiling_drag; -	bool edge_gaps;  	bool smart_gaps;  	int gaps_inner;  	int gaps_outer; @@ -531,6 +531,8 @@ void free_sway_binding(struct sway_binding *sb);  void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); +void load_swaybar(struct bar_config *bar); +  void load_swaybars(void);  void 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 {  	bool has_focus;  	struct wl_list focus_stack; // list of containers in focus order +	struct sway_workspace *workspace;  	// If the focused layer is set, views cannot receive keyboard focus  	struct wlr_layer_surface_v1 *focused_layer; @@ -112,8 +113,16 @@ void seat_set_focus_container(struct sway_seat *seat,  void seat_set_focus_workspace(struct sway_seat *seat,  		struct sway_workspace *ws); +/** + * Manipulate the focus stack without triggering any other behaviour. + * + * This can be used to set focus_inactive by calling the function a second time + * with the real focus. + */ +void seat_set_raw_focus(struct sway_seat *seat, struct sway_node *node); +  void seat_set_focus_warp(struct sway_seat *seat, -		struct sway_node *node, bool warp, bool notify); +		struct sway_node *node, bool warp);  void seat_set_focus_surface(struct sway_seat *seat,  		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,  		struct sway_workspace *new, const char *change);  void ipc_event_window(struct sway_container *window, const char *change);  void ipc_event_barconfig_update(struct bar_config *bar); +void ipc_event_bar_state_update(struct bar_config *bar);  void ipc_event_mode(const char *mode, bool pango);  void ipc_event_shutdown(const char *reason);  void 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 @@  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; 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 {  };  struct swaylock_state { +	struct loop *eventloop; +	struct loop_timer *clear_indicator_timer; // clears the indicator +	struct loop_timer *clear_password_timer;  // clears the password buffer +	struct loop_timer *verify_password_timer;  	struct wl_display *display;  	struct wl_compositor *compositor;  	struct zwlr_layer_shell_v1 *layer_shell; | 
