aboutsummaryrefslogtreecommitdiff
path: root/include/sway
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-02-24 23:29:08 +0100
committerGitHub <noreply@github.com>2018-02-24 23:29:08 +0100
commit583c30dbe3e3249ec1b753fddbfa982db56dce31 (patch)
treece07d65ab79287280f1f5468e2e62eb5cbef4089 /include/sway
parentb28602aa7425cf435150e6008624429737e037d3 (diff)
parent1cca3965f395f624f698cc162946c6cbd6b10673 (diff)
Merge pull request #1585 from acrisci/focus-overhaul
focus overhaul
Diffstat (limited to 'include/sway')
-rw-r--r--include/sway/commands.h4
-rw-r--r--include/sway/container.h12
-rw-r--r--include/sway/input/input-manager.h5
-rw-r--r--include/sway/input/seat.h30
-rw-r--r--include/sway/layout.h20
-rw-r--r--include/sway/output.h1
-rw-r--r--include/sway/server.h6
-rw-r--r--include/sway/workspace.h10
8 files changed, 70 insertions, 18 deletions
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