commit 00fb0483f9e50dad4fec136fa03bfc2680fc9b6d
parent 4acbd3286e491181a636bc3b9b5ceb62f19dfc4e
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Fri, 13 Jan 2006 14:24:55 +0200
sanitized show/hide crap into map/unmap, implemented differentiation between focus/unfocus now
Diffstat:
9 files changed, 70 insertions(+), 80 deletions(-)
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -28,29 +28,20 @@ alloc_client(Window w)
void
focus_client(Client * c)
{
- Frame *f = 0;
- /*
- static Client *old = nil;
-
- if(old && (old != c)) {
- ungrab_client(old, AnyModifier, AnyButton);
- grab_client(old, AnyModifier, AnyButton);
- }
- */
-
- /* sel client */
- ungrab_client(c, AnyModifier, AnyButton);
grab_client(c, Mod1Mask, Button1);
grab_client(c, Mod1Mask, Button3);
- f = c->frame;
- f->sel = c;
+ c->frame->sel = c;
XRaiseWindow(dpy, c->win);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
XSync(dpy, False);
invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
- /*
- old = c;
- */
+}
+
+void
+unfocus_client(Client * c)
+{
+ ungrab_client(c, AnyModifier, AnyButton);
+ grab_client(c, AnyModifier, AnyButton);
}
void
@@ -65,7 +56,7 @@ set_client_state(Client * c, int state)
}
void
-show_client(Client * c)
+map_client(Client * c)
{
XMapRaised(dpy, c->win);
set_client_state(c, NormalState);
@@ -73,7 +64,7 @@ show_client(Client * c)
}
void
-hide_client(Client * c)
+unmap_client(Client * c)
{
ungrab_client(c, AnyModifier, AnyButton);
XUnmapWindow(dpy, c->win);
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -62,30 +62,33 @@ handle_buttonpress(XEvent * e)
if(f)
handle_frame_buttonpress(ev, f);
- else if((c = win_to_client(ev->window))) {
- if(c->frame) { /* client is attached */
+ else if((c = win_to_client(ev->window)) && c->frame) {
+ Layout *l = sel_layout();
+ Client *old = sel_client();
+ if(old != c)
+ unfocus_client(old);
+ if(l != c->frame->layout)
focus_layout(c->frame->layout);
- focus_client(c);
- ev->state &= valid_mask;
- if(ev->state & Mod1Mask) {
- Align align;
- XRaiseWindow(dpy, c->frame->win);
- switch (ev->button) {
- case Button1:
- mouse_move(c->frame);
- break;
- case Button3:
- align = xy_to_align(&c->rect, ev->x, ev->y);
- if(align == CENTER)
- mouse_move(c->frame);
- else
- mouse_resize(c->frame, align);
- break;
- default:
- break;
- }
- }
- }
+ focus_client(c);
+ ev->state &= valid_mask;
+ if(ev->state & Mod1Mask) {
+ Align align;
+ XRaiseWindow(dpy, c->frame->win);
+ switch (ev->button) {
+ case Button1:
+ mouse_move(c->frame);
+ break;
+ case Button3:
+ align = xy_to_align(&c->rect, ev->x, ev->y);
+ if(align == CENTER)
+ mouse_move(c->frame);
+ else
+ mouse_resize(c->frame, align);
+ break;
+ default:
+ break;
+ }
+ }
}
}
diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c
@@ -281,7 +281,7 @@ attach_client_to_frame(Frame * f, Client * client)
client->frame = f;
resize_frame(f, &f->rect, 0);
reparent_client(client, f->win, client->rect.x, client->rect.y);
- show_client(client);
+ map_client(client);
}
void
@@ -308,7 +308,7 @@ detach_client_from_frame(Client * c, Bool unmap)
if(!c->destroyed) {
if(!unmap) {
attach_detached(c);
- hide_client(c);
+ unmap_client(c);
}
c->rect.x = f->rect.x;
c->rect.y = f->rect.y;
diff --git a/cmd/wm/layout.c b/cmd/wm/layout.c
@@ -62,10 +62,11 @@ focus_layout(Layout *l)
p->file[P_SEL_LAYOUT]->content = l->file[L_PREFIX]->content;
if((c = l->def->sel(l)))
l->def->focus(l, c, False);
+ invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
}
void
-hide_layout(Layout *l)
+unmap_layout(Layout *l)
{
Frame *f;
for(f = l->def->frames(l); f; f = f->next)
@@ -73,7 +74,7 @@ hide_layout(Layout *l)
}
void
-show_layout(Layout *l, Bool raise)
+map_layout(Layout *l, Bool raise)
{
Frame *f;
for(f = l->def->frames(l); f; f = f->next) {
diff --git a/cmd/wm/layout_column.c b/cmd/wm/layout_column.c
@@ -1,5 +1,5 @@
/*
- * (C)opyright MMIV-MMV Anselm R. Garbe <garbeam at gmail dot com>
+ * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details.
*/
@@ -420,6 +420,8 @@ focus_col(Layout *l, Client *c, Bool raise)
Client *old = sel_col(l);
Cell *cell = c->frame->aux;
+ if(old != c)
+ unfocus_client(old);
acme->sel = cell->col;
cell->col->sel = cell;
c->frame->file[L_SEL_FRAME]->content = c->frame->file[F_PREFIX]->content;
diff --git a/cmd/wm/layout_float.c b/cmd/wm/layout_float.c
@@ -188,6 +188,8 @@ focus_float(Layout *l, Client *c, Bool raise)
Float *fl = l->aux;
Client *old = fl->sel->sel;
+ if(old != c)
+ unfocus_client(old);
fl->sel = c->frame;
l->file[L_SEL_FRAME]->content = c->frame->file[F_PREFIX]->content;
if(raise) {
diff --git a/cmd/wm/page.c b/cmd/wm/page.c
@@ -58,7 +58,6 @@ alloc_page()
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
npages++;
XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &npages, 1);
- focus_page(new);
return new;
}
@@ -128,10 +127,9 @@ destroy_page(Page * p)
void
focus_page(Page * p)
{
- if(selpage != p)
- hide_page(selpage);
selpage = p;
- show_page(p);
+ map_layout(p->managed, False);
+ map_layout(p->floating, False);
def[WM_SEL_PAGE]->content = p->file[P_PREFIX]->content;
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
focus_layout(sel_layout());
@@ -139,6 +137,15 @@ focus_page(Page * p)
32, PropModeReplace, (unsigned char *) &(selpage->index), 1);
}
+void
+unfocus_page(Page * p)
+{
+ selpage = nil;
+ def[WM_SEL_PAGE]->content = nil;
+ unmap_layout(p->managed);
+ unmap_layout(p->floating);
+}
+
XRectangle *
rectangles(unsigned int *num)
{
@@ -170,20 +177,6 @@ rectangles(unsigned int *num)
return result;
}
-void
-hide_page(Page * p)
-{
- hide_layout(p->managed);
- hide_layout(p->floating);
-}
-
-void
-show_page(Page * p)
-{
- show_layout(p->managed, False);
- show_layout(p->floating, False);
-}
-
static void
handle_after_write_page(IXPServer * s, File * file)
{
@@ -223,7 +216,6 @@ toggle_layout(void *obj, char *arg)
p->sel = p->managed;
focus_layout(p->sel);
- invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
}
Page *
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -330,7 +330,7 @@ draw_detached_clients()
XMoveResizeWindow(dpy, c->win, cr.x, cr.y, cr.width,
cr.height);
configure_client(c);
- show_client(c);
+ map_client(c);
XRaiseWindow(dpy, c->win);
grab_client(c, AnyModifier, AnyButton);
XSync(dpy, False);
@@ -372,7 +372,7 @@ detached_clients(void *obj, char *arg)
case KeyPress:
XUnmapWindow(dpy, transient);
for(c = detached; c; c = c->next)
- hide_client(c);
+ unmap_client(c);
if((n = handle_kpress(&ev.xkey)) != -1) {
if(n - 1 < ndetached) {
c = clientat(detached, n);
@@ -386,7 +386,7 @@ detached_clients(void *obj, char *arg)
case ButtonPress:
XUnmapWindow(dpy, transient);
for(c = detached; c; c = c->next)
- hide_client(c);
+ unmap_client(c);
if((ev.xbutton.button == Button1)
&& (c = win_to_client(ev.xbutton.window))) {
detach_detached(c);
@@ -460,10 +460,9 @@ _destroy_page(void *obj, char *arg)
static void
new_page(void *obj, char *arg)
{
- Page *p = selpage;
- if(p)
- hide_page(p);
- selpage = alloc_page();
+ if(selpage)
+ unfocus_page(selpage);
+ focus_page(alloc_page());
}
Client *
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -113,7 +113,7 @@ struct LayoutDef {
void (*init) (Layout *, Client *); /* called when layout is initialized */
Client *(*deinit) (Layout *); /* called when layout is uninitialized */
void (*arrange) (Layout *); /* called when layout is resized */
- Bool(*attach) (Layout *, Client *); /* called on attach */
+ Bool(*attach) (Layout *, Client *); /* called on attach */
void (*detach) (Layout *, Client *, Bool unmap); /* called on detach */
void (*resize) (Frame *, XRectangle *, XPoint *); /* called after resize */
void (*focus) (Layout *, Client *, Bool raise); /* focussing a client */
@@ -220,10 +220,11 @@ void draw_clients(Frame * f);
void gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert);
void grab_client(Client * c, unsigned long mod, unsigned int button);
void ungrab_client(Client * c, unsigned long mod, unsigned int button);
-void hide_client(Client * c);
-void show_client(Client * c);
+void unmap_client(Client * c);
+void map_client(Client * c);
void reparent_client(Client * c, Window w, int x, int y);
void focus_client(Client * c);
+void unfocus_client(Client * c);
void attach_client(Client * c);
void detach_client(Client * c, Bool unmap);
Client *sel_client();
@@ -261,16 +262,15 @@ Page *pageat(unsigned int idx);
Page *alloc_page();
void destroy_page(Page * p);
void focus_page(Page * p);
+void unfocus_page(Page * p);
XRectangle *rectangles(unsigned int *num);
-void hide_page(Page * p);
-void show_page(Page * p);
/* layout.c */
Layout *alloc_layout(Page * p, char *layout);
void destroy_layout(Layout *l);
void focus_layout(Layout *l);
-void hide_layout(Layout *l);
-void show_layout(Layout *l, Bool raise);
+void unmap_layout(Layout *l);
+void map_layout(Layout *l, Bool raise);
Layout *sel_layout();
void attach_frame_to_layout(Layout *l, Frame * f);
void detach_frame_from_layout(Frame * f);