remove drawcontext everywhere

This commit is contained in:
Julien Danjou 2007-10-10 14:09:36 +02:00
parent 1a1146eff2
commit e733af41ec
15 changed files with 113 additions and 168 deletions

View File

@ -43,17 +43,15 @@
Client *clients = NULL;
Client *sel = NULL;
Client *stack = NULL;
DC *dc;
static int (*xerrorxlib) (Display *, XErrorEvent *);
static Bool readin = True, running = True;
/** Cleanup everything on quit
* \param drawcontext Drawcontext ref
* \param awesomeconf awesome config
*/
static void
cleanup(DC *drawcontext, awesome_config *awesomeconf)
cleanup(awesome_config *awesomeconf)
{
int screen, i;
@ -62,7 +60,7 @@ cleanup(DC *drawcontext, awesome_config *awesomeconf)
while(stack)
{
unban(stack);
unmanage(stack, drawcontext, NormalState, awesomeconf);
unmanage(stack, NormalState, awesomeconf);
}
for(screen = 0; screen < get_screen_count(awesomeconf->display); screen++)
@ -72,7 +70,6 @@ cleanup(DC *drawcontext, awesome_config *awesomeconf)
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, awesomeconf[screen].phys_screen));
XFreePixmap(awesomeconf->display, awesomeconf[screen].statusbar.drawable);
XFreeGC(awesomeconf->display, drawcontext[screen].gc);
XDestroyWindow(awesomeconf->display, awesomeconf[screen].statusbar.window);
XFreeCursor(awesomeconf->display, awesomeconf[screen].cursor[CurNormal]);
XFreeCursor(awesomeconf->display, awesomeconf[screen].cursor[CurResize]);
@ -97,7 +94,6 @@ cleanup(DC *drawcontext, awesome_config *awesomeconf)
XSetInputFocus(awesomeconf->display, PointerRoot, RevertToPointerRoot, CurrentTime);
XSync(awesomeconf->display, False);
p_delete(&awesomeconf);
p_delete(&dc);
}
/** Get a window state (WM_STATE)
@ -126,11 +122,10 @@ getstate(Display *disp, Window w)
/** Scan X to find windows to manage
* \param screen Screen number
* \param drawcontext Drawcontext ref
* \param awesomeconf awesome config
*/
static void
scan(DC *drawcontext, awesome_config *awesomeconf)
scan(awesome_config *awesomeconf)
{
unsigned int i, num;
int screen, real_screen;
@ -152,7 +147,7 @@ scan(DC *drawcontext, awesome_config *awesomeconf)
{
if(screen == 0)
real_screen = get_screen_bycoord(awesomeconf->display, wa.x, wa.y);
manage(awesomeconf->display, &drawcontext[real_screen], wins[i], &wa, &awesomeconf[real_screen]);
manage(awesomeconf->display, wins[i], &wa, &awesomeconf[real_screen]);
}
}
/* now the transients */
@ -165,7 +160,7 @@ scan(DC *drawcontext, awesome_config *awesomeconf)
{
if(screen == 0)
real_screen = get_screen_bycoord(awesomeconf->display, wa.x, wa.y);
manage(awesomeconf->display, &drawcontext[real_screen], wins[i], &wa, &awesomeconf[real_screen]);
manage(awesomeconf->display, wins[i], &wa, &awesomeconf[real_screen]);
}
}
}
@ -180,7 +175,7 @@ scan(DC *drawcontext, awesome_config *awesomeconf)
* \todo clean things...
*/
static void
setup(DC *drawcontext, awesome_config *awesomeconf)
setup(awesome_config *awesomeconf)
{
XSetWindowAttributes wa;
@ -205,8 +200,6 @@ setup(DC *drawcontext, awesome_config *awesomeconf)
/* bar */
awesomeconf->statusbar.height = awesomeconf->font->height + 2;
initstatusbar(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar, awesomeconf->cursor[CurNormal]);
drawcontext->gc = XCreateGC(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), 0, 0);
XSetLineAttributes(awesomeconf->display, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter);
}
/** Startup Error handler to check if another window manager
@ -222,14 +215,12 @@ xerrorstart(Display * disp __attribute__ ((unused)), XErrorEvent * ee __attribut
/** Quit awesome
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param awesomeconf awesome config
* \param arg nothing
* \ingroup ui_callback
*/
void
uicb_quit(Display *disp __attribute__ ((unused)),
DC *drawcontext __attribute__ ((unused)),
awesome_config *awesomeconf __attribute__((unused)),
const char *arg __attribute__ ((unused)))
{
@ -320,14 +311,13 @@ main(int argc, char *argv[])
XSync(dpy, False);
/* allocate stuff */
dc = p_new(DC, get_screen_count(dpy));
awesomeconf = p_new(awesome_config, get_screen_count(dpy));
for(screen = 0; screen < get_screen_count(dpy); screen++)
{
parse_config(dpy, screen, confpath, &awesomeconf[screen]);
setup(&dc[screen], &awesomeconf[screen]);
drawstatusbar(dpy, &dc[screen], &awesomeconf[screen]);
setup(&awesomeconf[screen]);
drawstatusbar(dpy, &awesomeconf[screen]);
}
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
@ -375,7 +365,7 @@ main(int argc, char *argv[])
awesomeconf[screen].have_randr = awesomeconf[0].have_randr;
}
scan(dc, awesomeconf);
scan(awesomeconf);
XSync(dpy, False);
@ -415,7 +405,7 @@ main(int argc, char *argv[])
a_strncpy(awesomeconf[0].statustext, sizeof(awesomeconf[0].statustext),
p + 1, sizeof(awesomeconf[0].statustext));
}
drawstatusbar(dpy, &dc[0], &awesomeconf[0]);
drawstatusbar(dpy, &awesomeconf[0]);
}
while(XPending(dpy))
@ -425,7 +415,7 @@ main(int argc, char *argv[])
handler[ev.type](&ev, awesomeconf); /* call handler */
}
}
cleanup(dc, awesomeconf);
cleanup(awesomeconf);
XCloseDisplay(dpy);
return EXIT_SUCCESS;

View File

@ -303,13 +303,12 @@ detach(Client * c)
/** Give focus to client, or to first client if c is NULL
* \param disp Display ref
* \param drawcontext drawcontext ref
* \param c client
* \param selscreen True if current screen is selected
* \param awesomeconf awesome config
*/
void
focus(Display *disp, DC *drawcontext, Client * c, Bool selscreen, awesome_config *awesomeconf)
focus(Display *disp, Client * c, Bool selscreen, awesome_config *awesomeconf)
{
/* if c is NULL or invisible, take next client in the stack */
if((!c && selscreen) || (c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags)))
@ -333,7 +332,7 @@ focus(Display *disp, DC *drawcontext, Client * c, Bool selscreen, awesome_config
if(!selscreen)
return;
sel = c;
drawstatusbar(disp, drawcontext, awesomeconf);
drawstatusbar(disp, awesomeconf);
if(sel)
{
XSetWindowBorder(sel->display, sel->win, awesomeconf->colors_selected[ColBorder].pixel);
@ -379,13 +378,12 @@ loadprops(Client * c, int ntags)
/** Manage a new client
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param w The window
* \param wa Window attributes
* \param awesomeconf awesome config
*/
void
manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
manage(Display *disp, Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
{
int i;
Client *c, *t = NULL;
@ -453,7 +451,7 @@ manage(Display *disp, DC *drawcontext, Window w, XWindowAttributes *wa, awesome_
attachstack(c);
XMoveResizeWindow(disp, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
c->isbanned = True;
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
void
@ -567,7 +565,7 @@ unban(Client * c)
}
void
unmanage(Client * c, DC *drawcontext, long state, awesome_config *awesomeconf)
unmanage(Client * c, long state, awesome_config *awesomeconf)
{
XWindowChanges wc;
@ -579,14 +577,14 @@ unmanage(Client * c, DC *drawcontext, long state, awesome_config *awesomeconf)
detach(c);
detachstack(c);
if(sel == c)
focus(c->display, drawcontext, NULL, True, awesomeconf);
focus(c->display, NULL, True, awesomeconf);
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
setclientstate(c, state);
XSync(c->display, False);
XSetErrorHandler(xerror);
XUngrabServer(c->display);
if(state != NormalState)
arrange(c->display, drawcontext, awesomeconf);
arrange(c->display, awesomeconf);
p_delete(&c->tags);
p_delete(&c);
}
@ -668,14 +666,12 @@ set_shape(Client *c)
/** Set selected client transparency
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param awesomeconf awesome config
* \param arg unused arg
* \ingroup ui_callback
*/
void
uicb_settrans(Display *disp __attribute__ ((unused)),
DC *drawcontext __attribute__ ((unused)),
awesome_config *awesomeconf __attribute__ ((unused)),
const char *arg)
{
@ -721,14 +717,12 @@ uicb_settrans(Display *disp __attribute__ ((unused)),
/** Set borrder size
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param awesomeconf awesome config
* \param arg X, +X or -X
* \ingroup ui_callback
*/
void
uicb_setborder(Display *disp __attribute__ ((unused)),
DC *drawcontext __attribute__ ((unused)),
awesome_config *awesomeconf,
const char *arg)
{
@ -741,7 +735,6 @@ uicb_setborder(Display *disp __attribute__ ((unused)),
void
uicb_swapnext(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -754,13 +747,12 @@ uicb_swapnext(Display *disp,
if(next)
{
client_swap(sel, next);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
}
void
uicb_swapprev(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -773,13 +765,12 @@ uicb_swapprev(Display *disp,
if(prev)
{
client_swap(prev, sel);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
}
void
uicb_moveresize(Display *disp __attribute__ ((unused)),
DC *drawcontext __attribute__ ((unused)),
awesome_config *awesomeconf,
const char *arg)
{
@ -816,14 +807,12 @@ uicb_moveresize(Display *disp __attribute__ ((unused)),
/** Kill selected client
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param awesomeconf awesome config
* \param arg unused
* \ingroup ui_callback
*/
void
uicb_killclient(Display *disp __attribute__ ((unused)),
DC *drawcontext __attribute__ ((unused)),
awesome_config *awesomeconf __attribute__ ((unused)),
const char *arg __attribute__ ((unused)))
{

View File

@ -66,11 +66,11 @@ inline void attach(Client *); /* attaches c to global client list */
void ban(Client *); /* bans c */
void configure(Client *); /* send synthetic configure event */
void detach(Client *); /* detaches c from global client list */
void focus(Display *, DC *, Client *, Bool, awesome_config *); /* focus c if visible && !NULL, or focus top visible */
void manage(Display *, DC *, Window, XWindowAttributes *, awesome_config *);
void focus(Display *, Client *, Bool, awesome_config *); /* focus c if visible && !NULL, or focus top visible */
void manage(Display *, Window, XWindowAttributes *, awesome_config *);
void resize(Client *, int, int, int, int, awesome_config *, Bool); /* resize with given coordinates c */
void unban(Client *); /* unbans c */
void unmanage(Client *, DC *, long, awesome_config *); /* unmanage c */
void unmanage(Client *, long, awesome_config *); /* unmanage c */
inline void updatesizehints(Client *); /* update the size hint variables of c */
void updatetitle(Client *); /* update the name of c */
void saveprops(Client * c, int); /* saves client properties */

View File

@ -25,7 +25,7 @@
#include "config.h"
/** Common prototype definition for ui_callbak functions */
#define UICB_PROTO(name) void name(Display *, DC *, awesome_config *, const char *)
#define UICB_PROTO(name) void name(Display *, awesome_config *, const char *)
/** Common prototype definition for layouts function */
#define LAYOUT_PROTO(name) void name(Display *, awesome_config *)

View File

@ -162,7 +162,6 @@ name_func_lookup(const char *funcname, const NameFuncLink * list)
/** Parse configuration file and initialize some stuff
* \param disp Display ref
* \param scr Screen number
* \param drawcontext Draw context
*/
void
parse_config(Display * disp, int scr,const char *confpatharg, awesome_config *awesomeconf)

View File

@ -37,11 +37,6 @@ enum
enum
{ CurNormal, CurResize, CurMove, CurLast }; /* cursor */
typedef struct
{
GC gc;
} DC;
typedef struct
{
char *prop;
@ -61,7 +56,7 @@ typedef struct
{
unsigned long mod;
KeySym keysym;
void (*func) (Display *, DC *, awesome_config *, char *);
void (*func) (Display *, awesome_config *, char *);
char *arg;
} Key;

65
event.c
View File

@ -36,7 +36,6 @@
#include "layouts/floating.h"
/* extern */
extern DC *dc; /* global draw context */
extern Client *clients, *sel; /* global client list */
#define CLEANMASK(mask, screen) (mask & ~(awesomeconf[screen].numlockmask | LockMask))
@ -161,68 +160,68 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
if(ev->button == Button1)
{
if(ev->state & awesomeconf[screen].modkey)
uicb_tag(e->xany.display, &dc[screen], &awesomeconf[screen], awesomeconf[screen].tags[i].name);
uicb_tag(e->xany.display, &awesomeconf[screen], awesomeconf[screen].tags[i].name);
else
uicb_view(e->xany.display, &dc[screen], &awesomeconf[screen], awesomeconf[screen].tags[i].name);
uicb_view(e->xany.display, &awesomeconf[screen], awesomeconf[screen].tags[i].name);
}
else if(ev->button == Button3)
{
if(ev->state & awesomeconf[screen].modkey)
uicb_toggletag(e->xany.display, &dc[screen], &awesomeconf[screen], awesomeconf[screen].tags[i].name);
uicb_toggletag(e->xany.display, &awesomeconf[screen], awesomeconf[screen].tags[i].name);
else
uicb_toggleview(e->xany.display, &dc[screen], &awesomeconf[screen], awesomeconf[screen].tags[i].name);
uicb_toggleview(e->xany.display, &awesomeconf[screen], awesomeconf[screen].tags[i].name);
}
else if(ev->button == Button4)
uicb_tag_viewnext(e->xany.display, &dc[screen], &awesomeconf[screen], NULL);
uicb_tag_viewnext(e->xany.display, &awesomeconf[screen], NULL);
else if(ev->button == Button5)
uicb_tag_viewprev(e->xany.display, &dc[screen], &awesomeconf[screen], NULL);
uicb_tag_viewprev(e->xany.display, &awesomeconf[screen], NULL);
return;
}
}
x += awesomeconf[screen].statusbar.width;
if(ev->x < x && (ev->button == Button1 || ev->button == Button4))
uicb_setlayout(e->xany.display, &dc[screen], &awesomeconf[screen], "+1");
uicb_setlayout(e->xany.display, &awesomeconf[screen], "+1");
else if(ev->x < x && (ev->button == Button3 || ev->button == Button5))
uicb_setlayout(e->xany.display, &dc[screen], &awesomeconf[screen], "-1");
uicb_setlayout(e->xany.display, &awesomeconf[screen], "-1");
else if(ev->button == Button4)
uicb_focusnext(e->xany.display, &dc[screen], &awesomeconf[screen], NULL);
uicb_focusnext(e->xany.display, &awesomeconf[screen], NULL);
else if(ev->button == Button5)
uicb_focusprev(e->xany.display, &dc[screen], &awesomeconf[screen], NULL);
uicb_focusprev(e->xany.display, &awesomeconf[screen], NULL);
return;
}
if((c = getclient(ev->window)))
{
focus(c->display, &dc[c->screen], c, ev->same_screen, &awesomeconf[c->screen]);
focus(c->display, c, ev->same_screen, &awesomeconf[c->screen]);
if(CLEANMASK(ev->state, c->screen) != awesomeconf[c->screen].modkey)
return;
if(ev->button == Button1)
{
if(!IS_ARRANGE(layout_floating) && !c->isfloating)
uicb_togglefloating(e->xany.display, &dc[c->screen], &awesomeconf[c->screen], NULL);
uicb_togglefloating(e->xany.display, &awesomeconf[c->screen], NULL);
else
restack(e->xany.display, &dc[c->screen], &awesomeconf[c->screen]);
restack(e->xany.display, &awesomeconf[c->screen]);
movemouse(c, &awesomeconf[c->screen]);
}
else if(ev->button == Button2)
{
if(!IS_ARRANGE(layout_floating) && !c->isfixed && c->isfloating)
uicb_togglefloating(e->xany.display, &dc[c->screen], &awesomeconf[c->screen], NULL);
uicb_togglefloating(e->xany.display, &awesomeconf[c->screen], NULL);
else
uicb_zoom(e->xany.display, &dc[c->screen], &awesomeconf[c->screen], NULL);
uicb_zoom(e->xany.display, &awesomeconf[c->screen], NULL);
}
else if(ev->button == Button3)
{
if(!IS_ARRANGE(layout_floating) && !c->isfloating)
uicb_togglefloating(e->xany.display, &dc[c->screen], &awesomeconf[c->screen], NULL);
uicb_togglefloating(e->xany.display, &awesomeconf[c->screen], NULL);
else
restack(e->xany.display, &dc[c->screen], &awesomeconf[c->screen]);
restack(e->xany.display, &awesomeconf[c->screen]);
resizemouse(c, &awesomeconf[c->screen]);
}
else if(ev->button == Button4)
uicb_settrans(e->xany.display, &dc[c->screen], &awesomeconf[c->screen], "+5");
uicb_settrans(e->xany.display, &awesomeconf[c->screen], "+5");
else if(ev->button == Button5)
uicb_settrans(e->xany.display, &dc[c->screen], &awesomeconf[c->screen], "-5");
uicb_settrans(e->xany.display, &awesomeconf[c->screen], "-5");
}
else if(!sel)
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
@ -231,9 +230,9 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
{
screen = get_screen_bycoord(e->xany.display, x, y);
if(ev->button == Button4)
uicb_tag_viewnext(e->xany.display, &dc[screen], &awesomeconf[screen], NULL);
uicb_tag_viewnext(e->xany.display, &awesomeconf[screen], NULL);
else if(ev->button == Button5)
uicb_tag_viewprev(e->xany.display, &dc[screen], &awesomeconf[screen], NULL);
uicb_tag_viewprev(e->xany.display, &awesomeconf[screen], NULL);
break;
}
}
@ -311,7 +310,7 @@ handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf)
si[screen].width, awesomeconf[screen].statusbar.height);
XFree(si);
updatebarpos(e->xany.display, awesomeconf[screen].statusbar);
arrange(e->xany.display, &dc[screen], &awesomeconf[screen]);
arrange(e->xany.display, &awesomeconf[screen]);
}
}
@ -322,7 +321,7 @@ handle_event_destroynotify(XEvent * e, awesome_config *awesomeconf)
XDestroyWindowEvent *ev = &e->xdestroywindow;
if((c = getclient(ev->window)))
unmanage(c, &dc[c->screen], WithdrawnState, &awesomeconf[c->screen]);
unmanage(c, WithdrawnState, &awesomeconf[c->screen]);
}
void
@ -335,11 +334,11 @@ handle_event_enternotify(XEvent * e, awesome_config *awesomeconf)
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
return;
if((c = getclient(ev->window)))
focus(c->display, &dc[c->screen], c, ev->same_screen, &awesomeconf[c->screen]);
focus(c->display, c, ev->same_screen, &awesomeconf[c->screen]);
else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if(ev->window == RootWindow(e->xany.display, screen))
focus(e->xany.display, &dc[screen], NULL, True, &awesomeconf[screen]);
focus(e->xany.display, NULL, True, &awesomeconf[screen]);
}
void
@ -351,7 +350,7 @@ handle_event_expose(XEvent * e, awesome_config *awesomeconf)
if(!ev->count)
for(screen = 0; screen < get_screen_count(e->xany.display); screen++)
if(awesomeconf[screen].statusbar.window == ev->window)
drawstatusbar(e->xany.display, &dc[screen], &awesomeconf[screen]);
drawstatusbar(e->xany.display, &awesomeconf[screen]);
}
void
@ -381,7 +380,7 @@ handle_event_keypress(XEvent * e, awesome_config *awesomeconf)
for(i = 0; i < awesomeconf[screen].nkeys; i++)
if(keysym == awesomeconf[screen].keys[i].keysym
&& CLEANMASK(awesomeconf[screen].keys[i].mod, screen) == CLEANMASK(ev->state, screen) && awesomeconf[screen].keys[i].func)
awesomeconf[screen].keys[i].func(e->xany.display, &dc[screen], &awesomeconf[screen], awesomeconf[screen].keys[i].arg);
awesomeconf[screen].keys[i].func(e->xany.display, &awesomeconf[screen], awesomeconf[screen].keys[i].arg);
}
void
@ -392,7 +391,7 @@ handle_event_leavenotify(XEvent * e, awesome_config *awesomeconf)
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if((ev->window == RootWindow(e->xany.display, screen)) && !ev->same_screen)
focus(e->xany.display, &dc[screen], NULL, ev->same_screen, &awesomeconf[screen]);
focus(e->xany.display, NULL, ev->same_screen, &awesomeconf[screen]);
}
void
@ -423,7 +422,7 @@ handle_event_maprequest(XEvent * e, awesome_config *awesomeconf)
for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++);
if(screen == 0)
screen = get_screen_bycoord(e->xany.display, wa.x, wa.y);
manage(e->xany.display, &dc[screen], ev->window, &wa, &awesomeconf[screen]);
manage(e->xany.display, ev->window, &wa, &awesomeconf[screen]);
}
}
@ -443,7 +442,7 @@ handle_event_propertynotify(XEvent * e, awesome_config *awesomeconf)
case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(e->xany.display, c->win, &trans);
if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
arrange(e->xany.display, &dc[c->screen], &awesomeconf[c->screen]);
arrange(e->xany.display, &awesomeconf[c->screen]);
break;
case XA_WM_NORMAL_HINTS:
updatesizehints(c);
@ -453,7 +452,7 @@ handle_event_propertynotify(XEvent * e, awesome_config *awesomeconf)
{
updatetitle(c);
if(c == sel)
drawstatusbar(e->xany.display, &dc[c->screen], &awesomeconf[c->screen]);
drawstatusbar(e->xany.display, &awesomeconf[c->screen]);
}
}
}
@ -466,7 +465,7 @@ handle_event_unmapnotify(XEvent * e, awesome_config *awesomeconf)
if((c = getclient(ev->window))
&& ev->event == RootWindow(e->xany.display, c->phys_screen) && (ev->send_event || !c->unmapped))
unmanage(c, &dc[c->screen], WithdrawnState, &awesomeconf[c->screen]);
unmanage(c, WithdrawnState, &awesomeconf[c->screen]);
}
void

View File

@ -34,11 +34,10 @@ extern Client *clients, *sel; /* global client list */
/** Arrange windows following current selected layout
* \param disp display ref
* \param drawcontext drawcontext ref
* \param awesomeconf awesome config
*/
void
arrange(Display * disp, DC *drawcontext, awesome_config *awesomeconf)
arrange(Display * disp, awesome_config *awesomeconf)
{
Client *c;
@ -51,13 +50,12 @@ arrange(Display * disp, DC *drawcontext, awesome_config *awesomeconf)
ban(c);
}
awesomeconf->current_layout->arrange(disp, awesomeconf);
focus(disp, drawcontext, NULL, True, awesomeconf);
restack(disp, drawcontext, awesomeconf);
focus(disp, NULL, True, awesomeconf);
restack(disp, awesomeconf);
}
void
uicb_focusnext(Display *disp __attribute__ ((unused)),
DC *drawcontext,
awesome_config * awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -70,14 +68,13 @@ uicb_focusnext(Display *disp __attribute__ ((unused)),
for(c = clients; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next);
if(c)
{
focus(c->display, drawcontext, c, True, awesomeconf);
restack(c->display, drawcontext, awesomeconf);
focus(c->display, c, True, awesomeconf);
restack(c->display, awesomeconf);
}
}
void
uicb_focusprev(Display *disp __attribute__ ((unused)),
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -93,8 +90,8 @@ uicb_focusprev(Display *disp __attribute__ ((unused)),
}
if(c)
{
focus(c->display, drawcontext, c, True, awesomeconf);
restack(c->display, drawcontext, awesomeconf);
focus(c->display, c, True, awesomeconf);
restack(c->display, awesomeconf);
}
}
@ -114,13 +111,13 @@ loadawesomeprops(Display *disp, awesome_config * awesomeconf)
}
void
restack(Display * disp, DC * drawcontext, awesome_config *awesomeconf)
restack(Display * disp, awesome_config *awesomeconf)
{
Client *c;
XEvent ev;
XWindowChanges wc;
drawstatusbar(disp, drawcontext, awesomeconf);
drawstatusbar(disp, awesomeconf);
if(!sel)
return;
if(sel->isfloating || IS_ARRANGE(layout_floating))
@ -166,7 +163,6 @@ saveawesomeprops(Display *disp, awesome_config *awesomeconf)
void
uicb_setlayout(Display *disp,
DC *drawcontext,
awesome_config * awesomeconf,
const char *arg)
{
@ -191,9 +187,9 @@ uicb_setlayout(Display *disp,
c->ftview = True;
if(sel)
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
else
drawstatusbar(disp, drawcontext, awesomeconf);
drawstatusbar(disp, awesomeconf);
saveawesomeprops(disp, awesomeconf);
@ -203,7 +199,7 @@ uicb_setlayout(Display *disp,
}
static void
maximize(int x, int y, int w, int h, DC *drawcontext, awesome_config *awesomeconf)
maximize(int x, int y, int w, int h, awesome_config *awesomeconf)
{
if(!sel)
return;
@ -223,12 +219,11 @@ maximize(int x, int y, int w, int h, DC *drawcontext, awesome_config *awesomecon
else
sel->isfloating = False;
arrange(sel->display, drawcontext, awesomeconf);
arrange(sel->display, awesomeconf);
}
void
uicb_togglemax(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -237,13 +232,12 @@ uicb_togglemax(Display *disp,
maximize(si[awesomeconf->screen].x_org, si[awesomeconf->screen].y_org,
si[awesomeconf->screen].width - 2 * awesomeconf->borderpx,
si[awesomeconf->screen].height - 2 * awesomeconf->borderpx,
drawcontext, awesomeconf);
awesomeconf);
XFree(si);
}
void
uicb_toggleverticalmax(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -252,14 +246,13 @@ uicb_toggleverticalmax(Display *disp,
if(sel)
maximize(sel->x, si[awesomeconf->screen].y_org,
sel->w, si[awesomeconf->screen].height - 2 * awesomeconf->borderpx,
drawcontext, awesomeconf);
awesomeconf);
XFree(si);
}
void
uicb_togglehorizontalmax(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -268,13 +261,12 @@ uicb_togglehorizontalmax(Display *disp,
if(sel)
maximize(si[awesomeconf->screen].x_org, sel->y,
si[awesomeconf->screen].height - 2 * awesomeconf->borderpx, sel->h,
drawcontext, awesomeconf);
awesomeconf);
XFree(si);
}
void
uicb_zoom(Display *disp __attribute__ ((unused)),
DC *drawcontext __attribute__ ((unused)),
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -282,7 +274,7 @@ uicb_zoom(Display *disp __attribute__ ((unused)),
return;
detach(sel);
attach(sel);
focus(sel->display, drawcontext, sel, True, awesomeconf);
arrange(sel->display, drawcontext, awesomeconf);
focus(sel->display, sel, True, awesomeconf);
arrange(sel->display, awesomeconf);
}

View File

@ -29,8 +29,8 @@
#define AWESOMEPROPS_ATOM(disp) XInternAtom(disp, "_AWESOME_PROPERTIES", False)
void arrange(Display *, DC *, awesome_config *); /* arranges all windows depending on the layout in use */
void restack(Display *, DC *, awesome_config *); /* restores z layers of all clients */
void arrange(Display *, awesome_config *); /* arranges all windows depending on the layout in use */
void restack(Display *, awesome_config *); /* restores z layers of all clients */
void loadawesomeprops(Display *, awesome_config *);
void saveawesomeprops(Display *, awesome_config *);

View File

@ -33,7 +33,6 @@ extern Client *clients;
void
uicb_setnmaster(Display *disp,
DC * drawcontext,
awesome_config *awesomeconf,
const char * arg)
{
@ -44,12 +43,11 @@ uicb_setnmaster(Display *disp,
if((awesomeconf->nmaster = (int) compute_new_value_from_arg(arg, (double) awesomeconf->nmaster)) < 0)
awesomeconf->nmaster = 0;
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
void
uicb_setncol(Display *disp,
DC * drawcontext,
awesome_config *awesomeconf,
const char * arg)
{
@ -59,12 +57,11 @@ uicb_setncol(Display *disp,
if((awesomeconf->ncol = (int) compute_new_value_from_arg(arg, (double) awesomeconf->ncol)) < 1)
awesomeconf->ncol = 1;
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
void
uicb_setmwfact(Display *disp,
DC *drawcontext,
awesome_config * awesomeconf,
const char *arg)
{
@ -87,7 +84,7 @@ uicb_setmwfact(Display *disp,
else if(awesomeconf->mwfact > 0.9)
awesomeconf->mwfact = 0.9;
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
p_delete(&newarg);
}

View File

@ -191,7 +191,6 @@ move_mouse_pointer_to_screen(Display *disp, int screen)
void
uicb_focusnextscreen(Display *disp,
DC *drawcontext,
awesome_config * awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -201,15 +200,14 @@ uicb_focusnextscreen(Display *disp,
for(c = clients; c && !isvisible(c, next_screen, awesomeconf[next_screen - awesomeconf->screen].tags, awesomeconf[next_screen - awesomeconf->screen].ntags); c = c->next);
if(c)
{
focus(c->display, &drawcontext[next_screen - awesomeconf->screen], c, True, &awesomeconf[next_screen - awesomeconf->screen]);
restack(c->display, &drawcontext[next_screen - awesomeconf->screen], &awesomeconf[next_screen - awesomeconf->screen]);
focus(c->display, c, True, &awesomeconf[next_screen - awesomeconf->screen]);
restack(c->display, &awesomeconf[next_screen - awesomeconf->screen]);
}
move_mouse_pointer_to_screen(disp, next_screen);
}
void
uicb_focusprevscreen(Display *disp,
DC *drawcontext,
awesome_config * awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -219,22 +217,20 @@ uicb_focusprevscreen(Display *disp,
for(c = clients; c && !isvisible(c, prev_screen, awesomeconf[prev_screen - awesomeconf->screen].tags, awesomeconf[prev_screen - awesomeconf->screen].ntags); c = c->next);
if(c)
{
focus(c->display, &drawcontext[prev_screen - awesomeconf->screen], c, True, &awesomeconf[prev_screen - awesomeconf->screen]);
restack(c->display, &drawcontext[prev_screen - awesomeconf->screen], &awesomeconf[prev_screen - awesomeconf->screen]);
focus(c->display, c, True, &awesomeconf[prev_screen - awesomeconf->screen]);
restack(c->display, &awesomeconf[prev_screen - awesomeconf->screen]);
}
move_mouse_pointer_to_screen(disp, prev_screen);
}
/** Move client to a virtual screen (if Xinerama is active)
* \param disp Display ref
* \param drawcontext drawcontext ref
* \param awesomeconf awesome config
* \param arg screen number
* \ingroup ui_callback
*/
void
uicb_movetoscreen(Display *disp,
DC *drawcontext,
awesome_config * awesomeconf,
const char *arg)
{
@ -256,6 +252,6 @@ uicb_movetoscreen(Display *disp,
prev_screen = sel->screen;
move_client_to_screen(sel, &awesomeconf[new_screen - awesomeconf->screen], True);
move_mouse_pointer_to_screen(disp, new_screen);
arrange(disp, drawcontext, &awesomeconf[prev_screen - awesomeconf->screen]);
arrange(disp, &drawcontext[new_screen - awesomeconf->screen], &awesomeconf[new_screen - awesomeconf->screen]);
arrange(disp, &awesomeconf[prev_screen - awesomeconf->screen]);
arrange(disp, &awesomeconf[new_screen - awesomeconf->screen]);
}

View File

@ -48,30 +48,34 @@ isoccupied(unsigned int t, int screen)
}
void
drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
drawstatusbar(Display *disp, awesome_config * awesomeconf)
{
int z, i, x = 0, y = 0, w;
ScreenInfo *si = get_screen_info(disp, awesomeconf->screen, NULL);
GC gc;
gc = XCreateGC(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), 0, 0);
XSetLineAttributes(awesomeconf->display, gc, 1, LineSolid, CapButt, JoinMiter);
for(i = 0; i < awesomeconf->ntags; i++)
{
w = textwidth(disp, awesomeconf->font, awesomeconf->tags[i].name, a_strlen(awesomeconf->tags[i].name)) + awesomeconf->font->height;
if(awesomeconf->tags[i].selected)
{
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->tags[i].name, awesomeconf->colors_selected);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->tags[i].name, awesomeconf->colors_selected);
if(isoccupied(i, awesomeconf->screen))
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], awesomeconf->colors_selected[ColFG]);
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], awesomeconf->colors_selected[ColFG]);
}
else
{
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->tags[i].name, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->tags[i].name, awesomeconf->colors_normal);
if(isoccupied(i, awesomeconf->screen))
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], awesomeconf->colors_normal[ColFG]);
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, gc, awesomeconf->statusbar.drawable, sel && sel->tags[i], awesomeconf->colors_normal[ColFG]);
}
x += w;
}
w = awesomeconf->statusbar.width;
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->current_layout->symbol, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->current_layout->symbol, awesomeconf->colors_normal);
z = x + w;
w = textwidth(disp, awesomeconf->font, awesomeconf->statustext, a_strlen(awesomeconf->statustext)) + awesomeconf->font->height;
x = si[awesomeconf->screen].width - w;
@ -80,26 +84,27 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
x = z;
w = si[awesomeconf->screen].width - z;
}
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->statustext, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, gc, awesomeconf->statusbar.drawable, awesomeconf->font, awesomeconf->statustext, awesomeconf->colors_normal);
if((w = x - z) > awesomeconf->statusbar.height)
{
x = z;
if(sel)
{
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, sel->name, awesomeconf->colors_selected);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, gc, awesomeconf->statusbar.drawable, awesomeconf->font, sel->name, awesomeconf->colors_selected);
if(sel->isfloating)
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, drawcontext->gc, awesomeconf->statusbar.drawable, sel->ismax, awesomeconf->colors_selected[ColFG]);
drawsquare(disp, x, y, (awesomeconf->font->height + 2) / 4, gc, awesomeconf->statusbar.drawable, sel->ismax, awesomeconf->colors_selected[ColFG]);
}
else if(IS_ARRANGE(layout_tile) || IS_ARRANGE(layout_tileleft))
{
char buf[256];
snprintf(buf, sizeof(buf), "nmaster: %d ncol: %d mwfact: %.2lf", awesomeconf->nmaster, awesomeconf->ncol, awesomeconf->mwfact);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, buf, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, gc, awesomeconf->statusbar.drawable, awesomeconf->font, buf, awesomeconf->colors_normal);
}
else
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, drawcontext->gc, awesomeconf->statusbar.drawable, awesomeconf->font, NULL, awesomeconf->colors_normal);
drawtext(disp, awesomeconf->phys_screen, x, y, w, awesomeconf->statusbar.height, gc, awesomeconf->statusbar.drawable, awesomeconf->font, NULL, awesomeconf->colors_normal);
}
XCopyArea(disp, awesomeconf->statusbar.drawable, awesomeconf->statusbar.window, drawcontext->gc, 0, 0, si[awesomeconf->screen].width, awesomeconf->statusbar.height, 0, 0);
XCopyArea(disp, awesomeconf->statusbar.drawable, awesomeconf->statusbar.window, gc, 0, 0, si[awesomeconf->screen].width, awesomeconf->statusbar.height, 0, 0);
XFreeGC(awesomeconf->display, gc);
XSync(disp, False);
}
@ -160,7 +165,6 @@ updatebarpos(Display *disp, Statusbar statusbar)
void
uicb_togglebar(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -169,6 +173,6 @@ uicb_togglebar(Display *disp,
else
awesomeconf->statusbar.position = BarOff;
updatebarpos(disp, awesomeconf->statusbar);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}

View File

@ -25,7 +25,7 @@
#include "common.h"
void initstatusbar(Display *, int, Statusbar *, Cursor);
void drawstatusbar(Display *, DC *, awesome_config *);
void drawstatusbar(Display *, awesome_config *);
void updatebarpos(Display *, Statusbar);
UICB_PROTO(uicb_togglebar);

30
tag.c
View File

@ -154,13 +154,11 @@ isvisible(Client * c, int screen, Tag * tags, int ntags)
/** Tag selected window with tag
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param arg Tag name
* \ingroup ui_callback
*/
void
uicb_tag(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg)
{
@ -174,18 +172,16 @@ uicb_tag(Display *disp,
if(i >= 0 && i < awesomeconf->ntags)
sel->tags[i] = True;
saveprops(sel, awesomeconf->ntags);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
/** Toggle floating state of a client
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param arg unused
* \ingroup ui_callback
*/
void
uicb_togglefloating(Display *disp,
DC *drawcontext,
awesome_config * awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -204,18 +200,16 @@ uicb_togglefloating(Display *disp,
sel->rh = sel->h;
}
saveprops(sel, awesomeconf->ntags);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
/** Toggle tag view
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param arg Tag name
* \ingroup ui_callback
*/
void
uicb_toggletag(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg)
{
@ -230,18 +224,16 @@ uicb_toggletag(Display *disp,
if(j == awesomeconf->ntags)
sel->tags[i] = True;
saveprops(sel, awesomeconf->ntags);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
/** Add a tag to viewed tags
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param arg Tag name
* \ingroup ui_callback
*/
void
uicb_toggleview(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg)
{
@ -254,7 +246,7 @@ uicb_toggleview(Display *disp,
if(j == awesomeconf->ntags)
awesomeconf->tags[i].selected = True;
saveawesomeprops(disp, awesomeconf);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
/** View tag
@ -265,7 +257,6 @@ uicb_toggleview(Display *disp,
*/
void
uicb_view(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg)
{
@ -283,7 +274,7 @@ uicb_view(Display *disp,
awesomeconf->current_layout = awesomeconf->tags[i].layout;
}
saveawesomeprops(disp, awesomeconf);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
/** View previously selected tags
@ -294,7 +285,6 @@ uicb_view(Display *disp,
*/
void
uicb_tag_prev_selected(Display * disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -307,18 +297,16 @@ uicb_tag_prev_selected(Display * disp,
awesomeconf->tags[i].selected = awesomeconf->tags[i].was_selected;
awesomeconf->tags[i].was_selected = t;
}
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
/** View next tag
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param arg unused
* \ingroup ui_callback
*/
void
uicb_tag_viewnext(Display *disp,
DC * drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -336,18 +324,16 @@ uicb_tag_viewnext(Display *disp,
awesomeconf->tags[firsttag].selected = True;
awesomeconf->current_layout = awesomeconf->tags[firsttag].layout;
saveawesomeprops(disp, awesomeconf);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}
/** View previous tag
* \param disp Display ref
* \param drawcontext Drawcontext ref
* \param arg unused
* \ingroup ui_callback
*/
void
uicb_tag_viewprev(Display *disp,
DC *drawcontext,
awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
@ -365,5 +351,5 @@ uicb_tag_viewprev(Display *disp,
awesomeconf->tags[firsttag].selected = True;
awesomeconf->current_layout = awesomeconf->tags[firsttag].layout;
saveawesomeprops(disp, awesomeconf);
arrange(disp, drawcontext, awesomeconf);
arrange(disp, awesomeconf);
}

2
util.c
View File

@ -56,7 +56,6 @@ eprint(const char *fmt, ...)
void
uicb_exec(Display * disp,
DC *drawcontext __attribute__ ((unused)),
awesome_config * awesomeconf __attribute__ ((unused)),
const char *arg)
{
@ -70,7 +69,6 @@ uicb_exec(Display * disp,
void
uicb_spawn(Display * disp,
DC *drawcontext __attribute__ ((unused)),
awesome_config * awesomeconf __attribute__ ((unused)),
const char *arg)
{