aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorThayne McCombs <astrothayne@gmail.com>2020-01-21 23:05:39 -0700
committerSimon Ser <contact@emersion.fr>2020-07-27 11:27:47 +0200
commitb20d52f71d6567b26199050ac0a2735eefd5a985 (patch)
treeae7403f35fe8c7c3f10619ebe807cdc1e8146525 /sway/commands
parentcfa403fc58f3df9cdef2bc03d0a8bbdd4333ed00 (diff)
Use wlr_output_layout_output_at to get output for move to cursor
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/move.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 23d392f9..c1d1fade 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -766,19 +766,18 @@ static struct cmd_results *cmd_move_to_position_pointer(
double ly = cursor->y - container->height / 2;
/* Correct target coordinates to be in bounds (on screen). */
- for (int i = 0; i < root->outputs->length; ++i) {
- struct wlr_box box;
- output_get_box(root->outputs->items[i], &box);
- if (wlr_box_contains_point(&box, cursor->x, cursor->y)) {
- lx = fmax(lx, box.x);
- ly = fmax(ly, box.y);
- if (lx + container->width > box.x + box.width) {
- lx = box.x + box.width - container->width;
- }
- if (ly + container->height > box.y + box.height) {
- ly = box.y + box.height - container->height;
- }
- break;
+ struct wlr_output *output = wlr_output_layout_output_at(
+ root->output_layout, cursor->x, cursor->y);
+ if (output) {
+ struct wlr_box *box =
+ wlr_output_layout_get_box(root->output_layout, output);
+ lx = fmax(lx, box->x);
+ ly = fmax(ly, box->y);
+ if (lx + container->width > box->x + box->width) {
+ lx = box->x + box->width - container->width;
+ }
+ if (ly + container->height > box->y + box->height) {
+ ly = box->y + box->height - container->height;
}
}