mirror of
https://github.com/0intro/wmii
synced 2024-11-30 01:23:12 +03:00
Fixed sizing bug in create_area with 1 column
This commit is contained in:
parent
b49635f533
commit
0adf0d0cb3
13
area.c
13
area.c
@ -7,7 +7,14 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
Client *
|
||||
static int
|
||||
max(int a, int b) {
|
||||
if(a > b)
|
||||
return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
Client *
|
||||
sel_client_of_area(Area *a) {
|
||||
return a && a->sel ? a->sel->client : nil;
|
||||
}
|
||||
@ -28,7 +35,7 @@ create_area(View *v, Area *pos, unsigned int w) {
|
||||
area_num++, i++;
|
||||
for(; a; a = a->next) area_num++;
|
||||
|
||||
col_num = area_num ? area_num - 1 : 0;
|
||||
col_num = max((area_num - 1), 0);
|
||||
if(!w) {
|
||||
if(area_num)
|
||||
w = screen->rect.width / (col_num + 1);
|
||||
@ -39,7 +46,7 @@ create_area(View *v, Area *pos, unsigned int w) {
|
||||
w = min_width;
|
||||
if(col_num && col_num * min_width + w > screen->rect.width)
|
||||
return nil;
|
||||
if(i > 1)
|
||||
if(i)
|
||||
scale_view(v, screen->rect.width - w);
|
||||
|
||||
a = ixp_emallocz(sizeof(Area));
|
||||
|
22
view.c
22
view.c
@ -209,16 +209,21 @@ restack_view(View *v) {
|
||||
|
||||
void
|
||||
scale_view(View *v, float w) {
|
||||
unsigned int xoff, col_size = 0;
|
||||
unsigned int min_width = screen->rect.width/NCOL;
|
||||
unsigned int xoff, num_col;
|
||||
unsigned int min_width;
|
||||
Area *a;
|
||||
float scale, dx = 0;
|
||||
int wdiff = 0;
|
||||
|
||||
min_width = screen->rect.width/NCOL;
|
||||
|
||||
if(!v->area->next)
|
||||
return;
|
||||
for(a=v->area->next; a; a=a->next, col_size++)
|
||||
dx += a->rect.width;
|
||||
|
||||
num_col = 0;
|
||||
for(a=v->area->next; a; a=a->next)
|
||||
num_col++, dx += a->rect.width;
|
||||
|
||||
scale = w / dx;
|
||||
xoff = 0;
|
||||
for(a=v->area->next; a; a=a->next) {
|
||||
@ -227,14 +232,15 @@ scale_view(View *v, float w) {
|
||||
a->rect.width = w - xoff;
|
||||
xoff += a->rect.width;
|
||||
}
|
||||
/* min_width can only be respected when there is enough space; the caller should guarantee this */
|
||||
if(col_size * min_width > w)
|
||||
/* min_width can only be respected when there is enough space;
|
||||
* the caller should guarantee this */
|
||||
if(num_col * min_width > w)
|
||||
return;
|
||||
xoff = 0;
|
||||
for(a=v->area->next, col_size--; a; a=a->next, col_size--) {
|
||||
for(a=v->area->next, num_col--; a; a=a->next, num_col--) {
|
||||
if(a->rect.width < min_width)
|
||||
a->rect.width = min_width;
|
||||
else if((wdiff = xoff + a->rect.width - w + col_size * min_width) > 0)
|
||||
else if((wdiff = xoff + a->rect.width - w + num_col * min_width) > 0)
|
||||
a->rect.width -= wdiff;
|
||||
if(!a->next)
|
||||
a->rect.width = w - xoff;
|
||||
|
Loading…
Reference in New Issue
Block a user