changeset: 29:f9633c146e1a
tag: tip
user: Denis Grelich <denisg_AT_suckless.org>
date: Tue Feb 06 19:58:11 2007 +0100
files: Makefile helpers.c manage.c structures.c update.c wmii.h
description:
yet more implementation. Does still not compile.
diff -r 8d60f3fd69d5 -r f9633c146e1a Makefile
--- a/Makefile Tue Feb 06 14:46:46 2007 +0100
+++ b/Makefile Tue Feb 06 19:58:11 2007 +0100
@@ -3,7 +3,7 @@
include config.mk
-SRC = main.c client.c frame.c draw.c init.c scope.c view.c column.c mouse.c event.c
+SRC = structures.c helpers.c update.c manage.c main.c
OBJ = ${SRC:.c=.o}
all: options wmiiwm
diff -r 8d60f3fd69d5 -r f9633c146e1a helpers.c
--- a/helpers.c Tue Feb 06 14:46:46 2007 +0100
+++ b/helpers.c Tue Feb 06 19:58:11 2007 +0100
@@ -12,18 +12,18 @@ Frame *
Frame *
get_frame (Scope *scp, View *vw, Area *ar, Window win, Client *clnt) {
if (ar)
- return get_frame_of_view(ar, win, clnt);
+ return get_frame_of_area(ar, win, clnt);
Scope *s = scp ? scp :
(vw ? vw->scope : scope);
while (s) {
View *v = vw ? vw : s->view;
while (v) {
Frame *f;
- if ((f = get_frame_of_view(ar, win, clnt)))
+ if ((f = get_frame_of_area(ar, win, clnt)))
return f;
Area *a;
for (a = v->col; a; a = a->next)
- if ((f = get_frame_of_view(ar, win, clnt)))
+ if ((f = get_frame_of_area(ar, win, clnt)))
return f;
v = vw ? NULL : v->next;
}
@@ -43,7 +43,7 @@ visible_frame_of_client (Client *c) {
visible_frame_of_client (Client *c) {
Frame *f;
for (f = c->f; f; f = f->next)
- if (f->view = scope->sel)
+ if (f->view == scope->sel)
return f;
return NULL;
}
diff -r 8d60f3fd69d5 -r f9633c146e1a manage.c
--- a/manage.c Tue Feb 06 14:46:46 2007 +0100
+++ b/manage.c Tue Feb 06 19:58:11 2007 +0100
@@ -1,17 +1,18 @@
#include "wmii.h"
+#include "string.h"
void
manage_window (Window win) {
- Client *c = create_client (win);
+ Client *c = create_client(win);
/* FIXME: tagging rules and stuff:
* for each tag in ... do */
tag_client(c, DEFAULT_TAG);
}
void
-unmanage_client (Client *c) {
+destroy_client (Client *c) {
while (c->tag[0])
- untag_client(c, c->tag);
+ untag_client(c, c->tag[0]);
destroy_client(c);
}
@@ -23,21 +24,22 @@ tag_client (Client *c, const char *tag)
return False;
c->tag[i] = ixp_estrdup(tag);
View *v = get_view(tag);
- create_frame(c, v);
+ Frame *f = create_frame(c, v);
Column *col = v->c_sel;
if (col->f_cnt >= 4)
create_column(v, col);
attach_frame(f, col);
- if (col != c_sel) // meaning a new column was created
+ if (col != v->c_sel) // meaning a new column was created
update_view(v);
else
- update_column(col);
+ update_area(col);
return True;
}
void
untag_client (Client *c, const char *tag) {
char **ta = NULL;
+ uint i;
for (i = 0; c->tag[i] && i < MAX_VIEW_COUNT ; ++i)
if (!strcmp(tag, c->tag[i])) {
ta = &c->tag[i];
@@ -48,8 +50,9 @@ untag_client (Client *c, const char *tag
memmove(ta, ta + 1, MAX_VIEW_COUNT - i);
c->tag[MAX_VIEW_COUNT] = NULL;
+ View *v = get_view(tag);
+ Frame *f = get_frame(v->scope, v, NULL, None, c);
Area *fa = f->area;
- View *v = fa->view;
if (f == sel_of_view(f->view)) {
Frame *sel = f->prev ? f->prev : f->next;
detach_frame(f);
@@ -57,7 +60,7 @@ untag_client (Client *c, const char *tag
if (fa->floating) {
if (!sel) {
v->float_selected = False;
- update_column(v->c_sel);
+ update_area(v->c_sel);
}
else {
v->flt->sel = sel;
@@ -109,6 +112,7 @@ move_frame (Frame *f, Area *dest) {
attach_frame(f, dest);
update_area(fa);
}
+ return True; // FIXME: fails if column full
}
void
@@ -117,9 +121,9 @@ focus_frame (Frame *f) {
Frame *old = sel_of_view(v);
v->float_selected = f->area->floating;
f->area->sel = f;
- if (!f->float_selected)
+ if (!v->float_selected)
v->c_sel = f->area;
- if (old && old != f->area)
+ if (old && old->area != f->area)
update_area(old->area);
update_area(f->area);
}
diff -r 8d60f3fd69d5 -r f9633c146e1a structures.c
--- a/structures.c Tue Feb 06 14:46:46 2007 +0100
+++ b/structures.c Tue Feb 06 19:58:11 2007 +0100
@@ -1,4 +1,6 @@
#include "wmii.h"
+#include "string.h"
+#include "stdlib.h"
View *
get_view (const char *tag) {
@@ -25,7 +27,7 @@ destroy_view (View *v) {
destroy_view (View *v) {
free(v->tag);
View **vp;
- for (*vp = &scope->view; *vp; *vp = &(*vp)->next) {
+ for (vp = &scope->view; *vp; vp = &(*vp)->next) {
if (*vp == v) {
*vp = v->next;
break;
@@ -47,7 +49,7 @@ create_column (View *v, Column *after) {
col->floating = False;
++v->c_cnt;
if (!v->c_sel)
- v->sel = col;
+ v->c_sel = col;
return col;
}
@@ -93,5 +95,70 @@ destroy_frame (Frame *f) {
break;
}
}
- // proceed here
+ if (f->view == scope->sel)
+ XUnmapWindow(dpy, f->client->framewin);
+ free(f);
}
+
+Client *
+create_client (Window w) {
+ static XWindowAttributes wa;
+ if (!XGetWindowAttributes(dpy, w, &wa))
+ return NULL;
+ Client *c = ixp_emallocz(sizeof(Client));
+ c->rect.x = wa.x;
+ c->rect.y = wa.y;
+ c->rect.w = wa.width;
+ c->rect.h = wa.height;
+ XSetWindowBorderWidth(dpy, c->win, 0);
+ XGetTransientForHint(dpy, c->win, &c->trans);
+ long msize;
+ if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
+ c->size.flags = PSize;
+ if(c->size.flags & PMinSize && c->size.flags & PMaxSize
+ && c->size.min_width == c->size.max_width
+ && c->size.min_height == c->size.max_height)
+ c->fixedsize = True;
+ else
+ c->fixedsize = False;
+ XSetWindowAttributes fwa;
+ fwa.override_redirect = 1;
+ fwa.background_pixmap = ParentRelative;
+ fwa.event_mask = SubstructureNotifyMask | SubstructureRedirectMask |
+ ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask;
+ c->framewin = XCreateWindow(dpy, root, 0, 0,
+ def.frame_min.w, def.frame_min.h, 0,
+ DefaultDepth(dpy, screen), CopyFromParent,
+ DefaultVisual(dpy, screen),
+ CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa);
+ XSelectInput(dpy, w, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
+ PropertyChangeMask | EnterWindowMask);
+ XReparentWindow(dpy, w, c->framewin, def.border, def.barheight);
+ c->next = clients;
+ clients = c;
+ return c;
+}
+
+Scope *
+init_scope (int x, int y, uint w, uint h) {
+ Scope *s = ixp_emallocz(sizeof (Scope));
+
+ s->rect.x = x;
+ s->rect.y = y;
+ s->rect.w = w;
+ s->rect.h = h;
+ s->mnrect = s->rect;
+
+ scope = s;
+ return s;
+}
+
+void
+free_scope (Scope *s) {
+ if (s->next)
+ s->next->prev = s->prev;
+ if (s->prev)
+ s->prev->next = s->next;
+ if (scope == s)
+ scope = s->next;
+}
diff -r 8d60f3fd69d5 -r f9633c146e1a update.c
--- a/update.c Tue Feb 06 14:46:46 2007 +0100
+++ b/update.c Tue Feb 06 19:58:11 2007 +0100
@@ -1,1 +1,37 @@
#include "wmii.h"
+
+void
+draw_frame (Frame *f) {
+ uint x = f->rect.x, y = f->rect.y;
+ uint w = f->rect.w, h;
+ if (f->rollup && (f != f->area->sel))
+ h = def.barheight;
+ else
+ h = f->rect.h;
+
+ Color color;
+ if (f == sel_of_view(f->view))
+ color = def.focuscolor;
+ else if (f == f->area->sel)
+ color = def.selcolor;
+ else
+ color = def.normcolor;
+ if (f->rollup)
+ color.bg = def.normcolor.bg;
+
+ /* client area */
+ f->crect.w = w - 2 * def.border;
+ f->crect.x = (w - f->crect.w) / 2;
+ if ((f->rollup && (f != f->area->sel)))
+ XUnmapWindow(dpy, f->client->win);
+ else {
+ f->crect.h = h - (def.border + def.barheight);
+ // TODO: INCREMENT HANDLING GOES HERE
+ // snap_to_increment(f->client, &crect, WITHOUT_BORDER);
+ // -----------------------------------
+ XMapWindow(dpy, f->client->win);
+ XMoveResizeWindow(dpy, f->client->win,
+ f->crect.x, f->crect.y, f->crect.w, f->crect.h);
+ }
+
+}
diff -r 8d60f3fd69d5 -r f9633c146e1a wmii.h
--- a/wmii.h Tue Feb 06 14:46:46 2007 +0100
+++ b/wmii.h Tue Feb 06 19:58:11 2007 +0100
@@ -149,7 +149,6 @@ Scope *scope;
Scope *scope;
Client *clients;
View *views;
-View *sel_view;
Display *dpy;
Window root;
@@ -157,7 +156,7 @@ GC gc;
GC gc;
/* manage.c */
-void manage_window (Window *w);
+void manage_window (Window w);
void destroy_client (Client *c);
Bool tag_client (Client *c, const char *tag);
void untag_client (Client *c, const char *tag);
@@ -184,6 +183,7 @@ void destroy_frame (Frame *f);
void destroy_frame (Frame *f);
Client *create_client (Window w);
Scope *init_scope (int x, int y, uint w, uint h);
+void free_scope (Scope *s);
/* update.c */
void update_view (View *v);
Received on Tue Feb 06 2007 - 20:10:04 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:56 UTC