commit 6bb011dc1eb52dff866504f4c8490c3b7ca6c4a4
parent 3f77f1c4dd5a687a74f574ece30c9f4fc7781ee8
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Fri, 31 Mar 2006 07:57:33 +0200
sanitized float handling, '~' is only used in /def/rules now, nowhere else and skipped explicitly as tag, Client struct contains a floating flag now (if set, the client will be floating in all views), added [n] suffix to view labels of the bar (does not occur in tags which have not yet been selected, thus no view) showing the focused area of the specific view
Diffstat:
7 files changed, 36 insertions(+), 22 deletions(-)
diff --git a/cmd/wm/area.c b/cmd/wm/area.c
@@ -72,10 +72,12 @@ select_area(Area *a, char *arg)
Area *new;
View *v = a->view;
int i = area2index(a);
+
if(i == -1)
return;
if(i)
v->revert = i;
+
if(!strncmp(arg, "toggle", 7)) {
if(i)
i = 0;
@@ -110,6 +112,11 @@ select_area(Area *a, char *arg)
v->sel = i;
for(i = 0; i < a->nframe; i++)
draw_client(a->frame[i]->client);
+
+ if(!new->nframe) {
+ update_view_label(v);
+ draw_bar();
+ }
}
void
@@ -129,6 +136,7 @@ attach_toarea(Area *a, Client *c)
if(clientofview(a->view, c))
return;
+ c->floating = !area2index(a); /* set floating flag */
f = cext_emallocz(sizeof(Frame));
f->id = id++;
f->area = a;
diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c
@@ -8,6 +8,16 @@
#include "wm.h"
+void
+update_view_label(View *v)
+{
+ static char vname[256];
+ Label *l;
+ tags2str(vname, sizeof(vname), v->tag, v->ntag);
+ if((l = name2label(vname)))
+ snprintf(l->data, sizeof(l->data), "%s[%d]", vname, v->sel);
+}
+
static int
comp_label_intern(const void *l1, const void *l2)
{
@@ -186,7 +196,7 @@ lid2index(unsigned short id)
Label *
name2label(const char *name)
{
- char buf[256];
+ static char buf[256];
unsigned int i;
cext_strlcpy(buf, name, sizeof(buf));
@@ -200,7 +210,6 @@ void
update_bar_tags()
{
unsigned int i;
- char vname[256];
Label *l = nil;
for(i = 0; (i < nlabel) && label[i]->intern; i++) {
@@ -214,11 +223,8 @@ update_bar_tags()
l = get_label(tag[i], True);
cext_strlcpy(l->data, tag[i], sizeof(l->data));
}
- for(i = 0; i < nview; i++) {
- View *v = view[i];
- tags2str(vname, sizeof(vname), v->tag, v->ntag);
- l = get_label(vname, True);
- cext_strlcpy(l->data, vname, sizeof(l->data));
- }
+ for(i = 0; i < nview; i++)
+ update_view_label(view[i]);
+
draw_bar();
}
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -82,9 +82,10 @@ focus_client(Client *c)
{
Client *old = sel_client();
Frame *f = c->frame[c->sel];
+ View *v = f->area->view;
int i = area2index(f->area);
- f->area->view->sel = i;
+ v->sel = i;
f->area->sel = frame2index(f);
if(old && (old != c)) {
grab_mouse(old->framewin, AnyModifier, Button1);
@@ -94,7 +95,9 @@ focus_client(Client *c)
grab_mouse(c->framewin, Mod1Mask, Button1);
grab_mouse(c->framewin, Mod1Mask, Button3);
- restack_view(f->area->view);
+ restack_view(v);
+ update_view_label(v);
+ draw_bar();
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
draw_client(c);
@@ -353,12 +356,6 @@ manage_client(Client *c)
c->ntag++;
}
}
- else if((c->ntag == 1) && !strncmp(c->tag[0], "~", 2)) {
- for(i = 0; i < v->ntag && i + 1 < MAX_TAGS; i++) {
- cext_strlcpy(c->tag[i + 1], v->tag[i], sizeof(c->tag[i + 1]));
- c->ntag++;
- }
- }
update_tags();
}
diff --git a/cmd/wm/rule.c b/cmd/wm/rule.c
@@ -116,8 +116,12 @@ match(Client *c, const char *prop)
Rule *r = &rule[i];
if(r->is_valid && !regexec(&r->regex, prop, 1, &tmpregm, 0)) {
for(j = 0; c->ntag < MAX_TAGS && j < r->ntag; j++) {
- cext_strlcpy(c->tag[c->ntag], r->tag[j], sizeof(c->tag[c->ntag]));
- c->ntag++;
+ if(!strncmp(r->tag[j], "~", 2))
+ c->floating = True;
+ else {
+ cext_strlcpy(c->tag[c->ntag], r->tag[j], sizeof(c->tag[c->ntag]));
+ c->ntag++;
+ }
}
}
}
diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c
@@ -56,8 +56,6 @@ update_tags()
for(i = 0; i < nclient; i++) {
for(j = 0; j < client[i]->ntag; j++) {
- if(!strncmp(client[i]->tag[j], "~", 2)) /* magic floating tag */
- continue;
if(!istag(client[i]->tag[j])) {
tag = (char **)cext_array_attach((void **)tag, strdup(client[i]->tag[j]),
sizeof(char *), &tagsz);
diff --git a/cmd/wm/view.c b/cmd/wm/view.c
@@ -240,7 +240,7 @@ attach_toview(View *v, Client *c)
{
Area *a;
- if(c->trans || clienthastag(c, "~"))
+ if(c->trans || c->floating)
a = v->area[0];
else
a = v->area[v->sel];
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -110,7 +110,7 @@ struct Client {
char classinst[256];
int proto;
unsigned int border;
- Bool destroyed;
+ Bool floating;
Window win;
Window trans;
XRectangle rect;
@@ -222,6 +222,7 @@ unsigned int bar_height();
Label *name2label(const char *name);
int label2index(Label *l);
void update_bar_tags();
+void update_view_label(View *v);
/* client.c */
Client *alloc_client(Window w, XWindowAttributes *wa);