*/
void client_mark(xcb_connection_t *conn, Client *client, const char *mark);
+/**
+ * Returns the minimum height of a specific window. The height is calculated
+ * by using 2 pixels (for the client window itself), possibly padding this to
+ * comply with the client’s base_height and then adding the decoration height.
+ *
+ */
+uint32_t client_min_height(Client *client);
+
+/**
+ * See client_min_height.
+ *
+ */
+uint32_t client_min_width(Client *client);
+
/**
* Pretty-prints the client’s information into the logfile.
*
#include "client.h"
#include "table.h"
#include "workspace.h"
+#include "config.h"
/*
* Removes the given client from the container, either because it will be inserted into another
break;
}
}
+
+/*
+ * Returns the minimum height of a specific window. The height is calculated
+ * by using 2 pixels (for the client window itself), possibly padding this to
+ * comply with the client’s base_height and then adding the decoration height.
+ *
+ */
+uint32_t client_min_height(Client *client) {
+ uint32_t height = max(2, client->base_height);
+ i3Font *font = load_font(global_conn, config.font);
+
+ if (client->titlebar_position == TITLEBAR_OFF && client->borderless)
+ return height;
+
+ if (client->titlebar_position == TITLEBAR_OFF && !client->borderless)
+ return height + 2;
+
+ return height + font->height + 2 + 2;
+}
+
+/*
+ * See client_min_height.
+ *
+ */
+uint32_t client_min_width(Client *client) {
+ uint32_t width = max(2, client->base_width);
+
+ if (client->titlebar_position == TITLEBAR_OFF && client->borderless)
+ return width;
+
+ if (client->titlebar_position == TITLEBAR_OFF && !client->borderless)
+ return width + 2;
+
+ return width + 2 + 2;
+}
case BORDER_RIGHT: {
int new_width = old_rect->width + (new_x - event->root_x);
if ((new_width < 0) ||
- (new_width < 50 && client->rect.width >= new_width))
+ (new_width < client_min_width(client) && client->rect.width >= new_width))
return;
client->rect.width = new_width;
break;
case BORDER_BOTTOM: {
int new_height = old_rect->height + (new_y - event->root_y);
if ((new_height < 0) ||
- (new_height < 20 && client->rect.height >= new_height))
+ (new_height < client_min_height(client) && client->rect.height >= new_height))
return;
client->rect.height = old_rect->height + (new_y - event->root_y);
break;
case BORDER_TOP: {
int new_height = old_rect->height + (event->root_y - new_y);
if ((new_height < 0) ||
- (new_height < 20 && client->rect.height >= new_height))
+ (new_height < client_min_height(client) && client->rect.height >= new_height))
return;
client->rect.y = old_rect->y + (new_y - event->root_y);
case BORDER_LEFT: {
int new_width = old_rect->width + (event->root_x - new_x);
if ((new_width < 0) ||
- (new_width < 50 && client->rect.width >= new_width))
+ (new_width < client_min_width(client) && client->rect.width >= new_width))
return;
client->rect.x = old_rect->x + (new_x - event->root_x);
client->rect.width = new_width;
int32_t new_height = old_rect->height + (new_y - event->root_y);
/* Obey minimum window size and reposition the client */
- if (new_width >= 50)
+ if (new_width > 0 && new_width >= client_min_width(client))
client->rect.width = new_width;
- if (new_height >= 20)
+ if (new_height > 0 && new_height >= client_min_height(client))
client->rect.height = new_height;
/* resize_client flushes */