Added an explicit floating member to Areas

This commit is contained in:
Kris Maglione 2006-06-23 21:22:04 -04:00
parent 489a00c835
commit 01290a7bdd
9 changed files with 90 additions and 78 deletions

View File

@ -96,7 +96,7 @@ select_area(Area *a, char *arg)
else
new = v->area->next;
} else if(!strncmp(arg, "left", 5)) {
if(a == v->area)
if(a->floating)
return Ebadvalue;
for(new=v->area->next;
new && new->next != a;
@ -104,7 +104,7 @@ select_area(Area *a, char *arg)
if(!new)
new=v->area->next;
} else if(!strncmp(arg, "right", 5)) {
if(a == v->area)
if(a->floating)
return Ebadvalue;
new = a->next ? a->next : a;
}
@ -133,7 +133,7 @@ select_area(Area *a, char *arg)
if(new->sel)
focus_client(new->sel->client, True);
v->sel = new;
if(a != v->area)
if(!a->floating)
v->revert = a;
draw_frames();
return nil;
@ -253,7 +253,7 @@ attach_to_area(Area *a, Client *c, Bool send)
Frame *f;
for(f=a->frame, i=1; f; f=f->anext, i++);
c->floating = (a == v->area);
c->floating = a->floating;
if(!c->floating) {
h = a->rect.height / i;
if(a->frame)
@ -290,7 +290,7 @@ detach_from_area(Area *a, Client *c)
cext_assert(f->area == a);
destroy_frame(f);
if(a != a->view->area) {
if(!a->floating) {
if(a->frame)
arrange_column(a, False);
else {

View File

@ -138,7 +138,7 @@ focus_client(Client *c, Bool restack)
v = f->area->view;
v->sel = f->area;
f->area->sel = f;
c->floating = (f->area == v->area);
c->floating = f->area->floating;
if(restack)
restack_view(v);
else {
@ -484,7 +484,7 @@ void
resize_client(Client *c, XRectangle *r, Bool ignore_xcall)
{
Frame *f = c->sel;
Bool floating = (f->area == f->area->view->area);
Bool floating = f->area->floating;
BlitzAlign stickycorner = 0;;
if(f->rect.x != r->x && f->rect.x + f->rect.width == r->x + r->width)
@ -535,7 +535,7 @@ newcol_client(Client *c, char *arg)
Area *to, *a = f->area;
View *v = a->view;
if(a == v->area)
if(a->floating)
return;
if(!f->anext && f == a->frame)
return;
@ -582,7 +582,7 @@ size_client(Client *c, char *arg)
return;
new.width += w;
new.height += h;
if(f->area != f->area->view->area)
if(!f->area->floating)
resize_column(f->client, &new, nil);
else
resize_client(f->client, &new, False);
@ -608,7 +608,7 @@ send_client(Frame *f, char *arg)
return 0;
if(i && !strncmp(arg, "left", 5)) {
if(a == v->area)
if(a->floating)
return Ebadvalue;
for(to=v->area->next; to && a != to->next; to=to->next);
if(!to && (f->anext || f != a->frame))
@ -618,7 +618,7 @@ send_client(Frame *f, char *arg)
send_to_area(to, a, c);
}
else if(i && !strncmp(arg, "right", 5)) {
if(a == v->area)
if(a->floating)
return Ebadvalue;
if(!(to = a->next) && (f->anext || f!= a->frame))
to = new_column(v, a, 0);
@ -627,9 +627,9 @@ send_client(Frame *f, char *arg)
send_to_area(to, a, c);
}
else if(!strncmp(arg, "toggle", 7)) {
if(a != v->area)
if(!a->floating)
to = v->area;
else if(c->revert && c->revert != v->area)
else if(c->revert && !c->revert->floating)
to = c->revert;
else
to = v->area->next;

View File

@ -152,7 +152,7 @@ handle_configurerequest(XEvent *e)
c = client_of_win(ev->window);
ev->value_mask &= ~CWSibling;
if(c) {
if(c->frame && c->sel->area == c->sel->area->view->area) {
if(c->frame && c->sel->area->floating) {
gravitate_client(c, True);
if(c->frame) {

View File

@ -157,7 +157,7 @@ draw_frame(Frame *f)
f->posbar.rect.height = height_of_bar();
snprintf(buf, sizeof(buf), "%s%d/%d",
(f->area == f->area->view->area) ? "~" : "", fidx + 1, size);
f->area->floating ? "~" : "", fidx + 1, size);
w = f->posbar.rect.width =
f->posbar.rect.height + blitz_textwidth(&def.font, buf);

View File

@ -631,7 +631,7 @@ fs_read(P9Req *r) {
r->ofcall.data = buf;
tf = f = lookup_file(f, nil);
/* Note: f->tab.name == "."; goto next */
/* Note: f->tab.name == "." so we skip it */
for(f=f->next; f; f=f->next) {
dostat(&s, fs_size(f), f);
n = ixp_sizeof_stat(&s);
@ -693,6 +693,8 @@ fs_read(P9Req *r) {
return;
}
}
/* This is an assert because it should this should not be called if
* the file is not open for reading. */
cext_assert(!"Read called on an unreadable file");
}
@ -700,7 +702,7 @@ fs_read(P9Req *r) {
void
fs_write(P9Req *r) {
FileId *f;
char *buf, *errstr = nil;
char *errstr = nil;
unsigned int i;
if(r->ifcall.count == 0)
@ -759,13 +761,20 @@ fs_write(P9Req *r) {
r->ofcall.count = r->ifcall.count;
return respond(r, nil);
case FsFEvent:
buf = cext_emallocz(r->ifcall.count + 1);
bcopy(r->ifcall.data, buf, r->ifcall.count);
write_event("%s", buf);
free(buf);
if(r->ifcall.data[r->ifcall.count-1] == '\n') {
r->ifcall.data = realloc(r->ifcall.data, r->ifcall.count + 1);
r->ifcall.data[r->ifcall.count] = '\0';
}else{
r->ifcall.data = realloc(r->ifcall.data, r->ifcall.count + 2);
r->ifcall.data[r->ifcall.count] = '\n';
r->ifcall.data[r->ifcall.count + 1] = '\0';
}
write_event("%s", (char *)r->ifcall.data);
r->ofcall.count = r->ifcall.count;
return respond(r, nil);
}
/* This is an assert because it should this should not be called if
* the file is not open for writing. */
cext_assert(!"Write called on an unwritable file");
}

View File

@ -210,7 +210,6 @@ void
handle_key(Window w, unsigned long mod, KeyCode keycode)
{
Key *k;
char buf[128];
for(k=key; k; k->tnext=k->lnext, k=k->lnext);
Key *found = match_keys(key, mod, keycode, False);

View File

@ -179,7 +179,7 @@ do_mouse_resize(Client *c, BlitzAlign align)
XEvent ev;
unsigned int num = 0, di;
Frame *f = c->sel;
Bool floating = (f->area == f->area->view->area);
Bool floating = f->area->floating;
int snap = floating ? rect.height / 66 : 0;
XRectangle *rects = floating ? rects_of_view(f->area->view, &num) : nil;
XRectangle frect = f->rect, ofrect;

View File

@ -9,6 +9,60 @@
#include "wm.h"
static Bool
is_of_view(View *v, Client *c)
{
Area *a;
for(a=v->area; a; a=a->next)
if(is_of_area(a, c))
return True;
return False;
}
static Bool
is_view_of(Client *c, View *v)
{
ViewLink *l;
for(l=c->views; l; l=l->next)
if(l->view == v)
return True;
return False;
}
static Bool
is_empty(View *v)
{
Area *a;
for(a=v->area; a; a=a->next)
if(a->frame)
return False;
return True;
}
View *
view_of_id(unsigned short id) {
View *v;
for(v = view; v; v=v->next)
if(v->id == id) break;
return v;
}
View *
view_of_name(const char *name)
{
View *v;
for(v = view; v; v=v->next)
if(!strcmp(v->name, name)) break;
return v;
}
static View *
get_view(const char *name)
{
View *v = view_of_name(name);
return v ? v : create_view(name);
}
static void
assign_sel_view(View *v)
{
@ -30,8 +84,10 @@ create_view(const char *name)
cext_strlcpy(v->name, name, sizeof(v->name));
create_area(v, nil, 0);
create_area(v, v->area, 0);
v->area->floating = True;
for(i=&view; *i && (strcmp((*i)->name, name) < 0); i=&(*i)->next);
for(i=&view; *i; i=&(*i)->next)
if(strcmp((*i)->name, name) < 0) break;
v->next = *i;
*i = v;
@ -130,28 +186,6 @@ rects_of_view(View *v, unsigned int *num)
return (result - *num);
}
View *
view_of_id(unsigned short id) {
View *v;
for(v = view; v && v->id != id; v=v->next);
return v;
}
View *
view_of_name(const char *name)
{
View *v;
for(v = view; v && strcmp(v->name, name); v=v->next);
return v;
}
static View *
get_view(const char *name)
{
View *v = view_of_name(name);
return v ? v : create_view(name);
}
void
select_view(const char *arg)
{
@ -164,16 +198,6 @@ select_view(const char *arg)
update_views(); /* performs focus_view */
}
static Bool
is_of_view(View *v, Client *c)
{
Area *a;
for(a=v->area; a; a=a->next)
if(is_of_area(a, c))
return True;
return False;
}
void
detach_from_view(View *v, Client *c)
{
@ -198,7 +222,7 @@ attach_to_view(View *v, Client *c)
if(c->trans || c->floating || c->fixedsize
|| (c->rect.width == rect.width && c->rect.height == rect.height))
a = v->area;
else if(starting && v->sel == v->area)
else if(starting && v->sel->floating)
a = v->area->next;
else
a = v->sel;
@ -329,16 +353,6 @@ update_client_views(Client *c)
}
}
static Bool
is_view_of(Client *c, View *v)
{
ViewLink *l;
for(l=c->views; l; l=l->next)
if(l->view == v)
return True;
return False;
}
Client *
sel_client_of_view(View *v) {
return v->sel && v->sel->sel ? v->sel->sel->client : nil;
@ -419,7 +433,6 @@ clientframe_of_view(View *v, Client *c)
return f;
}
/* XXX: This will need cleanup too */
char *
message_view(View *v, char *message) {
unsigned int n, i;
@ -455,16 +468,6 @@ message_view(View *v, char *message) {
return Ebadvalue;
}
static Bool
is_empty(View *v)
{
Area *a;
for(a=v->area; a; a=a->next)
if(a->frame)
return False;
return True;
}
void
update_views()
{

View File

@ -69,6 +69,7 @@ struct Area {
Frame *frame;
Frame *sel;
View *view;
Bool floating;
unsigned short id;
int mode;
XRectangle rect;