]> git.sur5r.net Git - i3/i3/blobdiff - src/floating.c
Bugfix: Use more precise floating point arithmetic (Thanks helgiks)
[i3/i3] / src / floating.c
index 394145457111cf7a7d167fcfd3385b57ae9ea5a9..4177b6e5a0b71f2f8919dcc73bed5504be4defc9 100644 (file)
@@ -26,6 +26,7 @@
 #include "layout.h"
 #include "client.h"
 #include "floating.h"
+#include "workspace.h"
 
 /*
  * Toggles floating mode for the given client.
@@ -43,17 +44,18 @@ void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic
         if (con == NULL) {
                 LOG("This client is already in floating (container == NULL), re-inserting\n");
                 Client *next_tiling;
-                SLIST_FOREACH(next_tiling, &(client->workspace->focus_stack), focus_clients)
+                Workspace *ws = client->workspace;
+                SLIST_FOREACH(next_tiling, &(ws->focus_stack), focus_clients)
                         if (!client_is_floating(next_tiling))
                                 break;
                 /* If there are no tiling clients on this workspace, there can only be one
                  * container: the first one */
-                if (next_tiling == TAILQ_END(&(client->workspace->focus_stack)))
-                        con = client->workspace->table[0][0];
+                if (next_tiling == TAILQ_END(&(ws->focus_stack)))
+                        con = ws->table[0][0];
                 else con = next_tiling->container;
 
                 /* Remove the client from the list of floating clients */
-                TAILQ_REMOVE(&(client->workspace->floating_clients), client, floating_clients);
+                TAILQ_REMOVE(&(ws->floating_clients), client, floating_clients);
 
                 LOG("destination container = %p\n", con);
                 Client *old_focused = con->currently_focused;
@@ -152,7 +154,6 @@ void floating_assign_to_workspace(Client *client, Workspace *new_workspace) {
         TAILQ_INSERT_TAIL(&(client->workspace->floating_clients), client, floating_clients);
         if (client->fullscreen)
                 client->workspace->fullscreen_client = client;
-
 }
 
 /*
@@ -270,13 +271,13 @@ void floating_resize_window(xcb_connection_t *conn, Client *client, xcb_button_p
         void resize_window_callback(Rect *old_rect, uint32_t new_x, uint32_t new_y) {
                 int32_t new_width = old_rect->width + (new_x - event->root_x);
                 int32_t new_height = old_rect->height + (new_y - event->root_y);
-                /* Obey minimum window size */
-                if (new_width < 75 || new_height < 50)
-                        return;
 
-                /* Reposition the client correctly while moving */
-                client->rect.width = new_width;
-                client->rect.height = new_height;
+                /* Obey minimum window size and reposition the client */
+                if (new_width >= 50)
+                        client->rect.width = new_width;
+
+                if (new_height >= 20)
+                        client->rect.height = new_height;
 
                 /* resize_client flushes */
                 resize_client(conn, client);
@@ -342,8 +343,13 @@ void drag_pointer(xcb_connection_t *conn, Client *client, xcb_button_press_event
                                         /* motion_notify events are saved for later */
                                         FREE(last_motion_notify);
                                         last_motion_notify = inside_event;
-
                                         break;
+
+                                case XCB_UNMAP_NOTIFY:
+                                        LOG("Unmap-notify, aborting\n");
+                                        xcb_event_handle(&evenths, inside_event);
+                                        goto done;
+
                                 default:
                                         LOG("Passing to original handler\n");
                                         /* Use original handler */