mirror of
https://github.com/0intro/wmii
synced 2025-02-08 18:34:43 +03:00
New drop_move algorithm for managed mode. Works, but sucks. Will replace soon.
This commit is contained in:
parent
232d65861b
commit
67a60e670a
22
area.c
22
area.c
@ -15,23 +15,25 @@ sel_client_of_area(Area *a) {
|
||||
Area *
|
||||
create_area(View *v, Area *pos, unsigned int w) {
|
||||
static unsigned short id = 1;
|
||||
unsigned int area_size, col_size, i;
|
||||
unsigned int area_num, col_num, i;
|
||||
unsigned int min_width = screen->rect.width/NCOL;
|
||||
Area *ta, *a, **p = pos ? &pos->next : &v->area;
|
||||
|
||||
for(i = 0, area_size = 0, a=v->area; a && a != *p; a=a->next, area_size++, i++);
|
||||
col_size = area_size ? area_size - 1 : 0;
|
||||
area_num = 0;
|
||||
for(a = v->area; a && a != *p; a=a->next)
|
||||
area_num++;
|
||||
col_num = area_num ? area_num - 1 : 0;
|
||||
if(!w) {
|
||||
if(col_size)
|
||||
w = screen->rect.width / (col_size + 1);
|
||||
if(area_num)
|
||||
w = screen->rect.width / (col_num + 1);
|
||||
else
|
||||
w = screen->rect.width;
|
||||
}
|
||||
if(w < min_width)
|
||||
w = min_width;
|
||||
if(col_size && col_size * min_width + w > screen->rect.width)
|
||||
if(col_num && col_num * min_width + w > screen->rect.width)
|
||||
return NULL;
|
||||
if(area_size > 1)
|
||||
if(area_num > 1)
|
||||
scale_view(v, screen->rect.width - w);
|
||||
a = ixp_emallocz(sizeof(Area));
|
||||
a->view = v;
|
||||
@ -45,8 +47,10 @@ create_area(View *v, Area *pos, unsigned int w) {
|
||||
a->next = *p;
|
||||
*p = a;
|
||||
v->sel = a;
|
||||
if(i) write_event("CreateColumn %d\n", i);
|
||||
for(ta=v->area, i = 0; ta && ta != v->sel; ta=ta->next, i++);
|
||||
if(area_num) write_event("CreateColumn %d\n", area_num);
|
||||
|
||||
i = 0;
|
||||
for(ta=v->area; ta && ta != v->sel; ta=ta->next) i++;
|
||||
if(i) write_event("ColumnFocus %d\n", i);
|
||||
else write_event("FocusFloating\n");
|
||||
return a;
|
||||
|
99
column.c
99
column.c
@ -5,6 +5,19 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int
|
||||
max(int a, int b) {
|
||||
if(a > b)
|
||||
return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
static int
|
||||
min(int a, int b) {
|
||||
if(a < b)
|
||||
return a;
|
||||
return b;
|
||||
}
|
||||
|
||||
char *
|
||||
str_of_column_mode(int mode) {
|
||||
@ -298,6 +311,8 @@ AfterVertical:
|
||||
focus_view(screen, v);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* I think this will go later */
|
||||
static Frame *
|
||||
frame_of_point(XPoint *pt) {
|
||||
Area *a;
|
||||
@ -313,9 +328,88 @@ frame_of_point(XPoint *pt) {
|
||||
f=f->anext);
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
drop_move(Frame *f, XRectangle *new, XPoint *pt) {
|
||||
drop_move(Frame *f, XRectangle *nrect) {
|
||||
XRectangle *arect, *frect;
|
||||
Frame *ft, *f_high;
|
||||
Area *a, *a_high;
|
||||
View *v;
|
||||
int high, over, before;
|
||||
|
||||
v = f->view;
|
||||
high = 0;
|
||||
a_high = NULL;
|
||||
|
||||
for(a = v->area->next; a; a = a->next) {
|
||||
arect = &a->rect;
|
||||
over = min(arect->x + arect->width, nrect->x + nrect->width) -
|
||||
max(arect->x, nrect->x);
|
||||
if(over > high) {
|
||||
high = over;
|
||||
a_high = a;
|
||||
}
|
||||
}
|
||||
|
||||
over = (nrect->x + nrect->width) - screen->rect.width;
|
||||
if(over > high) {
|
||||
for(a_high = f->area; a_high->next; a_high = a_high->next);
|
||||
a_high = new_column(v, a_high, 0);
|
||||
send_to_area(a_high, f->area, f);
|
||||
arrange_column(a_high, False);
|
||||
return;
|
||||
}else if(-(nrect->x) > high) {
|
||||
a_high = new_column(v, v->area, 0);
|
||||
send_to_area(a_high, f->area, f);
|
||||
arrange_column(a_high, False);
|
||||
return;
|
||||
}
|
||||
|
||||
if(f->area != a_high)
|
||||
send_to_area(a_high, f->area, f);
|
||||
|
||||
high = 0;
|
||||
for(ft = f->area->frame; ft; ft = ft->anext) {
|
||||
frect = &ft->rect;
|
||||
over = min(frect->y + frect->height, nrect->y + nrect->height) -
|
||||
max(frect->y, nrect->y);
|
||||
if(over > high) {
|
||||
high = over;
|
||||
f_high = ft;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
over = (nrect->y + nrect->height) - (screen->rect.height - screen->brect.height);
|
||||
if(over > high) {
|
||||
remove_frame(f);
|
||||
for(ft = f->area->frame; ft->anext; ft = ft->anext);
|
||||
insert_frame(ft, f, False);
|
||||
focus(f->client, False);
|
||||
return;
|
||||
}else if(-(nrect->y) > high) {
|
||||
remove_frame(f);
|
||||
insert_frame(f->area->frame, f, True);
|
||||
focus(f->client, False);
|
||||
return;
|
||||
}
|
||||
|
||||
if(f_high != f) {
|
||||
remove_frame(f);
|
||||
frect = &f_high->rect;
|
||||
before = (frect->y - nrect->y) >
|
||||
((nrect->y + nrect->height) - (frect->y + frect->height)) ?
|
||||
True : False;
|
||||
insert_frame(f_high, f, before);
|
||||
focus(f->client, False);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* I'm keeping this around for the moment. Rather than digging through hg later */
|
||||
static void
|
||||
drop_move_old(Frame *f, XRectangle *new, XPoint *pt) {
|
||||
Area *tgt, *src;
|
||||
Frame *ft;
|
||||
View *v;
|
||||
@ -370,12 +464,13 @@ drop_move(Frame *f, XRectangle *new, XPoint *pt) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
resize_column(Client *c, XRectangle *r, XPoint *pt) {
|
||||
Frame *f = c->sel;
|
||||
if((f->rect.width == r->width) && (f->rect.height == r->height))
|
||||
drop_move(f, r, pt);
|
||||
drop_move(f, r);
|
||||
else
|
||||
drop_resize(f, r);
|
||||
}
|
||||
|
8
frame.c
8
frame.c
@ -37,10 +37,12 @@ create_frame(Client *c, View *v) {
|
||||
|
||||
void
|
||||
remove_frame(Frame *f) {
|
||||
Area *a = f->area;
|
||||
Frame **ft = &a->frame;
|
||||
Area *a;
|
||||
Frame **ft;
|
||||
|
||||
for(; *ft && *ft != f; ft=&(*ft)->anext);
|
||||
a = f->area;
|
||||
for(ft = &a->frame; *ft; ft=&(*ft)->anext)
|
||||
if(*ft == f) break;
|
||||
*ft = f->anext;
|
||||
}
|
||||
|
||||
|
8
mouse.c
8
mouse.c
@ -222,16 +222,16 @@ do_mouse_resize(Client *c, BlitzAlign align) {
|
||||
if(rects)
|
||||
free(rects);
|
||||
|
||||
XUngrabServer(blz.dpy);
|
||||
XUngrabPointer(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
|
||||
XTranslateCoordinates(blz.dpy, c->framewin, blz.root,
|
||||
frect.width * rx, frect.height * ry,
|
||||
&dx, &dy, &dummy);
|
||||
if(dy > screen->brect.y)
|
||||
dy = screen->brect.y - 1;
|
||||
XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, dx, dy);
|
||||
|
||||
XUngrabServer(blz.dpy);
|
||||
XUngrabPointer(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
return;
|
||||
case MotionNotify:
|
||||
ofrect = frect;
|
||||
|
Loading…
x
Reference in New Issue
Block a user