aboutsummaryrefslogtreecommitdiffstats
path: root/sway/handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index cd97ab43..1fe2dc27 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -57,14 +57,16 @@ 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) {
62 if (pointer_test(lookup->floating->items[i], &mouse_origin)) { 63 if (pointer_test(lookup->floating->items[i], &mouse_origin)) {
63 lookup = lookup->floating->items[i]; 64 lookup = lookup->floating->items[i];
65 got_floating = true;
64 break; 66 break;
65 } 67 }
66 } 68 }
67 if (i < len) { 69 if (got_floating) {
68 continue; 70 continue;
69 } 71 }
70 } 72 }
@@ -106,6 +108,12 @@ static void handle_output_destroyed(wlc_handle output) {
106 if (i < list->length) { 108 if (i < list->length) {
107 destroy_output(list->items[i]); 109 destroy_output(list->items[i]);
108 } 110 }
111 if (list->length == 0) {
112 active_workspace = NULL;
113 } else {
114 //switch to other outputs active workspace
115 workspace_switch(((swayc_t *)root_container.children->items[0])->focused);
116 }
109} 117}
110 118
111static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) { 119static 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
320 mouse_origin = *origin; 328 mouse_origin = *origin;
321 bool changed_floating = false; 329 bool changed_floating = false;
322 int i = 0; 330 int i = 0;
331 if (!active_workspace) {
332 return false;
333 }
323 // Do checks to determine if proper keys are being held 334 // Do checks to determine if proper keys are being held
324 swayc_t *view = active_workspace->focused; 335 swayc_t *view = active_workspace->focused;
325 if (m1_held) { 336 if (m1_held && view) {
326 if (view->is_floating) { 337 if (view->is_floating) {
327 while (keys_pressed[i++]) { 338 while (keys_pressed[i++]) {
328 if (keys_pressed[i] == config->floating_mod) { 339 if (keys_pressed[i] == config->floating_mod) {
@@ -338,7 +349,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
338 } 349 }
339 } 350 }
340 } 351 }
341 } else if (m2_held) { 352 } else if (m2_held && view) {
342 if (view->is_floating) { 353 if (view->is_floating) {
343 while (keys_pressed[i++]) { 354 while (keys_pressed[i++]) {
344 if (keys_pressed[i] == config->floating_mod) { 355 if (keys_pressed[i] == config->floating_mod) {
@@ -400,7 +411,11 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
400 } 411 }
401 } 412 }
402 if (config->focus_follows_mouse && prev_handle != handle) { 413 if (config->focus_follows_mouse && prev_handle != handle) {
403 set_focused_container(container_under_pointer()); 414 //Dont change focus if fullscreen
415 swayc_t *focused = get_focused_view(view);
416 if (!(focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) {
417 set_focused_container(container_under_pointer());
418 }
404 } 419 }
405 prev_handle = handle; 420 prev_handle = handle;
406 prev_pos = mouse_origin; 421 prev_pos = mouse_origin;
@@ -412,8 +427,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
412} 427}
413 428
414static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, 429static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers,
415 uint32_t button, enum wlc_button_state state) { 430 uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) {
416 swayc_t *focused = get_focused_container(&root_container); 431 swayc_t *focused = get_focused_container(&root_container);
432 //dont change focus if fullscreen
433 if (focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) {
434 return false;
435 }
417 if (state == WLC_BUTTON_STATE_PRESSED) { 436 if (state == WLC_BUTTON_STATE_PRESSED) {
418 sway_log(L_DEBUG, "Mouse button %u pressed", button); 437 sway_log(L_DEBUG, "Mouse button %u pressed", button);
419 if (button == 272) { 438 if (button == 272) {
@@ -424,6 +443,17 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
424 } 443 }
425 swayc_t *pointer = container_under_pointer(); 444 swayc_t *pointer = container_under_pointer();
426 set_focused_container(pointer); 445 set_focused_container(pointer);
446 if (pointer->is_floating) {
447 int i;
448 for (i = 0; i < pointer->parent->floating->length; i++) {
449 if (pointer->parent->floating->items[i] == pointer) {
450 list_del(pointer->parent->floating, i);
451 list_add(pointer->parent->floating, pointer);
452 break;
453 }
454 }
455 arrange_windows(pointer->parent, -1, -1);
456 }
427 return (pointer && pointer != focused); 457 return (pointer && pointer != focused);
428 } else { 458 } else {
429 sway_log(L_DEBUG, "Mouse button %u released", button); 459 sway_log(L_DEBUG, "Mouse button %u released", button);