]> git.sur5r.net Git - i3/i3/blobdiff - src/floating.c
Rename new_container to workspace_layout
[i3/i3] / src / floating.c
index 2218da29c1bdb2588454ffd013304a4492b60621..6cc9a16817adbac4574f5b7538cf18fc5fc44e93 100644 (file)
@@ -94,8 +94,7 @@ void floating_enable(Con *con, bool automatic) {
     free(name);
 
     /* find the height for the decorations */
-    i3Font *font = load_font(conn, config.font);
-    int deco_height = font->height + 5;
+    int deco_height = config.font.height + 5;
 
     DLOG("Original rect: (%d, %d) with %d x %d\n", con->rect.x, con->rect.y, con->rect.width, con->rect.height);
     Rect zero = { 0, 0, 0, 0 };
@@ -176,7 +175,8 @@ void floating_disable(Con *con, bool automatic) {
 
     /* 3: re-attach to the parent of the currently focused con on the workspace
      * this floating con was on */
-    Con *focused = con_descend_focused(con_get_workspace(con));
+    Con *focused = con_descend_tiling_focused(con_get_workspace(con));
+
     /* if there is no other container on this workspace, focused will be the
      * workspace itself */
     if (focused->type == CT_WORKSPACE)
@@ -231,10 +231,10 @@ DRAGGING_CB(drag_window_callback) {
     /* Reposition the client correctly while moving */
     con->rect.x = old_rect->x + (new_x - event->root_x);
     con->rect.y = old_rect->y + (new_y - event->root_y);
-    /* TODO: don’t re-render the whole tree just because we change
-     * coordinates of a floating window */
-    tree_render();
-    x_push_changes(croot);
+
+    render_con(con, false);
+    x_push_node(con, true);
+    xcb_flush(conn);
 }
 
 /*
@@ -284,12 +284,10 @@ DRAGGING_CB(resize_window_callback) {
         dest_height = old_rect->height - (new_y - event->root_y);
     else dest_height = old_rect->height + (new_y - event->root_y);
 
-    /* TODO: minimum window size */
-#if 0
     /* Obey minimum window size */
-    dest_width = max(dest_width, client_min_width(client));
-    dest_height = max(dest_height, client_min_height(client));
-#endif
+    Rect minimum = con_minimum_size(con);
+    dest_width = max(dest_width, minimum.width);
+    dest_height = max(dest_height, minimum.height);
 
     /* User wants to keep proportions, so we may have to adjust our values */
     if (params->proportional) {
@@ -376,19 +374,15 @@ void drag_pointer(Con *con, xcb_button_press_event_t *event, xcb_window_t
     while ((inside_event = xcb_wait_for_event(conn))) {
         /* We now handle all events we can get using xcb_poll_for_event */
         do {
-            /* Same as get_event_handler in xcb */
-            int nr = inside_event->response_type;
-            if (nr == 0) {
-                /* An error occured */
-                //handle_event(NULL, conn, inside_event);
+            /* skip x11 errors */
+            if (inside_event->response_type == 0) {
                 free(inside_event);
                 continue;
             }
-            assert(nr < 256);
-            nr &= XCB_EVENT_RESPONSE_TYPE_MASK;
-            assert(nr >= 2);
+            /* Strip off the highest bit (set if the event is generated) */
+            int type = (inside_event->response_type & 0x7F);
 
-            switch (nr) {
+            switch (type) {
                 case XCB_BUTTON_RELEASE:
                     goto done;
 
@@ -400,13 +394,13 @@ void drag_pointer(Con *con, xcb_button_press_event_t *event, xcb_window_t
 
                 case XCB_UNMAP_NOTIFY:
                     DLOG("Unmap-notify, aborting\n");
-                    xcb_event_handle(&evenths, inside_event);
+                    handle_event(type, inside_event);
                     goto done;
 
                 default:
                     DLOG("Passing to original handler\n");
                     /* Use original handler */
-                    xcb_event_handle(&evenths, inside_event);
+                    handle_event(type, inside_event);
                     break;
             }
             if (last_motion_notify != inside_event)