commit e02d9ae205b359c8ff3e7e2c6008bd93fa83d6aa
parent f210f90702f8f402b85e6f279f2817869c4f361c
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Sun, 7 May 2006 23:58:06 +0200
several cleanups
Diffstat:
5 files changed, 54 insertions(+), 81 deletions(-)
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -287,7 +287,7 @@ draw_client(Client *c)
d.align = CENTER;
snprintf(buf, sizeof(buf), "%s%d/%d",
/* if */ !idx_of_area(f->area) ? "~" : "",
- fidx, f->area->frame.size);
+ fidx + 1, f->area->frame.size);
w = d.rect.width = d.rect.height + blitz_textwidth(dpy, &blitzfont, buf);
d.rect.x = f->rect.width - d.rect.width;
d.data = buf;
@@ -553,41 +553,6 @@ select_client(Client *c, char *arg)
}
void
-swap_clients(Client *c, XPoint *pt)
-{
-
- unsigned int i, j;
- Frame *f1 = c->frame.data[c->sel], *f2 = nil;
-
- for(i = 1; i < view.data[sel]->area.size; i++) {
- Area *a = view.data[sel]->area.data[i];
- if(blitz_ispointinrect(pt->x, pt->y, &a->rect)) {
- for(j = 0; j < a->frame.size; j++) {
- if(blitz_ispointinrect(pt->x, pt->y, &a->frame.data[j]->rect)) {
- f2 = a->frame.data[j];
- break;
- }
- }
- break;
- }
- }
-
- if(!f2 || f1 == f2 || !idx_of_area(f1->area))
- return;
-
- f1->client = f2->client;
- f2->client = c;
- f1->client->frame.data[f1->client->sel] = f1;
- f2->client->frame.data[f2->client->sel] = f2;
-
- arrange_column(f1->area, False);
- if(f1->area != f2->area)
- arrange_column(f2->area, False);
- focus_client(c, True);
- flush_masked_events(EnterWindowMask);
-}
-
-void
swap_client(Client *c, char *arg)
{
Frame *f1 = c->frame.data[c->sel], *f2;
diff --git a/cmd/wm/column.c b/cmd/wm/column.c
@@ -327,7 +327,7 @@ AfterVertical:
}
static void
-drop_moving(Frame *f, XRectangle *new, XPoint *pt)
+drop_move(Frame *f, XRectangle *new, XPoint *pt)
{
Area *tgt = nil, *src = f->area;
View *v = src->view;
@@ -349,8 +349,8 @@ drop_moving(Frame *f, XRectangle *new, XPoint *pt)
if(tgt != src)
send_to_area(tgt, src, f->client);
else {
- for(i = 0; (i < src->frame.size) && !blitz_ispointinrect(
- pt->x, pt->y, &src->frame.data[i]->rect); i++);
+ for(i = 0; (i < src->frame.size) &&
+ !blitz_ispointinrect(pt->x, pt->y, &src->frame.data[i]->rect); i++);
if((i < src->frame.size) && (f != src->frame.data[i])) {
unsigned int j = idx_of_frame(f);
Frame *tmp = src->frame.data[j];
@@ -364,11 +364,44 @@ drop_moving(Frame *f, XRectangle *new, XPoint *pt)
}
void
+drop_swap(Client *c, XPoint *pt)
+{
+
+ unsigned int i, j;
+ Frame *f1 = c->frame.data[c->sel], *f2 = nil;
+ View *v = view.data[sel];
+
+ for(i = 1; (i < v->area.size) &&
+ !blitz_ispointinrect(pt->x, pt->y, &v->area.data[i]->rect); i++);
+ if(i < v->area.size) {
+ Area *a = v->area.data[i];
+ for(j = 0; j < a->frame.size &&
+ !blitz_ispointinrect(pt->x, pt->y, &a->frame.data[j]->rect); j++);
+ if(j < a->frame.size)
+ f2 = a->frame.data[j];
+ }
+
+ if(!f2 || f1 == f2 || !idx_of_area(f1->area))
+ return;
+
+ f1->client = f2->client;
+ f2->client = c;
+ f1->client->frame.data[f1->client->sel] = f1;
+ f2->client->frame.data[f2->client->sel] = f2;
+
+ arrange_column(f1->area, False);
+ if(f1->area != f2->area)
+ arrange_column(f2->area, False);
+ focus_client(c, True);
+ flush_masked_events(EnterWindowMask);
+}
+
+void
resize_column(Client *c, XRectangle *r, XPoint *pt)
{
Frame *f = c->frame.data[c->sel];
if((f->rect.width == r->width) && (f->rect.height == r->height))
- drop_moving(f, r, pt);
+ drop_move(f, r, pt);
else
drop_resize(f, r);
}
diff --git a/cmd/wm/mouse.c b/cmd/wm/mouse.c
@@ -38,10 +38,7 @@ snap_move(XRectangle * r, XRectangle * rects,
/* check west neighbors leftwards */
if(!w) {
if(r->x - i == (rects[j].x + rects[j].width)) {
- /*
- * west edge of neighbor found, check
- * vert match
- */
+ /* west edge of neighbor found, check vert match */
w = check_vert_match(r, &rects[j]);
if(w)
r->x = rects[j].x + rects[j].width;
@@ -50,10 +47,7 @@ snap_move(XRectangle * r, XRectangle * rects,
/* check west neighbors rightwards */
if(!w) {
if(r->x + i == (rects[j].x + rects[j].width)) {
- /*
- * west edge of neighbor found, check
- * vert match
- */
+ /* west edge of neighbor found, check vert match */
w = check_vert_match(r, &rects[j]);
if(w)
r->x = rects[j].x + rects[j].width;
@@ -62,10 +56,7 @@ snap_move(XRectangle * r, XRectangle * rects,
/* check east neighbors leftwards */
if(!e) {
if(r->x + r->width - i == rects[j].x) {
- /*
- * east edge of neighbor found, check
- * vert match
- */
+ /* east edge of neighbor found, check vert match */
e = check_vert_match(r, &rects[j]);
if(e)
r->x = rects[j].x - r->width;
@@ -74,10 +65,7 @@ snap_move(XRectangle * r, XRectangle * rects,
/* check east neighbors rightwards */
if(!e) {
if(r->x + r->width + i == rects[j].x) {
- /*
- * east edge of neighbor found, check
- * vert match
- */
+ /* east edge of neighbor found, check vert match */
e = check_vert_match(r, &rects[j]);
if(e)
r->x = rects[j].x - r->width;
@@ -111,10 +99,7 @@ snap_move(XRectangle * r, XRectangle * rects,
/* check north neighbors upwards */
if(!n) {
if(r->y - i == (rects[j].y + rects[j].height)) {
- /*
- * north edge of neighbor found,
- * check horiz match
- */
+ /* north edge of neighbor found, check horiz match */
n = check_horiz_match(r, &rects[j]);
if(n)
r->y = rects[j].y + rects[j].height;
@@ -123,10 +108,7 @@ snap_move(XRectangle * r, XRectangle * rects,
/* check north neighbors downwards */
if(!n) {
if(r->y + i == (rects[j].y + rects[j].height)) {
- /*
- * north edge of neighbor found,
- * check horiz match
- */
+ /* north edge of neighbor found, check horiz match */
n = check_horiz_match(r, &rects[j]);
if(n)
r->y = rects[j].y + rects[j].height;
@@ -135,10 +117,7 @@ snap_move(XRectangle * r, XRectangle * rects,
/* check south neighbors upwards */
if(!s) {
if(r->y + r->height - i == rects[j].y) {
- /*
- * south edge of neighbor found,
- * check horiz match
- */
+ /* south edge of neighbor found, check horiz match */
s = check_horiz_match(r, &rects[j]);
if(s)
r->y = rects[j].y - r->height;
@@ -147,10 +126,7 @@ snap_move(XRectangle * r, XRectangle * rects,
/* check south neighbors downwards */
if(!s) {
if(r->y + r->height + i == rects[j].y) {
- /*
- * south edge of neighbor found,
- * check horiz match
- */
+ /* south edge of neighbor found, check horiz match */
s = check_horiz_match(r, &rects[j]);
if(s)
r->y = rects[j].y - r->height;
@@ -204,7 +180,6 @@ do_mouse_move(Client *c, XButtonPressedEvent *e, Bool swap)
int px = 0, py = 0, wex, wey, ex, ey, first = 1, i;
Window dummy;
XEvent ev;
- /* borders */
int snapw = (rect.width * def.snap) / 1000;
int snaph = (rect.height * def.snap) / 1000;
unsigned int num;
@@ -238,7 +213,7 @@ do_mouse_move(Client *c, XButtonPressedEvent *e, Bool swap)
draw_pseudo_border(&frect);
if(idx_of_area(f->area)) {
if(swap)
- swap_clients(c, &pt);
+ drop_swap(c, &pt);
else
resize_column(c, &frect, &pt);
}
@@ -451,7 +426,6 @@ do_mouse_resize(Client *c, XButtonPressedEvent *e, BlitzAlign align)
int px = 0, py = 0, i, ox, oy, first = 1;
Window dummy;
XEvent ev;
- /* borders */
int snapw = (rect.width * def.snap) / 1000;
int snaph = (rect.height * def.snap) / 1000;
unsigned int dmask;
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -229,7 +229,6 @@ void select_client(Client *c, char *arg);
void send_client_to(Client *c, char *arg);
void resize_all_clients();
void swap_client(Client *c, char *arg);
-void swap_clients(Client *c, XPoint *pt);
Client *sel_client();
int idx_of_client_id(unsigned short id);
Client *client_of_win(Window w);
@@ -244,6 +243,7 @@ int column_mode_of_str(char *arg);
char *str_of_column_mode(int mode);
Area *new_left_column(View *v);
Area *new_right_column(View *v);
+void drop_swap(Client *c, XPoint *pt);
/* event.c */
void init_x_event_handler();
diff --git a/cmd/wm/wmiiwm.1 b/cmd/wm/wmiiwm.1
@@ -77,11 +77,12 @@ application window.
.TP 2
Client
An application window surrounded by a frame window containing a border and a
-title\-bar. The title\-bar normally shows only two labels, one displaying the
-tags of a client and the other the client's name. However, if the containing
-column is in maximized mode, a third label is required. It shows which client
-is currently visible and more importantly, the number of clients within the
-column.
+title\-bar. The title\-bar three labels, first one displaying the tags of a
+client, second one displaying the client's title, and the third one displaying
+the client's index and the number of overall clients within a column.
+If the client is focused within a column, the third label is highlighted.
+If the client is attached to floating layer, a ~ character is prepended in
+the third label as well.
.TP 2
Floating layer
A screen layer of