Take into account the window’s base_{width,height} when resizing (Thanks Mirko)
This commit is contained in:
parent
8d8804221b
commit
f87b98e0a7
|
@ -112,6 +112,20 @@ void client_map(xcb_connection_t *conn, Client *client);
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
|
36
src/client.c
36
src/client.c
|
@ -26,6 +26,7 @@
|
|||
#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
|
||||
|
@ -372,3 +373,38 @@ void client_mark(xcb_connection_t *conn, Client *client, const char *mark) {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ int floating_border_click(xcb_connection_t *conn, Client *client, xcb_button_pre
|
|||
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;
|
||||
|
@ -182,7 +182,7 @@ int floating_border_click(xcb_connection_t *conn, Client *client, xcb_button_pre
|
|||
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;
|
||||
|
@ -191,7 +191,7 @@ int floating_border_click(xcb_connection_t *conn, Client *client, xcb_button_pre
|
|||
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);
|
||||
|
@ -202,7 +202,7 @@ int floating_border_click(xcb_connection_t *conn, Client *client, xcb_button_pre
|
|||
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;
|
||||
|
@ -273,10 +273,10 @@ void floating_resize_window(xcb_connection_t *conn, Client *client, xcb_button_p
|
|||
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 */
|
||||
|
|
Loading…
Reference in New Issue