Rename Structure -> structure

This commit is contained in:
Martin Duquesnoy 2011-09-09 00:25:51 +02:00
parent 299fc0bc25
commit 3f7978b9e2
21 changed files with 409 additions and 303 deletions

View File

@ -7,20 +7,20 @@
#include "barwin.h"
#include "util.h"
/** Create a Barwin
/** Create a barwin
* \param parent Parent window of the BarWindow
* \param x X position
* \param y Y position
* \param w Barwin Width
* \param h Barwin Height
* \param color Barwin color
* \param w barwin Width
* \param h barwin Height
* \param color barwin color
* \param entermask bool for know if the EnterMask mask is needed
* \return The BarWindow pointer
*/
struct Barwin*
struct barwin*
barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool entermask)
{
struct Barwin *b = (struct Barwin*)xcalloc(1, sizeof(struct Barwin));
struct barwin *b = (struct barwin*)xcalloc(1, sizeof(struct barwin));
XSetWindowAttributes at =
{
.override_redirect = True,
@ -32,8 +32,13 @@ barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool e
at.event_mask |= BARWIN_ENTERMASK;
/* Create window */
b->win = XCreateWindow(W->dpy, parent, x, y, w, h, 0, W->xdepth, CopyFromParent,
DefaultVisual(W->dpy, W->xscreen), BARWIN_WINCW, &at);
b->win = XCreateWindow(W->dpy, parent,
x, y, w, h,
0, W->xdepth,
CopyFromParent,
DefaultVisual(W->dpy, W->xscreen),
BARWIN_WINCW,
&at);
b->dr = XCreatePixmap(W->dpy, parent, w, h, W->xdepth);
@ -53,31 +58,31 @@ barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool e
return b;
}
/** Delete a Barwin
* \param bw Barwin pointer
/** Delete a barwin
* \param bw barwin pointer
*/
void
barwin_remove(struct Barwin *b)
barwin_remove(struct barwin *b)
{
SLIST_REMOVE(&W->h.barwin, b, Barwin, next);
SLIST_REMOVE(&W->h.barwin, b, barwin, next);
XSelectInput(W->dpy, b->win, NoEventMask);
XDestroyWindow(W->dpy, b->win);
XFreePixmap(W->dpy, b->dr);
/* Free mousebinds */
FREE_LIST(Mousebind, b->mousebinds);
FREE_LIST(mousebind, b->mousebinds);
free(b);
}
/** Resize a Barwin
* \param bw Barwin pointer
/** Resize a barwin
* \param bw barwin pointer
* \param w Width
* \param h Height
*/
void
barwin_resize(struct Barwin *b, int w, int h)
barwin_resize(struct barwin *b, int w, int h)
{
/* Frame */
XFreePixmap(W->dpy, b->dr);
@ -91,11 +96,11 @@ barwin_resize(struct Barwin *b, int w, int h)
}
void
barwin_mousebind_new(struct Barwin *b, unsigned int button, bool u, struct Geo a, void (*func)(Uicb), Uicb cmd)
barwin_mousebind_new(struct barwin *b, unsigned int button, bool u, struct geo a, void (*func)(Uicb), Uicb cmd)
{
struct Mousebind *m;
struct mousebind *m;
m = xcalloc(1, sizeof(struct Mousebind));
m = xcalloc(1, sizeof(struct mousebind));
m->button = button;
m->use_area = u;
@ -107,11 +112,11 @@ barwin_mousebind_new(struct Barwin *b, unsigned int button, bool u, struct Geo a
SLIST_INSERT_HEAD(&b->mousebinds, m, next);
}
/** Refresh the Barwin Color
* \param bw Barwin pointer
/** Refresh the barwin Color
* \param bw barwin pointer
*/
void
barwin_refresh_color(struct Barwin *b)
barwin_refresh_color(struct barwin *b)
{
XSetForeground(W->dpy, W->gc, b->bg);
XFillRectangle(W->dpy, b->dr, W->gc, 0, 0, b->geo.w, b->geo.h);

View File

@ -23,10 +23,10 @@
#define barwin_map(b) XMapWindow(W->dpy, b->win);
#define barwin_unmap(b) XUnmapWindow(W->dpy, b->win);
struct Barwin* barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool entermask);
void barwin_remove(struct Barwin *b);
void barwin_resize(struct Barwin *b, int w, int h);
void barwin_mousebind_new(struct Barwin *b, unsigned int button, bool u, struct Geo a, void (*func)(Uicb), Uicb cmd);
void barwin_refresh_color(struct Barwin *b);
struct barwin* barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool entermask);
void barwin_remove(struct barwin *b);
void barwin_resize(struct barwin *b, int w, int h);
void barwin_mousebind_new(struct barwin *b, unsigned int button, bool u, struct geo a, void (*func)(Uicb), Uicb cmd);
void barwin_refresh_color(struct barwin *b);
#endif /* BARWIN_H */

View File

@ -3,6 +3,8 @@
* For license, see COPYING.
*/
#include <X11/Xutil.h>
#include "client.h"
#include "config.h"
#include "util.h"
@ -10,11 +12,11 @@
#define CLIENT_MOUSE_MOD Mod1Mask
/** Send a ConfigureRequest event to the struct Client
* \param c struct Client pointer
/** Send a ConfigureRequest event to the struct client
* \param c struct client pointer
*/
void
client_configure(struct Client *c)
client_configure(struct client *c)
{
XConfigureEvent ev;
@ -33,10 +35,10 @@ client_configure(struct Client *c)
XSync(W->dpy, False);
}
struct Client*
struct client*
client_gb_win(Window w)
{
struct Client *c = SLIST_FIRST(&W->h.client);
struct client *c = SLIST_FIRST(&W->h.client);
while(c && c->win != w)
c = SLIST_NEXT(c, next);
@ -45,25 +47,25 @@ client_gb_win(Window w)
}
/** Map a client
* \param c struct Client pointer
* \param c struct client pointer
*/
void
client_map(struct Client *c)
client_map(struct client *c)
{
XMapWindow(W->dpy, c->win);
}
/** Unmap a client
* \param c struct Client pointer
* \param c struct client pointer
*/
void
client_unmap(struct Client *c)
client_unmap(struct client *c)
{
XUnmapWindow(W->dpy, c->win);
}
static void
client_grabbuttons(struct Client *c, bool focused)
client_grabbuttons(struct client *c, bool focused)
{
wmfs_numlockmask();
@ -94,7 +96,7 @@ client_grabbuttons(struct Client *c, bool focused)
}
void
client_focus(struct Client *c)
client_focus(struct client *c)
{
/* Unfocus selected */
if(W->client && W->client != c)
@ -121,10 +123,10 @@ client_focus(struct Client *c)
}
/** Get a client name
* \param c struct Client pointer
* \param c struct client pointer
*/
void
client_get_name(struct Client *c)
client_get_name(struct client *c)
{
Atom rt;
int rf;
@ -142,10 +144,10 @@ client_get_name(struct Client *c)
}
/** Close a client
* \param c struct Client pointer
* \param c struct client pointer
*/
void
client_close(struct Client *c)
client_close(struct client *c)
{
XEvent ev;
Atom *atom = NULL;
@ -180,30 +182,29 @@ client_close(struct Client *c)
XKillClient(W->dpy, c->win);
}
struct Client*
struct client*
client_new(Window w, XWindowAttributes *wa)
{
struct Client *c;
c = xcalloc(1, sizeof(struct Client));
struct client *c = xcalloc(1, sizeof(struct client));
/* C attributes */
c->win = w;
c->screen = W->screen;
c->flags = 0;
c->tag = NULL;
/* Set tag */
tag_client(W->screen->seltag, c);
/* struct Geometry */
/* struct geometry */
c->geo.x = wa->x;
c->geo.y = wa->y;
c->geo.w = wa->width;
c->geo.h = wa->height;
/* X window attributes */
XSelectInput(W->dpy, w, EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask);
XSelectInput(W->dpy, w, EnterWindowMask | FocusChangeMask
| PropertyChangeMask | StructureNotifyMask);
XSetWindowBorder(W->dpy, w, THEME_DEFAULT->client_n.bg);
XSetWindowBorderWidth(W->dpy, w, THEME_DEFAULT->client_border_width);
client_grabbuttons(c, false);
@ -211,14 +212,10 @@ client_new(Window w, XWindowAttributes *wa)
/* Attach */
SLIST_INSERT_HEAD(&W->h.client, c, next);
XMoveResizeWindow(W->dpy, w,
c->screen->ugeo.x,
c->screen->ugeo.y,
c->screen->ugeo.w,
c->screen->ugeo.h);
/* Insert in frame */
frame_client(c->tag->frame, c);
client_map(c);
WIN_STATE(c->win, Map);
XRaiseWindow(W->dpy, w);
@ -228,9 +225,9 @@ client_new(Window w, XWindowAttributes *wa)
}
void
client_remove(struct Client *c)
client_remove(struct client *c)
{
struct Client *cc;
struct client *cc;
XGrabServer(W->dpy);
XSetErrorHandler(wmfs_error_handler_dummy);
@ -241,9 +238,12 @@ client_remove(struct Client *c)
if(c->tag->sel == c)
c->tag->sel = SLIST_FIRST(&c->tag->clients);
SLIST_REMOVE(&W->h.client, c, Client, next);
SLIST_REMOVE(&W->h.client, c, client, next);
tag_client(NULL, c);
frame_client(NULL, c);
ewmh_set_wm_state(c->win, WithdrawnState);
XSync(W->dpy, False);
XUngrabServer(W->dpy);
@ -255,5 +255,5 @@ client_remove(struct Client *c)
void
client_free(void)
{
FREE_LIST(Client, W->h.client);
FREE_LIST(client, W->h.client);
}

View File

@ -8,15 +8,13 @@
#include "wmfs.h"
void client_configure(struct Client *c);
struct Client *client_gb_win(Window w);
void client_map(struct Client *c);
void client_unmap(struct Client *c);
void client_focus(struct Client *c);
void client_get_name(struct Client *c);
void client_close(struct Client *c);
struct Client *client_new(Window w, XWindowAttributes *wa);
void client_remove(struct Client *c);
void client_configure(struct client *c);
struct client *client_gb_win(Window w);
void client_focus(struct client *c);
void client_get_name(struct client *c);
void client_close(struct client *c);
struct client *client_new(Window w, XWindowAttributes *wa);
void client_remove(struct client *c);
void client_free(void);
#endif /* CLIENT_H */

View File

@ -16,7 +16,7 @@
static void
config_theme(void)
{
struct Theme *t;
struct theme *t;
size_t i, n;
struct conf_sec *sec, **ks;
char *name;
@ -34,7 +34,7 @@ config_theme(void)
/* [theme]*/
for(i = 0; i < n; ++i)
{
t = (struct Theme*)xcalloc(1, sizeof(struct Theme));
t = (struct theme*)xcalloc(1, sizeof(struct theme));
t->name = fetch_opt_first(ks[i], "default", "name").str;
@ -55,7 +55,7 @@ config_theme(void)
t->tags_border_col = color_atoh(fetch_opt_first(ks[i], "#888888", "tags_border_color").str);
t->tags_border_width = fetch_opt_first(ks[i], "0", "tags_border_width").num;
/* Client / Frame */
/* Client / frame */
t->client_n.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "client_normal_fg").str);
t->client_n.bg = color_atoh(fetch_opt_first(ks[i], "#222222", "client_normal_bg").str);
t->client_s.fg = color_atoh(fetch_opt_first(ks[i], "#222222", "client_sel_fg").str);
@ -73,8 +73,8 @@ config_theme(void)
static void
config_bars(void)
{
struct Scr33n *s;
struct Theme *t;
struct screen *s;
struct theme *t;
size_t i, n;
struct conf_sec *sec, **ks;
int screenid;
@ -106,8 +106,8 @@ config_bars(void)
static void
config_tag(void)
{
struct Scr33n *s;
struct Tag *t;
struct screen *s;
struct tag *t;
size_t i, n;
struct conf_sec *sec, **ks;
char *name;
@ -146,7 +146,7 @@ config_keybind(void)
struct conf_sec *sec, **ks;
struct opt_type *opt;
char *cmd;
struct Keybind *k;
struct keybind *k;
/* [keys] */
sec = fetch_section_first(NULL, "keys");
@ -158,7 +158,7 @@ config_keybind(void)
/* [key] */
for(i = 0; i < n; ++i)
{
k = (struct Keybind*)xcalloc(1, sizeof(struct Keybind));
k = (struct keybind*)xcalloc(1, sizeof(struct keybind));
/* mod = {} */
opt = fetch_opt(ks[i], "", "mod");

View File

@ -71,10 +71,10 @@ modkey_keysym(const char *name)
return NoSymbol;
}
static inline struct Theme*
static inline struct theme*
name_to_theme(const char *name)
{
struct Theme *t;
struct theme *t;
SLIST_FOREACH(t, &W->h.theme, next)
if(!strcmp(t->name, name))

View File

@ -16,14 +16,14 @@
#define PAD (8)
static inline void
draw_text(Drawable d, struct Theme *t, int x, int y, Color fg, const char *str)
draw_text(Drawable d, struct theme *t, int x, int y, Color fg, const char *str)
{
XSetForeground(W->dpy, W->gc, fg);
XmbDrawString(W->dpy, d, t->font.fontset, W->gc, x, y, str, strlen(str));
}
static inline unsigned short
draw_textw(struct Theme *t, const char *str)
draw_textw(struct theme *t, const char *str)
{
XRectangle r;

View File

@ -16,8 +16,8 @@ static void
event_buttonpress(XEvent *e)
{
XButtonEvent *ev = &e->xbutton;
struct Mousebind *m;
struct Barwin *b;
struct mousebind *m;
struct barwin *b;
screen_update_sel();
@ -38,7 +38,7 @@ static void
event_enternotify(XEvent *e)
{
XCrossingEvent *ev = &e->xcrossing;
struct Client *c;
struct client *c;
if((ev->mode != NotifyNormal || ev->detail == NotifyInferior)
&& ev->window != W->root)
@ -51,8 +51,8 @@ event_enternotify(XEvent *e)
static void
event_clientmessageevent(XEvent *e)
{
/* XClientMessageEvent *ev = &e->xclient;
Client *c;*/
/* XclientMessageEvent *ev = &e->xclient;
client *c;*/
}
static void
@ -60,7 +60,7 @@ event_configureevent(XEvent *e)
{
XConfigureRequestEvent *ev = &e->xconfigurerequest;
XWindowChanges wc;
struct Client *c;
struct client *c;
if((c = client_gb_win(ev->window)))
{
@ -95,7 +95,7 @@ static void
event_destroynotify(XEvent *e)
{
XDestroyWindowEvent *ev = &e->xdestroywindow;
struct Client *c;
struct client *c;
if((c = client_gb_win(ev->window)))
client_remove(c);
@ -104,7 +104,7 @@ event_destroynotify(XEvent *e)
static void
event_focusin(XEvent *e)
{
struct Client *c;
struct client *c;
if(W->client && e->xfocus.window != W->client->win)
client_focus(W->client);
@ -122,7 +122,7 @@ event_maprequest(XEvent *e)
return;
if(!client_gb_win(ev->window))
(struct Client*)client_new(ev->window, &at);
(struct client*)client_new(ev->window, &at);
}
static void
@ -139,7 +139,7 @@ static void
event_propertynotify(XEvent *e)
{
XPropertyEvent *ev = &e->xproperty;
struct Client *c;
struct client *c;
if(ev->state == PropertyDelete)
return;
@ -176,7 +176,7 @@ static void
event_unmapnotify(XEvent *e)
{
XUnmapEvent *ev = &e->xunmap;
struct Client *c;
struct client *c;
if((c = client_gb_win(ev->window)) && ev->send_event)
client_remove(c);
@ -187,7 +187,7 @@ event_motionnotify(XEvent *e)
{
/*
XMotionEvent *ev = &e->xmotion;
Client *c;
client *c;
* Option follow mouvement
@ -201,7 +201,7 @@ event_keypress(XEvent *e)
{
XKeyPressedEvent *ev = &e->xkey;
KeySym keysym = XKeycodeToKeysym(EVDPY(e), (KeyCode)ev->keycode, 0);
struct Keybind *k;
struct keybind *k;
screen_update_sel();
@ -215,7 +215,7 @@ static void
event_expose(XEvent *e)
{
XExposeEvent *ev = &e->xexpose;
struct Barwin *b;
struct barwin *b;
SLIST_FOREACH(b, &W->h.barwin, next)
if(b->win == ev->window)

View File

@ -4,6 +4,7 @@
*/
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include "ewmh.h"
#include "util.h"
@ -16,6 +17,7 @@ ewmh_init(void)
W->net_atom = xcalloc(net_last, sizeof(Atom));
/* EWMH hints */
W->net_atom[wm_state] = ATOM("WM_STATE");
W->net_atom[net_supported] = ATOM("_NET_SUPPORTED");
W->net_atom[net_client_list] = ATOM("_NET_CLIENT_LIST");
W->net_atom[net_frame_extents] = ATOM("_NET_FRAME_EXTENTS");
@ -92,3 +94,13 @@ ewmh_init(void)
*/
}
void
ewmh_set_wm_state(Window w, int state)
{
unsigned char d[] = { state, None };
XChangeProperty(W->dpy, w, W->net_atom[wm_state],
W->net_atom[wm_state], 32, PropModeReplace, d, 2);
}

View File

@ -12,6 +12,9 @@
/* Ewmh hints list */
enum
{
/* ICCCM */
wm_state,
/* EWMH */
net_supported,
net_wm_name,
net_client_list,
@ -66,5 +69,6 @@ enum
};
void ewmh_init(void);
void ewmh_set_wm_state(Window w, int state);
#endif /* EWMH_H */

View File

@ -3,40 +3,48 @@
* For license, see COPYING.
*/
#include <X11/Xutil.h>
#include "wmfs.h"
#include "frame.h"
#include "barwin.h"
#include "tag.h"
#include "util.h"
#include "config.h"
struct Frame*
frame_new(struct Tag *t)
struct frame*
frame_new(struct tag *t)
{
struct Geo g = t->screen->ugeo;
struct Frame *f = xcalloc(1, sizeof(struct Frame));
struct frame *f = xcalloc(1, sizeof(struct frame));
XSetWindowAttributes at =
{
.override_redirect = True,
.background_pixel = THEME_DEFAULT->frame_bg,
.override_redirect = true,
.background_pixmap = ParentRelative,
.event_mask = (BARWIN_MASK | BARWIN_ENTERMASK)
.event_mask = BARWIN_MASK
};
f->tag = t;
f->geo = g;
f->geo = t->screen->ugeo;
t->frame = f;
f->win = XCreateWindow(W->dpy, W->root, g.x, g.y, g.w, g.h, 0, W->xdepth,
CopyFromParent, DefaultVisual(W->dpy, W->xscreen),
(CWOverrideRedirect | CWEventMask), &at);
f->win = XCreateWindow(W->dpy, W->root,
f->geo.x, f->geo.y,
f->geo.w, f->geo.h,
0, CopyFromParent,
InputOutput,
CopyFromParent,
(CWOverrideRedirect | CWBackPixmap | CWBackPixel | CWEventMask),
&at);
SLIST_INIT(&f->clients);
SLIST_INSERT_HEAD(&t->frames, f, next);
}
static void
frame_remove(struct Frame *f)
frame_remove(struct frame *f)
{
SLIST_REMOVE(&f->tag->frames, f, Frame, next);
SLIST_REMOVE(&f->tag->frames, f, frame, next);
XDestroyWindow(W->dpy, f->win);
/* frame_arrange(f->tag); */
@ -44,36 +52,93 @@ frame_remove(struct Frame *f)
}
void
frame_free(struct Tag *t)
frame_free(struct tag *t)
{
struct Frame *f;
struct frame *f;
SLIST_FOREACH(f, &t->frames, next)
frame_remove(f);
}
void
frame_client(struct Frame *f, struct Client *c)
frame_client(struct frame *f, struct client *c)
{
/* Remove client from its previous frame */
if(c->frame)
SLIST_REMOVE(&c->frame->clients, c, Client, fnext);
{
if(c->frame == f)
return;
/* Adjust tag with frame's one */
if(f->tag != c->tag)
tag_client(f->tag, c);
SLIST_REMOVE(&c->frame->clients, c, client, fnext);
}
XReparentWindow(W->dpy, c->win, f->win, 1, 1);
/* Case of client remove, f = NULL */
if(!f)
{
if(c->frame && FRAME_EMPTY(c->frame))
frame_unmap(c->frame);
XReparentWindow(W->dpy, c->win, W->root, c->geo.x, c->geo.y);
return;
}
XReparentWindow(W->dpy, c->win, f->win,
THEME_DEFAULT->client_border_width,
THEME_DEFAULT->client_titlebar_width);
XResizeWindow(W->dpy, c->win,
f->geo.w - (THEME_DEFAULT->client_border_width << 1) - 1,
f->geo.h - (THEME_DEFAULT->client_titlebar_width
+ THEME_DEFAULT->client_border_width >> 1));
/* XReparentWindow(W->dpy, c->win, c->titlebar->win, 1, 1); */
SLIST_INSERT_HEAD(&f->clients, c, next);
/*split_integrate(f, c) */
SLIST_INSERT_HEAD(&f->clients, c, fnext);
frame_update(f);
}
void
frame_update(struct Frame *f)
frame_map(struct frame *f)
{
struct client *c;
WIN_STATE(f->win, Map);
SLIST_FOREACH(c, &f->clients, fnext)
ewmh_set_wm_state(c->win, NormalState);
}
void
frame_unmap(struct frame *f)
{
struct client *c;
WIN_STATE(f->win, Unmap);
SLIST_FOREACH(c, &f->clients, fnext)
ewmh_set_wm_state(c->win, IconicState);
}
void
frame_update(struct frame *f)
{
if(FRAME_EMPTY(f))
return;
/* Resize frame */
/* TODO: frame_arrange or something */
XMoveResizeWindow(W->dpy,
f->win,
f->geo.x,
f->geo.y,
f->geo.w,
f->geo.h);
frame_map(f);
}

View File

@ -8,8 +8,30 @@
#include "wmfs.h"
struct Frame *frame_new(struct Tag *t);
void frame_free(struct Tag *t);
void frame_update(struct Frame *f);
#define FRAME_EMPTY(f) SLIST_EMPTY(&f->clients)
/*
* Update each frame's geo of a screen after
* usable geo update (infobar_placement())
*/
static inline void
frame_update_geo(struct screen *s)
{
struct tag *t;
struct frame *f;
TAILQ_FOREACH(t, &s->tags, next)
{
SLIST_FOREACH(f, &t->frames, next)
f->geo = s->ugeo;
}
}
struct frame *frame_new(struct tag *t);
void frame_free(struct tag *t);
void frame_update(struct frame *f);
void frame_map(struct frame *f);
void frame_unmap(struct frame *f);
#endif /* FRAME_H */

View File

@ -10,14 +10,14 @@
#include "util.h"
#include "tag.h"
static void infobar_elem_tag_init(struct Element *e);
static void infobar_elem_tag_update(struct Element *e);
static void infobar_elem_tag_init(struct element *e);
static void infobar_elem_tag_update(struct element *e);
const struct elem_funcs
{
char c;
void (*func_init)(struct Element *e);
void (*func_update)(struct Element *e);
void (*func_init)(struct element *e);
void (*func_update)(struct element *e);
} elem_funcs[] =
{
{ 't', infobar_elem_tag_init, infobar_elem_tag_update },
@ -30,11 +30,11 @@ const struct elem_funcs
};
static void
infobar_elem_tag_init(struct Element *e)
infobar_elem_tag_init(struct element *e)
{
struct Tag *t;
struct Barwin *b, *prev;
struct Geo g = { 0, 0, 0, 0 };
struct tag *t;
struct barwin *b, *prev;
struct geo g = { 0, 0, 0, 0 };
int s, j;
infobar_elem_placement(e);
@ -80,14 +80,14 @@ infobar_elem_tag_init(struct Element *e)
}
static void
infobar_elem_tag_update(struct Element *e)
infobar_elem_tag_update(struct element *e)
{
struct Tag *t, *sel = e->infobar->screen->seltag;
struct Barwin *b;
struct tag *t, *sel = e->infobar->screen->seltag;
struct barwin *b;
SLIST_FOREACH(b, &e->bars, enext)
{
t = (struct Tag*)b->ptr;
t = (struct tag*)b->ptr;
/* Selected */
/* TODO: color from conf */
@ -112,9 +112,9 @@ infobar_elem_tag_update(struct Element *e)
}
static void
infobar_elem_init(struct Infobar *i)
infobar_elem_init(struct infobar *i)
{
struct Element *e;
struct element *e;
int n, j;
TAILQ_INIT(&i->elements);
@ -124,7 +124,7 @@ infobar_elem_init(struct Infobar *i)
for(j = 0; j < LEN(elem_funcs); ++j)
if(elem_funcs[j].c == i->elemorder[n])
{
e = xcalloc(1, sizeof(struct Element));
e = xcalloc(1, sizeof(struct element));
SLIST_INIT(&e->bars);
@ -143,9 +143,9 @@ infobar_elem_init(struct Infobar *i)
}
void
infobar_elem_update(struct Infobar *i)
infobar_elem_update(struct infobar *i)
{
struct Element *e;
struct element *e;
TAILQ_FOREACH(e, &i->elements, next)
if(i->screen->elemupdate & FLAGINT(e->type))
@ -153,9 +153,9 @@ infobar_elem_update(struct Infobar *i)
}
void
infobar_elem_remove(struct Element *e)
infobar_elem_remove(struct element *e)
{
struct Barwin *b;
struct barwin *b;
TAILQ_REMOVE(&e->infobar->elements, e, next);
@ -167,13 +167,13 @@ infobar_elem_remove(struct Element *e)
}
}
struct Infobar*
infobar_new(struct Scr33n *s, struct Theme *theme, Barpos pos, const char *elem)
struct infobar*
infobar_new(struct screen *s, struct theme *theme, Barpos pos, const char *elem)
{
bool map;
int n;
struct Infobar *i = (struct Infobar*)xcalloc(1, sizeof(struct Infobar));
struct infobar *i = (struct infobar*)xcalloc(1, sizeof(struct infobar));
i->screen = s;
i->theme = theme;
@ -181,13 +181,13 @@ infobar_new(struct Scr33n *s, struct Theme *theme, Barpos pos, const char *elem)
map = infobar_placement(i, pos);
/* struct Barwin create */
/* struct barwin create */
i->bar = barwin_new(W->root, i->geo.x, i->geo.y, i->geo.w, i->geo.h,
theme->bars.fg, theme->bars.bg, false);
SLIST_INSERT_HEAD(&s->infobars, i, next);
/* struct Elements */
/* struct elements */
infobar_elem_init(i);
/* Render, only if pos is Top or Bottom */
@ -203,7 +203,7 @@ infobar_new(struct Scr33n *s, struct Theme *theme, Barpos pos, const char *elem)
}
void
infobar_refresh(struct Infobar *i)
infobar_refresh(struct infobar *i)
{
infobar_elem_update(i);
@ -211,9 +211,9 @@ infobar_refresh(struct Infobar *i)
}
void
infobar_remove(struct Infobar *i)
infobar_remove(struct infobar *i)
{
struct Element *e;
struct element *e;
free(i->elemorder);
@ -222,15 +222,15 @@ infobar_remove(struct Infobar *i)
barwin_remove(i->bar);
SLIST_REMOVE(&i->screen->infobars, i, Infobar, next);
SLIST_REMOVE(&i->screen->infobars, i, infobar, next);
free(i);
}
void
infobar_free(struct Scr33n *s)
infobar_free(struct screen *s)
{
struct Infobar *i;
struct infobar *i;
while(!SLIST_EMPTY(&s->infobars))
{

View File

@ -9,20 +9,21 @@
#include "wmfs.h"
#include "util.h"
#include "draw.h"
#include "frame.h"
enum { ElemTag = 0, ElemLayout, ElemSelbar, ElemStatus, ElemCustom, ElemLast };
struct Infobar *infobar_new(struct Scr33n *s, struct Theme *theme, Barpos pos, const char *elem);
void infobar_elem_update(struct Infobar *i);
void infobar_refresh(struct Infobar *i);
void infobar_remove(struct Infobar *i);
void infobar_free(struct Scr33n *s);
struct infobar *infobar_new(struct screen *s, struct theme *theme, Barpos pos, const char *elem);
void infobar_elem_update(struct infobar *i);
void infobar_refresh(struct infobar *i);
void infobar_remove(struct infobar *i);
void infobar_free(struct screen *s);
/* Basic placement of elements */
static inline void
infobar_elem_placement(struct Element *e)
infobar_elem_placement(struct element *e)
{
struct Element *p = TAILQ_PREV(e, esub, next);
struct element *p = TAILQ_PREV(e, esub, next);
e->geo.y = e->geo.w = 0;
e->geo.h = e->infobar->geo.h;
@ -31,7 +32,7 @@ infobar_elem_placement(struct Element *e)
/* Bars placement management and usable space management */
static inline bool
infobar_placement(struct Infobar *i, Barpos p)
infobar_placement(struct infobar *i, Barpos p)
{
i->pos = p;
i->geo = i->screen->ugeo;
@ -52,13 +53,15 @@ infobar_placement(struct Infobar *i, Barpos p)
return false;
}
frame_update_geo(i->screen);
return true;
}
static inline void
infobar_elem_screen_update(struct Scr33n *s, int addf)
infobar_elem_screen_update(struct screen *s, int addf)
{
struct Infobar *i;
struct infobar *i;
s->elemupdate |= FLAGINT(addf);

View File

@ -14,10 +14,10 @@
#include "tag.h"
#include "infobar.h"
static struct Scr33n*
screen_new(struct Geo *g, int id)
static struct screen*
screen_new(struct geo *g, int id)
{
struct Scr33n *s = (struct Scr33n*)xcalloc(1, sizeof(struct Scr33n));
struct screen *s = (struct screen*)xcalloc(1, sizeof(struct screen));
s->geo = s->ugeo = *g;
s->seltag = NULL;
@ -37,8 +37,8 @@ screen_new(struct Geo *g, int id)
void
screen_init(void)
{
struct Scr33n *s;
struct Geo g;
struct screen *s;
struct geo g;
SLIST_INIT(&W->h.screen);
@ -76,13 +76,13 @@ screen_init(void)
/*
* Update selected screen with mouse location
*/
struct Scr33n*
struct screen*
screen_update_sel(void)
{
#ifdef HAVE_XINERAMA
if(XineramaIsActive(W->dpy))
{
struct Scr33n *s;
struct screen *s;
Window w;
int d, x, y;
@ -100,7 +100,7 @@ screen_update_sel(void)
void
screen_free(void)
{
struct Scr33n *s;
struct screen *s;
while(!SLIST_EMPTY(&W->h.screen))
{

View File

@ -8,10 +8,10 @@
#include "wmfs.h"
static inline struct Scr33n*
static inline struct screen*
screen_gb_id(int id)
{
struct Scr33n *s;
struct screen *s;
SLIST_FOREACH(s, &W->h.screen, next)
if(s->id == id)
@ -21,7 +21,7 @@ screen_gb_id(int id)
}
void screen_init(void);
struct Scr33n* screen_update_sel(void);
struct screen* screen_update_sel(void);
void screen_free(void);
#endif /* SCREEN_H */

View File

@ -9,12 +9,12 @@
#include "client.h"
#include "frame.h"
struct Tag*
tag_new(struct Scr33n *s, char *name)
struct tag*
tag_new(struct screen *s, char *name)
{
struct Tag *t;
struct tag *t;
t = xcalloc(1, sizeof(struct Tag));
t = xcalloc(1, sizeof(struct tag));
t->screen = s;
t->name = xstrdup(name);
@ -24,10 +24,8 @@ tag_new(struct Scr33n *s, char *name)
SLIST_INIT(&t->clients);
SLIST_INIT(&t->frames);
/*
* tmp
*/
t->frame = frame_new(t);
/* only one frame for now, *tmp* */
frame_new(t); /* t->frame */
TAILQ_INSERT_TAIL(&s->tags, t, next);
@ -35,56 +33,56 @@ tag_new(struct Scr33n *s, char *name)
}
void
tag_screen(struct Scr33n *s, struct Tag *t)
tag_screen(struct screen *s, struct tag *t)
{
struct Frame *f;
struct Client *c;
struct frame *f;
struct client *c;
/* Hide previous tag's clients */
if(s->seltag)
SLIST_FOREACH(c, &s->seltag->clients, tnext)
client_unmap(c);
s->seltag = t;
/* Hide previous tag's frame */
SLIST_FOREACH(f, &s->seltag->frames, next)
frame_unmap(f);
/* Unhide selected tag's clients */
SLIST_FOREACH(c, &t->clients, tnext)
client_map(c);
SLIST_FOREACH(f, &t->frames, next)
frame_update(f);
s->seltag = t;
client_focus(t->sel);
infobar_elem_screen_update(s, ElemTag);
SLIST_FOREACH(f, &t->frames, next)
frame_update(f);
}
void
tag_client(struct Tag *t, struct Client *c)
tag_client(struct tag *t, struct client *c)
{
/* Remove client from its previous tag */
if(c->tag)
{
SLIST_REMOVE(&c->tag->clients, c, Client, tnext);
if(c->tag == t)
return;
SLIST_REMOVE(&c->tag->clients, c, client, tnext);
if(c->tag->sel == c)
c->tag->sel = NULL;
}
/* Case of client remove, t = NULL */
if(!(c->tag = t))
/* Case of client remove */
if(!t)
return;
c->tag = t;
/* Insert in new tag list */
SLIST_INSERT_HEAD(&t->clients, c, tnext);
}
void
uicb_tag_set(Uicb cmd)
{
int i = 0, n = ATOI(cmd);
struct Tag *t;
struct tag *t;
TAILQ_FOREACH(t, &W->screen->tags, next)
if(++i == n)
@ -97,7 +95,7 @@ uicb_tag_set(Uicb cmd)
void
uicb_tag_set_with_name(Uicb cmd)
{
struct Tag *t;
struct tag *t;
TAILQ_FOREACH(t, &W->screen->tags, next)
if(!strcmp(cmd, t->name))
@ -111,7 +109,7 @@ void
uicb_tag_next(Uicb cmd)
{
(void)cmd;
struct Tag *t;
struct tag *t;
if((t = TAILQ_NEXT(W->screen->seltag, next)))
tag_screen(W->screen, t);
@ -123,7 +121,7 @@ void
uicb_tag_prev(Uicb cmd)
{
(void)cmd;
struct Tag *t;
struct tag *t;
if((t = TAILQ_PREV(W->screen->seltag, tsub, next)))
tag_screen(W->screen, t);
@ -132,9 +130,9 @@ uicb_tag_prev(Uicb cmd)
}
static void
tag_remove(struct Tag *t)
tag_remove(struct tag *t)
{
struct Frame *f;
struct frame *f;
free(t->name);
@ -143,11 +141,10 @@ tag_remove(struct Tag *t)
free(t);
}
void
tag_free(struct Scr33n *s)
tag_free(struct screen *s)
{
struct Tag *t;
struct tag *t;
TAILQ_FOREACH(t, &s->tags, next)
{

View File

@ -8,10 +8,10 @@
#include "wmfs.h"
struct Tag *tag_new(struct Scr33n *s, char *name);
void tag_screen(struct Scr33n *s, struct Tag *t);
void tag_client(struct Tag *t, struct Client *c);
void tag_free(struct Scr33n *s);
struct tag *tag_new(struct screen *s, char *name);
void tag_screen(struct screen *s, struct tag *t);
void tag_client(struct tag *t, struct client *c);
void tag_free(struct screen *s);
void uicb_tag_set(Uicb cmd);
void uicb_tag_set_with_name(Uicb cmd);
void uicb_tag_next(Uicb cmd);

View File

@ -19,11 +19,20 @@
} \
} while(/* CONSTCOND */ 0);
#define ATOM(a) XInternAtom(W->dpy, (a), False)
#define LEN(x) (sizeof(x) / sizeof(*x))
#define FLAGINT(i) (1 << i)
#define ATOI(s) strtol(s, NULL, 10)
#define INAREA(i, j, a) ((i) >= (a).x && (i) <= (a).x + (a).w && (j) >= (a).y && (j) <= (a).y + (a).h)
/* t is Map or Unmap */
#define WIN_STATE(w, t) do { \
X##t##Subwindows(W->dpy, w); \
X##t##Window(W->dpy, w); \
} while( /* CONSTCOND */ 0);
#define ATOM(a) XInternAtom(W->dpy, (a), False)
#define LEN(x) (sizeof(x) / sizeof(*x))
#define FLAGINT(i) (1 << i)
#define ATOI(s) strtol(s, NULL, 10)
#define ABS(j) (j < 0 ? -j : j)
#define INAREA(i, j, a) ((i) >= (a).x && (i) <= (a).x + (a).w && (j) >= (a).y && (j) <= (a).y + (a).h)
/*
* "#RRGGBB" -> 0xRRGGBB

View File

@ -73,7 +73,7 @@ wmfs_numlockmask(void)
}
void
wmfs_init_font(char *font, struct Theme *t)
wmfs_init_font(char *font, struct theme *t)
{
XFontStruct **xfs = NULL;
char **misschar, **names, *defstring;
@ -150,7 +150,7 @@ void
wmfs_grab_keys(void)
{
KeyCode c;
struct Keybind *k;
struct keybind *k;
wmfs_numlockmask();
@ -252,12 +252,12 @@ wmfs_init(void)
void
wmfs_quit(void)
{
struct Keybind *k;
struct Theme *t;
struct keybind *k;
struct theme *t;
/* Will free:
*
* Screens -> Tags
* Screens -> tags
* -> Infobars -> Elements
*/
screen_free();
@ -306,7 +306,7 @@ uicb_quit(Uicb cmd)
int
main(int argc, char **argv)
{
W = (struct Wmfs*)xcalloc(1, sizeof(struct Wmfs));
W = (struct wmfs*)xcalloc(1, sizeof(struct wmfs));
/* Get X display */

View File

@ -37,128 +37,120 @@ typedef enum { Right = 0, Left, Top, Bottom, Center, PositionLast } Position;
* Structures
*/
struct Geo
struct geo
{
int x, y, w, h;
};
/* struct Barwin */
struct Barwin
struct barwin
{
struct Geo geo;
struct geo geo;
Window win;
Drawable dr;
Color fg, bg;
Flags flags;
void *ptr; /* Special cases */
SLIST_HEAD(, Mousebind) mousebinds;
SLIST_ENTRY(Barwin) next; /* global barwin */
SLIST_ENTRY(Barwin) enext; /* element barwin */
SLIST_HEAD(, mousebind) mousebinds;
SLIST_ENTRY(barwin) next; /* global barwin */
SLIST_ENTRY(barwin) enext; /* element barwin */
};
/* struct Infobar's element */
struct Element
struct element
{
struct Geo geo;
struct Infobar *infobar;
struct geo geo;
struct infobar *infobar;
int type;
void (*func_init)(struct Element *e);
void (*func_update)(struct Element *e);
SLIST_HEAD(, Barwin) bars;
TAILQ_ENTRY(Element) next;
void (*func_init)(struct element *e);
void (*func_update)(struct element *e);
SLIST_HEAD(, barwin) bars;
TAILQ_ENTRY(element) next;
};
/* struct Infobar */
struct Infobar
struct infobar
{
struct Barwin *bar;
struct Geo geo;
struct Scr33n *screen;
struct Theme *theme;
struct barwin *bar;
struct geo geo;
struct screen *screen;
struct theme *theme;
char *elemorder;
Barpos pos;
TAILQ_HEAD(esub, Element) elements;
SLIST_ENTRY(Infobar) next;
TAILQ_HEAD(esub, element) elements;
SLIST_ENTRY(infobar) next;
};
/* Screen */
struct Scr33n
struct screen
{
struct Geo geo, ugeo;
struct Tag *seltag;
struct geo geo, ugeo;
struct tag *seltag;
int id;
Flags elemupdate;
TAILQ_HEAD(tsub, Tag) tags;
SLIST_HEAD(, Infobar) infobars;
SLIST_ENTRY(Scr33n) next;
TAILQ_HEAD(tsub, tag) tags;
SLIST_HEAD(, infobar) infobars;
SLIST_ENTRY(screen) next;
};
/* struct Tag */
struct Tag
struct tag
{
struct Scr33n *screen;
struct Client *sel;
struct Frame *frame;
struct screen *screen;
struct client *sel;
struct frame *frame;
char *name;
Flags flags;
SLIST_HEAD(, Frame) frames;
SLIST_HEAD(, Client) clients;
TAILQ_ENTRY(Tag) next;
SLIST_HEAD(, frame) frames;
SLIST_HEAD(, client) clients;
TAILQ_ENTRY(tag) next;
};
/* struct Client */
struct Client
struct client
{
struct Tag *tag;
struct Scr33n *screen;
struct Frame *frame;
struct Barwin *titlebar;
struct Geo geo;
struct tag *tag;
struct screen *screen;
struct frame *frame;
struct barwin *titlebar;
struct geo geo;
char *title;
Flags flags;
Window win;
SLIST_ENTRY(Client) next; /* Global list */
SLIST_ENTRY(Client) tnext; /* struct Tag list */
SLIST_ENTRY(Client) fnext; /* struct struct Frame list */
SLIST_ENTRY(client) next; /* Global list */
SLIST_ENTRY(client) tnext; /* struct tag list */
SLIST_ENTRY(client) fnext; /* struct struct frame list */
};
/* struct struct Frame */
struct Frame
struct frame
{
struct Tag *tag;
struct Geo geo;
struct tag *tag;
struct geo geo;
Window win;
Color fg, bg;
SLIST_HEAD(, Client) clients;
SLIST_ENTRY(Frame) next;
SLIST_HEAD(, client) clients;
SLIST_ENTRY(frame) next;
};
/* Config */
struct Keybind
struct keybind
{
unsigned int mod;
void (*func)(Uicb);
Uicb cmd;
KeySym keysym;
SLIST_ENTRY(Keybind) next;
SLIST_ENTRY(keybind) next;
};
struct Mousebind
struct mousebind
{
struct Geo area;
struct geo area;
unsigned int button;
bool use_area;
void (*func)(Uicb);
Uicb cmd;
SLIST_ENTRY(Mousebind) next;
SLIST_ENTRY(mousebind) next;
};
struct Colpair
struct colpair
{
Color fg, bg;
};
struct Theme
struct theme
{
char *name;
@ -170,25 +162,24 @@ struct Theme
} font;
/* Bars */
struct Colpair bars;
struct colpair bars;
int bars_width;
/* struct Elements */
struct Colpair tags_n, tags_s; /* normal / selected */
/* struct elements */
struct colpair tags_n, tags_s; /* normal / selected */
int tags_border_width;
Color tags_border_col;
/* struct Client / struct struct Frame */
struct Colpair client_n, client_s;
/* client / frame */
struct colpair client_n, client_s;
Color frame_bg;
int client_titlebar_width;
int client_border_width;
SLIST_ENTRY(Theme) next;
SLIST_ENTRY(theme) next;
};
/* Global struct */
struct Wmfs
struct wmfs
{
/* X11 stuffs */
Display *dpy;
@ -202,18 +193,18 @@ struct Wmfs
/* Lists heads */
struct
{
SLIST_HEAD(, Scr33n) screen;
SLIST_HEAD(, Client) client;
SLIST_HEAD(, Keybind) keybind;
SLIST_HEAD(, Barwin) barwin;
SLIST_HEAD(, Theme) theme;
SLIST_HEAD(, screen) screen;
SLIST_HEAD(, client) client;
SLIST_HEAD(, keybind) keybind;
SLIST_HEAD(, barwin) barwin;
SLIST_HEAD(, theme) theme;
} h;
/*
* Selected screen, client
*/
struct Scr33n *screen;
struct Client *client;
struct screen *screen;
struct client *client;
};
@ -221,13 +212,13 @@ int wmfs_error_handler(Display *d, XErrorEvent *event);
int wmfs_error_handler_dummy(Display *d, XErrorEvent *event);
void wmfs_grab_keys(void);
void wmfs_numlockmask(void);
void wmfs_init_font(char *font, struct Theme *t);
void wmfs_init_font(char *font, struct theme *t);
void wmfs_quit(void);
void uicb_reload(Uicb cmd);
void uicb_quit(Uicb cmd);
/* Single global variable */
struct Wmfs *W;
struct wmfs *W;
#endif /* WMFS_H */