]> git.lizzy.rs Git - bspwm.git/blobdiff - events.c
Lower the motion recorder when querying
[bspwm.git] / events.c
index 5df51077bdbe40e1503900256b208f07bfaec593..97a6bd09ce0bb65dc4a425921a819c695e5991eb 100644 (file)
--- a/events.c
+++ b/events.c
@@ -1,13 +1,13 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <xcb/xcb.h>
-#include <xcb/xcb_icccm.h>
 #include <xcb/xcb_event.h>
-#include "helpers.h"
+#include <xcb/xcb_icccm.h>
 #include "types.h"
 #include "bspwm.h"
 #include "settings.h"
-#include "utils.h"
+#include "helpers.h"
 #include "window.h"
 #include "events.h"
 #include "tree.h"
@@ -35,17 +35,13 @@ void handle_event(xcb_generic_event_t *evt)
         case XCB_PROPERTY_NOTIFY:
             property_notify(evt);
             break;
-        case XCB_BUTTON_PRESS:
-            button_press(evt);
+        case XCB_ENTER_NOTIFY:
+            enter_notify(evt);
             break;
         case XCB_MOTION_NOTIFY:
-            motion_notify(evt);
-            break;
-        case XCB_BUTTON_RELEASE:
-            button_release(evt);
+            motion_notify();
             break;
         default:
-            /* PRINTF("received event %i\n", XCB_EVENT_RESPONSE_TYPE(evt)); */
             break;
     }
 }
@@ -56,60 +52,7 @@ void map_request(xcb_generic_event_t *evt)
 
     PRINTF("map request %X\n", e->window);
 
-    xcb_get_window_attributes_reply_t  *wa;
-    xcb_window_t win = e->window;
-    window_location_t loc;
-    wa = xcb_get_window_attributes_reply(dpy, xcb_get_window_attributes(dpy, win), NULL);
-
-    if ((wa != NULL && wa->override_redirect) || locate_window(win, &loc))
-        return;
-
-    free(wa);
-
-    client_t *c = make_client(win);
-    update_floating_rectangle(c);
-
-    bool floating = false, transient = false, fullscreen = false, takes_focus = true;
-
-    handle_rules(win, &floating, &transient, &fullscreen, &takes_focus);
-
-    if (c->transient)
-        floating = true;
-
-    node_t *birth = make_node();
-    birth->client = c;
-
-    if (floating)
-        split_mode = MODE_MANUAL;
-
-    insert_node(desk, birth);
-
-    if (floating)
-        toggle_floating(birth);
-
-    if (desk->focus != NULL && desk->focus->client->fullscreen)
-        toggle_fullscreen(desk->focus->client);
-
-    if (fullscreen)
-        toggle_fullscreen(birth->client);
-
-    c->transient = transient;
-
-    if (takes_focus)
-        focus_node(desk, birth, false);
-
-    apply_layout(desk, desk->root, root_rect);
-
-    window_show(c->window);
-
-    if (takes_focus)
-        xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, win, XCB_CURRENT_TIME);
-
-    uint32_t values[] = {CLIENT_EVENT_MASK};
-    xcb_change_window_attributes(dpy, c->window, XCB_CW_EVENT_MASK, values);
-
-    num_clients++;
-    ewmh_update_client_list();
+    manage_window(mon, mon->desk, e->window);
 }
 
 void configure_request(xcb_generic_event_t *evt)
@@ -170,10 +113,35 @@ void configure_request(xcb_generic_event_t *evt)
         }
 
         xcb_configure_window(dpy, e->window, mask, values);
-    }
+        if (is_managed)
+            window_draw_border(loc.node, loc.node == loc.desktop->focus, loc.monitor == mon);
+    } else {
+        xcb_configure_notify_event_t evt;
+        xcb_rectangle_t rect;
+        unsigned int bw;
+        xcb_window_t win = loc.node->client->window;
+
+        if (is_tiled(loc.node->client)) {
+            rect = loc.node->client->tiled_rectangle;
+            bw = border_width;
+        } else {
+            rect = loc.monitor->rectangle;
+            bw = 0;
+        }
 
-    if (is_managed && is_floating(loc.node->client))
-        apply_layout(loc.desktop, loc.node, root_rect);
+        evt.response_type = XCB_CONFIGURE_NOTIFY;
+        evt.event = win;
+        evt.window = win;
+        evt.above_sibling = XCB_NONE;
+        evt.x = rect.x;
+        evt.y = rect.y;
+        evt.width = rect.width;
+        evt.height = rect.height;
+        evt.border_width = bw;
+        evt.override_redirect = false;
+
+        xcb_send_event(dpy, false, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char *) &evt);
+    }
 }
 
 void destroy_notify(xcb_generic_event_t *evt)
@@ -185,7 +153,7 @@ void destroy_notify(xcb_generic_event_t *evt)
     window_location_t loc;
     if (locate_window(e->window, &loc)) {
         remove_node(loc.desktop, loc.node);
-        apply_layout(loc.desktop, loc.desktop->root, root_rect);
+        arrange(loc.monitor, loc.desktop);
     }
 }
 
@@ -193,16 +161,12 @@ void unmap_notify(xcb_generic_event_t *evt)
 {
     xcb_unmap_notify_event_t *e = (xcb_unmap_notify_event_t *) evt;
 
-    PRINTF("unmap notify %X %u\n", e->window, XCB_EVENT_SENT(e));
-
-    if (!XCB_EVENT_SENT(e))
-        return;
+    PRINTF("unmap notify %X\n", e->window);
 
     window_location_t loc;
     if (locate_window(e->window, &loc)) {
-        PRINTF("remove node in unmap notify %X\n", e->window);
         remove_node(loc.desktop, loc.node);
-        apply_layout(loc.desktop, loc.desktop->root, root_rect);
+        arrange(loc.monitor, loc.desktop);
     }
 }
 
@@ -218,12 +182,14 @@ void property_notify(xcb_generic_event_t *evt)
 
     window_location_t loc;
     if (locate_window(e->window, &loc)) {
-        if (loc.node == loc.desktop->focus)
-            return;
         if (xcb_icccm_get_wm_hints_reply(dpy, xcb_icccm_get_wm_hints(dpy, e->window), &hints, NULL) == 1) {
-            loc.node->client->urgent = (hints.flags & XCB_ICCCM_WM_HINT_X_URGENCY);
-            if (desk == loc.desktop)
-                apply_layout(loc.desktop, loc.desktop->root, root_rect);
+            uint32_t urgent = xcb_icccm_wm_hints_get_urgency(&hints);
+            if (urgent != 0 && loc.node != mon->desk->focus) {
+                loc.node->client->urgent = urgent;
+                put_status();
+                if (loc.monitor->desk == loc.desktop)
+                    arrange(loc.monitor, loc.desktop);
+            }
         }
     }
 }
@@ -232,153 +198,349 @@ void client_message(xcb_generic_event_t *evt)
 {
     xcb_client_message_event_t *e = (xcb_client_message_event_t *) evt;
 
-    PRINTF("client message %X\n", e->window);
+    PRINTF("client message %X %u\n", e->window, e->type);
 
-    window_location_t loc;
+    if (e->type == ewmh->_NET_CURRENT_DESKTOP) {
+        desktop_location_t loc;
+        if (ewmh_locate_desktop(e->data.data32[0], &loc)) {
+            select_monitor(loc.monitor);
+            select_desktop(loc.desktop);
+        }
+        return;
+    }
 
+    window_location_t loc;
     if (!locate_window(e->window, &loc))
         return;
 
     if (e->type == ewmh->_NET_WM_STATE) {
-        handle_state(loc.node, e->data.data32[1], e->data.data32[0]);
-        handle_state(loc.node, e->data.data32[2], e->data.data32[0]);
+        handle_state(loc.monitor, loc.desktop, loc.node, e->data.data32[1], e->data.data32[0]);
+        handle_state(loc.monitor, loc.desktop, loc.node, e->data.data32[2], e->data.data32[0]);
     } else if (e->type == ewmh->_NET_ACTIVE_WINDOW) {
-        if (desk->focus != NULL && desk->focus->client->fullscreen)
-            return;
-        apply_layout(loc.desktop, loc.desktop->root, root_rect);
-        if (desk != loc.desktop)
-            select_desktop(loc.desktop);
-        focus_node(loc.desktop, loc.node, true);
+        if (loc.desktop->focus->client->fullscreen && loc.desktop->focus != loc.node)
+            toggle_fullscreen(loc.monitor, loc.desktop->focus->client);
+        select_monitor(loc.monitor);
+        select_desktop(loc.desktop);
+        focus_node(loc.monitor, loc.desktop, loc.node, true);
+        arrange(loc.monitor, loc.desktop);
     }
 }
 
-void button_press(xcb_generic_event_t *evt)
+void enter_notify(xcb_generic_event_t *evt)
+{
+    xcb_enter_notify_event_t *e = (xcb_enter_notify_event_t *) evt;
+    xcb_window_t win = e->event;
+
+    PRINTF("enter notify %X %d %d\n", win, e->mode, e->detail);
+
+    if (e->mode != XCB_NOTIFY_MODE_NORMAL
+            || (mon->desk->focus != NULL && mon->desk->focus->client->window == win))
+        return;
+
+    enable_motion_recorder();
+}
+
+void motion_notify(void)
 {
-    xcb_button_press_event_t *e = (xcb_button_press_event_t *) evt;
-    xcb_window_t win = e->child;
+    PUTS("motion notify");
 
-    PRINTF("button press %X %u %u\n", win, e->detail, e->state);
+    disable_motion_recorder();
+
+    xcb_window_t win = XCB_NONE;
+    query_pointer(&win, NULL);
+    if (win != XCB_NONE)
+        window_focus(win);
+}
+
+void handle_state(monitor_t *m, desktop_t *d, node_t *n, xcb_atom_t state, unsigned int action)
+{
+    if (state == ewmh->_NET_WM_STATE_FULLSCREEN) {
+        bool fs = n->client->fullscreen;
+        if (action == XCB_EWMH_WM_STATE_TOGGLE
+                || (fs && action == XCB_EWMH_WM_STATE_REMOVE)
+                || (!fs && action == XCB_EWMH_WM_STATE_ADD)) {
+            toggle_fullscreen(m, n->client);
+            arrange(m, d);
+        }
+    }
+}
+
+void grab_pointer(pointer_action_t pac)
+{
+    PRINTF("grab pointer %u\n", pac);
+
+    xcb_window_t win = XCB_NONE;
+    xcb_point_t pos;
+
+    query_pointer(&win, &pos);
+
+    if (win == XCB_NONE)
+        return;
 
     window_location_t loc;
     if (locate_window(win, &loc)) {
-        client_t *c = loc.node->client;
-        switch (e->detail)  {
-            case XCB_BUTTON_INDEX_2:
-                focus_node(loc.desktop, loc.node, true);
+        client_t *c = NULL;
+        frozen_pointer->position = pos;
+        frozen_pointer->action = pac;
+        c = loc.node->client;
+        frozen_pointer->monitor = loc.monitor;
+        frozen_pointer->desktop = loc.desktop;
+        frozen_pointer->node = loc.node;
+        frozen_pointer->client = c;
+        frozen_pointer->window = c->window;
+        frozen_pointer->horizontal_fence = NULL;
+        frozen_pointer->vertical_fence = NULL;
+
+        switch (pac)  {
+            case ACTION_FOCUS:
+                focus_node(loc.monitor, loc.desktop, loc.node, true);
                 break;
-            case XCB_BUTTON_INDEX_1:
-            case XCB_BUTTON_INDEX_3:
-                if (!is_floating(loc.node->client))
+            case ACTION_MOVE:
+            case ACTION_RESIZE_SIDE:
+            case ACTION_RESIZE_CORNER:
+                if (is_tiled(c)) {
+                    frozen_pointer->rectangle = c->tiled_rectangle;
+                    frozen_pointer->is_tiled = true;
+                } else if (is_floating(c)) {
+                    frozen_pointer->rectangle = c->floating_rectangle;
+                    frozen_pointer->is_tiled = false;
+                } else {
+                    frozen_pointer->action = ACTION_NONE;
                     return;
-                PUTS("grab pointer from button press");
-                frozen_pointer->desktop = loc.desktop;
-                frozen_pointer->node = loc.node;
-                frozen_pointer->rectangle = c->floating_rectangle;
-                frozen_pointer->position = (xcb_point_t) {e->root_x, e->root_y};
-                frozen_pointer->button = e->detail;
-                if (e->detail == XCB_BUTTON_INDEX_3) {
-                    int16_t mid_x, mid_y;
-                    mid_x = c->floating_rectangle.x + (c->floating_rectangle.width / 2);
-                    mid_y = c->floating_rectangle.y + (c->floating_rectangle.height / 2);
-                    if (e->root_x > mid_x) {
-                        if (e->root_y > mid_y)
-                            frozen_pointer->corner = BOTTOM_RIGHT;
+                }
+                if (pac == ACTION_RESIZE_SIDE) {
+                    float W = frozen_pointer->rectangle.width;
+                    float H = frozen_pointer->rectangle.height;
+                    float ratio = W / H;
+                    float x = pos.x - frozen_pointer->rectangle.x;
+                    float y = pos.y - frozen_pointer->rectangle.y;
+                    float diag_a = ratio * y;
+                    float diag_b = W - diag_a;
+                    if (x < diag_a) {
+                        if (x < diag_b)
+                            frozen_pointer->side = SIDE_LEFT;
+                        else
+                            frozen_pointer->side = SIDE_BOTTOM;
+                    } else {
+                        if (x < diag_b)
+                            frozen_pointer->side = SIDE_TOP;
+                        else
+                            frozen_pointer->side = SIDE_RIGHT;
+                    }
+                } else if (pac == ACTION_RESIZE_CORNER) {
+                    int16_t mid_x = frozen_pointer->rectangle.x + (frozen_pointer->rectangle.width / 2);
+                    int16_t mid_y = frozen_pointer->rectangle.y + (frozen_pointer->rectangle.height / 2);
+                    if (pos.x > mid_x) {
+                        if (pos.y > mid_y)
+                            frozen_pointer->corner = CORNER_BOTTOM_RIGHT;
                         else
-                            frozen_pointer->corner = TOP_RIGHT;
+                            frozen_pointer->corner = CORNER_TOP_RIGHT;
                     } else {
-                        if (e->root_y > mid_y)
-                            frozen_pointer->corner = BOTTOM_LEFT;
+                        if (pos.y > mid_y)
+                            frozen_pointer->corner = CORNER_BOTTOM_LEFT;
                         else
-                            frozen_pointer->corner = TOP_LEFT;
+                            frozen_pointer->corner = CORNER_TOP_LEFT;
+                    }
+                }
+                if (frozen_pointer->is_tiled) {
+                    if (pac == ACTION_RESIZE_SIDE) {
+                        switch (frozen_pointer->side) {
+                            case SIDE_TOP:
+                                frozen_pointer->horizontal_fence = find_fence(loc.node, DIR_UP);
+                                break;
+                            case SIDE_RIGHT:
+                                frozen_pointer->vertical_fence = find_fence(loc.node, DIR_RIGHT);
+                                break;
+                            case SIDE_BOTTOM:
+                                frozen_pointer->horizontal_fence = find_fence(loc.node, DIR_DOWN);
+                                break;
+                            case SIDE_LEFT:
+                                frozen_pointer->vertical_fence = find_fence(loc.node, DIR_LEFT);
+                                break;
+                        }
+                    } else if (pac == ACTION_RESIZE_CORNER) {
+                        switch (frozen_pointer->corner) {
+                            case CORNER_TOP_LEFT:
+                                frozen_pointer->horizontal_fence = find_fence(loc.node, DIR_UP);
+                                frozen_pointer->vertical_fence = find_fence(loc.node, DIR_LEFT);
+                                break;
+                            case CORNER_TOP_RIGHT:
+                                frozen_pointer->horizontal_fence = find_fence(loc.node, DIR_UP);
+                                frozen_pointer->vertical_fence = find_fence(loc.node, DIR_RIGHT);
+                                break;
+                            case CORNER_BOTTOM_RIGHT:
+                                frozen_pointer->horizontal_fence = find_fence(loc.node, DIR_DOWN);
+                                frozen_pointer->vertical_fence = find_fence(loc.node, DIR_RIGHT);
+                                break;
+                            case CORNER_BOTTOM_LEFT:
+                                frozen_pointer->horizontal_fence = find_fence(loc.node, DIR_DOWN);
+                                frozen_pointer->vertical_fence = find_fence(loc.node, DIR_LEFT);
+                                break;
+                        }
                     }
+                    if (frozen_pointer->horizontal_fence != NULL)
+                        frozen_pointer->horizontal_ratio = frozen_pointer->horizontal_fence->split_ratio;
+                    if (frozen_pointer->vertical_fence != NULL)
+                        frozen_pointer->vertical_ratio = frozen_pointer->vertical_fence->split_ratio;
                 }
-                xcb_grab_pointer(dpy, false, screen->root, XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_BUTTON_RELEASE, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_CURRENT_TIME);
+                break;
+            case ACTION_NONE:
                 break;
         }
+    } else {
+        frozen_pointer->action = ACTION_NONE;
     }
 }
 
-void motion_notify(xcb_generic_event_t *evt)
+void track_pointer(int root_x, int root_y)
 {
-    xcb_motion_notify_event_t *e = (xcb_motion_notify_event_t *) evt;
+    if (frozen_pointer->action == ACTION_NONE)
+        return;
 
     int16_t delta_x, delta_y, x, y, w, h;
     uint16_t width, height;
 
+    pointer_action_t pac = frozen_pointer->action;
+    monitor_t *m = frozen_pointer->monitor;
     desktop_t *d = frozen_pointer->desktop;
     node_t *n = frozen_pointer->node;
-    client_t *c = n->client;
+    client_t *c = frozen_pointer->client;
+    xcb_window_t win = frozen_pointer->window;
     xcb_rectangle_t rect = frozen_pointer->rectangle;
-    xcb_window_t win = c->window;
-
-    PRINTF("motion notify %X %u\n", win, frozen_pointer->button);
-
-    delta_x = e->root_x - frozen_pointer->position.x;
-    delta_y = e->root_y - frozen_pointer->position.y;
-
-    switch (frozen_pointer->button) {
-        case XCB_BUTTON_INDEX_1:
-            x = rect.x + delta_x;
-            y = rect.y + delta_y;
-            window_move(win, x, y);
+    node_t *vertical_fence = frozen_pointer->vertical_fence;
+    node_t *horizontal_fence = frozen_pointer->horizontal_fence;
+
+    x = y = 0;
+    w = h = 1;
+
+    delta_x = root_x - frozen_pointer->position.x;
+    delta_y = root_y - frozen_pointer->position.y;
+
+    switch (pac) {
+        case ACTION_MOVE:
+            if (frozen_pointer->is_tiled) {
+                xcb_window_t pwin = XCB_NONE;
+                query_pointer(&pwin, NULL);
+                if (pwin != XCB_NONE) {
+                    window_location_t loc;
+                    if (locate_window(pwin, &loc) && is_tiled(loc.node->client)) {
+                        swap_nodes(d, n, loc.desktop, loc.node);
+                        arrange(m, d);
+                        if (m != loc.monitor) {
+                            arrange(loc.monitor, loc.desktop);
+                            frozen_pointer->monitor = loc.monitor;
+                            frozen_pointer->desktop = loc.desktop;
+                        }
+                    }
+                }
+            } else {
+                x = rect.x + delta_x;
+                y = rect.y + delta_y;
+                window_move(win, x, y);
+            }
             break;
-        case XCB_BUTTON_INDEX_3:
-            switch (frozen_pointer->corner) {
-                case TOP_LEFT:
-                    x = rect.x + delta_x;
-                    y = rect.y + delta_y;
-                    w = rect.width - delta_x;
-                    h = rect.height - delta_y;
-                    break;
-                case TOP_RIGHT:
-                    x = rect.x;
-                    y = rect.y + delta_y;
-                    w = rect.width + delta_x;
-                    h = rect.height - delta_y;
-                    break;
-                case BOTTOM_LEFT:
-                    x = rect.x + delta_x;
-                    y = rect.y;
-                    w = rect.width - delta_x;
-                    h = rect.height + delta_y;
-                    break;
-                case BOTTOM_RIGHT:
-                    x = rect.x;
-                    y = rect.y;
-                    w = rect.width + delta_x;
-                    h = rect.height + delta_y;
-                    break;
+        case ACTION_RESIZE_SIDE:
+        case ACTION_RESIZE_CORNER:
+            if (frozen_pointer->is_tiled) {
+                if (vertical_fence != NULL) {
+                    double sr = frozen_pointer->vertical_ratio + (double) delta_x / vertical_fence->rectangle.width;
+                    sr = MAX(0, sr);
+                    sr = MIN(1, sr);
+                    vertical_fence->split_ratio = sr;
+                }
+                if (horizontal_fence != NULL) {
+                    double sr = frozen_pointer->horizontal_ratio + (double) delta_y / horizontal_fence->rectangle.height;
+                    sr = MAX(0, sr);
+                    sr = MIN(1, sr);
+                    horizontal_fence->split_ratio = sr;
+                }
+                arrange(mon, mon->desk);
+            } else {
+                if (pac == ACTION_RESIZE_SIDE) {
+                    switch (frozen_pointer->side) {
+                        case SIDE_TOP:
+                            x = rect.x;
+                            y = rect.y + delta_y;
+                            w = rect.width;
+                            h = rect.height - delta_y;
+                            break;
+                        case SIDE_RIGHT:
+                            x = rect.x;
+                            y = rect.y;
+                            w = rect.width + delta_x;
+                            h = rect.height;
+                            break;
+                        case SIDE_BOTTOM:
+                            x = rect.x;
+                            y = rect.y;
+                            w = rect.width;
+                            h = rect.height + delta_y;
+                            break;
+                        case SIDE_LEFT:
+                            x = rect.x + delta_x;
+                            y = rect.y;
+                            w = rect.width - delta_x;
+                            h = rect.height;
+                            break;
+                    }
+                    width = MAX(1, w);
+                    height = MAX(1, h);
+                    window_move_resize(win, x, y, width, height);
+                    c->floating_rectangle = (xcb_rectangle_t) {x, y, width, height};
+                    window_draw_border(n, d->focus == n, mon == m);
+                } else if (pac == ACTION_RESIZE_CORNER) {
+                    switch (frozen_pointer->corner) {
+                        case CORNER_TOP_LEFT:
+                            x = rect.x + delta_x;
+                            y = rect.y + delta_y;
+                            w = rect.width - delta_x;
+                            h = rect.height - delta_y;
+                            break;
+                        case CORNER_TOP_RIGHT:
+                            x = rect.x;
+                            y = rect.y + delta_y;
+                            w = rect.width + delta_x;
+                            h = rect.height - delta_y;
+                            break;
+                        case CORNER_BOTTOM_LEFT:
+                            x = rect.x + delta_x;
+                            y = rect.y;
+                            w = rect.width - delta_x;
+                            h = rect.height + delta_y;
+                            break;
+                        case CORNER_BOTTOM_RIGHT:
+                            x = rect.x;
+                            y = rect.y;
+                            w = rect.width + delta_x;
+                            h = rect.height + delta_y;
+                            break;
+                    }
+                    width = MAX(1, w);
+                    height = MAX(1, h);
+                    window_move_resize(win, x, y, width, height);
+                    c->floating_rectangle = (xcb_rectangle_t) {x, y, width, height};
+                    window_draw_border(n, d->focus == n, mon == m);
+                }
             }
-            width = MAX(1, w);
-            height = MAX(1, h);
-            window_move_resize(win, x, y, width, height);
-            c->floating_rectangle = (xcb_rectangle_t) {x, y, width, height};
-            window_draw_border(n, (d->focus == n));
+            break;
+        case ACTION_FOCUS:
+        case ACTION_NONE:
+            break;
     }
 }
 
-void button_release(xcb_generic_event_t *evt)
+void ungrab_pointer(void)
 {
-    xcb_button_press_event_t *e = (xcb_button_press_event_t *) evt;
-    xcb_window_t win = e->child;
+    PUTS("ungrab pointer");
 
-    PRINTF("button release %X %u %u\n", win, e->detail, e->state);
-
-    xcb_ungrab_pointer(dpy, XCB_CURRENT_TIME);
-
-    window_location_t loc;
-    if (locate_window(win, &loc)) {
-        update_floating_rectangle(loc.node->client);
-    }
-}
+    if (frozen_pointer->action == ACTION_NONE)
+        return;
 
-void handle_state(node_t *n, xcb_atom_t state, unsigned int action)
-{
-    if (state == ewmh->_NET_WM_STATE_FULLSCREEN) {
-        bool fs = n->client->fullscreen;
-        if (action == XCB_EWMH_WM_STATE_TOGGLE
-                || (fs && action == XCB_EWMH_WM_STATE_REMOVE)
-                || (!fs && action == XCB_EWMH_WM_STATE_ADD))
-            toggle_fullscreen(n->client);
+    if (is_floating(frozen_pointer->client))
+        update_floating_rectangle(frozen_pointer->client);
+    monitor_t *m = underlying_monitor(frozen_pointer->client);
+    if (m != NULL && m != frozen_pointer->monitor) {
+        transfer_node(frozen_pointer->monitor, frozen_pointer->desktop, m, m->desk, frozen_pointer->node);
+        select_monitor(m);
     }
 }