summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/view.h1
-rw-r--r--sway/commands.c2
-rw-r--r--sway/commands/focus.c41
-rw-r--r--sway/desktop/xwayland.c21
-rw-r--r--sway/input/cursor.c4
-rw-r--r--sway/tree/layout.c4
6 files changed, 65 insertions, 8 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index e270f851..068d92c6 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -140,6 +140,7 @@ struct sway_xwayland_view {
140 struct wl_listener set_title; 140 struct wl_listener set_title;
141 struct wl_listener set_class; 141 struct wl_listener set_class;
142 struct wl_listener set_window_type; 142 struct wl_listener set_window_type;
143 struct wl_listener set_hints;
143 struct wl_listener map; 144 struct wl_listener map;
144 struct wl_listener unmap; 145 struct wl_listener unmap;
145 struct wl_listener destroy; 146 struct wl_listener destroy;
diff --git a/sway/commands.c b/sway/commands.c
index a3e6a500..73c968ea 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -103,6 +103,7 @@ static struct cmd_handler handlers[] = {
103 { "exec_always", cmd_exec_always }, 103 { "exec_always", cmd_exec_always },
104 { "floating_maximum_size", cmd_floating_maximum_size }, 104 { "floating_maximum_size", cmd_floating_maximum_size },
105 { "floating_minimum_size", cmd_floating_minimum_size }, 105 { "floating_minimum_size", cmd_floating_minimum_size },
106 { "focus", cmd_focus },
106 { "focus_follows_mouse", cmd_focus_follows_mouse }, 107 { "focus_follows_mouse", cmd_focus_follows_mouse },
107 { "focus_wrapping", cmd_focus_wrapping }, 108 { "focus_wrapping", cmd_focus_wrapping },
108 { "font", cmd_font }, 109 { "font", cmd_font },
@@ -137,7 +138,6 @@ static struct cmd_handler command_handlers[] = {
137 { "border", cmd_border }, 138 { "border", cmd_border },
138 { "exit", cmd_exit }, 139 { "exit", cmd_exit },
139 { "floating", cmd_floating }, 140 { "floating", cmd_floating },
140 { "focus", cmd_focus },
141 { "fullscreen", cmd_fullscreen }, 141 { "fullscreen", cmd_fullscreen },
142 { "kill", cmd_kill }, 142 { "kill", cmd_kill },
143 { "layout", cmd_layout }, 143 { "layout", cmd_layout },
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index b24d5007..9cd8bfae 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -4,9 +4,11 @@
4#include "sway/commands.h" 4#include "sway/commands.h"
5#include "sway/input/input-manager.h" 5#include "sway/input/input-manager.h"
6#include "sway/input/seat.h" 6#include "sway/input/seat.h"
7#include "sway/output.h"
7#include "sway/tree/arrange.h" 8#include "sway/tree/arrange.h"
8#include "sway/tree/view.h" 9#include "sway/tree/view.h"
9#include "sway/tree/workspace.h" 10#include "sway/tree/workspace.h"
11#include "stringop.h"
10 12
11static bool parse_movement_direction(const char *name, 13static bool parse_movement_direction(const char *name,
12 enum movement_direction *out) { 14 enum movement_direction *out) {
@@ -44,7 +46,40 @@ static struct cmd_results *focus_mode(struct sway_container *con,
44 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 46 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
45} 47}
46 48
49static struct cmd_results *focus_output(struct sway_container *con,
50 struct sway_seat *seat, int argc, char **argv) {
51 if (!argc) {
52 return cmd_results_new(CMD_INVALID, "focus",
53 "Expected 'focus output <direction|name>'");
54 }
55 char *identifier = join_args(argv, argc);
56 struct sway_container *output = output_by_name(identifier);
57
58 if (!output) {
59 enum movement_direction direction;
60 if (!parse_movement_direction(identifier, &direction) ||
61 direction == MOVE_PARENT || direction == MOVE_CHILD) {
62 free(identifier);
63 return cmd_results_new(CMD_INVALID, "focus",
64 "There is no output with that name");
65 }
66 struct sway_container *focus = seat_get_focus(seat);
67 focus = container_parent(focus, C_OUTPUT);
68 output = container_get_in_direction(focus, seat, direction);
69 }
70
71 free(identifier);
72 if (output) {
73 seat_set_focus(seat, seat_get_focus_inactive(seat, output));
74 }
75
76 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
77}
78
47struct cmd_results *cmd_focus(int argc, char **argv) { 79struct cmd_results *cmd_focus(int argc, char **argv) {
80 if (config->reading || !config->active) {
81 return cmd_results_new(CMD_DEFER, NULL, NULL);
82 }
48 struct sway_container *con = config->handler_context.current_container; 83 struct sway_container *con = config->handler_context.current_container;
49 struct sway_seat *seat = config->handler_context.seat; 84 struct sway_seat *seat = config->handler_context.seat;
50 if (con->type < C_WORKSPACE) { 85 if (con->type < C_WORKSPACE) {
@@ -65,7 +100,11 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
65 return focus_mode(con, seat, !container_is_floating(con)); 100 return focus_mode(con, seat, !container_is_floating(con));
66 } 101 }
67 102
68 // TODO: focus output <direction|name> 103 if (strcmp(argv[0], "output") == 0) {
104 argc--; argv++;
105 return focus_output(con, seat, argc, argv);
106 }
107
69 enum movement_direction direction = 0; 108 enum movement_direction direction = 0;
70 if (!parse_movement_direction(argv[0], &direction)) { 109 if (!parse_movement_direction(argv[0], &direction)) {
71 return cmd_results_new(CMD_INVALID, "focus", 110 return cmd_results_new(CMD_INVALID, "focus",
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 7737a33a..72dc7ca2 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -290,10 +290,6 @@ static void handle_commit(struct wl_listener *listener, void *data) {
290 } 290 }
291 291
292 view_damage_from(view); 292 view_damage_from(view);
293
294 if (view->allow_request_urgent) {
295 view_set_urgent(view, (bool)xsurface->hints_urgency);
296 }
297} 293}
298 294
299static void handle_destroy(struct wl_listener *listener, void *data) { 295static void handle_destroy(struct wl_listener *listener, void *data) {
@@ -312,6 +308,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
312 wl_list_remove(&xwayland_view->set_title.link); 308 wl_list_remove(&xwayland_view->set_title.link);
313 wl_list_remove(&xwayland_view->set_class.link); 309 wl_list_remove(&xwayland_view->set_class.link);
314 wl_list_remove(&xwayland_view->set_window_type.link); 310 wl_list_remove(&xwayland_view->set_window_type.link);
311 wl_list_remove(&xwayland_view->set_hints.link);
315 wl_list_remove(&xwayland_view->map.link); 312 wl_list_remove(&xwayland_view->map.link);
316 wl_list_remove(&xwayland_view->unmap.link); 313 wl_list_remove(&xwayland_view->unmap.link);
317 view_destroy(&xwayland_view->view); 314 view_destroy(&xwayland_view->view);
@@ -437,6 +434,19 @@ static void handle_set_window_type(struct wl_listener *listener, void *data) {
437 view_execute_criteria(view); 434 view_execute_criteria(view);
438} 435}
439 436
437static void handle_set_hints(struct wl_listener *listener, void *data) {
438 struct sway_xwayland_view *xwayland_view =
439 wl_container_of(listener, xwayland_view, set_hints);
440 struct sway_view *view = &xwayland_view->view;
441 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
442 if (!xsurface->mapped) {
443 return;
444 }
445 if (view->allow_request_urgent) {
446 view_set_urgent(view, (bool)xsurface->hints_urgency);
447 }
448}
449
440struct sway_view *view_from_wlr_xwayland_surface( 450struct sway_view *view_from_wlr_xwayland_surface(
441 struct wlr_xwayland_surface *xsurface) { 451 struct wlr_xwayland_surface *xsurface) {
442 return xsurface->data; 452 return xsurface->data;
@@ -489,6 +499,9 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
489 &xwayland_view->set_window_type); 499 &xwayland_view->set_window_type);
490 xwayland_view->set_window_type.notify = handle_set_window_type; 500 xwayland_view->set_window_type.notify = handle_set_window_type;
491 501
502 wl_signal_add(&xsurface->events.set_hints, &xwayland_view->set_hints);
503 xwayland_view->set_hints.notify = handle_set_hints;
504
492 wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap); 505 wl_signal_add(&xsurface->events.unmap, &xwayland_view->unmap);
493 xwayland_view->unmap.notify = handle_unmap; 506 xwayland_view->unmap.notify = handle_unmap;
494 507
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 7a9f3ed7..c76c20b3 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -220,7 +220,6 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
220 struct sway_drag_icon *drag_icon = wlr_drag_icon->data; 220 struct sway_drag_icon *drag_icon = wlr_drag_icon->data;
221 drag_icon_update_position(drag_icon); 221 drag_icon_update_position(drag_icon);
222 } 222 }
223 transaction_commit_dirty();
224} 223}
225 224
226static void handle_cursor_motion(struct wl_listener *listener, void *data) { 225static void handle_cursor_motion(struct wl_listener *listener, void *data) {
@@ -230,6 +229,7 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
230 wlr_cursor_move(cursor->cursor, event->device, 229 wlr_cursor_move(cursor->cursor, event->device,
231 event->delta_x, event->delta_y); 230 event->delta_x, event->delta_y);
232 cursor_send_pointer_motion(cursor, event->time_msec, true); 231 cursor_send_pointer_motion(cursor, event->time_msec, true);
232 transaction_commit_dirty();
233} 233}
234 234
235static void handle_cursor_motion_absolute( 235static void handle_cursor_motion_absolute(
@@ -240,6 +240,7 @@ static void handle_cursor_motion_absolute(
240 struct wlr_event_pointer_motion_absolute *event = data; 240 struct wlr_event_pointer_motion_absolute *event = data;
241 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); 241 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
242 cursor_send_pointer_motion(cursor, event->time_msec, true); 242 cursor_send_pointer_motion(cursor, event->time_msec, true);
243 transaction_commit_dirty();
243} 244}
244 245
245void dispatch_cursor_button(struct sway_cursor *cursor, 246void dispatch_cursor_button(struct sway_cursor *cursor,
@@ -426,6 +427,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
426 427
427 wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y); 428 wlr_cursor_warp_absolute(cursor->cursor, event->device, x, y);
428 cursor_send_pointer_motion(cursor, event->time_msec, true); 429 cursor_send_pointer_motion(cursor, event->time_msec, true);
430 transaction_commit_dirty();
429} 431}
430 432
431static void handle_tool_tip(struct wl_listener *listener, void *data) { 433static void handle_tool_tip(struct wl_listener *listener, void *data) {
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 197a2fc8..1f898f8a 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -232,7 +232,9 @@ void container_move_to(struct sway_container *container,
232 } 232 }
233 if (new_workspace != old_workspace) { 233 if (new_workspace != old_workspace) {
234 workspace_detect_urgent(new_workspace); 234 workspace_detect_urgent(new_workspace);
235 workspace_detect_urgent(old_workspace); 235 if (old_workspace) {
236 workspace_detect_urgent(old_workspace);
237 }
236 } 238 }
237} 239}
238 240