aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-02-24 23:29:08 +0100
committerLibravatar GitHub <noreply@github.com>2018-02-24 23:29:08 +0100
commit583c30dbe3e3249ec1b753fddbfa982db56dce31 (patch)
treece07d65ab79287280f1f5468e2e62eb5cbef4089 /include
parentImplement workspaces (diff)
parentstatic bfs queue (diff)
downloadsway-583c30dbe3e3249ec1b753fddbfa982db56dce31.tar.gz
sway-583c30dbe3e3249ec1b753fddbfa982db56dce31.tar.zst
sway-583c30dbe3e3249ec1b753fddbfa982db56dce31.zip
Merge pull request #1585 from acrisci/focus-overhaul
focus overhaul
Diffstat (limited to 'include')
-rw-r--r--include/log.h4
-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
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 @@
5 5
6void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2); 6void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2);
7#define sway_abort(FMT, ...) \ 7#define sway_abort(FMT, ...) \
8 _sway_abort("[%s:%d] " FMT, _strip_path(__FILE__), __LINE__, ##__VA_ARGS__) 8 _sway_abort("[%s:%d] " FMT, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
9 9
10bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3); 10bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3);
11#define sway_assert(COND, FMT, ...) \ 11#define sway_assert(COND, FMT, ...) \
12 _sway_assert(COND, "[%s:%d] %s:" FMT, _strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__) 12 _sway_assert(COND, "[%s:%d] %s:" FMT, wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
13 13
14void error_handler(int sig); 14void error_handler(int sig);
15 15
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,
46 enum expected_args type, int val); 46 enum expected_args type, int val);
47 47
48/** 48/**
49 * Parse and handles a command. 49 * Parse and executes a command.
50 */ 50 */
51struct cmd_results *handle_command(char *command); 51struct cmd_results *execute_command(char *command, struct sway_seat *seat);
52/** 52/**
53 * Parse and handles a command during config file loading. 53 * Parse and handles a command during config file loading.
54 * 54 *
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 {
106 * The parent of this container. NULL for the root container. 106 * The parent of this container. NULL for the root container.
107 */ 107 */
108 struct sway_container *parent; 108 struct sway_container *parent;
109 /**
110 * Which of this container's children has focus.
111 */
112 struct sway_container *focused;
113 109
114 /** 110 /**
115 * Number of master views in auto layouts. 111 * Number of master views in auto layouts.
@@ -162,4 +158,12 @@ void container_map(swayc_t *container,
162swayc_t *swayc_at(swayc_t *parent, double lx, double ly, 158swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
163 struct wlr_surface **surface, double *sx, double *sy); 159 struct wlr_surface **surface, double *sx, double *sy);
164 160
161/**
162 * Apply the function for each child of the container breadth first.
163 */
164void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data),
165 void *data);
166
167swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout);
168
165#endif 169#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 {
16 struct wlr_input_device *wlr_device; 16 struct wlr_input_device *wlr_device;
17 struct input_config *config; 17 struct input_config *config;
18 struct wl_list link; 18 struct wl_list link;
19 struct wl_listener device_destroy;
19}; 20};
20 21
21struct sway_input_manager { 22struct sway_input_manager {
22 struct wl_listener input_add;
23 struct wl_listener input_remove;
24 struct sway_server *server; 23 struct sway_server *server;
25 struct wl_list devices; 24 struct wl_list devices;
26 struct wl_list seats; 25 struct wl_list seats;
26
27 struct wl_listener new_input;
27}; 28};
28 29
29struct sway_input_manager *sway_input_manager_create( 30struct 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 {
12 struct wl_list link; // sway_seat::devices 12 struct wl_list link; // sway_seat::devices
13}; 13};
14 14
15struct sway_seat_container {
16 struct sway_seat *seat;
17 swayc_t *container;
18
19 struct wl_list link; // sway_seat::focus_stack
20
21 struct wl_listener destroy;
22};
23
15struct sway_seat { 24struct sway_seat {
16 struct wlr_seat *wlr_seat; 25 struct wlr_seat *wlr_seat;
17 struct seat_config *config; 26 struct seat_config *config;
18 struct sway_cursor *cursor; 27 struct sway_cursor *cursor;
19 struct sway_input_manager *input; 28 struct sway_input_manager *input;
20 swayc_t *focus; 29
30 bool has_focus;
31 struct wl_list focus_stack; // list of containers in focus order
21 32
22 struct wl_listener focus_destroy; 33 struct wl_listener focus_destroy;
34 struct wl_listener new_container;
23 35
24 struct wl_list devices; // sway_seat_device::link 36 struct wl_list devices; // sway_seat_device::link
25 37
@@ -44,6 +56,22 @@ void sway_seat_configure_xcursor(struct sway_seat *seat);
44 56
45void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container); 57void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container);
46 58
59swayc_t *sway_seat_get_focus(struct sway_seat *seat);
60
61/**
62 * Return the last container to be focused for the seat (or the most recently
63 * opened if no container has received focused) that is a child of the given
64 * container. The focus-inactive container of the root window is the focused
65 * container for the seat (if the seat does have focus). This function can be
66 * used to determine what container gets focused next if the focused container
67 * is destroyed, or focus moves to a container with children and we need to
68 * descend into the next leaf in focus order.
69 */
70swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container);
71
72swayc_t *sway_seat_get_focus_by_type(struct sway_seat *seat,
73 enum swayc_types type);
74
47void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); 75void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config);
48 76
49#endif 77#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 @@
2#define _SWAY_LAYOUT_H 2#define _SWAY_LAYOUT_H
3 3
4#include <wlr/types/wlr_output_layout.h> 4#include <wlr/types/wlr_output_layout.h>
5#include "sway/container.h"
6
7enum movement_direction {
8 MOVE_LEFT,
9 MOVE_RIGHT,
10 MOVE_UP,
11 MOVE_DOWN,
12 MOVE_PARENT,
13 MOVE_CHILD,
14 MOVE_NEXT,
15 MOVE_PREV,
16 MOVE_FIRST
17};
5 18
6struct sway_container; 19struct sway_container;
7 20
@@ -11,13 +24,20 @@ struct sway_root {
11 struct wl_listener output_layout_change; 24 struct wl_listener output_layout_change;
12 25
13 struct wl_list unmanaged_views; // sway_view::unmanaged_view_link 26 struct wl_list unmanaged_views; // sway_view::unmanaged_view_link
27
28 struct {
29 struct wl_signal new_container;
30 } events;
14}; 31};
15 32
16void init_layout(void); 33void init_layout(void);
17void add_child(struct sway_container *parent, struct sway_container *child); 34void add_child(struct sway_container *parent, struct sway_container *child);
35swayc_t *add_sibling(swayc_t *parent, swayc_t *child);
18struct sway_container *remove_child(struct sway_container *child); 36struct sway_container *remove_child(struct sway_container *child);
19enum swayc_layouts default_layout(struct sway_container *output); 37enum swayc_layouts default_layout(struct sway_container *output);
20void sort_workspaces(struct sway_container *output); 38void sort_workspaces(struct sway_container *output);
21void arrange_windows(struct sway_container *container, double width, double height); 39void arrange_windows(struct sway_container *container, double width, double height);
40swayc_t *get_swayc_in_direction(swayc_t *container,
41 struct sway_seat *seat, enum movement_direction dir);
22 42
23#endif 43#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 {
14 struct timespec last_frame; 14 struct timespec last_frame;
15 15
16 struct wl_listener frame; 16 struct wl_listener frame;
17 struct wl_listener output_destroy;
17}; 18};
18 19
19#endif 20#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 {
24 24
25 struct sway_input_manager *input; 25 struct sway_input_manager *input;
26 26
27 struct wl_listener output_add; 27 struct wl_listener new_output;
28 struct wl_listener output_remove;
29 struct wl_listener output_frame; 28 struct wl_listener output_frame;
30 29
31 struct wlr_xdg_shell_v6 *xdg_shell_v6; 30 struct wlr_xdg_shell_v6 *xdg_shell_v6;
@@ -45,8 +44,7 @@ bool server_init(struct sway_server *server);
45void server_fini(struct sway_server *server); 44void server_fini(struct sway_server *server);
46void server_run(struct sway_server *server); 45void server_run(struct sway_server *server);
47 46
48void output_add_notify(struct wl_listener *listener, void *data); 47void handle_new_output(struct wl_listener *listener, void *data);
49void output_remove_notify(struct wl_listener *listener, void *data);
50 48
51void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); 49void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
52void handle_xwayland_surface(struct wl_listener *listener, void *data); 50void 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 @@
1#ifndef _SWAY_WORKSPACE_H 1#ifndef _SWAY_WORKSPACE_H
2#define _SWAY_WORKSPACE_H 2#define _SWAY_WORKSPACE_H
3 3
4struct sway_container; 4#include "sway/container.h"
5 5
6extern char *prev_workspace_name; 6extern char *prev_workspace_name;
7 7
@@ -12,9 +12,9 @@ bool workspace_switch(swayc_t *workspace);
12struct sway_container *workspace_by_number(const char* name); 12struct sway_container *workspace_by_number(const char* name);
13swayc_t *workspace_by_name(const char*); 13swayc_t *workspace_by_name(const char*);
14 14
15struct sway_container *workspace_output_next(struct sway_container *current); 15struct sway_container *workspace_output_next(swayc_t *current);
16struct sway_container *workspace_next(struct sway_container *current); 16struct sway_container *workspace_next(swayc_t *current);
17struct sway_container *workspace_output_prev(struct sway_container *current); 17struct sway_container *workspace_output_prev(swayc_t *current);
18struct sway_container *workspace_prev(struct sway_container *current); 18struct sway_container *workspace_prev(swayc_t *current);
19 19
20#endif 20#endif