From 23b90d8e69d203697c5548fdd140bf3052749dfa Mon Sep 17 00:00:00 2001 From: Luminarys Date: Tue, 18 Aug 2015 10:39:37 -0500 Subject: Fixed mouse clicks from triggering a segfault --- sway/handlers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sway/handlers.c') diff --git a/sway/handlers.c b/sway/handlers.c index cd97ab43..4980f65c 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -322,7 +322,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct int i = 0; // 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 +338,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) { -- cgit v1.2.3 From 03e83c7ef94e90a78390209af8d9c2a0c0adb237 Mon Sep 17 00:00:00 2001 From: taiyu Date: Tue, 18 Aug 2015 11:22:52 -0700 Subject: restored fullscreen/focus behavior --- sway/handlers.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'sway/handlers.c') diff --git a/sway/handlers.c b/sway/handlers.c index 4980f65c..ec2b123e 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -106,6 +106,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,6 +326,9 @@ 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 && view) { @@ -400,7 +409,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 +427,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) { -- cgit v1.2.3 From 01c6caced600921eecb00767347caef1b9a282a0 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Tue, 18 Aug 2015 13:52:57 -0500 Subject: Added in proper focus handling for floating windows --- sway/handlers.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'sway/handlers.c') 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) { } // 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) { + sway_log(L_DEBUG, "Checking index %d of floating items", i); if (pointer_test(lookup->floating->items[i], &mouse_origin)) { + sway_log(L_DEBUG, "Got hit for floatin on %d", i); lookup = lookup->floating->items[i]; + got_floating = true; break; } } - if (i < len) { + if (got_floating) { continue; } } // search children len = lookup->children->length; for (i = 0; i < len; ++i) { + sway_log(L_DEBUG, "Checking index %d of standard children", i); if (pointer_test(lookup->children->items[i], &mouse_origin)) { lookup = lookup->children->items[i]; break; @@ -441,6 +446,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); -- cgit v1.2.3 From 7756f423c3449e58746dfc66517b389abee8b88f Mon Sep 17 00:00:00 2001 From: Luminarys Date: Tue, 18 Aug 2015 13:54:52 -0500 Subject: Removed unnecessary debugging lines --- sway/handlers.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'sway/handlers.c') diff --git a/sway/handlers.c b/sway/handlers.c index b2ead56c..534b4e4f 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -60,9 +60,7 @@ swayc_t *container_under_pointer(void) { i = len = lookup->floating->length; bool got_floating = false; while (--i > -1) { - sway_log(L_DEBUG, "Checking index %d of floating items", i); if (pointer_test(lookup->floating->items[i], &mouse_origin)) { - sway_log(L_DEBUG, "Got hit for floatin on %d", i); lookup = lookup->floating->items[i]; got_floating = true; break; @@ -75,7 +73,6 @@ swayc_t *container_under_pointer(void) { // search children len = lookup->children->length; for (i = 0; i < len; ++i) { - sway_log(L_DEBUG, "Checking index %d of standard children", i); if (pointer_test(lookup->children->items[i], &mouse_origin)) { lookup = lookup->children->items[i]; break; -- cgit v1.2.3 From 5b6e48987204c0d2298dda2d9b30b4208abdd8d5 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Tue, 18 Aug 2015 16:28:24 -0500 Subject: More patches for wlc compat --- sway/handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/handlers.c') diff --git a/sway/handlers.c b/sway/handlers.c index 534b4e4f..1fe2dc27 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -427,7 +427,7 @@ 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) { + uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) { 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) { -- cgit v1.2.3