aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-18 13:52:57 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-18 13:53:06 -0500
commit01c6caced600921eecb00767347caef1b9a282a0 (patch)
treecd9ec0bcaf5df2fb567ae3f324fdbc8ca59d74ac
parentMerge pull request #70 from taiyu-len/master (diff)
downloadsway-01c6caced600921eecb00767347caef1b9a282a0.tar.gz
sway-01c6caced600921eecb00767347caef1b9a282a0.tar.zst
sway-01c6caced600921eecb00767347caef1b9a282a0.zip
Added in proper focus handling for floating windows
-rw-r--r--sway/handlers.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index ec2b123e..b2ead56c 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -57,20 +57,25 @@ swayc_t *container_under_pointer(void) {
57 } 57 }
58 // if workspace, search floating 58 // if workspace, search floating
59 if (lookup->type == C_WORKSPACE) { 59 if (lookup->type == C_WORKSPACE) {
60 len = lookup->floating->length; 60 i = len = lookup->floating->length;
61 for (i = 0; i < len; ++i) { 61 bool got_floating = false;
62 while (--i > -1) {
63 sway_log(L_DEBUG, "Checking index %d of floating items", i);
62 if (pointer_test(lookup->floating->items[i], &mouse_origin)) { 64 if (pointer_test(lookup->floating->items[i], &mouse_origin)) {
65 sway_log(L_DEBUG, "Got hit for floatin on %d", i);
63 lookup = lookup->floating->items[i]; 66 lookup = lookup->floating->items[i];
67 got_floating = true;
64 break; 68 break;
65 } 69 }
66 } 70 }
67 if (i < len) { 71 if (got_floating) {
68 continue; 72 continue;
69 } 73 }
70 } 74 }
71 // search children 75 // search children
72 len = lookup->children->length; 76 len = lookup->children->length;
73 for (i = 0; i < len; ++i) { 77 for (i = 0; i < len; ++i) {
78 sway_log(L_DEBUG, "Checking index %d of standard children", i);
74 if (pointer_test(lookup->children->items[i], &mouse_origin)) { 79 if (pointer_test(lookup->children->items[i], &mouse_origin)) {
75 lookup = lookup->children->items[i]; 80 lookup = lookup->children->items[i];
76 break; 81 break;
@@ -441,6 +446,17 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
441 } 446 }
442 swayc_t *pointer = container_under_pointer(); 447 swayc_t *pointer = container_under_pointer();
443 set_focused_container(pointer); 448 set_focused_container(pointer);
449 if (pointer->is_floating) {
450 int i;
451 for (i = 0; i < pointer->parent->floating->length; i++) {
452 if (pointer->parent->floating->items[i] == pointer) {
453 list_del(pointer->parent->floating, i);
454 list_add(pointer->parent->floating, pointer);
455 break;
456 }
457 }
458 arrange_windows(pointer->parent, -1, -1);
459 }
444 return (pointer && pointer != focused); 460 return (pointer && pointer != focused);
445 } else { 461 } else {
446 sway_log(L_DEBUG, "Mouse button %u released", button); 462 sway_log(L_DEBUG, "Mouse button %u released", button);