aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-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) {
}
if (!focused || focused->type == C_OUTPUT) {
focused = get_focused_container(&root_container);
+ // Move focus from floating view
+ if (focused->is_floating) {
+ // To workspace if there are no children
+ if (focused->parent->children->length == 0) {
+ focused = focused->parent;
+ }
+ // TODO find a better way of doing this
+ // Or to focused container
+ else {
+ focused = get_focused_container(focused->parent->children->items[0]);
+ }
+ }
}
sway_log(L_DEBUG, "handle:%ld type:%x state:%x parent:%ld "
"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
pointer_mode_set(button, !(modifiers->mods ^ config->floating_mod));
}
- // Return if mode has been set
- if (pointer_state.mode) {
- return EVENT_HANDLED;
- }
-
- // Always send mouse release
- if (state == WLC_BUTTON_STATE_RELEASED) {
- return EVENT_PASSTHROUGH;
- }
-
// Check whether to change focus
swayc_t *pointer = pointer_state.view;
- if (pointer && focused != pointer) {
- set_focused_container(pointer_state.view);
+ if (pointer) {
+ if (focused != pointer) {
+ set_focused_container(pointer_state.view);
+ }
// Send to front if floating
if (pointer->is_floating) {
int i;
@@ -459,10 +463,20 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
break;
}
}
- wlc_view_bring_to_front(view);
+ wlc_view_bring_to_front(pointer->handle);
}
}
+ // Return if mode has been set
+ if (pointer_state.mode) {
+ return EVENT_HANDLED;
+ }
+
+ // Always send mouse release
+ if (state == WLC_BUTTON_STATE_RELEASED) {
+ return EVENT_PASSTHROUGH;
+ }
+
// Finally send click
return EVENT_PASSTHROUGH;
}