aboutsummaryrefslogtreecommitdiff
path: root/sway/handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index cd97ab43..534b4e4f 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -57,14 +57,16 @@ swayc_t *container_under_pointer(void) {
}
// if workspace, search floating
if (lookup->type == C_WORKSPACE) {
- len = lookup->floating->length;
- for (i = 0; i < len; ++i) {
+ i = len = lookup->floating->length;
+ bool got_floating = false;
+ while (--i > -1) {
if (pointer_test(lookup->floating->items[i], &mouse_origin)) {
lookup = lookup->floating->items[i];
+ got_floating = true;
break;
}
}
- if (i < len) {
+ if (got_floating) {
continue;
}
}
@@ -106,6 +108,12 @@ static void handle_output_destroyed(wlc_handle output) {
if (i < list->length) {
destroy_output(list->items[i]);
}
+ if (list->length == 0) {
+ active_workspace = NULL;
+ } else {
+ //switch to other outputs active workspace
+ workspace_switch(((swayc_t *)root_container.children->items[0])->focused);
+ }
}
static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) {
@@ -320,9 +328,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
mouse_origin = *origin;
bool changed_floating = false;
int i = 0;
+ if (!active_workspace) {
+ return false;
+ }
// Do checks to determine if proper keys are being held
swayc_t *view = active_workspace->focused;
- if (m1_held) {
+ if (m1_held && view) {
if (view->is_floating) {
while (keys_pressed[i++]) {
if (keys_pressed[i] == config->floating_mod) {
@@ -338,7 +349,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
}
}
}
- } else if (m2_held) {
+ } else if (m2_held && view) {
if (view->is_floating) {
while (keys_pressed[i++]) {
if (keys_pressed[i] == config->floating_mod) {
@@ -400,7 +411,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
}
}
if (config->focus_follows_mouse && prev_handle != handle) {
- set_focused_container(container_under_pointer());
+ //Dont change focus if fullscreen
+ swayc_t *focused = get_focused_view(view);
+ if (!(focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) {
+ set_focused_container(container_under_pointer());
+ }
}
prev_handle = handle;
prev_pos = mouse_origin;
@@ -414,6 +429,10 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers,
uint32_t button, enum wlc_button_state state) {
swayc_t *focused = get_focused_container(&root_container);
+ //dont change focus if fullscreen
+ if (focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) {
+ return false;
+ }
if (state == WLC_BUTTON_STATE_PRESSED) {
sway_log(L_DEBUG, "Mouse button %u pressed", button);
if (button == 272) {
@@ -424,6 +443,17 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
}
swayc_t *pointer = container_under_pointer();
set_focused_container(pointer);
+ if (pointer->is_floating) {
+ int i;
+ for (i = 0; i < pointer->parent->floating->length; i++) {
+ if (pointer->parent->floating->items[i] == pointer) {
+ list_del(pointer->parent->floating, i);
+ list_add(pointer->parent->floating, pointer);
+ break;
+ }
+ }
+ arrange_windows(pointer->parent, -1, -1);
+ }
return (pointer && pointer != focused);
} else {
sway_log(L_DEBUG, "Mouse button %u released", button);