diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ipc.h | 1 | ||||
-rw-r--r-- | include/list.h | 7 | ||||
-rw-r--r-- | include/readline.h | 10 | ||||
-rw-r--r-- | include/stringop.h | 8 | ||||
-rw-r--r-- | include/sway/commands.h | 22 | ||||
-rw-r--r-- | include/sway/config.h | 39 | ||||
-rw-r--r-- | include/sway/input/cursor.h | 37 | ||||
-rw-r--r-- | include/sway/input/input-manager.h | 10 | ||||
-rw-r--r-- | include/sway/input/seat.h | 88 | ||||
-rw-r--r-- | include/sway/output.h | 12 | ||||
-rw-r--r-- | include/sway/tree/container.h | 8 | ||||
-rw-r--r-- | include/sway/tree/view.h | 7 | ||||
-rw-r--r-- | include/swaybar/bar.h | 14 | ||||
-rw-r--r-- | include/swaybar/config.h | 18 | ||||
-rw-r--r-- | include/swaybar/i3bar.h | 3 | ||||
-rw-r--r-- | include/swaybar/input.h | 12 | ||||
-rw-r--r-- | include/swaybar/tray/host.h | 17 | ||||
-rw-r--r-- | include/swaybar/tray/icon.h | 52 | ||||
-rw-r--r-- | include/swaybar/tray/item.h | 49 | ||||
-rw-r--r-- | include/swaybar/tray/sni.h | 82 | ||||
-rw-r--r-- | include/swaybar/tray/tray.h | 40 | ||||
-rw-r--r-- | include/swaybar/tray/watcher.h | 18 | ||||
-rw-r--r-- | include/swaylock/swaylock.h | 5 | ||||
-rw-r--r-- | include/swaynag/swaynag.h | 1 |
24 files changed, 397 insertions, 163 deletions
diff --git a/include/ipc.h b/include/ipc.h index 9063b933..6063f69c 100644 --- a/include/ipc.h +++ b/include/ipc.h @@ -16,6 +16,7 @@ enum ipc_command_type { IPC_GET_BINDING_MODES = 8, IPC_GET_CONFIG = 9, IPC_SEND_TICK = 10, + IPC_SYNC = 11, // sway-specific command types IPC_GET_INPUTS = 100, diff --git a/include/list.h b/include/list.h index 03851a82..895f6cc0 100644 --- a/include/list.h +++ b/include/list.h @@ -9,7 +9,6 @@ typedef struct { list_t *create_list(void); void list_free(list_t *list); -void list_foreach(list_t *list, void (*callback)(void* item)); void list_add(list_t *list, void *item); void list_insert(list_t *list, int index, void *item); void list_del(list_t *list, int index); @@ -27,4 +26,10 @@ void list_stable_sort(list_t *list, int compare(const void *a, const void *b)); void list_swap(list_t *list, int src, int dest); // move item to end of list void list_move_to_end(list_t *list, void *item); + +/* Calls `free` for each item in the list, then frees the list. + * Do not use this to free lists of primitives or items that require more + * complicated deallocation code. + */ +void list_free_items_and_destroy(list_t *list); #endif diff --git a/include/readline.h b/include/readline.h deleted file mode 100644 index ee2eba5d..00000000 --- a/include/readline.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _SWAY_READLINE_H -#define _SWAY_READLINE_H - -#include <stdio.h> - -char *read_line(FILE *file); -char *peek_line(FILE *file, int line_offset, long *position); -char *read_line_buffer(FILE *file, char *string, size_t string_len); - -#endif diff --git a/include/stringop.h b/include/stringop.h index 919e605c..f7ca60a5 100644 --- a/include/stringop.h +++ b/include/stringop.h @@ -3,10 +3,7 @@ #include "list.h" -// array of whitespace characters to use for delims -extern const char whitespace[]; - -char *strip_whitespace(char *str); +void strip_whitespace(char *str); char *strip_comments(char *str); void strip_quotes(char *str); @@ -17,9 +14,8 @@ char *lenient_strncat(char *dest, const char *src, size_t len); // strcmp that also handles null pointers. int lenient_strcmp(char *a, char *b); -// Simply split a string with delims, free with `free_flat_list` +// Simply split a string with delims, free with `list_free_items_and_destroy` list_t *split_string(const char *str, const char *delims); -void free_flat_list(list_t *list); // Splits an argument string, keeping quotes intact char **split_args(const char *str, int *argc); diff --git a/include/sway/commands.h b/include/sway/commands.h index 32925369..5d45d78b 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -56,7 +56,7 @@ struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers, * all matching containers. Otherwise, it'll run on the `con` container. If * `con` is NULL then it'll run on the currently focused container. */ -struct cmd_results *execute_command(char *command, struct sway_seat *seat, +list_t *execute_command(char *command, struct sway_seat *seat, struct sway_container *con); /** * Parse and handles a command during config file loading. @@ -82,11 +82,11 @@ struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, c */ void free_cmd_results(struct cmd_results *results); /** - * Serializes cmd_results to a JSON string. + * Serializes a list of cmd_results to a JSON string. * * Free the JSON string later on. */ -char *cmd_results_to_json(struct cmd_results *results); +char *cmd_results_to_json(list_t *res_list); struct cmd_results *add_color(const char *name, char *buffer, const char *color); @@ -172,7 +172,11 @@ sway_cmd cmd_swaybg_command; sway_cmd cmd_swaynag_command; sway_cmd cmd_swap; sway_cmd cmd_tiling_drag; +sway_cmd cmd_tiling_drag_threshold; +sway_cmd cmd_title_align; sway_cmd cmd_title_format; +sway_cmd cmd_titlebar_border_thickness; +sway_cmd cmd_titlebar_padding; sway_cmd cmd_unmark; sway_cmd cmd_urgent; sway_cmd cmd_workspace; @@ -180,12 +184,12 @@ sway_cmd cmd_workspace_layout; sway_cmd cmd_ws_auto_back_and_forth; sway_cmd cmd_xwayland; -sway_cmd bar_cmd_activate_button; +sway_cmd bar_cmd_bindcode; sway_cmd bar_cmd_binding_mode_indicator; sway_cmd bar_cmd_bindsym; sway_cmd bar_cmd_colors; -sway_cmd bar_cmd_context_button; sway_cmd bar_cmd_font; +sway_cmd bar_cmd_gaps; sway_cmd bar_cmd_mode; sway_cmd bar_cmd_modifier; sway_cmd bar_cmd_output; @@ -194,12 +198,15 @@ sway_cmd bar_cmd_hidden_state; sway_cmd bar_cmd_icon_theme; sway_cmd bar_cmd_id; sway_cmd bar_cmd_position; -sway_cmd bar_cmd_secondary_button; sway_cmd bar_cmd_separator_symbol; sway_cmd bar_cmd_status_command; +sway_cmd bar_cmd_status_edge_padding; +sway_cmd bar_cmd_status_padding; sway_cmd bar_cmd_pango_markup; sway_cmd bar_cmd_strip_workspace_numbers; +sway_cmd bar_cmd_strip_workspace_name; sway_cmd bar_cmd_swaybar_command; +sway_cmd bar_cmd_tray_bindsym; sway_cmd bar_cmd_tray_output; sway_cmd bar_cmd_tray_padding; sway_cmd bar_cmd_wrap_scroll; @@ -255,8 +262,9 @@ sway_cmd output_cmd_scale; sway_cmd output_cmd_transform; sway_cmd seat_cmd_attach; -sway_cmd seat_cmd_fallback; sway_cmd seat_cmd_cursor; +sway_cmd seat_cmd_fallback; +sway_cmd seat_cmd_hide_cursor; sway_cmd cmd_ipc_cmd; sway_cmd cmd_ipc_events; diff --git a/include/sway/config.h b/include/sway/config.h index c44533ee..96fe899b 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -6,6 +6,7 @@ #include <time.h> #include <wlr/types/wlr_box.h> #include <xkbcommon/xkbcommon.h> +#include "../include/config.h" #include "list.h" #include "swaynag.h" #include "tree/container.h" @@ -26,7 +27,8 @@ struct sway_variable { enum binding_input_type { BINDING_KEYCODE, BINDING_KEYSYM, - BINDING_MOUSE, + BINDING_MOUSECODE, + BINDING_MOUSESYM, }; enum binding_flags { @@ -140,6 +142,7 @@ struct seat_config { char *name; int fallback; // -1 means not set list_t *attachments; // list of seat_attachment configs + int hide_cursor_timeout; }; enum config_dpms { @@ -224,9 +227,13 @@ struct bar_config { bool wrap_scroll; char *separator_symbol; bool strip_workspace_numbers; + bool strip_workspace_name; bool binding_mode_indicator; bool verbose; + struct side_gaps gaps; pid_t pid; + int status_padding; + int status_edge_padding; struct { char *background; char *statusline; @@ -250,6 +257,13 @@ struct bar_config { char *binding_mode_bg; char *binding_mode_text; } colors; + +#if HAVE_TRAY + char *icon_theme; + const char *tray_bindings[10]; // mouse buttons 0-9 + list_t *tray_outputs; // char * + int tray_padding; +#endif }; struct bar_binding { @@ -356,6 +370,12 @@ enum mouse_warping_mode { WARP_CONTAINER }; +enum alignment { + ALIGN_LEFT, + ALIGN_CENTER, + ALIGN_RIGHT +}; + /** * The configuration struct. The result of loading a config file. */ @@ -390,6 +410,9 @@ struct sway_config { size_t font_height; size_t font_baseline; bool pango_markup; + int titlebar_border_thickness; + int titlebar_h_padding; + int titlebar_v_padding; size_t urgent_timeout; enum sway_fowa focus_on_window_activation; enum sway_popup_during_fullscreen popup_during_fullscreen; @@ -406,7 +429,10 @@ struct sway_config { bool validating; bool auto_back_and_forth; bool show_marks; + enum alignment title_align; + bool tiling_drag; + int tiling_drag_threshold; bool smart_gaps; int gaps_inner; @@ -415,6 +441,8 @@ struct sway_config { list_t *config_chain; const char *current_config_path; const char *current_config; + int current_config_line_number; + char *current_config_line; enum sway_container_border border; enum sway_container_border floating_border; @@ -480,6 +508,11 @@ bool read_config(FILE *file, struct sway_config *config, struct swaynag_instance *swaynag); /** + * Adds a warning entry to the swaynag instance used for errors. + */ +void config_add_swaynag_warning(char *fmt, ...); + +/** * Free config struct */ void free_config(struct sway_config *config); @@ -516,7 +549,7 @@ struct seat_attachment_config *seat_attachment_config_new(void); struct seat_attachment_config *seat_config_get_attachment( struct seat_config *seat_config, char *identifier); -void apply_seat_config(struct seat_config *seat); +struct seat_config *store_seat_config(struct seat_config *seat); int output_name_cmp(const void *item, const void *data); @@ -535,8 +568,6 @@ void apply_output_config_to_outputs(struct output_config *oc); void free_output_config(struct output_config *oc); -void create_default_output_configs(void); - int workspace_output_cmp_workspace(const void *a, const void *b); int sway_binding_cmp(const void *a, const void *b); diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 50ac453b..77aa0ea1 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h @@ -1,10 +1,17 @@ #ifndef _SWAY_INPUT_CURSOR_H #define _SWAY_INPUT_CURSOR_H +#include <stdbool.h> #include <stdint.h> +#include <wlr/types/wlr_surface.h> #include "sway/input/seat.h" #define SWAY_CURSOR_PRESSED_BUTTONS_CAP 32 +#define SWAY_SCROLL_UP KEY_MAX + 1 +#define SWAY_SCROLL_DOWN KEY_MAX + 2 +#define SWAY_SCROLL_LEFT KEY_MAX + 3 +#define SWAY_SCROLL_RIGHT KEY_MAX + 4 + struct sway_cursor { struct sway_seat *seat; struct wlr_cursor *cursor; @@ -16,6 +23,8 @@ struct sway_cursor { const char *image; struct wl_client *image_client; + struct wlr_surface *image_surface; + int hotspot_x, hotspot_y; struct wl_listener motion; struct wl_listener motion_absolute; @@ -33,11 +42,20 @@ struct sway_cursor { struct wl_listener request_set_cursor; + struct wl_event_source *hide_source; + bool hidden; + // Mouse binding state uint32_t pressed_buttons[SWAY_CURSOR_PRESSED_BUTTONS_CAP]; size_t pressed_button_count; }; +struct sway_node; + +struct sway_node *node_at_coords( + struct sway_seat *seat, double lx, double ly, + struct wlr_surface **surface, double *sx, double *sy); + void sway_cursor_destroy(struct sway_cursor *cursor); struct sway_cursor *sway_cursor_create(struct sway_seat *seat); @@ -48,6 +66,10 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat); */ void cursor_rebase(struct sway_cursor *cursor); +void cursor_handle_activity(struct sway_cursor *cursor); +void cursor_unhide(struct sway_cursor *cursor); +int cursor_get_timeout(struct sway_cursor *cursor); + /** * Like cursor_rebase, but also allows focus to change when the cursor enters a * new container. @@ -58,12 +80,27 @@ void dispatch_cursor_button(struct sway_cursor *cursor, struct wlr_input_device *device, uint32_t time_msec, uint32_t button, enum wlr_button_state state); +void dispatch_cursor_axis(struct sway_cursor *cursor, + struct wlr_event_pointer_axis *event); + void cursor_set_image(struct sway_cursor *cursor, const char *image, struct wl_client *client); +void cursor_set_image_surface(struct sway_cursor *cursor, + struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y, + struct wl_client *client); + void cursor_warp_to_container(struct sway_cursor *cursor, struct sway_container *container); void cursor_warp_to_workspace(struct sway_cursor *cursor, struct sway_workspace *workspace); + +uint32_t get_mouse_bindsym(const char *name, char **error); + +uint32_t get_mouse_bindcode(const char *name, char **error); + +// Considers both bindsym and bindcode +uint32_t get_mouse_button(const char *name, char **error); + #endif diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 219aa9ba..8e8bf1f2 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -37,6 +37,10 @@ void input_manager_configure_xcursor(void); void input_manager_apply_input_config(struct input_config *input_config); +void input_manager_reset_input(struct sway_input_device *input_device); + +void input_manager_reset_all_inputs(); + void input_manager_apply_seat_config(struct seat_config *seat_config); struct sway_seat *input_manager_get_default_seat(void); @@ -44,6 +48,12 @@ struct sway_seat *input_manager_get_default_seat(void); struct sway_seat *input_manager_get_seat(const char *seat_name); /** + * If none of the seat configs have a fallback setting (either true or false), + * create the default seat (if needed) and set it as the fallback + */ +void input_manager_verify_fallback_seat(void); + +/** * Gets the last seat the user interacted with */ struct sway_seat *input_manager_current_seat(void); diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index bef2af77..d2f14895 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -6,6 +6,17 @@ #include <wlr/util/edges.h> #include "sway/input/input-manager.h" +struct sway_seat; + +struct sway_seatop_impl { + void (*motion)(struct sway_seat *seat, uint32_t time_msec); + void (*finish)(struct sway_seat *seat); + void (*abort)(struct sway_seat *seat); + void (*unref)(struct sway_seat *seat, struct sway_container *con); + void (*render)(struct sway_seat *seat, struct sway_output *output, + pixman_region32_t *damage); +}; + struct sway_seat_device { struct sway_seat *sway_seat; struct sway_input_device *input_device; @@ -35,15 +46,6 @@ struct sway_drag_icon { struct wl_listener destroy; }; -enum sway_seat_operation { - OP_NONE, - OP_DOWN, - OP_MOVE_FLOATING, - OP_MOVE_TILING, - OP_RESIZE_FLOATING, - OP_RESIZE_TILING, -}; - struct sway_seat { struct wlr_seat *wlr_seat; struct sway_cursor *cursor; @@ -63,19 +65,10 @@ struct sway_seat { int32_t touch_id; double touch_x, touch_y; - // Operations (drag and resize) - enum sway_seat_operation operation; - struct sway_container *op_container; - struct sway_node *op_target_node; // target for tiling move - enum wlr_edges op_target_edge; - struct wlr_box op_drop_box; - enum wlr_edges op_resize_edge; - uint32_t op_button; - bool op_resize_preserve_ratio; - double op_ref_lx, op_ref_ly; // cursor's x/y at start of op - double op_ref_width, op_ref_height; // container's size at start of op - double op_ref_con_lx, op_ref_con_ly; // container's x/y at start of op - bool op_moved; // if the mouse moved during a down op + // Seat operations (drag and resize) + const struct sway_seatop_impl *seatop_impl; + void *seatop_data; + uint32_t seatop_button; uint32_t last_button; uint32_t last_button_serial; @@ -99,6 +92,9 @@ void seat_add_device(struct sway_seat *seat, void seat_configure_device(struct sway_seat *seat, struct sway_input_device *device); +void seat_reset_device(struct sway_seat *seat, + struct sway_input_device *input_device); + void seat_remove_device(struct sway_seat *seat, struct sway_input_device *device); @@ -174,33 +170,65 @@ void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config); struct seat_config *seat_get_config(struct sway_seat *seat); +struct seat_config *seat_get_config_by_name(const char *name); + bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); void drag_icon_update_position(struct sway_drag_icon *icon); -void seat_begin_down(struct sway_seat *seat, struct sway_container *con, - uint32_t button, double sx, double sy); +void seatop_begin_down(struct sway_seat *seat, + struct sway_container *con, uint32_t button, int sx, int sy); -void seat_begin_move_floating(struct sway_seat *seat, +void seatop_begin_move_floating(struct sway_seat *seat, struct sway_container *con, uint32_t button); -void seat_begin_move_tiling(struct sway_seat *seat, +void seatop_begin_move_tiling_threshold(struct sway_seat *seat, struct sway_container *con, uint32_t button); -void seat_begin_resize_floating(struct sway_seat *seat, +void seatop_begin_move_tiling(struct sway_seat *seat, + struct sway_container *con, uint32_t button); + +void seatop_begin_resize_floating(struct sway_seat *seat, struct sway_container *con, uint32_t button, enum wlr_edges edge); -void seat_begin_resize_tiling(struct sway_seat *seat, +void seatop_begin_resize_tiling(struct sway_seat *seat, struct sway_container *con, uint32_t button, enum wlr_edges edge); struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat, struct sway_workspace *workspace); -void seat_end_mouse_operation(struct sway_seat *seat); - void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, uint32_t button, enum wlr_button_state state); void seat_consider_warp_to_focus(struct sway_seat *seat); +bool seat_doing_seatop(struct sway_seat *seat); + +void seatop_motion(struct sway_seat *seat, uint32_t time_msec); + +/** + * End a seatop and apply the affects. + */ +void seatop_finish(struct sway_seat *seat); + +/** + * End a seatop without applying the affects. + */ +void seatop_abort(struct sway_seat *seat); + +/** + * Instructs the seatop implementation to drop any references to the given + * container (eg. because the container is destroying). + * The seatop may choose to abort itself in response to this. + */ +void seatop_unref(struct sway_seat *seat, struct sway_container *con); + +/** + * Instructs a seatop to render anything that it needs to render + * (eg. dropzone for move-tiling) + */ +void seatop_render(struct sway_seat *seat, struct sway_output *output, + pixman_region32_t *damage); + + #endif diff --git a/include/sway/output.h b/include/sway/output.h index 43c1ab96..bdf9614d 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -84,9 +84,7 @@ void output_damage_box(struct sway_output *output, struct wlr_box *box); void output_damage_whole_container(struct sway_output *output, struct sway_container *con); -struct sway_output *output_by_name(const char *name); - -struct sway_output *output_by_identifier(const char *identifier); +struct sway_output *output_by_name_or_id(const char *name_or_id); void output_sort_workspaces(struct sway_output *output); @@ -148,4 +146,12 @@ enum sway_container_layout output_get_default_layout( void output_add_listeners(struct sway_output *output); +void render_rect(struct wlr_output *wlr_output, + pixman_region32_t *output_damage, const struct wlr_box *_box, + float color[static 4]); + +void premultiply_alpha(float color[4], float opacity); + +void scale_box(struct wlr_box *box, float scale); + #endif diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index f907aad2..9a432cb2 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -10,12 +10,6 @@ struct sway_view; struct sway_seat; -#define TITLEBAR_BORDER_THICKNESS 1 - -// Padding includes titlebar border -#define TITLEBAR_H_PADDING 3 -#define TITLEBAR_V_PADDING 4 - enum sway_container_layout { L_NONE, L_HORIZ, @@ -339,4 +333,6 @@ void container_add_mark(struct sway_container *container, char *mark); void container_update_marks_textures(struct sway_container *container); +void container_raise_floating(struct sway_container *con); + #endif diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 4716c688..5cc9777b 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -195,6 +195,7 @@ struct sway_view_child { struct sway_view *view; struct wlr_surface *surface; + bool mapped; struct wl_listener surface_commit; struct wl_listener surface_new_subsurface; @@ -203,6 +204,12 @@ struct sway_view_child { struct wl_listener surface_destroy; }; +struct sway_subsurface { + struct sway_view_child child; + + struct wl_listener destroy; +}; + struct sway_xdg_popup_v6 { struct sway_view_child child; diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 95b20510..2d9ba0d9 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -1,6 +1,7 @@ #ifndef _SWAYBAR_BAR_H #define _SWAYBAR_BAR_H #include <wayland-client.h> +#include "config.h" #include "input.h" #include "pool-buffer.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" @@ -8,6 +9,9 @@ struct swaybar_config; struct swaybar_output; +#if HAVE_TRAY +struct swaybar_tray; +#endif struct swaybar_workspace; struct loop; @@ -38,6 +42,10 @@ struct swaybar { int ipc_socketfd; struct wl_list outputs; // swaybar_output::link + +#if HAVE_TRAY + struct swaybar_tray *tray; +#endif }; struct swaybar_output { @@ -53,6 +61,7 @@ struct swaybar_output { struct wl_list hotspots; // swaybar_hotspot::link char *name; + char *identifier; bool focused; uint32_t width, height; @@ -62,12 +71,15 @@ struct swaybar_output { struct pool_buffer *current_buffer; bool dirty; bool frame_scheduled; + + uint32_t output_height, output_width, output_x, output_y; }; struct swaybar_workspace { struct wl_list link; // swaybar_output::workspaces int num; char *name; + char *label; bool focused; bool visible; bool urgent; @@ -77,6 +89,8 @@ bool bar_setup(struct swaybar *bar, const char *socket_path); void bar_run(struct swaybar *bar); void bar_teardown(struct swaybar *bar); +void set_bar_dirty(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, diff --git a/include/swaybar/config.h b/include/swaybar/config.h index 5d40790a..add0a1cf 100644 --- a/include/swaybar/config.h +++ b/include/swaybar/config.h @@ -3,6 +3,7 @@ #include <stdbool.h> #include <stdint.h> #include <wayland-client.h> +#include "../include/config.h" #include "list.h" #include "util.h" @@ -34,6 +35,7 @@ struct swaybar_config { char *hidden_state; char *modifier; bool strip_workspace_numbers; + bool strip_workspace_name; bool binding_mode_indicator; bool wrap_scroll; bool workspace_buttons; @@ -41,6 +43,14 @@ struct swaybar_config { struct wl_list outputs; // config_output::link bool all_outputs; int height; + int status_padding; + int status_edge_padding; + struct { + int top; + int right; + int bottom; + int left; + } gaps; struct { uint32_t background; @@ -57,6 +67,14 @@ struct swaybar_config { struct box_colors urgent_workspace; struct box_colors binding_mode; } colors; + +#if HAVE_TRAY + char *icon_theme; + char *tray_bindings[10]; // mouse buttons 0-9 + bool tray_hidden; + list_t *tray_outputs; // char * + int tray_padding; +#endif }; struct swaybar_config *init_config(void); diff --git a/include/swaybar/i3bar.h b/include/swaybar/i3bar.h index 3f1ecc25..aa4415ff 100644 --- a/include/swaybar/i3bar.h +++ b/include/swaybar/i3bar.h @@ -27,6 +27,7 @@ struct i3bar_block { void i3bar_block_unref(struct i3bar_block *block); bool i3bar_handle_readable(struct status_line *status); enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, - struct i3bar_block *block, int x, int y, enum x11_button button); + struct i3bar_block *block, int x, int y, int rx, int ry, int w, int h, + uint32_t button); #endif diff --git a/include/swaybar/input.h b/include/swaybar/input.h index a552e7ac..4b46b0de 100644 --- a/include/swaybar/input.h +++ b/include/swaybar/input.h @@ -4,6 +4,12 @@ #include <wayland-client.h> #include "list.h" +#define SWAY_SCROLL_UP KEY_MAX + 1 +#define SWAY_SCROLL_DOWN KEY_MAX + 2 +#define SWAY_SCROLL_LEFT KEY_MAX + 3 +#define SWAY_SCROLL_RIGHT KEY_MAX + 4 + +struct swaybar; struct swaybar_output; struct swaybar_pointer { @@ -13,6 +19,7 @@ struct swaybar_pointer { struct wl_surface *cursor_surface; struct swaybar_output *current; int x, y; + uint32_t serial; }; enum x11_button { @@ -37,13 +44,16 @@ struct swaybar_hotspot { 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); + struct swaybar_hotspot *hotspot, int x, int y, uint32_t button, + void *data); void (*destroy)(void *data); void *data; }; extern const struct wl_seat_listener seat_listener; +void update_cursor(struct swaybar *bar); + void free_hotspots(struct wl_list *list); #endif diff --git a/include/swaybar/tray/host.h b/include/swaybar/tray/host.h new file mode 100644 index 00000000..2d4cf82b --- /dev/null +++ b/include/swaybar/tray/host.h @@ -0,0 +1,17 @@ +#ifndef _SWAYBAR_TRAY_HOST_H +#define _SWAYBAR_TRAY_HOST_H + +#include <stdbool.h> + +struct swaybar_tray; + +struct swaybar_host { + struct swaybar_tray *tray; + char *service; + char *watcher_interface; +}; + +bool init_host(struct swaybar_host *host, char *protocol, struct swaybar_tray *tray); +void finish_host(struct swaybar_host *host); + +#endif diff --git a/include/swaybar/tray/icon.h b/include/swaybar/tray/icon.h index 1cc6ff9c..7a6c400c 100644 --- a/include/swaybar/tray/icon.h +++ b/include/swaybar/tray/icon.h @@ -1,16 +1,44 @@ -#ifndef _SWAYBAR_ICON_H -#define _SWAYBAR_ICON_H +#ifndef _SWAYBAR_TRAY_ICON_H +#define _SWAYBAR_TRAY_ICON_H -#include <stdint.h> -#include <stdbool.h> -#include <client/cairo.h> +#include "list.h" -/** - * Returns the image found by `name` that is closest to `size` - */ -cairo_surface_t *find_icon(const char *name, int size); +enum subdir_type { + THRESHOLD, + SCALABLE, + FIXED +}; + +struct icon_theme_subdir { + char *name; + int size; + enum subdir_type type; + int max_size; + int min_size; + int threshold; +}; + +struct icon_theme { + char *name; + char *comment; + char *inherits; + list_t *directories; // char * -/* Struct used internally only */ -struct subdir; + char *dir; + list_t *subdirs; // struct icon_theme_subdir * +}; + +void init_themes(list_t **themes, list_t **basedirs); +void finish_themes(list_t *themes, list_t *basedirs); + +/* + * Finds an icon of a specified size given a list of themes and base directories. + * If the icon is found, the pointers min_size & max_size are set to minimum & + * maximum size that the icon can be scaled to, respectively. + * Returns: path of icon (which should be freed), or NULL if the icon is not found. + */ +char *find_icon(list_t *themes, list_t *basedirs, char *name, int size, + char *theme, int *min_size, int *max_size); +char *find_icon_in_dir(char *name, char *dir, int *min_size, int *max_size); -#endif /* _SWAYBAR_ICON_H */ +#endif diff --git a/include/swaybar/tray/item.h b/include/swaybar/tray/item.h new file mode 100644 index 00000000..4238bdb8 --- /dev/null +++ b/include/swaybar/tray/item.h @@ -0,0 +1,49 @@ +#ifndef _SWAYBAR_TRAY_ITEM_H +#define _SWAYBAR_TRAY_ITEM_H + +#include <cairo.h> +#include <stdbool.h> +#include <stdint.h> +#include "swaybar/tray/tray.h" +#include "list.h" + +struct swaybar_output; + +struct swaybar_pixmap { + int size; + unsigned char pixels[]; +}; + +struct swaybar_sni { + // icon properties + struct swaybar_tray *tray; + cairo_surface_t *icon; + int min_size; + int max_size; + + // dbus properties + char *watcher_id; + char *service; + char *path; + char *interface; + + char *status; + char *icon_name; + list_t *icon_pixmap; // struct swaybar_pixmap * + char *attention_icon_name; + list_t *attention_icon_pixmap; // struct swaybar_pixmap * + bool item_is_menu; + char *menu; + char *icon_theme_path; // non-standard KDE property + + sd_bus_slot *new_icon_slot; + sd_bus_slot *new_attention_icon_slot; + sd_bus_slot *new_status_slot; +}; + +struct swaybar_sni *create_sni(char *id, struct swaybar_tray *tray); +void destroy_sni(struct swaybar_sni *sni); +uint32_t render_sni(cairo_t *cairo, struct swaybar_output *output, double *x, + struct swaybar_sni *sni); + +#endif diff --git a/include/swaybar/tray/sni.h b/include/swaybar/tray/sni.h deleted file mode 100644 index c2544e2a..00000000 --- a/include/swaybar/tray/sni.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef _SWAYBAR_SNI_H -#define _SWAYBAR_SNI_H - -#include <stdbool.h> -#include <client/cairo.h> - -struct StatusNotifierItem { - /* Name registered to sni watcher */ - char *name; - /* Unique bus name, needed for determining signal origins */ - char *unique_name; - bool kde_special_snowflake; - - cairo_surface_t *image; - bool dirty; -}; - -/* Each output holds an sni_icon_ref of each item to render */ -struct sni_icon_ref { - cairo_surface_t *icon; - struct StatusNotifierItem *ref; -}; - -struct sni_icon_ref *sni_icon_ref_create(struct StatusNotifierItem *item, - int height); - -void sni_icon_ref_free(struct sni_icon_ref *sni_ref); - -/** - * Will return a new item and get its icon. (see warning below) - * May return `NULL` if `name` is not valid. - */ -struct StatusNotifierItem *sni_create(const char *name); - -/** - * `item` must be a struct StatusNotifierItem * - * `str` must be a NUL terminated char * - * - * Returns 0 if `item` has a name of `str` - */ -int sni_str_cmp(const void *item, const void *str); - -/** - * Returns 0 if `item` has a unique name of `str` or if - * `item->unique_name == NULL` - */ -int sni_uniq_cmp(const void *item, const void *str); - -/** - * Gets an icon for the given item if found. - * - * XXX - * This function keeps a reference to the item until it gets responses, make - * sure that the reference and item are valid during this time. - */ -void get_icon(struct StatusNotifierItem *item); - -/** - * Calls the "activate" method on the given StatusNotifierItem - * - * x and y should be where the item was clicked - */ -void sni_activate(struct StatusNotifierItem *item, uint32_t x, uint32_t y); - -/** - * Asks the item to draw a context menu at the given x and y coords - */ -void sni_context_menu(struct StatusNotifierItem *item, uint32_t x, uint32_t y); - -/** - * Calls the "secondary activate" method on the given StatusNotifierItem - * - * x and y should be where the item was clicked - */ -void sni_secondary(struct StatusNotifierItem *item, uint32_t x, uint32_t y); - -/** - * Deconstructs `item` - */ -void sni_free(struct StatusNotifierItem *item); - -#endif /* _SWAYBAR_SNI_H */ diff --git a/include/swaybar/tray/tray.h b/include/swaybar/tray/tray.h new file mode 100644 index 00000000..8958b69a --- /dev/null +++ b/include/swaybar/tray/tray.h @@ -0,0 +1,40 @@ +#ifndef _SWAYBAR_TRAY_TRAY_H +#define _SWAYBAR_TRAY_TRAY_H + +#include "config.h" +#ifdef HAVE_SYSTEMD +#include <systemd/sd-bus.h> +#elif HAVE_ELOGIND +#include <elogind/sd-bus.h> +#endif +#include <cairo.h> +#include <stdint.h> +#include "swaybar/tray/host.h" +#include "list.h" + +struct swaybar; +struct swaybar_output; +struct swaybar_watcher; + +struct swaybar_tray { + struct swaybar *bar; + + int fd; + sd_bus *bus; + + struct swaybar_host host_xdg; + struct swaybar_host host_kde; + list_t *items; // struct swaybar_sni * + struct swaybar_watcher *watcher_xdg; + struct swaybar_watcher *watcher_kde; + + list_t *basedirs; // char * + list_t *themes; // struct swaybar_theme * +}; + +struct swaybar_tray *create_tray(struct swaybar *bar); +void destroy_tray(struct swaybar_tray *tray); +void tray_in(int fd, short mask, void *data); +uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x); + +#endif diff --git a/include/swaybar/tray/watcher.h b/include/swaybar/tray/watcher.h new file mode 100644 index 00000000..8f276da8 --- /dev/null +++ b/include/swaybar/tray/watcher.h @@ -0,0 +1,18 @@ +#ifndef _SWAYBAR_TRAY_WATCHER_H +#define _SWAYBAR_TRAY_WATCHER_H + +#include "swaybar/tray/tray.h" +#include "list.h" + +struct swaybar_watcher { + char *interface; + sd_bus *bus; + list_t *hosts; + list_t *items; + int version; +}; + +struct swaybar_watcher *create_watcher(char *protocol, sd_bus *bus); +void destroy_watcher(struct swaybar_watcher *watcher); + +#endif diff --git a/include/swaylock/swaylock.h b/include/swaylock/swaylock.h index 18af7ab4..516a56f4 100644 --- a/include/swaylock/swaylock.h +++ b/include/swaylock/swaylock.h @@ -22,6 +22,7 @@ enum auth_state { struct swaylock_colorset { uint32_t input; uint32_t cleared; + uint32_t caps_lock; uint32_t verifying; uint32_t wrong; }; @@ -30,6 +31,8 @@ struct swaylock_colors { uint32_t background; uint32_t bs_highlight; uint32_t key_highlight; + uint32_t caps_lock_bs_highlight; + uint32_t caps_lock_key_highlight; uint32_t separator; struct swaylock_colorset inside; struct swaylock_colorset line; @@ -45,6 +48,8 @@ struct swaylock_args { uint32_t thickness; bool ignore_empty; bool show_indicator; + bool show_caps_lock_text; + bool show_caps_lock_indicator; bool daemonize; }; diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h index a32d1503..0fd1eb50 100644 --- a/include/swaynag/swaynag.h +++ b/include/swaynag/swaynag.h @@ -44,6 +44,7 @@ struct swaynag_button { int y; int width; int height; + bool terminal; }; struct swaynag_details { |