summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/handlers.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 8b127d35..d0b129e8 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -163,6 +163,18 @@ static bool handle_view_created(wlc_handle handle) {
163 } 163 }
164 if (!focused || focused->type == C_OUTPUT) { 164 if (!focused || focused->type == C_OUTPUT) {
165 focused = get_focused_container(&root_container); 165 focused = get_focused_container(&root_container);
166 // Move focus from floating view
167 if (focused->is_floating) {
168 // To workspace if there are no children
169 if (focused->parent->children->length == 0) {
170 focused = focused->parent;
171 }
172 // TODO find a better way of doing this
173 // Or to focused container
174 else {
175 focused = get_focused_container(focused->parent->children->items[0]);
176 }
177 }
166 } 178 }
167 sway_log(L_DEBUG, "handle:%ld type:%x state:%x parent:%ld " 179 sway_log(L_DEBUG, "handle:%ld type:%x state:%x parent:%ld "
168 "mask:%d (x:%d y:%d w:%d h:%d) title:%s " 180 "mask:%d (x:%d y:%d w:%d h:%d) title:%s "
@@ -435,20 +447,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
435 pointer_mode_set(button, !(modifiers->mods ^ config->floating_mod)); 447 pointer_mode_set(button, !(modifiers->mods ^ config->floating_mod));
436 } 448 }
437 449
438 // Return if mode has been set
439 if (pointer_state.mode) {
440 return EVENT_HANDLED;
441 }
442
443 // Always send mouse release
444 if (state == WLC_BUTTON_STATE_RELEASED) {
445 return EVENT_PASSTHROUGH;
446 }
447
448 // Check whether to change focus 450 // Check whether to change focus
449 swayc_t *pointer = pointer_state.view; 451 swayc_t *pointer = pointer_state.view;
450 if (pointer && focused != pointer) { 452 if (pointer) {
451 set_focused_container(pointer_state.view); 453 if (focused != pointer) {
454 set_focused_container(pointer_state.view);
455 }
452 // Send to front if floating 456 // Send to front if floating
453 if (pointer->is_floating) { 457 if (pointer->is_floating) {
454 int i; 458 int i;
@@ -459,10 +463,20 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
459 break; 463 break;
460 } 464 }
461 } 465 }
462 wlc_view_bring_to_front(view); 466 wlc_view_bring_to_front(pointer->handle);
463 } 467 }
464 } 468 }
465 469
470 // Return if mode has been set
471 if (pointer_state.mode) {
472 return EVENT_HANDLED;
473 }
474
475 // Always send mouse release
476 if (state == WLC_BUTTON_STATE_RELEASED) {
477 return EVENT_PASSTHROUGH;
478 }
479
466 // Finally send click 480 // Finally send click
467 return EVENT_PASSTHROUGH; 481 return EVENT_PASSTHROUGH;
468} 482}