summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-22 01:15:25 +0200
committerLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-22 01:18:51 +0200
commitfc1bacf034c4e18dec435883e8804508d3c95fe0 (patch)
treed95f4f25f5fc941d323aab5261cbaa2567fbe776 /sway
parentMerge pull request #197 from sce/configure_outputs_during_reload_ (diff)
downloadsway-fc1bacf034c4e18dec435883e8804508d3c95fe0.tar.gz
sway-fc1bacf034c4e18dec435883e8804508d3c95fe0.tar.zst
sway-fc1bacf034c4e18dec435883e8804508d3c95fe0.zip
Switch to adjacent output when hitting output edge.
(Currently, after switching output the relative position of the mouse stays the same.)
Diffstat (limited to 'sway')
-rw-r--r--sway/handlers.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index cf07bc8b..4b6aaedd 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -353,6 +353,64 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
353} 353}
354 354
355static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) { 355static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) {
356 // Switch to adjacent output if touching output edge.
357 //
358 // Since this doesn't currently support moving windows between outputs we
359 // don't do the switch if the pointer is in a mode.
360 if (!pointer_state.mode) {
361 swayc_t *output = swayc_active_output();
362
363 // TODO: This implementation is naïve: We assume all outputs are
364 // perfectly aligned (ie. only a single output per edge which covers
365 // the whole edge).
366 if (origin->x == 0) { // Left edge
367 for(int i = 0; i < root_container.children->length; ++i) {
368 swayc_t *c = root_container.children->items[i];
369 if (c == output || c->type != C_OUTPUT) {
370 continue;
371 }
372 if (c->y == output->y && c->x + c->width == output->x) {
373 sway_log(L_DEBUG, "%s is right of %s", output->name, c->name);
374 workspace_switch(c);
375 }
376 }
377 } else if ((double)origin->x == output->width) { // Right edge
378 for(int i = 0; i < root_container.children->length; ++i) {
379 swayc_t *c = root_container.children->items[i];
380 if (c == output || c->type != C_OUTPUT) {
381 continue;
382 }
383 if (c->y == output->y && output->x + output->width == c->x) {
384 sway_log(L_DEBUG, "%s is left of %s", output->name, c->name);
385 workspace_switch(c);
386 }
387 }
388 }
389 if (origin->y == 0) { // Top edge
390 for(int i = 0; i < root_container.children->length; ++i) {
391 swayc_t *c = root_container.children->items[i];
392 if (c == output || c->type != C_OUTPUT) {
393 continue;
394 }
395 if (output->x == c->x && c->y + c->height == output->y) {
396 sway_log(L_DEBUG, "%s is below %s", output->name, c->name);
397 workspace_switch(c);
398 }
399 }
400 } else if ((double)origin->y == output->height) { // Bottom edge
401 for(int i = 0; i < root_container.children->length; ++i) {
402 swayc_t *c = root_container.children->items[i];
403 if (c == output || c->type != C_OUTPUT) {
404 continue;
405 }
406 if (output->x == c->x && output->y + output->height == c->y) {
407 sway_log(L_DEBUG, "%s is above %s", output->name, c->name);
408 workspace_switch(c);
409 }
410 }
411 }
412 }
413
356 // Update pointer origin 414 // Update pointer origin
357 pointer_state.delta.x = origin->x - pointer_state.origin.x; 415 pointer_state.delta.x = origin->x - pointer_state.origin.x;
358 pointer_state.delta.y = origin->y - pointer_state.origin.y; 416 pointer_state.delta.y = origin->y - pointer_state.origin.y;