aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-29 23:19:14 -0400
committerLibravatar GitHub <noreply@github.com>2018-03-29 23:19:14 -0400
commit6b7841b11ff4cd35f54d69dc92029855893e5ce0 (patch)
tree88c2de0d08e00b2a30cb20cdfadfa6e53f5c59b4 /sway/input
parentMerge pull request #1652 from ascent12/glclear (diff)
parentarrange windows (diff)
downloadsway-6b7841b11ff4cd35f54d69dc92029855893e5ce0.tar.gz
sway-6b7841b11ff4cd35f54d69dc92029855893e5ce0.tar.zst
sway-6b7841b11ff4cd35f54d69dc92029855893e5ce0.zip
Merge pull request #1647 from acrisci/refactor-tree
Refactor tree
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c10
-rw-r--r--sway/input/input-manager.c4
-rw-r--r--sway/input/seat.c38
3 files changed, 26 insertions, 26 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 8a0d1df5..d57ac3e3 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -7,7 +7,7 @@
7#include <wlr/types/wlr_cursor.h> 7#include <wlr/types/wlr_cursor.h>
8#include <wlr/types/wlr_xcursor_manager.h> 8#include <wlr/types/wlr_xcursor_manager.h>
9#include "sway/input/cursor.h" 9#include "sway/input/cursor.h"
10#include "sway/view.h" 10#include "sway/tree/view.h"
11#include "list.h" 11#include "list.h"
12#include "log.h" 12#include "log.h"
13 13
@@ -49,8 +49,8 @@ static void cursor_send_pointer_motion(struct sway_cursor *cursor,
49 } 49 }
50 } 50 }
51 51
52 swayc_t *swayc = 52 struct sway_container *swayc =
53 swayc_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy); 53 container_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy);
54 if (swayc) { 54 if (swayc) {
55 wlr_seat_pointer_notify_enter(seat, surface, sx, sy); 55 wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
56 wlr_seat_pointer_notify_motion(seat, time, sx, sy); 56 wlr_seat_pointer_notify_motion(seat, time, sx, sy);
@@ -87,8 +87,8 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
87 if (event->button == BTN_LEFT) { 87 if (event->button == BTN_LEFT) {
88 struct wlr_surface *surface = NULL; 88 struct wlr_surface *surface = NULL;
89 double sx, sy; 89 double sx, sy;
90 swayc_t *swayc = 90 struct sway_container *swayc =
91 swayc_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy); 91 container_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy);
92 92
93 sway_seat_set_focus(cursor->seat, swayc); 93 sway_seat_set_focus(cursor->seat, swayc);
94 } 94 }
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 27c2c72e..d421a03f 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -278,7 +278,7 @@ struct sway_input_manager *sway_input_manager_create(
278} 278}
279 279
280bool sway_input_manager_has_focus(struct sway_input_manager *input, 280bool sway_input_manager_has_focus(struct sway_input_manager *input,
281 swayc_t *container) { 281 struct sway_container *container) {
282 struct sway_seat *seat = NULL; 282 struct sway_seat *seat = NULL;
283 wl_list_for_each(seat, &input->seats, link) { 283 wl_list_for_each(seat, &input->seats, link) {
284 if (sway_seat_get_focus(seat) == container) { 284 if (sway_seat_get_focus(seat) == container) {
@@ -290,7 +290,7 @@ bool sway_input_manager_has_focus(struct sway_input_manager *input,
290} 290}
291 291
292void sway_input_manager_set_focus(struct sway_input_manager *input, 292void sway_input_manager_set_focus(struct sway_input_manager *input,
293 swayc_t *container) { 293 struct sway_container *container) {
294 struct sway_seat *seat ; 294 struct sway_seat *seat ;
295 wl_list_for_each(seat, &input->seats, link) { 295 wl_list_for_each(seat, &input->seats, link) {
296 sway_seat_set_focus(seat, container); 296 sway_seat_set_focus(seat, container);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 648e7914..76d29b52 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1,13 +1,13 @@
1#define _XOPEN_SOURCE 700 1#define _XOPEN_SOURCE 700
2#include <wlr/types/wlr_cursor.h> 2#include <wlr/types/wlr_cursor.h>
3#include <wlr/types/wlr_xcursor_manager.h> 3#include <wlr/types/wlr_xcursor_manager.h>
4#include "sway/container.h" 4#include "sway/tree/container.h"
5#include "sway/input/seat.h" 5#include "sway/input/seat.h"
6#include "sway/input/cursor.h" 6#include "sway/input/cursor.h"
7#include "sway/input/input-manager.h" 7#include "sway/input/input-manager.h"
8#include "sway/input/keyboard.h" 8#include "sway/input/keyboard.h"
9#include "sway/output.h" 9#include "sway/output.h"
10#include "sway/view.h" 10#include "sway/tree/view.h"
11#include "log.h" 11#include "log.h"
12 12
13static void seat_device_destroy(struct sway_seat_device *seat_device) { 13static void seat_device_destroy(struct sway_seat_device *seat_device) {
@@ -37,7 +37,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
37 struct sway_seat_container *seat_con = 37 struct sway_seat_container *seat_con =
38 wl_container_of(listener, seat_con, destroy); 38 wl_container_of(listener, seat_con, destroy);
39 struct sway_seat *seat = seat_con->seat; 39 struct sway_seat *seat = seat_con->seat;
40 swayc_t *con = seat_con->container; 40 struct sway_container *con = seat_con->container;
41 41
42 bool is_focus = (sway_seat_get_focus(seat) == con); 42 bool is_focus = (sway_seat_get_focus(seat) == con);
43 43
@@ -46,7 +46,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
46 if (is_focus) { 46 if (is_focus) {
47 // pick next focus 47 // pick next focus
48 sway_seat_set_focus(seat, NULL); 48 sway_seat_set_focus(seat, NULL);
49 swayc_t *next = sway_seat_get_focus_inactive(seat, con->parent); 49 struct sway_container *next = sway_seat_get_focus_inactive(seat, con->parent);
50 if (next == NULL) { 50 if (next == NULL) {
51 next = con->parent; 51 next = con->parent;
52 } 52 }
@@ -59,7 +59,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
59} 59}
60 60
61static struct sway_seat_container *seat_container_from_container( 61static struct sway_seat_container *seat_container_from_container(
62 struct sway_seat *seat, swayc_t *con) { 62 struct sway_seat *seat, struct sway_container *con) {
63 if (con->type < C_WORKSPACE) { 63 if (con->type < C_WORKSPACE) {
64 // these don't get seat containers ever 64 // these don't get seat containers ever
65 return NULL; 65 return NULL;
@@ -89,11 +89,11 @@ static struct sway_seat_container *seat_container_from_container(
89 89
90static void handle_new_container(struct wl_listener *listener, void *data) { 90static void handle_new_container(struct wl_listener *listener, void *data) {
91 struct sway_seat *seat = wl_container_of(listener, seat, new_container); 91 struct sway_seat *seat = wl_container_of(listener, seat, new_container);
92 swayc_t *con = data; 92 struct sway_container *con = data;
93 seat_container_from_container(seat, con); 93 seat_container_from_container(seat, con);
94} 94}
95 95
96static void collect_focus_iter(swayc_t *con, void *data) { 96static void collect_focus_iter(struct sway_container *con, void *data) {
97 struct sway_seat *seat = data; 97 struct sway_seat *seat = data;
98 if (con->type > C_WORKSPACE) { 98 if (con->type > C_WORKSPACE) {
99 return; 99 return;
@@ -130,7 +130,7 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input,
130 // init the focus stack 130 // init the focus stack
131 wl_list_init(&seat->focus_stack); 131 wl_list_init(&seat->focus_stack);
132 132
133 container_for_each_bfs(&root_container, collect_focus_iter, seat); 133 container_for_each_descendent(&root_container, collect_focus_iter, seat);
134 134
135 wl_signal_add(&root_container.sway_root->events.new_container, 135 wl_signal_add(&root_container.sway_root->events.new_container,
136 &seat->new_container); 136 &seat->new_container);
@@ -166,7 +166,7 @@ static void seat_configure_keyboard(struct sway_seat *seat,
166 sway_keyboard_configure(seat_device->keyboard); 166 sway_keyboard_configure(seat_device->keyboard);
167 wlr_seat_set_keyboard(seat->wlr_seat, 167 wlr_seat_set_keyboard(seat->wlr_seat,
168 seat_device->input_device->wlr_device); 168 seat_device->input_device->wlr_device);
169 swayc_t *focus = sway_seat_get_focus(seat); 169 struct sway_container *focus = sway_seat_get_focus(seat);
170 if (focus && focus->type == C_VIEW) { 170 if (focus && focus->type == C_VIEW) {
171 // force notify reenter to pick up the new configuration 171 // force notify reenter to pick up the new configuration
172 wlr_seat_keyboard_clear_focus(seat->wlr_seat); 172 wlr_seat_keyboard_clear_focus(seat->wlr_seat);
@@ -270,7 +270,7 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
270 } 270 }
271 271
272 for (int i = 0; i < root_container.children->length; ++i) { 272 for (int i = 0; i < root_container.children->length; ++i) {
273 swayc_t *output_container = root_container.children->items[i]; 273 struct sway_container *output_container = root_container.children->items[i];
274 struct wlr_output *output = 274 struct wlr_output *output =
275 output_container->sway_output->wlr_output; 275 output_container->sway_output->wlr_output;
276 bool result = 276 bool result =
@@ -289,8 +289,8 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
289 seat->cursor->cursor->y); 289 seat->cursor->cursor->y);
290} 290}
291 291
292void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) { 292void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container) {
293 swayc_t *last_focus = sway_seat_get_focus(seat); 293 struct sway_container *last_focus = sway_seat_get_focus(seat);
294 294
295 if (container && last_focus == container) { 295 if (container && last_focus == container) {
296 return; 296 return;
@@ -330,9 +330,9 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) {
330 seat->has_focus = (container != NULL); 330 seat->has_focus = (container != NULL);
331} 331}
332 332
333swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container) { 333struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) {
334 struct sway_seat_container *current = NULL; 334 struct sway_seat_container *current = NULL;
335 swayc_t *parent = NULL; 335 struct sway_container *parent = NULL;
336 wl_list_for_each(current, &seat->focus_stack, link) { 336 wl_list_for_each(current, &seat->focus_stack, link) {
337 parent = current->container->parent; 337 parent = current->container->parent;
338 338
@@ -351,21 +351,21 @@ swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container
351 return NULL; 351 return NULL;
352} 352}
353 353
354swayc_t *sway_seat_get_focus(struct sway_seat *seat) { 354struct sway_container *sway_seat_get_focus(struct sway_seat *seat) {
355 if (!seat->has_focus) { 355 if (!seat->has_focus) {
356 return NULL; 356 return NULL;
357 } 357 }
358 return sway_seat_get_focus_inactive(seat, &root_container); 358 return sway_seat_get_focus_inactive(seat, &root_container);
359} 359}
360 360
361swayc_t *sway_seat_get_focus_by_type(struct sway_seat *seat, 361struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat,
362 enum swayc_types type) { 362 enum sway_container_type type) {
363 swayc_t *focus = sway_seat_get_focus_inactive(seat, &root_container); 363 struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
364 if (focus->type == type) { 364 if (focus->type == type) {
365 return focus; 365 return focus;
366 } 366 }
367 367
368 return swayc_parent_by_type(focus, type); 368 return container_parent(focus, type);
369} 369}
370 370
371void sway_seat_set_config(struct sway_seat *seat, 371void sway_seat_set_config(struct sway_seat *seat,