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