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 "barwin.h"
#include "util.h" #include "util.h"
/** Create a Barwin /** Create a barwin
* \param parent Parent window of the BarWindow * \param parent Parent window of the BarWindow
* \param x X position * \param x X position
* \param y Y position * \param y Y position
* \param w Barwin Width * \param w barwin Width
* \param h Barwin Height * \param h barwin Height
* \param color Barwin color * \param color barwin color
* \param entermask bool for know if the EnterMask mask is needed * \param entermask bool for know if the EnterMask mask is needed
* \return The BarWindow pointer * \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) 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 = XSetWindowAttributes at =
{ {
.override_redirect = True, .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; at.event_mask |= BARWIN_ENTERMASK;
/* Create window */ /* Create window */
b->win = XCreateWindow(W->dpy, parent, x, y, w, h, 0, W->xdepth, CopyFromParent, b->win = XCreateWindow(W->dpy, parent,
DefaultVisual(W->dpy, W->xscreen), BARWIN_WINCW, &at); 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); 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; return b;
} }
/** Delete a Barwin /** Delete a barwin
* \param bw Barwin pointer * \param bw barwin pointer
*/ */
void 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); XSelectInput(W->dpy, b->win, NoEventMask);
XDestroyWindow(W->dpy, b->win); XDestroyWindow(W->dpy, b->win);
XFreePixmap(W->dpy, b->dr); XFreePixmap(W->dpy, b->dr);
/* Free mousebinds */ /* Free mousebinds */
FREE_LIST(Mousebind, b->mousebinds); FREE_LIST(mousebind, b->mousebinds);
free(b); free(b);
} }
/** Resize a Barwin /** Resize a barwin
* \param bw Barwin pointer * \param bw barwin pointer
* \param w Width * \param w Width
* \param h Height * \param h Height
*/ */
void void
barwin_resize(struct Barwin *b, int w, int h) barwin_resize(struct barwin *b, int w, int h)
{ {
/* Frame */ /* Frame */
XFreePixmap(W->dpy, b->dr); XFreePixmap(W->dpy, b->dr);
@ -91,11 +96,11 @@ barwin_resize(struct Barwin *b, int w, int h)
} }
void 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->button = button;
m->use_area = u; 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); SLIST_INSERT_HEAD(&b->mousebinds, m, next);
} }
/** Refresh the Barwin Color /** Refresh the barwin Color
* \param bw Barwin pointer * \param bw barwin pointer
*/ */
void void
barwin_refresh_color(struct Barwin *b) barwin_refresh_color(struct barwin *b)
{ {
XSetForeground(W->dpy, W->gc, b->bg); XSetForeground(W->dpy, W->gc, b->bg);
XFillRectangle(W->dpy, b->dr, W->gc, 0, 0, b->geo.w, b->geo.h); 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_map(b) XMapWindow(W->dpy, b->win);
#define barwin_unmap(b) XUnmapWindow(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); 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_remove(struct barwin *b);
void barwin_resize(struct Barwin *b, int w, int h); 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_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); void barwin_refresh_color(struct barwin *b);
#endif /* BARWIN_H */ #endif /* BARWIN_H */

View File

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

View File

@ -16,7 +16,7 @@
static void static void
config_theme(void) config_theme(void)
{ {
struct Theme *t; struct theme *t;
size_t i, n; size_t i, n;
struct conf_sec *sec, **ks; struct conf_sec *sec, **ks;
char *name; char *name;
@ -34,7 +34,7 @@ config_theme(void)
/* [theme]*/ /* [theme]*/
for(i = 0; i < n; ++i) 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; 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_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; 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.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_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); 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 static void
config_bars(void) config_bars(void)
{ {
struct Scr33n *s; struct screen *s;
struct Theme *t; struct theme *t;
size_t i, n; size_t i, n;
struct conf_sec *sec, **ks; struct conf_sec *sec, **ks;
int screenid; int screenid;
@ -106,8 +106,8 @@ config_bars(void)
static void static void
config_tag(void) config_tag(void)
{ {
struct Scr33n *s; struct screen *s;
struct Tag *t; struct tag *t;
size_t i, n; size_t i, n;
struct conf_sec *sec, **ks; struct conf_sec *sec, **ks;
char *name; char *name;
@ -146,7 +146,7 @@ config_keybind(void)
struct conf_sec *sec, **ks; struct conf_sec *sec, **ks;
struct opt_type *opt; struct opt_type *opt;
char *cmd; char *cmd;
struct Keybind *k; struct keybind *k;
/* [keys] */ /* [keys] */
sec = fetch_section_first(NULL, "keys"); sec = fetch_section_first(NULL, "keys");
@ -158,7 +158,7 @@ config_keybind(void)
/* [key] */ /* [key] */
for(i = 0; i < n; ++i) for(i = 0; i < n; ++i)
{ {
k = (struct Keybind*)xcalloc(1, sizeof(struct Keybind)); k = (struct keybind*)xcalloc(1, sizeof(struct keybind));
/* mod = {} */ /* mod = {} */
opt = fetch_opt(ks[i], "", "mod"); opt = fetch_opt(ks[i], "", "mod");

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@
*/ */
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xutil.h>
#include "ewmh.h" #include "ewmh.h"
#include "util.h" #include "util.h"
@ -16,6 +17,7 @@ ewmh_init(void)
W->net_atom = xcalloc(net_last, sizeof(Atom)); W->net_atom = xcalloc(net_last, sizeof(Atom));
/* EWMH hints */ /* EWMH hints */
W->net_atom[wm_state] = ATOM("WM_STATE");
W->net_atom[net_supported] = ATOM("_NET_SUPPORTED"); W->net_atom[net_supported] = ATOM("_NET_SUPPORTED");
W->net_atom[net_client_list] = ATOM("_NET_CLIENT_LIST"); W->net_atom[net_client_list] = ATOM("_NET_CLIENT_LIST");
W->net_atom[net_frame_extents] = ATOM("_NET_FRAME_EXTENTS"); 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 */ /* Ewmh hints list */
enum enum
{ {
/* ICCCM */
wm_state,
/* EWMH */
net_supported, net_supported,
net_wm_name, net_wm_name,
net_client_list, net_client_list,
@ -66,5 +69,6 @@ enum
}; };
void ewmh_init(void); void ewmh_init(void);
void ewmh_set_wm_state(Window w, int state);
#endif /* EWMH_H */ #endif /* EWMH_H */

View File

@ -3,40 +3,48 @@
* For license, see COPYING. * For license, see COPYING.
*/ */
#include <X11/Xutil.h>
#include "wmfs.h" #include "wmfs.h"
#include "frame.h" #include "frame.h"
#include "barwin.h" #include "barwin.h"
#include "tag.h" #include "tag.h"
#include "util.h" #include "util.h"
#include "config.h"
struct Frame* struct frame*
frame_new(struct Tag *t) 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 = XSetWindowAttributes at =
{ {
.override_redirect = True, .background_pixel = THEME_DEFAULT->frame_bg,
.override_redirect = true,
.background_pixmap = ParentRelative, .background_pixmap = ParentRelative,
.event_mask = (BARWIN_MASK | BARWIN_ENTERMASK) .event_mask = BARWIN_MASK
}; };
f->tag = t; 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, f->win = XCreateWindow(W->dpy, W->root,
CopyFromParent, DefaultVisual(W->dpy, W->xscreen), f->geo.x, f->geo.y,
(CWOverrideRedirect | CWEventMask), &at); f->geo.w, f->geo.h,
0, CopyFromParent,
InputOutput,
CopyFromParent,
(CWOverrideRedirect | CWBackPixmap | CWBackPixel | CWEventMask),
&at);
SLIST_INIT(&f->clients); SLIST_INIT(&f->clients);
SLIST_INSERT_HEAD(&t->frames, f, next); SLIST_INSERT_HEAD(&t->frames, f, next);
} }
static void 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); XDestroyWindow(W->dpy, f->win);
/* frame_arrange(f->tag); */ /* frame_arrange(f->tag); */
@ -44,36 +52,93 @@ frame_remove(struct Frame *f)
} }
void void
frame_free(struct Tag *t) frame_free(struct tag *t)
{ {
struct Frame *f; struct frame *f;
SLIST_FOREACH(f, &t->frames, next) SLIST_FOREACH(f, &t->frames, next)
frame_remove(f); frame_remove(f);
} }
void void
frame_client(struct Frame *f, struct Client *c) frame_client(struct frame *f, struct client *c)
{ {
/* Remove client from its previous frame */ /* Remove client from its previous frame */
if(c->frame) if(c->frame)
SLIST_REMOVE(&c->frame->clients, c, Client, fnext); {
if(c->frame == f)
return;
/* Adjust tag with frame's one */ SLIST_REMOVE(&c->frame->clients, c, client, fnext);
if(f->tag != c->tag) }
tag_client(f->tag, c);
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); */ /* 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 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" #include "wmfs.h"
struct Frame *frame_new(struct Tag *t); #define FRAME_EMPTY(f) SLIST_EMPTY(&f->clients)
void frame_free(struct Tag *t);
void frame_update(struct Frame *f); /*
* 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 */ #endif /* FRAME_H */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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