aboutsummaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c25
-rw-r--r--sway/input/seat.c12
2 files changed, 32 insertions, 5 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 7390816f..74af6426 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -63,7 +63,7 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor,
*surface = xsurface->surface;
*sx = cursor->x - box.x;
*sy = cursor->y - box.y;
- return view->swayc;
+ return NULL;
}
}
}
@@ -175,7 +175,28 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
double sx, sy;
struct sway_container *cont =
container_at_cursor(cursor, &surface, &sx, &sy);
- sway_seat_set_focus(cursor->seat, cont);
+ // Avoid moving keyboard focus from a surface that accepts it to one
+ // that does not unless the change would move us to a new workspace.
+ //
+ // This prevents, for example, losing focus when clicking on swaybar.
+ //
+ // TODO: Replace this condition with something like
+ // !surface_accepts_keyboard_input
+ if (surface && cont && cont->type != C_VIEW) {
+ struct sway_container *new_ws = cont;
+ if (new_ws && new_ws->type != C_WORKSPACE) {
+ new_ws = container_parent(new_ws, C_WORKSPACE);
+ }
+ struct sway_container *old_ws = sway_seat_get_focus(cursor->seat);
+ if (old_ws && old_ws->type != C_WORKSPACE) {
+ old_ws = container_parent(old_ws, C_WORKSPACE);
+ }
+ if (new_ws != old_ws) {
+ sway_seat_set_focus(cursor->seat, cont);
+ }
+ } else {
+ sway_seat_set_focus(cursor->seat, cont);
+ }
}
wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, event->time_msec,
diff --git a/sway/input/seat.c b/sway/input/seat.c
index ae536264..8d592872 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -259,11 +259,11 @@ void sway_seat_remove_device(struct sway_seat *seat,
void sway_seat_configure_xcursor(struct sway_seat *seat) {
// TODO configure theme and size
- const char *cursor_theme = "default";
+ const char *cursor_theme = NULL;
if (!seat->cursor->xcursor_manager) {
seat->cursor->xcursor_manager =
- wlr_xcursor_manager_create("default", 24);
+ wlr_xcursor_manager_create(cursor_theme, 24);
if (sway_assert(seat->cursor->xcursor_manager,
"Cannot create XCursor manager for theme %s",
cursor_theme)) {
@@ -291,7 +291,8 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
seat->cursor->cursor->y);
}
-void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container) {
+void sway_seat_set_focus(struct sway_seat *seat,
+ struct sway_container *container) {
struct sway_container *last_focus = sway_seat_get_focus(seat);
if (container && last_focus == container) {
@@ -311,6 +312,11 @@ void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *containe
if (container->type == C_VIEW) {
struct sway_view *view = container->sway_view;
view_set_activated(view, true);
+ if (view->type == SWAY_XWAYLAND_VIEW) {
+ struct wlr_xwayland *xwayland =
+ seat->input->server->xwayland;
+ wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
+ }
struct wlr_keyboard *keyboard =
wlr_seat_get_keyboard(seat->wlr_seat);
if (keyboard) {