diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/log.h | 4 | ||||
-rw-r--r-- | include/sway/commands.h | 4 | ||||
-rw-r--r-- | include/sway/container.h | 12 | ||||
-rw-r--r-- | include/sway/input/input-manager.h | 5 | ||||
-rw-r--r-- | include/sway/input/seat.h | 30 | ||||
-rw-r--r-- | include/sway/layout.h | 20 | ||||
-rw-r--r-- | include/sway/output.h | 1 | ||||
-rw-r--r-- | include/sway/server.h | 6 | ||||
-rw-r--r-- | include/sway/workspace.h | 10 |
9 files changed, 72 insertions, 20 deletions
diff --git a/include/log.h b/include/log.h index 350a59ef..a9748127 100644 --- a/include/log.h +++ b/include/log.h @@ -5,11 +5,11 @@ void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2); #define sway_abort(FMT, ...) \ - _sway_abort("[%s:%d] " FMT, _strip_path(__FILE__), __LINE__, ##__VA_ARGS__) + _sway_abort("[%s:%d] " FMT, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3); #define sway_assert(COND, FMT, ...) \ - _sway_assert(COND, "[%s:%d] %s:" FMT, _strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__) + _sway_assert(COND, "[%s:%d] %s:" FMT, wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__) void error_handler(int sig); diff --git a/include/sway/commands.h b/include/sway/commands.h index 4ee7af2a..9ff18823 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -46,9 +46,9 @@ struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val); /** - * Parse and handles a command. + * Parse and executes a command. */ -struct cmd_results *handle_command(char *command); +struct cmd_results *execute_command(char *command, struct sway_seat *seat); /** * Parse and handles a command during config file loading. * diff --git a/include/sway/container.h b/include/sway/container.h index 0c66932d..f200a1a2 100644 --- a/include/sway/container.h +++ b/include/sway/container.h @@ -106,10 +106,6 @@ struct sway_container { * The parent of this container. NULL for the root container. */ struct sway_container *parent; - /** - * Which of this container's children has focus. - */ - struct sway_container *focused; /** * Number of master views in auto layouts. @@ -162,4 +158,12 @@ void container_map(swayc_t *container, swayc_t *swayc_at(swayc_t *parent, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy); +/** + * Apply the function for each child of the container breadth first. + */ +void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data), + void *data); + +swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout); + #endif diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 66ace262..eab7dc90 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -16,14 +16,15 @@ struct sway_input_device { struct wlr_input_device *wlr_device; struct input_config *config; struct wl_list link; + struct wl_listener device_destroy; }; struct sway_input_manager { - struct wl_listener input_add; - struct wl_listener input_remove; struct sway_server *server; struct wl_list devices; struct wl_list seats; + + struct wl_listener new_input; }; struct sway_input_manager *sway_input_manager_create( diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index b21cbccb..1d55bec7 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -12,14 +12,26 @@ struct sway_seat_device { struct wl_list link; // sway_seat::devices }; +struct sway_seat_container { + struct sway_seat *seat; + swayc_t *container; + + struct wl_list link; // sway_seat::focus_stack + + struct wl_listener destroy; +}; + struct sway_seat { struct wlr_seat *wlr_seat; struct seat_config *config; struct sway_cursor *cursor; struct sway_input_manager *input; - swayc_t *focus; + + bool has_focus; + struct wl_list focus_stack; // list of containers in focus order struct wl_listener focus_destroy; + struct wl_listener new_container; struct wl_list devices; // sway_seat_device::link @@ -44,6 +56,22 @@ void sway_seat_configure_xcursor(struct sway_seat *seat); void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container); +swayc_t *sway_seat_get_focus(struct sway_seat *seat); + +/** + * Return the last container to be focused for the seat (or the most recently + * opened if no container has received focused) that is a child of the given + * container. The focus-inactive container of the root window is the focused + * container for the seat (if the seat does have focus). This function can be + * used to determine what container gets focused next if the focused container + * is destroyed, or focus moves to a container with children and we need to + * descend into the next leaf in focus order. + */ +swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container); + +swayc_t *sway_seat_get_focus_by_type(struct sway_seat *seat, + enum swayc_types type); + void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); #endif diff --git a/include/sway/layout.h b/include/sway/layout.h index af561453..e82c4442 100644 --- a/include/sway/layout.h +++ b/include/sway/layout.h @@ -2,6 +2,19 @@ #define _SWAY_LAYOUT_H #include <wlr/types/wlr_output_layout.h> +#include "sway/container.h" + +enum movement_direction { + MOVE_LEFT, + MOVE_RIGHT, + MOVE_UP, + MOVE_DOWN, + MOVE_PARENT, + MOVE_CHILD, + MOVE_NEXT, + MOVE_PREV, + MOVE_FIRST +}; struct sway_container; @@ -11,13 +24,20 @@ struct sway_root { struct wl_listener output_layout_change; struct wl_list unmanaged_views; // sway_view::unmanaged_view_link + + struct { + struct wl_signal new_container; + } events; }; void init_layout(void); void add_child(struct sway_container *parent, struct sway_container *child); +swayc_t *add_sibling(swayc_t *parent, swayc_t *child); struct sway_container *remove_child(struct sway_container *child); enum swayc_layouts default_layout(struct sway_container *output); void sort_workspaces(struct sway_container *output); void arrange_windows(struct sway_container *container, double width, double height); +swayc_t *get_swayc_in_direction(swayc_t *container, + struct sway_seat *seat, enum movement_direction dir); #endif diff --git a/include/sway/output.h b/include/sway/output.h index 7ca02d7b..95d64705 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -14,6 +14,7 @@ struct sway_output { struct timespec last_frame; struct wl_listener frame; + struct wl_listener output_destroy; }; #endif diff --git a/include/sway/server.h b/include/sway/server.h index d497e132..3fcdb1ba 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -24,8 +24,7 @@ struct sway_server { struct sway_input_manager *input; - struct wl_listener output_add; - struct wl_listener output_remove; + struct wl_listener new_output; struct wl_listener output_frame; struct wlr_xdg_shell_v6 *xdg_shell_v6; @@ -45,8 +44,7 @@ bool server_init(struct sway_server *server); void server_fini(struct sway_server *server); void server_run(struct sway_server *server); -void output_add_notify(struct wl_listener *listener, void *data); -void output_remove_notify(struct wl_listener *listener, void *data); +void handle_new_output(struct wl_listener *listener, void *data); void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); void handle_xwayland_surface(struct wl_listener *listener, void *data); diff --git a/include/sway/workspace.h b/include/sway/workspace.h index 30bbdaa8..fee54255 100644 --- a/include/sway/workspace.h +++ b/include/sway/workspace.h @@ -1,7 +1,7 @@ #ifndef _SWAY_WORKSPACE_H #define _SWAY_WORKSPACE_H -struct sway_container; +#include "sway/container.h" extern char *prev_workspace_name; @@ -12,9 +12,9 @@ bool workspace_switch(swayc_t *workspace); struct sway_container *workspace_by_number(const char* name); swayc_t *workspace_by_name(const char*); -struct sway_container *workspace_output_next(struct sway_container *current); -struct sway_container *workspace_next(struct sway_container *current); -struct sway_container *workspace_output_prev(struct sway_container *current); -struct sway_container *workspace_prev(struct sway_container *current); +struct sway_container *workspace_output_next(swayc_t *current); +struct sway_container *workspace_next(swayc_t *current); +struct sway_container *workspace_output_prev(swayc_t *current); +struct sway_container *workspace_prev(swayc_t *current); #endif |