aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/output.c29
-rw-r--r--sway/input/cursor.c168
-rw-r--r--sway/input/input-manager.c133
-rw-r--r--sway/input/input.c77
-rw-r--r--sway/input/seat.c112
-rw-r--r--sway/main.c3
-rw-r--r--sway/meson.build4
-rw-r--r--sway/server.c4
-rw-r--r--sway/tree/container.c60
9 files changed, 508 insertions, 82 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 7eb48bdf..0e7f7060 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -12,6 +12,8 @@
#include "sway/output.h"
#include "sway/server.h"
#include "sway/view.h"
+#include "sway/input/input-manager.h"
+#include "sway/input/seat.h"
static void output_frame_view(swayc_t *view, void *data) {
struct sway_output *output = data;
@@ -23,8 +25,8 @@ static void output_frame_view(swayc_t *view, void *data) {
}
// TODO
// - Deal with wlr_output_layout
- int width = sway_view->width;
- int height = sway_view->height;
+ int width = sway_view->surface->current->width;
+ int height = sway_view->surface->current->height;
int render_width = width * wlr_output->scale;
int render_height = height * wlr_output->scale;
double ox = view->x, oy = view->y;
@@ -38,19 +40,33 @@ static void output_frame_view(swayc_t *view, void *data) {
// return;
//}
+ // if the shell specifies window geometry, make the top left corner of the
+ // window in the top left corner of the container to avoid arbitrarily
+ // sized gaps based on the attached buffer size
+ int window_offset_x = 0;
+ int window_offset_y = 0;
+
+ if (view->sway_view->type == SWAY_XDG_SHELL_V6_VIEW) {
+ window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry->x;
+ window_offset_y = view->sway_view->wlr_xdg_surface_v6->geometry->y;
+ }
+
// TODO
double rotation = 0;
float matrix[16];
float translate_origin[16];
wlr_matrix_translate(&translate_origin,
- (int)ox + render_width / 2, (int)oy + render_height / 2, 0);
+ (int)ox + render_width / 2 - window_offset_x,
+ (int)oy + render_height / 2 - window_offset_y,
+ 0);
float rotate[16];
wlr_matrix_rotate(&rotate, rotation);
float translate_center[16];
- wlr_matrix_translate(&translate_center, -render_width / 2,
+ wlr_matrix_translate(&translate_center,
+ -render_width / 2,
-render_height / 2, 0);
float scale[16];
@@ -120,6 +136,11 @@ void output_add_notify(struct wl_listener *listener, void *data) {
output->resolution.notify = output_resolution_notify;
wl_signal_add(&wlr_output->events.resolution, &output->resolution);
+ for (int i = 0; i < server->input->seats->length; ++i) {
+ struct sway_seat *seat = server->input->seats->items[i];
+ sway_seat_configure_xcursor(seat);
+ }
+
arrange_windows(output->swayc, -1, -1);
}
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
new file mode 100644
index 00000000..5f2d650e
--- /dev/null
+++ b/sway/input/cursor.c
@@ -0,0 +1,168 @@
+#define _XOPEN_SOURCE 700
+#include <wlr/types/wlr_cursor.h>
+#include <wlr/types/wlr_xcursor_manager.h>
+#include "sway/input/cursor.h"
+#include "sway/view.h"
+#include "list.h"
+#include "log.h"
+
+static void cursor_update_position(struct sway_cursor *cursor) {
+ double x = cursor->cursor->x;
+ double y = cursor->cursor->y;
+
+ wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
+ "left_ptr", cursor->cursor);
+
+ cursor->x = x;
+ cursor->y = y;
+}
+
+static void cursor_send_pointer_motion(struct sway_cursor *cursor,
+ uint32_t time) {
+ struct wlr_seat *seat = cursor->seat->seat;
+ struct wlr_surface *surface = NULL;
+ double sx, sy;
+ swayc_t *swayc =
+ swayc_at(&root_container, cursor->x, cursor->y, &surface, &sx, &sy);
+ if (swayc) {
+ wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
+ wlr_seat_pointer_notify_motion(seat, time, sx, sy);
+ } else {
+ wlr_seat_pointer_clear_focus(seat);
+ }
+}
+
+static void handle_cursor_motion(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, motion);
+ struct wlr_event_pointer_motion *event = data;
+ wlr_cursor_move(cursor->cursor, event->device,
+ event->delta_x, event->delta_y);
+ cursor_update_position(cursor);
+ cursor_send_pointer_motion(cursor, event->time_msec);
+}
+
+static void handle_cursor_motion_absolute(struct wl_listener *listener,
+ void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, motion_absolute);
+ struct wlr_event_pointer_motion_absolute *event = data;
+ wlr_cursor_warp_absolute(cursor->cursor, event->device,
+ event->x_mm / event->width_mm, event->y_mm / event->height_mm);
+ cursor_update_position(cursor);
+ cursor_send_pointer_motion(cursor, event->time_msec);
+}
+
+static void handle_cursor_button(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, button);
+ struct wlr_event_pointer_button *event = data;
+ wlr_seat_pointer_notify_button(cursor->seat->seat, event->time_msec,
+ event->button, event->state);
+}
+
+static void handle_cursor_axis(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, axis);
+ struct wlr_event_pointer_axis *event = data;
+ wlr_seat_pointer_notify_axis(cursor->seat->seat, event->time_msec,
+ event->orientation, event->delta);
+}
+
+static void handle_touch_down(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, touch_down);
+ struct wlr_event_touch_down *event = data;
+ sway_log(L_DEBUG, "TODO: handle touch down event: %p", event);
+}
+
+static void handle_touch_up(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, touch_up);
+ struct wlr_event_touch_up *event = data;
+ sway_log(L_DEBUG, "TODO: handle touch up event: %p", event);
+}
+
+static void handle_touch_motion(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, touch_motion);
+ struct wlr_event_touch_motion *event = data;
+ sway_log(L_DEBUG, "TODO: handle touch motion event: %p", event);
+}
+
+static void handle_tool_axis(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, tool_axis);
+ struct wlr_event_tablet_tool_axis *event = data;
+ sway_log(L_DEBUG, "TODO: handle tool axis event: %p", event);
+}
+
+static void handle_tool_tip(struct wl_listener *listener, void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, tool_tip);
+ struct wlr_event_tablet_tool_tip *event = data;
+ sway_log(L_DEBUG, "TODO: handle tool tip event: %p", event);
+}
+
+static void handle_request_set_cursor(struct wl_listener *listener,
+ void *data) {
+ struct sway_cursor *cursor =
+ wl_container_of(listener, cursor, request_set_cursor);
+ struct wlr_seat_pointer_request_set_cursor_event *event = data;
+ sway_log(L_DEBUG, "TODO: handle request set cursor event: %p", event);
+}
+
+struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
+ struct sway_cursor *cursor = calloc(1, sizeof(struct sway_cursor));
+ if (!sway_assert(cursor, "could not allocate sway cursor")) {
+ return NULL;
+ }
+
+ struct wlr_cursor *wlr_cursor = wlr_cursor_create();
+ if (!sway_assert(wlr_cursor, "could not allocate wlr cursor")) {
+ free(cursor);
+ return NULL;
+ }
+
+ cursor->seat = seat;
+ wlr_cursor_attach_output_layout(wlr_cursor, root_container.output_layout);
+
+ // input events
+ wl_signal_add(&wlr_cursor->events.motion, &cursor->motion);
+ cursor->motion.notify = handle_cursor_motion;
+
+ wl_signal_add(&wlr_cursor->events.motion_absolute,
+ &cursor->motion_absolute);
+ cursor->motion_absolute.notify = handle_cursor_motion_absolute;
+
+ wl_signal_add(&wlr_cursor->events.button, &cursor->button);
+ cursor->button.notify = handle_cursor_button;
+
+ wl_signal_add(&wlr_cursor->events.axis, &cursor->axis);
+ cursor->axis.notify = handle_cursor_axis;
+
+ wl_signal_add(&wlr_cursor->events.touch_down, &cursor->touch_down);
+ cursor->touch_down.notify = handle_touch_down;
+
+ wl_signal_add(&wlr_cursor->events.touch_up, &cursor->touch_up);
+ cursor->touch_up.notify = handle_touch_up;
+
+ wl_signal_add(&wlr_cursor->events.touch_motion,
+ &cursor->touch_motion);
+ cursor->touch_motion.notify = handle_touch_motion;
+
+ wl_signal_add(&wlr_cursor->events.tablet_tool_axis,
+ &cursor->tool_axis);
+ cursor->tool_axis.notify = handle_tool_axis;
+
+ wl_signal_add(&wlr_cursor->events.tablet_tool_tip, &cursor->tool_tip);
+ cursor->tool_tip.notify = handle_tool_tip;
+
+ wl_signal_add(&seat->seat->events.request_set_cursor,
+ &cursor->request_set_cursor);
+ cursor->request_set_cursor.notify = handle_request_set_cursor;
+
+ cursor->cursor = wlr_cursor;
+
+ return cursor;
+}
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
new file mode 100644
index 00000000..4f52e59a
--- /dev/null
+++ b/sway/input/input-manager.c
@@ -0,0 +1,133 @@
+#define _XOPEN_SOURCE 700
+#include <ctype.h>
+#include <float.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <libinput.h>
+#include "sway/config.h"
+#include "sway/input/input-manager.h"
+#include "sway/input/seat.h"
+#include "sway/server.h"
+#include "list.h"
+#include "log.h"
+
+static const char *default_seat = "seat0";
+
+struct input_config *current_input_config = NULL;
+
+static struct sway_seat *input_manager_get_seat(
+ struct sway_input_manager *input, const char *seat_name) {
+ struct sway_seat *seat = NULL;
+
+ for (int i = 0; i < input->seats->length; ++i) {
+ seat = input->seats->items[i];
+ if (strcmp(seat->seat->name, seat_name) == 0) {
+ return seat;
+ }
+ }
+
+ seat = sway_seat_create(input->server->wl_display, seat_name);
+ list_add(input->seats, seat);
+
+ return seat;
+}
+
+static void input_add_notify(struct wl_listener *listener, void *data) {
+ struct sway_input_manager *input =
+ wl_container_of(listener, input, input_add);
+ struct wlr_input_device *device = data;
+
+ // TODO device configuration
+ struct sway_seat *seat = input_manager_get_seat(input, default_seat);
+ sway_seat_add_device(seat, device);
+}
+
+static void input_remove_notify(struct wl_listener *listener, void *data) {
+ struct sway_input_manager *input =
+ wl_container_of(listener, input, input_remove);
+ struct wlr_input_device *device = data;
+
+ // TODO device configuration
+ struct sway_seat *seat = input_manager_get_seat(input, default_seat);
+ sway_seat_remove_device(seat, device);
+}
+
+struct sway_input_manager *sway_input_manager_create(
+ struct sway_server *server) {
+ struct sway_input_manager *input =
+ calloc(1, sizeof(struct sway_input_manager));
+ if (!input) {
+ return NULL;
+ }
+ // XXX probably don't need the full server
+ input->server = server;
+
+ input->seats = create_list();
+
+ // create the default seat
+ input_manager_get_seat(input, default_seat);
+
+ input->input_add.notify = input_add_notify;
+ wl_signal_add(&server->backend->events.input_add, &input->input_add);
+
+ input->input_remove.notify = input_remove_notify;
+ wl_signal_add(&server->backend->events.input_remove, &input->input_remove);
+
+ return input;
+}
+
+struct input_config *new_input_config(const char* identifier) {
+ struct input_config *input = calloc(1, sizeof(struct input_config));
+ if (!input) {
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
+ sway_log(L_DEBUG, "new_input_config(%s)", identifier);
+ if (!(input->identifier = strdup(identifier))) {
+ free(input);
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
+
+ input->tap = INT_MIN;
+ input->drag_lock = INT_MIN;
+ input->dwt = INT_MIN;
+ input->send_events = INT_MIN;
+ input->click_method = INT_MIN;
+ input->middle_emulation = INT_MIN;
+ input->natural_scroll = INT_MIN;
+ input->accel_profile = INT_MIN;
+ input->pointer_accel = FLT_MIN;
+ input->scroll_method = INT_MIN;
+ input->left_handed = INT_MIN;
+
+ return input;
+}
+
+char *libinput_dev_unique_id(struct libinput_device *device) {
+ int vendor = libinput_device_get_id_vendor(device);
+ int product = libinput_device_get_id_product(device);
+ char *name = strdup(libinput_device_get_name(device));
+
+ char *p = name;
+ for (; *p; ++p) {
+ if (*p == ' ') {
+ *p = '_';
+ }
+ }
+
+ sway_log(L_DEBUG, "rewritten name %s", name);
+
+ int len = strlen(name) + sizeof(char) * 6;
+ char *identifier = malloc(len);
+ if (!identifier) {
+ sway_log(L_ERROR, "Unable to allocate unique input device name");
+ return NULL;
+ }
+
+ const char *fmt = "%d:%d:%s";
+ snprintf(identifier, len, fmt, vendor, product, name);
+ free(name);
+ return identifier;
+}
diff --git a/sway/input/input.c b/sway/input/input.c
deleted file mode 100644
index 02b4995e..00000000
--- a/sway/input/input.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#define _XOPEN_SOURCE 700
-#include <ctype.h>
-#include <float.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <libinput.h>
-#include "sway/config.h"
-#include "sway/input.h"
-#include "sway/server.h"
-#include "list.h"
-#include "log.h"
-
-struct input_config *current_input_config = NULL;
-
-struct sway_input *sway_input_create(struct sway_server *server) {
- struct sway_input *input = calloc(1, sizeof(struct sway_input));
- if (!input) {
- return NULL;
- }
- return input;
-}
-
-struct input_config *new_input_config(const char* identifier) {
- struct input_config *input = calloc(1, sizeof(struct input_config));
- if (!input) {
- sway_log(L_DEBUG, "Unable to allocate input config");
- return NULL;
- }
- sway_log(L_DEBUG, "new_input_config(%s)", identifier);
- if (!(input->identifier = strdup(identifier))) {
- free(input);
- sway_log(L_DEBUG, "Unable to allocate input config");
- return NULL;
- }
-
- input->tap = INT_MIN;
- input->drag_lock = INT_MIN;
- input->dwt = INT_MIN;
- input->send_events = INT_MIN;
- input->click_method = INT_MIN;
- input->middle_emulation = INT_MIN;
- input->natural_scroll = INT_MIN;
- input->accel_profile = INT_MIN;
- input->pointer_accel = FLT_MIN;
- input->scroll_method = INT_MIN;
- input->left_handed = INT_MIN;
-
- return input;
-}
-
-char *libinput_dev_unique_id(struct libinput_device *device) {
- int vendor = libinput_device_get_id_vendor(device);
- int product = libinput_device_get_id_product(device);
- char *name = strdup(libinput_device_get_name(device));
-
- char *p = name;
- for (; *p; ++p) {
- if (*p == ' ') {
- *p = '_';
- }
- }
-
- sway_log(L_DEBUG, "rewritten name %s", name);
-
- int len = strlen(name) + sizeof(char) * 6;
- char *identifier = malloc(len);
- if (!identifier) {
- sway_log(L_ERROR, "Unable to allocate unique input device name");
- return NULL;
- }
-
- const char *fmt = "%d:%d:%s";
- snprintf(identifier, len, fmt, vendor, product, name);
- free(name);
- return identifier;
-}
diff --git a/sway/input/seat.c b/sway/input/seat.c
new file mode 100644
index 00000000..5aed1f68
--- /dev/null
+++ b/sway/input/seat.c
@@ -0,0 +1,112 @@
+#define _XOPEN_SOURCE 700
+#include <wlr/types/wlr_cursor.h>
+#include <wlr/types/wlr_xcursor_manager.h>
+#include "sway/input/seat.h"
+#include "sway/input/cursor.h"
+#include "sway/input/input-manager.h"
+#include "sway/output.h"
+#include "log.h"
+
+struct sway_seat *sway_seat_create(struct wl_display *display,
+ const char *seat_name) {
+ struct sway_seat *seat = calloc(1, sizeof(struct sway_seat));
+ if (!seat) {
+ return NULL;
+ }
+
+ seat->seat = wlr_seat_create(display, seat_name);
+ if (!sway_assert(seat->seat, "could not allocate seat")) {
+ return NULL;
+ }
+
+ seat->cursor = sway_cursor_create(seat);
+ if (!seat->cursor) {
+ wlr_seat_destroy(seat->seat);
+ free(seat);
+ return NULL;
+ }
+
+ wlr_seat_set_capabilities(seat->seat,
+ WL_SEAT_CAPABILITY_KEYBOARD |
+ WL_SEAT_CAPABILITY_POINTER |
+ WL_SEAT_CAPABILITY_TOUCH);
+
+ sway_seat_configure_xcursor(seat);
+
+ return seat;
+}
+
+static void seat_add_pointer(struct sway_seat *seat,
+ struct wlr_input_device *device) {
+ // TODO pointer configuration
+ wlr_cursor_attach_input_device(seat->cursor->cursor, device);
+}
+
+void sway_seat_add_device(struct sway_seat *seat,
+ struct wlr_input_device *device) {
+ sway_log(L_DEBUG, "input add: %s", device->name);
+ switch (device->type) {
+ case WLR_INPUT_DEVICE_POINTER:
+ seat_add_pointer(seat, device);
+ break;
+ case WLR_INPUT_DEVICE_KEYBOARD:
+ case WLR_INPUT_DEVICE_TOUCH:
+ case WLR_INPUT_DEVICE_TABLET_PAD:
+ case WLR_INPUT_DEVICE_TABLET_TOOL:
+ sway_log(L_DEBUG, "TODO: add other devices");
+ break;
+ }
+}
+
+static void seat_remove_pointer(struct sway_seat *seat,
+ struct wlr_input_device *device) {
+ // TODO
+}
+
+void sway_seat_remove_device(struct sway_seat *seat,
+ struct wlr_input_device *device) {
+ sway_log(L_DEBUG, "input remove: %s", device->name);
+ switch (device->type) {
+ case WLR_INPUT_DEVICE_POINTER:
+ seat_remove_pointer(seat, device);
+ break;
+ case WLR_INPUT_DEVICE_KEYBOARD:
+ case WLR_INPUT_DEVICE_TOUCH:
+ case WLR_INPUT_DEVICE_TABLET_PAD:
+ case WLR_INPUT_DEVICE_TABLET_TOOL:
+ sway_log(L_DEBUG, "TODO: remove other devices");
+ break;
+ }
+}
+
+void sway_seat_configure_xcursor(struct sway_seat *seat) {
+ // TODO configure theme and size
+ const char *cursor_theme = "default";
+
+ if (!seat->cursor->xcursor_manager) {
+ seat->cursor->xcursor_manager =
+ wlr_xcursor_manager_create("default", 24);
+ if (sway_assert(seat->cursor->xcursor_manager,
+ "Cannot create XCursor manager for theme %s", cursor_theme)) {
+ return;
+ }
+ }
+
+ for (int i = 0; i < root_container.children->length; ++i) {
+ swayc_t *output_container = root_container.children->items[i];
+ struct wlr_output *output =
+ output_container->sway_output->wlr_output;
+ bool result =
+ wlr_xcursor_manager_load(seat->cursor->xcursor_manager,
+ output->scale);
+
+ sway_assert(!result,
+ "Cannot load xcursor theme for output '%s' with scale %d",
+ output->name, output->scale);
+ }
+
+ wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager,
+ "left_ptr", seat->cursor->cursor);
+ wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x,
+ seat->cursor->cursor->y);
+}
diff --git a/sway/main.c b/sway/main.c
index bc843591..363f4d96 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -381,11 +381,12 @@ int main(int argc, char **argv) {
sway_log(L_INFO, "Starting sway version " SWAY_VERSION "\n");
+ init_layout();
+
if (!server_init(&server)) {
return 1;
}
- init_layout();
ipc_init(&server);
log_env();
diff --git a/sway/meson.build b/sway/meson.build
index ab863e87..18955693 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -2,6 +2,9 @@ sway_sources = files(
'main.c',
'server.c',
'commands.c',
+ 'input/input-manager.c',
+ 'input/seat.c',
+ 'input/cursor.c',
'commands/exit.c',
'commands/exec.c',
'commands/exec_always.c',
@@ -26,6 +29,7 @@ sway_deps = [
wlroots,
libcap,
math,
+ libinput,
]
executable(
diff --git a/sway/server.c b/sway/server.c
index 024d8429..7b9a5e8e 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -11,6 +11,7 @@
// TODO WLR: make Xwayland optional
#include <wlr/xwayland.h>
#include "sway/server.h"
+#include "sway/input/input-manager.h"
#include "log.h"
bool server_init(struct sway_server *server) {
@@ -58,6 +59,9 @@ bool server_init(struct sway_server *server) {
wlr_backend_destroy(server->backend);
return false;
}
+
+ server->input = sway_input_manager_create(server);
+
return true;
}
diff --git a/sway/tree/container.c b/sway/tree/container.c
index e205fbcf..321ef8b1 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include <wlr/types/wlr_output_layout.h>
+#include <wlr/types/wlr_wl_shell.h>
#include "sway/container.h"
#include "sway/layout.h"
#include "sway/output.h"
@@ -168,3 +169,62 @@ swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) {
} while (container && container->type != type);
return container;
}
+
+swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
+ struct wlr_surface **surface, double *sx, double *sy) {
+ list_t *queue = create_list();
+ list_add(queue, parent);
+
+ swayc_t *swayc = NULL;
+ while (queue->length) {
+ swayc = queue->items[0];
+ list_del(queue, 0);
+ if (swayc->type == C_VIEW) {
+ struct sway_view *sview = swayc->sway_view;
+ swayc_t *soutput = swayc_parent_by_type(swayc, C_OUTPUT);
+ struct wlr_box *output_box =
+ wlr_output_layout_get_box(root_container.output_layout,
+ soutput->sway_output->wlr_output);
+ double ox = lx - output_box->x;
+ double oy = ly - output_box->y;
+ double view_sx = ox - swayc->x;
+ double view_sy = oy - swayc->y;
+ int width = swayc->sway_view->surface->current->width;
+ int height = swayc->sway_view->surface->current->height;
+
+ // TODO popups and subsurfaces
+ switch (sview->type) {
+ case SWAY_WL_SHELL_VIEW:
+ break;
+ case SWAY_XDG_SHELL_V6_VIEW:
+ // the top left corner of the sway container is the
+ // coordinate of the top left corner of the window geometry
+ view_sx += sview->wlr_xdg_surface_v6->geometry->x;
+ view_sy += sview->wlr_xdg_surface_v6->geometry->y;
+ break;
+ case SWAY_XWAYLAND_VIEW:
+ break;
+ default:
+ break;
+ }
+
+ if (view_sx > 0 && view_sx < width &&
+ view_sy > 0 && view_sy < height &&
+ pixman_region32_contains_point(
+ &sview->surface->current->input,
+ view_sx, view_sy, NULL)) {
+ *sx = view_sx;
+ *sy = view_sy;
+ *surface = swayc->sway_view->surface;
+ list_free(queue);
+ return swayc;
+ }
+ } else {
+ list_cat(queue, swayc->children);
+ }
+ }
+
+ list_free(queue);
+
+ return NULL;
+}