Massive, massive interface refactoring.

The big change here is that we now keep our configuration structure in a global
variable called globalconf. This radically simplifies many interfaces, since
passing awesomeconf everywhere is no longer necessary. There are also more
subtle interface effects - now we can reliably identify a screen from just a
screen ID, rather than an awesomeconf, screenid tuple.

Overall, this patch makes most of the interfaces in awesome much nicer to use -
enjoy!

Yes, this is a huge patch, but since a lot of the refactoring was done
systematically using vim macros, splitting this up would have been very hard.
This commit is contained in:
Aldo Cortesi 2007-12-16 12:45:38 +11:00 committed by Julien Danjou
parent ec80635cbc
commit 2f74c079aa
33 changed files with 715 additions and 781 deletions

152
awesome.c
View File

@ -52,6 +52,8 @@
static int (*xerrorxlib) (Display *, XErrorEvent *); static int (*xerrorxlib) (Display *, XErrorEvent *);
static Bool running = True; static Bool running = True;
awesome_config globalconf;
static inline void static inline void
cleanup_buttons(Button *buttons) cleanup_buttons(Button *buttons)
{ {
@ -65,24 +67,24 @@ cleanup_buttons(Button *buttons)
} }
} }
void static void
cleanup_screen(awesome_config *awesomeconf, int screen) cleanup_screen(int screen)
{ {
Layout *l, *ln; Layout *l, *ln;
Tag *t, *tn; Tag *t, *tn;
XftFontClose(awesomeconf->display, awesomeconf->screens[screen].font); XftFontClose(globalconf.display, globalconf.screens[screen].font);
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen))); XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, get_phys_screen(globalconf.display, screen)));
XDestroyWindow(awesomeconf->display, awesomeconf->screens[screen].statusbar.window); XDestroyWindow(globalconf.display, globalconf.screens[screen].statusbar.window);
for(t = awesomeconf->screens[screen].tags; t; t = tn) for(t = globalconf.screens[screen].tags; t; t = tn)
{ {
tn = t->next; tn = t->next;
p_delete(&t->name); p_delete(&t->name);
p_delete(&t); p_delete(&t);
} }
for(l = awesomeconf->screens[screen].layouts; l; l = ln) for(l = globalconf.screens[screen].layouts; l; l = ln)
{ {
ln = l->next; ln = l->next;
p_delete(&l->symbol); p_delete(&l->symbol);
@ -94,23 +96,23 @@ cleanup_screen(awesome_config *awesomeconf, int screen)
* \param awesomeconf awesome config * \param awesomeconf awesome config
*/ */
static void static void
cleanup(awesome_config *awesomeconf) cleanup()
{ {
int screen; int screen;
Rule *r, *rn; Rule *r, *rn;
Key *k, *kn; Key *k, *kn;
while(awesomeconf->clients) while(globalconf.clients)
{ {
client_unban(awesomeconf->clients); client_unban(globalconf.clients);
client_unmanage(awesomeconf->clients, NormalState, awesomeconf); client_unmanage(globalconf.clients, NormalState);
} }
XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurNormal]); XFreeCursor(globalconf.display, globalconf.cursor[CurNormal]);
XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurResize]); XFreeCursor(globalconf.display, globalconf.cursor[CurResize]);
XFreeCursor(awesomeconf->display, awesomeconf->cursor[CurMove]); XFreeCursor(globalconf.display, globalconf.cursor[CurMove]);
for(r = awesomeconf->rules; r; r = rn) for(r = globalconf.rules; r; r = rn)
{ {
rn = r->next; rn = r->next;
p_delete(&r->prop); p_delete(&r->prop);
@ -120,72 +122,70 @@ cleanup(awesome_config *awesomeconf)
p_delete(&r); p_delete(&r);
} }
for(k = awesomeconf->keys; k; k = kn) for(k = globalconf.keys; k; k = kn)
{ {
kn = k->next; kn = k->next;
p_delete(&k->arg); p_delete(&k->arg);
p_delete(&k); p_delete(&k);
} }
cleanup_buttons(awesomeconf->buttons.tag); cleanup_buttons(globalconf.buttons.tag);
cleanup_buttons(awesomeconf->buttons.title); cleanup_buttons(globalconf.buttons.title);
cleanup_buttons(awesomeconf->buttons.layout); cleanup_buttons(globalconf.buttons.layout);
cleanup_buttons(awesomeconf->buttons.root); cleanup_buttons(globalconf.buttons.root);
cleanup_buttons(awesomeconf->buttons.client); cleanup_buttons(globalconf.buttons.client);
p_delete(&awesomeconf->configpath); p_delete(&globalconf.configpath);
for(screen = 0; screen < get_screen_count(awesomeconf->display); screen++) for(screen = 0; screen < get_screen_count(globalconf.display); screen++)
cleanup_screen(awesomeconf, screen); cleanup_screen(screen);
XSetInputFocus(awesomeconf->display, PointerRoot, RevertToPointerRoot, CurrentTime); XSetInputFocus(globalconf.display, PointerRoot, RevertToPointerRoot, CurrentTime);
XSync(awesomeconf->display, False); XSync(globalconf.display, False);
p_delete(&awesomeconf->clients); p_delete(&globalconf.clients);
p_delete(&awesomeconf);
} }
/** Scan X to find windows to manage /** Scan X to find windows to manage
* \param screen Screen number * \param screen Screen number
* \param awesomeconf awesome config
*/ */
static void static void
scan(awesome_config *awesomeconf) scan()
{ {
unsigned int i, num; unsigned int i, num;
int screen, real_screen; int screen, real_screen;
Window *wins = NULL, d1, d2; Window *wins = NULL, d1, d2;
XWindowAttributes wa; XWindowAttributes wa;
for(screen = 0; screen < ScreenCount(awesomeconf->display); screen++) for(screen = 0; screen < ScreenCount(globalconf.display); screen++)
{ {
if(XQueryTree(awesomeconf->display, RootWindow(awesomeconf->display, screen), &d1, &d2, &wins, &num)) if(XQueryTree(globalconf.display, RootWindow(globalconf.display, screen), &d1, &d2, &wins, &num))
{ {
real_screen = screen; real_screen = screen;
for(i = 0; i < num; i++) for(i = 0; i < num; i++)
{ {
if(!XGetWindowAttributes(awesomeconf->display, wins[i], &wa) if(!XGetWindowAttributes(globalconf.display, wins[i], &wa)
|| wa.override_redirect || wa.override_redirect
|| XGetTransientForHint(awesomeconf->display, wins[i], &d1)) || XGetTransientForHint(globalconf.display, wins[i], &d1))
continue; continue;
if(wa.map_state == IsViewable || window_getstate(awesomeconf->display, wins[i]) == IconicState) if(wa.map_state == IsViewable || window_getstate(globalconf.display, wins[i]) == IconicState)
{ {
if(screen == 0) if(screen == 0)
real_screen = get_screen_bycoord(awesomeconf->display, wa.x, wa.y); real_screen = get_screen_bycoord(globalconf.display, wa.x, wa.y);
client_manage(wins[i], &wa, awesomeconf, real_screen); client_manage(wins[i], &wa, real_screen);
} }
} }
/* now the transients */ /* now the transients */
for(i = 0; i < num; i++) for(i = 0; i < num; i++)
{ {
if(!XGetWindowAttributes(awesomeconf->display, wins[i], &wa)) if(!XGetWindowAttributes(globalconf.display, wins[i], &wa))
continue; continue;
if(XGetTransientForHint(awesomeconf->display, wins[i], &d1) if(XGetTransientForHint(globalconf.display, wins[i], &d1)
&& (wa.map_state == IsViewable || window_getstate(awesomeconf->display, wins[i]) == IconicState)) && (wa.map_state == IsViewable || window_getstate(globalconf.display, wins[i]) == IconicState))
{ {
if(screen == 0) if(screen == 0)
real_screen = get_screen_bycoord(awesomeconf->display, wa.x, wa.y); real_screen = get_screen_bycoord(globalconf.display, wa.x, wa.y);
client_manage(wins[i], &wa, awesomeconf, real_screen); client_manage(wins[i], &wa, real_screen);
} }
} }
} }
@ -195,40 +195,40 @@ scan(awesome_config *awesomeconf)
} }
/** Setup everything before running /** Setup everything before running
* \param awesomeconf awesome config ref * \param screen Screen number
* \todo clean things... * \todo clean things...
*/ */
static void static void
setup(awesome_config *awesomeconf, int screen) setup(int screen)
{ {
XSetWindowAttributes wa; XSetWindowAttributes wa;
/* init cursors */ /* init cursors */
awesomeconf->cursor[CurNormal] = XCreateFontCursor(awesomeconf->display, XC_left_ptr); globalconf.cursor[CurNormal] = XCreateFontCursor(globalconf.display, XC_left_ptr);
awesomeconf->cursor[CurResize] = XCreateFontCursor(awesomeconf->display, XC_sizing); globalconf.cursor[CurResize] = XCreateFontCursor(globalconf.display, XC_sizing);
awesomeconf->cursor[CurMove] = XCreateFontCursor(awesomeconf->display, XC_fleur); globalconf.cursor[CurMove] = XCreateFontCursor(globalconf.display, XC_fleur);
/* select for events */ /* select for events */
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask; | EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
wa.cursor = awesomeconf->cursor[CurNormal]; wa.cursor = globalconf.cursor[CurNormal];
XChangeWindowAttributes(awesomeconf->display, XChangeWindowAttributes(globalconf.display,
RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)), RootWindow(globalconf.display, get_phys_screen(globalconf.display, screen)),
CWEventMask | CWCursor, &wa); CWEventMask | CWCursor, &wa);
XSelectInput(awesomeconf->display, RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)), wa.event_mask); XSelectInput(globalconf.display, RootWindow(globalconf.display, get_phys_screen(globalconf.display, screen)), wa.event_mask);
grabkeys(awesomeconf, screen); grabkeys(screen);
} }
void static void
setup_screen(awesome_config *awesomeconf, int screen) setup_screen(int screen)
{ {
setup(awesomeconf, screen); setup(screen);
statusbar_init(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, statusbar_init(globalconf.display, screen, &globalconf.screens[screen].statusbar,
awesomeconf->cursor[CurNormal], awesomeconf->screens[screen].font, globalconf.cursor[CurNormal], globalconf.screens[screen].font,
&awesomeconf->screens[screen].padding); &globalconf.screens[screen].padding);
} }
/** Startup Error handler to check if another window manager /** Startup Error handler to check if another window manager
@ -243,14 +243,11 @@ xerrorstart(Display * disp __attribute__ ((unused)), XErrorEvent * ee __attribut
} }
/** Quit awesome /** Quit awesome
* \param awesomeconf awesome config
* \param arg nothing * \param arg nothing
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_quit(awesome_config *awesomeconf __attribute__((unused)), uicb_quit(int screen __attribute__ ((unused)), const char *arg __attribute__ ((unused)))
int screen __attribute__ ((unused)),
const char *arg __attribute__ ((unused)))
{ {
running = False; running = False;
} }
@ -282,7 +279,7 @@ xerror(Display * edpy, XErrorEvent * ee)
* \param argv who knows * \param argv who knows
* \return EXIT_SUCCESS I hope * \return EXIT_SUCCESS I hope
*/ */
typedef void event_handler (XEvent *, awesome_config *); typedef void event_handler (XEvent *);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@ -292,7 +289,6 @@ main(int argc, char *argv[])
fd_set rd; fd_set rd;
XEvent ev; XEvent ev;
Display * dpy; Display * dpy;
awesome_config *awesomeconf;
int shape_event, randr_event_base; int shape_event, randr_event_base;
int screen; int screen;
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
@ -337,19 +333,17 @@ main(int argc, char *argv[])
xerrorxlib = XSetErrorHandler(xerror); xerrorxlib = XSetErrorHandler(xerror);
XSync(dpy, False); XSync(dpy, False);
/* allocate stuff */ globalconf.screens = p_new(VirtScreen, get_screen_count(dpy));
awesomeconf = p_new(awesome_config, 1); focus_add_client(&globalconf.focus, NULL);
awesomeconf->screens = p_new(VirtScreen, get_screen_count(dpy));
focus_add_client(&awesomeconf->focus, NULL);
/* store display */ /* store display */
awesomeconf->display = dpy; globalconf.display = dpy;
parse_config(confpath, awesomeconf); parse_config(confpath);
for(screen = 0; screen < get_screen_count(dpy); screen++) for(screen = 0; screen < get_screen_count(dpy); screen++)
{ {
/* set screen */ /* set screen */
setup_screen(awesomeconf, screen); setup_screen(screen);
statusbar_draw(awesomeconf, screen); statusbar_draw(screen);
} }
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
@ -358,7 +352,7 @@ main(int argc, char *argv[])
/* do this only for real screen */ /* do this only for real screen */
for(screen = 0; screen < ScreenCount(dpy); screen++) for(screen = 0; screen < ScreenCount(dpy); screen++)
{ {
loadawesomeprops(awesomeconf, screen); loadawesomeprops(screen);
XChangeProperty(dpy, RootWindow(dpy, screen), netatom[NetSupported], XChangeProperty(dpy, RootWindow(dpy, screen), netatom[NetSupported],
XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast); XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast);
} }
@ -378,20 +372,20 @@ main(int argc, char *argv[])
handler[UnmapNotify] = handle_event_unmapnotify; handler[UnmapNotify] = handle_event_unmapnotify;
/* check for shape extension */ /* check for shape extension */
if((awesomeconf->have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy))) if((globalconf.have_shape = XShapeQueryExtension(dpy, &shape_event, &e_dummy)))
{ {
p_realloc(&handler, shape_event + 1); p_realloc(&handler, shape_event + 1);
handler[shape_event] = handle_event_shape; handler[shape_event] = handle_event_shape;
} }
/* check for randr extension */ /* check for randr extension */
if((awesomeconf->have_randr = XRRQueryExtension(dpy, &randr_event_base, &e_dummy))) if((globalconf.have_randr = XRRQueryExtension(dpy, &randr_event_base, &e_dummy)))
{ {
p_realloc(&handler, randr_event_base + RRScreenChangeNotify + 1); p_realloc(&handler, randr_event_base + RRScreenChangeNotify + 1);
handler[randr_event_base + RRScreenChangeNotify] = handle_event_randr_screen_change_notify; handler[randr_event_base + RRScreenChangeNotify] = handle_event_randr_screen_change_notify;
} }
scan(awesomeconf); scan();
XSync(dpy, False); XSync(dpy, False);
@ -438,14 +432,14 @@ main(int argc, char *argv[])
if(r >= ssizeof(buf)) if(r >= ssizeof(buf))
break; break;
buf[r] = '\0'; buf[r] = '\0';
parse_control(buf, awesomeconf); parse_control(buf);
} }
while(XPending(dpy)) while(XPending(dpy))
{ {
XNextEvent(dpy, &ev); XNextEvent(dpy, &ev);
if(handler[ev.type]) if(handler[ev.type])
handler[ev.type](&ev, awesomeconf); /* call handler */ handler[ev.type](&ev); /* call handler */
} }
} }
@ -455,7 +449,7 @@ main(int argc, char *argv[])
perror("error unlinking UNIX domain socket"); perror("error unlinking UNIX domain socket");
p_delete(&addr); p_delete(&addr);
cleanup(awesomeconf); cleanup();
XCloseDisplay(dpy); XCloseDisplay(dpy);
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -24,8 +24,6 @@
#include "common.h" #include "common.h"
void cleanup_screen(awesome_config *, int);
void setup_screen(awesome_config *, int);
int xerror(Display *, XErrorEvent *); int xerror(Display *, XErrorEvent *);
UICB_PROTO(uicb_quit); UICB_PROTO(uicb_quit);

237
client.c
View File

@ -35,6 +35,9 @@
#include "focus.h" #include "focus.h"
#include "layouts/floating.h" #include "layouts/floating.h"
extern awesome_config globalconf;
/** Load windows properties, restoring client's tag /** Load windows properties, restoring client's tag
* and floating state before awesome was restarted if any * and floating state before awesome was restarted if any
* \todo this may bug if number of tags is != than before * \todo this may bug if number of tags is != than before
@ -42,28 +45,28 @@
* \param ntags tags number * \param ntags tags number
*/ */
static Bool static Bool
client_loadprops(Client * c, VirtScreen *scr) client_loadprops(Client * c, int screen)
{ {
int i, ntags = 0; int i, ntags = 0;
Tag *tag; Tag *tag;
char *prop; char *prop;
Bool result = False; Bool result = False;
for(tag = scr->tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
ntags++; ntags++;
prop = p_new(char, ntags + 2); prop = p_new(char, ntags + 2);
if(xgettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, ntags + 2)) if(xgettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, ntags + 2))
{ {
for(i = 0, tag = scr->tags; tag && i < ntags && prop[i]; i++, tag = tag->next) for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
if(prop[i] == '1') if(prop[i] == '1')
{ {
tag_client(&scr->tclink, c, tag); tag_client(c, tag, screen);
result = True; result = True;
} }
else else
untag_client(&scr->tclink, c, tag); untag_client(c, tag, screen);
if(i <= ntags && prop[i]) if(i <= ntags && prop[i])
c->isfloating = prop[i] == '1'; c->isfloating = prop[i] == '1';
@ -160,16 +163,15 @@ client_ban(Client * c)
} }
/** Attach client to the beginning of the clients stack /** Attach client to the beginning of the clients stack
* \param head client list
* \param c the client * \param c the client
*/ */
void void
client_attach(Client **head, Client *c) client_attach(Client *c)
{ {
if(*head) if(globalconf.clients)
(*head)->prev = c; (globalconf.clients)->prev = c;
c->next = *head; c->next = globalconf.clients;
*head = c; globalconf.clients = c;
} }
/** Detach client from clients list /** Detach client from clients list
@ -177,80 +179,76 @@ client_attach(Client **head, Client *c)
* \param c client to detach * \param c client to detach
*/ */
void void
client_detach(Client **head, Client *c) client_detach(Client *c)
{ {
if(c->prev) if(c->prev)
c->prev->next = c->next; c->prev->next = c->next;
if(c->next) if(c->next)
c->next->prev = c->prev; c->next->prev = c->prev;
if(c == *head) if(c == globalconf.clients)
*head = c->next; globalconf.clients = c->next;
c->next = c->prev = NULL; c->next = c->prev = NULL;
} }
/** Give focus to client, or to first client if c is NULL /** Give focus to client, or to first client if c is NULL
* \param c client * \param c client
* \param selscreen True if current screen is selected * \param selscreen True if current screen is selected
* \param awesomeconf awesome config
*/ */
void void
focus(Client *c, Bool selscreen, awesome_config *awesomeconf, int screen) focus(Client *c, Bool selscreen, int screen)
{ {
/* unfocus current selected client */ /* unfocus current selected client */
if(awesomeconf->focus->client) if(globalconf.focus->client)
{ {
window_grabbuttons(awesomeconf->focus->client->display, awesomeconf->focus->client->phys_screen, window_grabbuttons(globalconf.focus->client->display, globalconf.focus->client->phys_screen,
awesomeconf->focus->client->win, False, True, awesomeconf->buttons.root, globalconf.focus->client->win, False, True);
awesomeconf->buttons.client, awesomeconf->numlockmask); XSetWindowBorder(globalconf.focus->client->display, globalconf.focus->client->win,
XSetWindowBorder(awesomeconf->focus->client->display, awesomeconf->focus->client->win, globalconf.screens[screen].colors_normal[ColBorder].pixel);
awesomeconf->screens[screen].colors_normal[ColBorder].pixel); window_settrans(globalconf.focus->client->display, globalconf.focus->client->win,
window_settrans(awesomeconf->focus->client->display, awesomeconf->focus->client->win, globalconf.screens[screen].opacity_unfocused);
awesomeconf->screens[screen].opacity_unfocused);
} }
/* if c is NULL or invisible, take next client in the stack */ /* if c is NULL or invisible, take next client in the stack */
if((!c && selscreen) || (c && !client_isvisible(c, &awesomeconf->screens[screen], screen))) if((!c && selscreen) || (c && !client_isvisible(c, screen)))
for(c = awesomeconf->clients; c && !client_isvisible(c, &awesomeconf->screens[screen], screen); c = c->next); for(c = globalconf.clients; c && !client_isvisible(c, screen); c = c->next);
if(c) if(c)
{ {
XSetWindowBorder(awesomeconf->display, c->win, awesomeconf->screens[screen].colors_selected[ColBorder].pixel); XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel);
window_grabbuttons(c->display, c->phys_screen, c->win, window_grabbuttons(c->display, c->phys_screen, c->win,
True, True, awesomeconf->buttons.root, True, True);
awesomeconf->buttons.client, awesomeconf->numlockmask);
} }
if(!selscreen) if(!selscreen)
return; return;
/* save old sel in focus history */ /* save old sel in focus history */
focus_add_client(&awesomeconf->focus, c); focus_add_client(&globalconf.focus, c);
statusbar_draw(awesomeconf, screen); statusbar_draw(screen);
if(awesomeconf->focus->client) if(globalconf.focus->client)
{ {
XSetInputFocus(awesomeconf->focus->client->display, XSetInputFocus(globalconf.focus->client->display,
awesomeconf->focus->client->win, RevertToPointerRoot, CurrentTime); globalconf.focus->client->win, RevertToPointerRoot, CurrentTime);
for(c = awesomeconf->clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(c != awesomeconf->focus->client) if(c != globalconf.focus->client)
window_settrans(awesomeconf->display, awesomeconf->focus->client->win, window_settrans(globalconf.display, globalconf.focus->client->win,
awesomeconf->screens[screen].opacity_unfocused); globalconf.screens[screen].opacity_unfocused);
window_settrans(awesomeconf->display, awesomeconf->focus->client->win, -1); window_settrans(globalconf.display, globalconf.focus->client->win, -1);
} }
else else
XSetInputFocus(awesomeconf->display, XSetInputFocus(globalconf.display,
RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)), RootWindow(globalconf.display, get_phys_screen(globalconf.display, screen)),
RevertToPointerRoot, CurrentTime); RevertToPointerRoot, CurrentTime);
} }
/** Manage a new client /** Manage a new client
* \param w The window * \param w The window
* \param wa Window attributes * \param wa Window attributes
* \param awesomeconf awesome config
*/ */
void void
client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf, int screen) client_manage(Window w, XWindowAttributes *wa, int screen)
{ {
Client *c, *t = NULL; Client *c, *t = NULL;
Window trans; Window trans;
@ -268,20 +266,20 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf, int
c->h = c->rh = wa->height; c->h = c->rh = wa->height;
c->oldborder = wa->border_width; c->oldborder = wa->border_width;
c->display = awesomeconf->display; c->display = globalconf.display;
c->screen = get_screen_bycoord(c->display, c->x, c->y); c->screen = get_screen_bycoord(c->display, c->x, c->y);
c->phys_screen = get_phys_screen(awesomeconf->display, c->screen); c->phys_screen = get_phys_screen(globalconf.display, c->screen);
move_client_to_screen(c, awesomeconf, screen, True); move_client_to_screen(c, screen, True);
/* update window title */ /* update window title */
client_updatetitle(c); client_updatetitle(c);
/* loadprops or apply rules if no props */ /* loadprops or apply rules if no props */
if(!client_loadprops(c, &awesomeconf->screens[screen])) if(!client_loadprops(c, screen))
tag_client_with_rules(c, awesomeconf); tag_client_with_rules(c);
screen_info = get_screen_info(awesomeconf->display, screen, NULL, NULL); screen_info = get_screen_info(globalconf.display, screen, NULL, NULL);
/* if window request fullscreen mode */ /* if window request fullscreen mode */
if(c->w == screen_info[screen].width && c->h == screen_info[screen].height) if(c->w == screen_info[screen].width && c->h == screen_info[screen].height)
@ -293,7 +291,7 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf, int
} }
else else
{ {
ScreenInfo *display_info = get_display_info(c->display, c->phys_screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); ScreenInfo *display_info = get_display_info(c->display, c->phys_screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
if(c->x + c->w + 2 * c->border > display_info->x_org + display_info->width) if(c->x + c->w + 2 * c->border > display_info->x_org + display_info->width)
c->x = c->rx = display_info->x_org + display_info->width - c->w - 2 * c->border; c->x = c->rx = display_info->x_org + display_info->width - c->w - 2 * c->border;
@ -304,7 +302,7 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf, int
if(c->y < display_info->y_org) if(c->y < display_info->y_org)
c->y = c->ry = display_info->y_org; c->y = c->ry = display_info->y_org;
c->border = awesomeconf->screens[screen].borderpx; c->border = globalconf.screens[screen].borderpx;
p_delete(&display_info); p_delete(&display_info);
} }
@ -313,7 +311,7 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf, int
/* set borders */ /* set borders */
wc.border_width = c->border; wc.border_width = c->border;
XConfigureWindow(c->display, w, CWBorderWidth, &wc); XConfigureWindow(c->display, w, CWBorderWidth, &wc);
XSetWindowBorder(c->display, w, awesomeconf->screens[screen].colors_normal[ColBorder].pixel); XSetWindowBorder(c->display, w, globalconf.screens[screen].colors_normal[ColBorder].pixel);
/* propagates border_width, if size doesn't change */ /* propagates border_width, if size doesn't change */
window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border); window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border);
@ -324,45 +322,43 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf, int
XSelectInput(c->display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XSelectInput(c->display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
/* handle xshape */ /* handle xshape */
if(awesomeconf->have_shape) if(globalconf.have_shape)
{ {
XShapeSelectInput(c->display, w, ShapeNotifyMask); XShapeSelectInput(c->display, w, ShapeNotifyMask);
window_setshape(c->display, c->phys_screen, c->win); window_setshape(c->display, c->phys_screen, c->win);
} }
/* grab buttons */ /* grab buttons */
window_grabbuttons(c->display, c->phys_screen, c->win, window_grabbuttons(c->display, c->phys_screen, c->win, False, True);
False, True, awesomeconf->buttons.root,
awesomeconf->buttons.client, awesomeconf->numlockmask);
/* check for transient and set tags like its parent */ /* check for transient and set tags like its parent */
if((rettrans = XGetTransientForHint(c->display, w, &trans) == Success) if((rettrans = XGetTransientForHint(c->display, w, &trans) == Success)
&& (t = get_client_bywin(awesomeconf->clients, trans))) && (t = get_client_bywin(globalconf.clients, trans)))
for(tag = awesomeconf->screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
if(is_client_tagged(awesomeconf->screens[c->screen].tclink, t, tag)) if(is_client_tagged(t, tag, c->screen))
tag_client(&awesomeconf->screens[c->screen].tclink, c, tag); tag_client(c, tag, c->screen);
/* should be floating if transsient or fixed) */ /* should be floating if transsient or fixed) */
if(!c->isfloating) if(!c->isfloating)
c->isfloating = (rettrans == Success) || c->isfixed; c->isfloating = (rettrans == Success) || c->isfixed;
/* save new props */ /* save new props */
client_saveprops(c, &awesomeconf->screens[c->screen]); client_saveprops(c, c->screen);
/* attach to the stack */ /* attach to the stack */
client_attach(&awesomeconf->clients, c); client_attach(c);
/* some windows require this */ /* some windows require this */
XMoveResizeWindow(c->display, c->win, c->x, c->y, c->w, c->h); XMoveResizeWindow(c->display, c->win, c->x, c->y, c->w, c->h);
focus(c, True, awesomeconf, screen); focus(c, True, screen);
/* rearrange to display new window */ /* rearrange to display new window */
arrange(awesomeconf, screen); arrange(screen);
} }
void void
client_resize(Client *c, int x, int y, int w, int h, awesome_config *awesomeconf, client_resize(Client *c, int x, int y, int w, int h,
Bool sizehints, Bool volatile_coords) Bool sizehints, Bool volatile_coords)
{ {
double dx, dy, max, min, ratio; double dx, dy, max, min, ratio;
@ -412,7 +408,7 @@ client_resize(Client *c, int x, int y, int w, int h, awesome_config *awesomeconf
if(w <= 0 || h <= 0) if(w <= 0 || h <= 0)
return; return;
/* offscreen appearance fixes */ /* offscreen appearance fixes */
si = get_display_info(c->display, c->phys_screen, NULL, &awesomeconf->screens[c->screen].padding); si = get_display_info(c->display, c->phys_screen, NULL, &globalconf.screens[c->screen].padding);
if(x > si->width) if(x > si->width)
x = si->width - w - 2 * c->border; x = si->width - w - 2 * c->border;
if(y > si->height) if(y > si->height)
@ -430,7 +426,7 @@ client_resize(Client *c, int x, int y, int w, int h, awesome_config *awesomeconf
c->h = wc.height = h; c->h = wc.height = h;
if(!volatile_coords if(!volatile_coords
&& (c->isfloating && (c->isfloating
|| get_current_layout(awesomeconf->screens[c->screen])->arrange == layout_floating)) || get_current_layout(c->screen)->arrange == layout_floating))
{ {
c->rx = c->x; c->rx = c->x;
c->ry = c->y; c->ry = c->y;
@ -445,25 +441,25 @@ client_resize(Client *c, int x, int y, int w, int h, awesome_config *awesomeconf
{ {
int new_screen = get_screen_bycoord(c->display, c->x, c->y); int new_screen = get_screen_bycoord(c->display, c->x, c->y);
if(c->screen != new_screen) if(c->screen != new_screen)
move_client_to_screen(c, awesomeconf, new_screen, False); move_client_to_screen(c, new_screen, False);
} }
} }
} }
void void
client_saveprops(Client * c, VirtScreen *scr) client_saveprops(Client * c, int screen)
{ {
int i = 0, ntags = 0; int i = 0, ntags = 0;
char *prop; char *prop;
Tag *tag; Tag *tag;
for(tag = scr->tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
ntags++; ntags++;
prop = p_new(char, ntags + 2); prop = p_new(char, ntags + 2);
for(tag = scr->tags; tag; tag = tag->next, i++) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next, i++)
prop[i] = is_client_tagged(scr->tclink, c, tag) ? '1' : '0'; prop[i] = is_client_tagged(c, tag, screen) ? '1' : '0';
if(i <= ntags) if(i <= ntags)
prop[i] = c->isfloating ? '1' : '0'; prop[i] = c->isfloating ? '1' : '0';
@ -484,7 +480,7 @@ client_unban(Client *c)
} }
void void
client_unmanage(Client *c, long state, awesome_config *awesomeconf) client_unmanage(Client *c, long state)
{ {
XWindowChanges wc; XWindowChanges wc;
Tag *tag; Tag *tag;
@ -493,19 +489,19 @@ client_unmanage(Client *c, long state, awesome_config *awesomeconf)
/* The server grab construct avoids race conditions. */ /* The server grab construct avoids race conditions. */
XGrabServer(c->display); XGrabServer(c->display);
XConfigureWindow(c->display, c->win, CWBorderWidth, &wc); /* restore border */ XConfigureWindow(c->display, c->win, CWBorderWidth, &wc); /* restore border */
client_detach(&awesomeconf->clients, c); client_detach(c);
if(awesomeconf->focus->client == c) if(globalconf.focus->client == c)
focus(NULL, True, awesomeconf, c->screen); focus(NULL, True, c->screen);
focus_delete_client(&awesomeconf->focus, c); focus_delete_client(&globalconf.focus, c);
for(tag = awesomeconf->screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
untag_client(&awesomeconf->screens[c->screen].tclink, c, tag); untag_client(c, tag, c->screen);
XUngrabButton(c->display, AnyButton, AnyModifier, c->win); XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
window_setstate(c->display, c->win, state); window_setstate(c->display, c->win, state);
XSync(c->display, False); XSync(c->display, False);
XSetErrorHandler(xerror); XSetErrorHandler(xerror);
XUngrabServer(c->display); XUngrabServer(c->display);
if(state != NormalState) if(state != NormalState)
arrange(awesomeconf, c->screen); arrange(c->screen);
p_delete(&c); p_delete(&c);
} }
@ -578,28 +574,25 @@ client_updatesizehints(Client *c)
* \return True or False * \return True or False
*/ */
Bool Bool
client_isvisible(Client *c, VirtScreen *scr, int screen) client_isvisible(Client *c, int screen)
{ {
Tag *tag; Tag *tag;
if(c->screen != screen) if(c->screen != screen)
return False; return False;
for(tag = scr->tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
if(tag->selected && is_client_tagged(scr->tclink, c, tag)) if(tag->selected && is_client_tagged(c, tag, screen))
return True; return True;
return False; return False;
} }
/** Set selected client transparency /** Set selected client transparency
* \param awesomeconf awesome config
* \param arg unused arg * \param arg unused arg
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_settrans(awesome_config *awesomeconf, uicb_client_settrans(int screen __attribute__ ((unused)), const char *arg)
int screen __attribute__ ((unused)),
const char *arg)
{ {
double delta = 100.0, current_opacity = 100.0; double delta = 100.0, current_opacity = 100.0;
unsigned char *data; unsigned char *data;
@ -608,12 +601,12 @@ uicb_client_settrans(awesome_config *awesomeconf,
unsigned long n, left; unsigned long n, left;
unsigned int current_opacity_raw = 0; unsigned int current_opacity_raw = 0;
int set_prop = 0; int set_prop = 0;
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
XGetWindowProperty(awesomeconf->display, sel->win, XGetWindowProperty(globalconf.display, sel->win,
XInternAtom(sel->display, "_NET_WM_WINDOW_OPACITY", False), XInternAtom(sel->display, "_NET_WM_WINDOW_OPACITY", False),
0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
(unsigned char **) &data); (unsigned char **) &data);
@ -644,75 +637,66 @@ uicb_client_settrans(awesome_config *awesomeconf,
/** Set border size /** Set border size
* \param awesomeconf awesome config
* \param arg X, +X or -X * \param arg X, +X or -X
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_setborder(awesome_config *awesomeconf, uicb_setborder(int screen, const char *arg)
int screen,
const char *arg)
{ {
if(!arg) if(!arg)
return; return;
if((awesomeconf->screens[screen].borderpx = (int) compute_new_value_from_arg(arg, (double) awesomeconf->screens[screen].borderpx)) < 0) if((globalconf.screens[screen].borderpx = (int) compute_new_value_from_arg(arg, (double) globalconf.screens[screen].borderpx)) < 0)
awesomeconf->screens[screen].borderpx = 0; globalconf.screens[screen].borderpx = 0;
} }
void void
uicb_client_swapnext(awesome_config *awesomeconf, uicb_client_swapnext(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Client *next, *sel = awesomeconf->focus->client; Client *next, *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
for(next = sel->next; next && !client_isvisible(next, &awesomeconf->screens[screen], screen); next = next->next); for(next = sel->next; next && !client_isvisible(next, screen); next = next->next);
if(next) if(next)
{ {
client_swap(&awesomeconf->clients, sel, next); client_swap(&globalconf.clients, sel, next);
arrange(awesomeconf, screen); arrange(screen);
/* restore focus */ /* restore focus */
focus(sel, True, awesomeconf, screen); focus(sel, True, screen);
} }
} }
void void
uicb_client_swapprev(awesome_config *awesomeconf, uicb_client_swapprev(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Client *prev, *sel = awesomeconf->focus->client; Client *prev, *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
for(prev = sel->prev; prev && !client_isvisible(prev, &awesomeconf->screens[screen], screen); prev = prev->prev); for(prev = sel->prev; prev && !client_isvisible(prev, screen); prev = prev->prev);
if(prev) if(prev)
{ {
client_swap(&awesomeconf->clients, prev, sel); client_swap(&globalconf.clients, prev, sel);
arrange(awesomeconf, screen); arrange(screen);
/* restore focus */ /* restore focus */
focus(sel, True, awesomeconf, screen); focus(sel, True, screen);
} }
} }
void void
uicb_client_moveresize(awesome_config *awesomeconf, uicb_client_moveresize(int screen, const char *arg)
int screen,
const char *arg)
{ {
int nx, ny, nw, nh, ox, oy, ow, oh; int nx, ny, nw, nh, ox, oy, ow, oh;
char x[8], y[8], w[8], h[8]; char x[8], y[8], w[8], h[8];
int mx, my, dx, dy, nmx, nmy; int mx, my, dx, dy, nmx, nmy;
unsigned int dui; unsigned int dui;
Window dummy; Window dummy;
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
if(get_current_layout(awesomeconf->screens[screen])->arrange != layout_floating) if(get_current_layout(screen)->arrange != layout_floating)
if(!sel || !sel->isfloating || sel->isfixed || !arg) if(!sel || !sel->isfloating || sel->isfixed || !arg)
return; return;
if(sscanf(arg, "%s %s %s %s", x, y, w, h) != 4) if(sscanf(arg, "%s %s %s %s", x, y, w, h) != 4)
@ -727,28 +711,25 @@ uicb_client_moveresize(awesome_config *awesomeconf,
ow = sel->w; ow = sel->w;
oh = sel->h; oh = sel->h;
Bool xqp = XQueryPointer(awesomeconf->display, RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)), &dummy, &dummy, &mx, &my, &dx, &dy, &dui); Bool xqp = XQueryPointer(globalconf.display, RootWindow(globalconf.display, get_phys_screen(globalconf.display, screen)), &dummy, &dummy, &mx, &my, &dx, &dy, &dui);
client_resize(sel, nx, ny, nw, nh, awesomeconf, True, False); client_resize(sel, nx, ny, nw, nh, True, False);
if (xqp && ox <= mx && (ox + ow) >= mx && oy <= my && (oy + oh) >= my) if (xqp && ox <= mx && (ox + ow) >= mx && oy <= my && (oy + oh) >= my)
{ {
nmx = mx - ox + sel->w - ow - 1 < 0 ? 0 : mx - ox + sel->w - ow - 1; nmx = mx - ox + sel->w - ow - 1 < 0 ? 0 : mx - ox + sel->w - ow - 1;
nmy = my - oy + sel->h - oh - 1 < 0 ? 0 : my - oy + sel->h - oh - 1; nmy = my - oy + sel->h - oh - 1 < 0 ? 0 : my - oy + sel->h - oh - 1;
XWarpPointer(awesomeconf->display, None, sel->win, 0, 0, 0, 0, nmx, nmy); XWarpPointer(globalconf.display, None, sel->win, 0, 0, 0, 0, nmx, nmy);
} }
} }
/** Kill selected client /** Kill selected client
* \param awesomeconf awesome config
* \param arg unused * \param arg unused
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_kill(awesome_config *awesomeconf, uicb_client_kill(int screen __attribute__ ((unused)), const char *arg __attribute__ ((unused)))
int screen __attribute__ ((unused)),
const char *arg __attribute__ ((unused)))
{ {
XEvent ev; XEvent ev;
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
@ -756,13 +737,13 @@ uicb_client_kill(awesome_config *awesomeconf,
{ {
ev.type = ClientMessage; ev.type = ClientMessage;
ev.xclient.window = sel->win; ev.xclient.window = sel->win;
ev.xclient.message_type = XInternAtom(awesomeconf->display, "WM_PROTOCOLS", False); ev.xclient.message_type = XInternAtom(globalconf.display, "WM_PROTOCOLS", False);
ev.xclient.format = 32; ev.xclient.format = 32;
ev.xclient.data.l[0] = XInternAtom(awesomeconf->display, "WM_DELETE_WINDOW", False); ev.xclient.data.l[0] = XInternAtom(globalconf.display, "WM_DELETE_WINDOW", False);
ev.xclient.data.l[1] = CurrentTime; ev.xclient.data.l[1] = CurrentTime;
XSendEvent(awesomeconf->display, sel->win, False, NoEventMask, &ev); XSendEvent(globalconf.display, sel->win, False, NoEventMask, &ev);
} }
else else
XKillClient(awesomeconf->display, sel->win); XKillClient(globalconf.display, sel->win);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -24,19 +24,19 @@
#include "common.h" #include "common.h"
Bool client_isvisible(Client *, VirtScreen *, int); Bool client_isvisible(Client *, int);
Client * get_client_bywin(Client *, Window); Client * get_client_bywin(Client *, Window);
void client_attach(Client **, Client *); void client_attach(Client *);
void client_detach(Client **, Client *); void client_detach(Client *);
void client_ban(Client *); void client_ban(Client *);
void focus(Client *, Bool, awesome_config *, int); void focus(Client *, Bool, int);
void client_manage(Window, XWindowAttributes *, awesome_config *, int); void client_manage(Window, XWindowAttributes *, int);
void client_resize(Client *, int, int, int, int, awesome_config *, Bool, Bool); void client_resize(Client *, int, int, int, int, Bool, Bool);
void client_unban(Client *); void client_unban(Client *);
void client_unmanage(Client *, long, awesome_config *); void client_unmanage(Client *, long);
void client_updatesizehints(Client *); void client_updatesizehints(Client *);
void client_updatetitle(Client *); void client_updatetitle(Client *);
void client_saveprops(Client *, VirtScreen *); void client_saveprops(Client *, int);
UICB_PROTO(uicb_client_kill); UICB_PROTO(uicb_client_kill);
UICB_PROTO(uicb_client_moveresize); UICB_PROTO(uicb_client_moveresize);

View File

@ -24,11 +24,11 @@
#include "config.h" #include "config.h"
/** Common prototype definition for ui_callbak functions */ /** Common prototype definition for ui_callback functions */
#define UICB_PROTO(name) void name(awesome_config *, int, const char *) #define UICB_PROTO(name) void name(int, const char *)
/** Common prototype definition for layouts function */ /** Common prototype definition for layouts function */
#define LAYOUT_PROTO(name) void name(awesome_config *, int) #define LAYOUT_PROTO(name) void name(int)
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -41,6 +41,8 @@
#define AWESOME_CONFIG_FILE ".awesomerc" #define AWESOME_CONFIG_FILE ".awesomerc"
extern awesome_config globalconf;
static XColor initxcolor(Display *, int, const char *); static XColor initxcolor(Display *, int, const char *);
static unsigned int get_numlockmask(Display *); static unsigned int get_numlockmask(Display *);
@ -247,7 +249,7 @@ static Key *section_keys(cfg_t *cfg_keys)
* \param scr Screen number * \param scr Screen number
*/ */
void void
parse_config(const char *confpatharg, awesome_config *awesomeconf) parse_config(const char *confpatharg)
{ {
static cfg_opt_t general_opts[] = static cfg_opt_t general_opts[] =
{ {
@ -415,7 +417,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
a_strcat(confpath, confpath_len, AWESOME_CONFIG_FILE); a_strcat(confpath, confpath_len, AWESOME_CONFIG_FILE);
} }
awesomeconf->configpath = a_strdup(confpath); globalconf.configpath = a_strdup(confpath);
cfg = cfg_init(opts, CFGF_NONE); cfg = cfg_init(opts, CFGF_NONE);
@ -431,9 +433,9 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath); cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
/* get the right screen section */ /* get the right screen section */
for(screen = 0; screen < get_screen_count(awesomeconf->display); screen++) for(screen = 0; screen < get_screen_count(globalconf.display); screen++)
{ {
virtscreen = &awesomeconf->screens[screen]; virtscreen = &globalconf.screens[screen];
a_strcpy(virtscreen->statustext, a_strcpy(virtscreen->statustext,
sizeof(virtscreen->statustext), sizeof(virtscreen->statustext),
"awesome-" VERSION " (" RELEASE ")"); "awesome-" VERSION " (" RELEASE ")");
@ -465,29 +467,29 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
virtscreen->opacity_unfocused = cfg_getint(cfg_general, "opacity_unfocused"); virtscreen->opacity_unfocused = cfg_getint(cfg_general, "opacity_unfocused");
virtscreen->focus_move_pointer = cfg_getbool(cfg_general, "focus_move_pointer"); virtscreen->focus_move_pointer = cfg_getbool(cfg_general, "focus_move_pointer");
virtscreen->allow_lower_floats = cfg_getbool(cfg_general, "allow_lower_floats"); virtscreen->allow_lower_floats = cfg_getbool(cfg_general, "allow_lower_floats");
virtscreen->font = XftFontOpenName(awesomeconf->display, virtscreen->font = XftFontOpenName(globalconf.display,
get_phys_screen(awesomeconf->display, screen), get_phys_screen(globalconf.display, screen),
cfg_getstr(cfg_general, "font")); cfg_getstr(cfg_general, "font"));
if(!virtscreen->font) if(!virtscreen->font)
eprint("awesome: cannot init font\n"); eprint("awesome: cannot init font\n");
/* Colors */ /* Colors */
virtscreen->colors_normal[ColBorder] = initxcolor(awesomeconf->display, virtscreen->colors_normal[ColBorder] = initxcolor(globalconf.display,
get_phys_screen(awesomeconf->display, screen), get_phys_screen(globalconf.display, screen),
cfg_getstr(cfg_colors, "normal_border")); cfg_getstr(cfg_colors, "normal_border"));
virtscreen->colors_normal[ColBG] = initxcolor(awesomeconf->display, virtscreen->colors_normal[ColBG] = initxcolor(globalconf.display,
get_phys_screen(awesomeconf->display, screen), get_phys_screen(globalconf.display, screen),
cfg_getstr(cfg_colors, "normal_bg")); cfg_getstr(cfg_colors, "normal_bg"));
virtscreen->colors_normal[ColFG] = initxcolor(awesomeconf->display, virtscreen->colors_normal[ColFG] = initxcolor(globalconf.display,
get_phys_screen(awesomeconf->display, screen), get_phys_screen(globalconf.display, screen),
cfg_getstr(cfg_colors, "normal_fg")); cfg_getstr(cfg_colors, "normal_fg"));
virtscreen->colors_selected[ColBorder] = initxcolor(awesomeconf->display, virtscreen->colors_selected[ColBorder] = initxcolor(globalconf.display,
get_phys_screen(awesomeconf->display, screen), get_phys_screen(globalconf.display, screen),
cfg_getstr(cfg_colors, "focus_border")); cfg_getstr(cfg_colors, "focus_border"));
virtscreen->colors_selected[ColBG] = initxcolor(awesomeconf->display, virtscreen->colors_selected[ColBG] = initxcolor(globalconf.display,
get_phys_screen(awesomeconf->display, screen), get_phys_screen(globalconf.display, screen),
cfg_getstr(cfg_colors, "focus_bg")); cfg_getstr(cfg_colors, "focus_bg"));
virtscreen->colors_selected[ColFG] = initxcolor(awesomeconf->display, virtscreen->colors_selected[ColFG] = initxcolor(globalconf.display,
get_phys_screen(awesomeconf->display, screen), get_phys_screen(globalconf.display, screen),
cfg_getstr(cfg_colors, "focus_fg")); cfg_getstr(cfg_colors, "focus_fg"));
/* Statusbar */ /* Statusbar */
@ -584,7 +586,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
/* Rules */ /* Rules */
if(cfg_size(cfg_rules, "rule")) if(cfg_size(cfg_rules, "rule"))
{ {
awesomeconf->rules = rule = p_new(Rule, 1); globalconf.rules = rule = p_new(Rule, 1);
for(i = 0; i < cfg_size(cfg_rules, "rule"); i++) for(i = 0; i < cfg_size(cfg_rules, "rule"); i++)
{ {
cfgsectmp = cfg_getnsec(cfg_rules, "rule", i); cfgsectmp = cfg_getnsec(cfg_rules, "rule", i);
@ -594,7 +596,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
rule->tags = NULL; rule->tags = NULL;
rule->isfloating = cfg_getbool(cfgsectmp, "float"); rule->isfloating = cfg_getbool(cfgsectmp, "float");
rule->screen = cfg_getint(cfgsectmp, "screen"); rule->screen = cfg_getint(cfgsectmp, "screen");
if(rule->screen >= get_screen_count(awesomeconf->display)) if(rule->screen >= get_screen_count(globalconf.display))
rule->screen = 0; rule->screen = 0;
if(i < cfg_size(cfg_rules, "rule") - 1) if(i < cfg_size(cfg_rules, "rule") - 1)
@ -604,30 +606,30 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
} }
} }
else else
awesomeconf->rules = NULL; globalconf.rules = NULL;
compileregs(awesomeconf->rules); compileregs(globalconf.rules);
/* Mouse: tags click bindings */ /* Mouse: tags click bindings */
awesomeconf->buttons.tag = parse_mouse_bindings(cfg_mouse, "tag", False); globalconf.buttons.tag = parse_mouse_bindings(cfg_mouse, "tag", False);
/* Mouse: layout click bindings */ /* Mouse: layout click bindings */
awesomeconf->buttons.layout = parse_mouse_bindings(cfg_mouse, "layout", True); globalconf.buttons.layout = parse_mouse_bindings(cfg_mouse, "layout", True);
/* Mouse: title click bindings */ /* Mouse: title click bindings */
awesomeconf->buttons.title = parse_mouse_bindings(cfg_mouse, "title", True); globalconf.buttons.title = parse_mouse_bindings(cfg_mouse, "title", True);
/* Mouse: root window click bindings */ /* Mouse: root window click bindings */
awesomeconf->buttons.root = parse_mouse_bindings(cfg_mouse, "root", True); globalconf.buttons.root = parse_mouse_bindings(cfg_mouse, "root", True);
/* Mouse: client windows click bindings */ /* Mouse: client windows click bindings */
awesomeconf->buttons.client = parse_mouse_bindings(cfg_mouse, "client", True); globalconf.buttons.client = parse_mouse_bindings(cfg_mouse, "client", True);
/* Keys */ /* Keys */
awesomeconf->numlockmask = get_numlockmask(awesomeconf->display); globalconf.numlockmask = get_numlockmask(globalconf.display);
awesomeconf->keys = section_keys(cfg_keys); globalconf.keys = section_keys(cfg_keys);
if(defconfig) if(defconfig)
{ {

View File

@ -55,7 +55,7 @@ typedef struct Layout Layout;
struct Layout struct Layout
{ {
char *symbol; char *symbol;
void (*arrange) (awesome_config *, int); void (*arrange) (int);
Layout *next; Layout *next;
}; };
@ -64,7 +64,7 @@ struct Key
{ {
unsigned long mod; unsigned long mod;
KeySym keysym; KeySym keysym;
void (*func) (awesome_config *, int, char *); void (*func) (int, char *);
char *arg; char *arg;
Key *next; Key *next;
}; };
@ -74,7 +74,7 @@ struct Button
{ {
unsigned long mod; unsigned long mod;
unsigned int button; unsigned int button;
void (*func) (awesome_config *, int, char *); void (*func) (int, char *);
char *arg; char *arg;
Button *next; Button *next;
}; };
@ -224,9 +224,7 @@ typedef struct
struct Widget struct Widget
{ {
char *name; char *name;
int (*draw)(DrawCtx *, int (*draw)(DrawCtx *, int, int, int, int);
awesome_config *,
VirtScreen, int, int, int, int);
Statusbar *statusbar; Statusbar *statusbar;
int alignment; int alignment;
Widget *next; Widget *next;
@ -269,7 +267,7 @@ struct awesome_config
FocusList *focus; FocusList *focus;
}; };
void parse_config(const char *, awesome_config *); void parse_config(const char *);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

190
event.c
View File

@ -37,28 +37,30 @@
#include "layouts/tile.h" #include "layouts/tile.h"
#include "layouts/floating.h" #include "layouts/floating.h"
#define CLEANMASK(mask, acf) (mask & ~(acf->numlockmask | LockMask))
extern awesome_config globalconf;
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
static void static void
handle_mouse_button_press(awesome_config *awesomeconf, int screen, handle_mouse_button_press(int screen, unsigned int button, unsigned int state,
unsigned int button, unsigned int state,
Button *buttons, char *arg) Button *buttons, char *arg)
{ {
Button *b; Button *b;
for(b = buttons; b; b = b->next) for(b = buttons; b; b = b->next)
if(button == b->button && CLEANMASK(state, awesomeconf) == b->mod && b->func) if(button == b->button && CLEANMASK(state) == b->mod && b->func)
{ {
if(arg) if(arg)
b->func(awesomeconf, screen, arg); b->func(screen, arg);
else else
b->func(awesomeconf, screen, b->arg); b->func(screen, b->arg);
return; return;
} }
} }
void void
handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf) handle_event_buttonpress(XEvent * e)
{ {
int i, screen, x = 0, y = 0; int i, screen, x = 0, y = 0;
unsigned int udummy; unsigned int udummy;
@ -69,52 +71,46 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
XButtonPressedEvent *ev = &e->xbutton; XButtonPressedEvent *ev = &e->xbutton;
for(screen = 0; screen < get_screen_count(e->xany.display); screen++) for(screen = 0; screen < get_screen_count(e->xany.display); screen++)
if(awesomeconf->screens[screen].statusbar.window == ev->window) if(globalconf.screens[screen].statusbar.window == ev->window)
{ {
for(i = 1, tag = awesomeconf->screens[screen].tags; tag; tag = tag->next, i++) for(i = 1, tag = globalconf.screens[screen].tags; tag; tag = tag->next, i++)
{ {
x += textwidth_primitive(e->xany.display, awesomeconf->screens[screen].font, awesomeconf->screens[screen].tags[i].name); x += textwidth_primitive(e->xany.display, globalconf.screens[screen].font, globalconf.screens[screen].tags[i].name);
if(((awesomeconf->screens[screen].statusbar.position == BarTop if(((globalconf.screens[screen].statusbar.position == BarTop
|| awesomeconf->screens[screen].statusbar.position == BarBot) || globalconf.screens[screen].statusbar.position == BarBot)
&& ev->x < x) && ev->x < x)
|| (awesomeconf->screens[screen].statusbar.position == BarRight && ev->y < x) || (globalconf.screens[screen].statusbar.position == BarRight && ev->y < x)
|| (awesomeconf->screens[screen].statusbar.position == BarLeft && ev->y > awesomeconf->screens[screen].statusbar.width - x)) || (globalconf.screens[screen].statusbar.position == BarLeft && ev->y > globalconf.screens[screen].statusbar.width - x))
{ {
snprintf(arg, sizeof(arg), "%d", i); snprintf(arg, sizeof(arg), "%d", i);
handle_mouse_button_press(awesomeconf, screen, ev->button, ev->state, handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.tag, arg);
awesomeconf->buttons.tag, arg);
return; return;
} }
} }
x += awesomeconf->screens[screen].statusbar.txtlayoutwidth; x += globalconf.screens[screen].statusbar.txtlayoutwidth;
if(((awesomeconf->screens[screen].statusbar.position == BarTop if(((globalconf.screens[screen].statusbar.position == BarTop
|| awesomeconf->screens[screen].statusbar.position == BarBot) || globalconf.screens[screen].statusbar.position == BarBot)
&& ev->x < x) && ev->x < x)
|| (awesomeconf->screens[screen].statusbar.position == BarRight && ev->y < x) || (globalconf.screens[screen].statusbar.position == BarRight && ev->y < x)
|| (awesomeconf->screens[screen].statusbar.position == BarLeft && ev->y > awesomeconf->screens[screen].statusbar.width - x)) || (globalconf.screens[screen].statusbar.position == BarLeft && ev->y > globalconf.screens[screen].statusbar.width - x))
handle_mouse_button_press(awesomeconf, screen, ev->button, ev->state, handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.layout, NULL);
awesomeconf->buttons.layout, NULL);
else else
handle_mouse_button_press(awesomeconf, screen, ev->button, ev->state, handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.title, NULL);
awesomeconf->buttons.title, NULL);
return; return;
} }
if((c = get_client_bywin(awesomeconf->clients, ev->window))) if((c = get_client_bywin(globalconf.clients, ev->window)))
{ {
focus(c, ev->same_screen, awesomeconf, c->screen); focus(c, ev->same_screen, c->screen);
if(CLEANMASK(ev->state, awesomeconf) == NoSymbol if(CLEANMASK(ev->state) == NoSymbol
&& ev->button == Button1) && ev->button == Button1)
{ {
restack(awesomeconf, c->screen); restack(c->screen);
XAllowEvents(c->display, ReplayPointer, CurrentTime); XAllowEvents(c->display, ReplayPointer, CurrentTime);
window_grabbuttons(c->display, c->phys_screen, c->win, window_grabbuttons(c->display, c->phys_screen, c->win, True, True);
True, True, awesomeconf->buttons.root,
awesomeconf->buttons.client, awesomeconf->numlockmask);
} }
else else
handle_mouse_button_press(awesomeconf, c->screen, ev->button, ev->state, handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL);
awesomeconf->buttons.client, NULL);
} }
else else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
@ -122,27 +118,27 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
&& XQueryPointer(e->xany.display, ev->window, &wdummy, &wdummy, &x, &y, &i, &i, &udummy)) && XQueryPointer(e->xany.display, ev->window, &wdummy, &wdummy, &x, &y, &i, &i, &udummy))
{ {
screen = get_screen_bycoord(e->xany.display, x, y); screen = get_screen_bycoord(e->xany.display, x, y);
handle_mouse_button_press(awesomeconf, screen, ev->button, ev->state, handle_mouse_button_press(screen, ev->button, ev->state,
awesomeconf->buttons.root, NULL); globalconf.buttons.root, NULL);
return; return;
} }
} }
void void
handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf) handle_event_configurerequest(XEvent * e)
{ {
Client *c; Client *c;
XConfigureRequestEvent *ev = &e->xconfigurerequest; XConfigureRequestEvent *ev = &e->xconfigurerequest;
XWindowChanges wc; XWindowChanges wc;
int old_screen; int old_screen;
if((c = get_client_bywin(awesomeconf->clients, ev->window))) if((c = get_client_bywin(globalconf.clients, ev->window)))
{ {
c->ismax = False; c->ismax = False;
if(ev->value_mask & CWBorderWidth) if(ev->value_mask & CWBorderWidth)
c->border = ev->border_width; c->border = ev->border_width;
if(c->isfixed || c->isfloating if(c->isfixed || c->isfloating
|| get_current_layout(awesomeconf->screens[c->screen])->arrange == layout_floating) || get_current_layout(c->screen)->arrange == layout_floating)
{ {
if(ev->value_mask & CWX) if(ev->value_mask & CWX)
c->rx = c->x = ev->x; c->rx = c->x = ev->x;
@ -159,13 +155,13 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
c->screen = get_screen_bycoord(c->display, c->x, c->y); c->screen = get_screen_bycoord(c->display, c->x, c->y);
if(old_screen != c->screen) if(old_screen != c->screen)
{ {
move_client_to_screen(c, awesomeconf, c->screen, False); move_client_to_screen(c, c->screen, False);
statusbar_draw(awesomeconf, old_screen); statusbar_draw(old_screen);
statusbar_draw(awesomeconf, c->screen); statusbar_draw(c->screen);
} }
tag_client_with_rules(c, awesomeconf); tag_client_with_rules(c);
XMoveResizeWindow(e->xany.display, c->win, c->rx, c->ry, c->rw, c->rh); XMoveResizeWindow(e->xany.display, c->win, c->rx, c->ry, c->rw, c->rh);
arrange(awesomeconf, c->screen); arrange(c->screen);
} }
else else
window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border); window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border);
@ -185,7 +181,7 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
} }
void void
handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf) handle_event_configurenotify(XEvent * e)
{ {
XConfigureEvent *ev = &e->xconfigure; XConfigureEvent *ev = &e->xconfigure;
int screen; int screen;
@ -200,32 +196,32 @@ handle_event_configurenotify(XEvent * e, awesome_config *awesomeconf)
DisplayHeight(e->xany.display, screen) = ev->height; DisplayHeight(e->xany.display, screen) = ev->height;
/* update statusbar */ /* update statusbar */
si = get_screen_info(e->xany.display, screen, NULL, &awesomeconf->screens[screen].padding); si = get_screen_info(e->xany.display, screen, NULL, &globalconf.screens[screen].padding);
awesomeconf->screens[screen].statusbar.width = si[screen].width; globalconf.screens[screen].statusbar.width = si[screen].width;
p_delete(&si); p_delete(&si);
XResizeWindow(e->xany.display, XResizeWindow(e->xany.display,
awesomeconf->screens[screen].statusbar.window, globalconf.screens[screen].statusbar.window,
awesomeconf->screens[screen].statusbar.width, globalconf.screens[screen].statusbar.width,
awesomeconf->screens[screen].statusbar.height); globalconf.screens[screen].statusbar.height);
statusbar_update_position(e->xany.display, awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); statusbar_update_position(e->xany.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
arrange(awesomeconf, screen); arrange(screen);
} }
} }
void void
handle_event_destroynotify(XEvent * e, awesome_config *awesomeconf) handle_event_destroynotify(XEvent * e)
{ {
Client *c; Client *c;
XDestroyWindowEvent *ev = &e->xdestroywindow; XDestroyWindowEvent *ev = &e->xdestroywindow;
if((c = get_client_bywin(awesomeconf->clients, ev->window))) if((c = get_client_bywin(globalconf.clients, ev->window)))
client_unmanage(c, WithdrawnState, awesomeconf); client_unmanage(c, WithdrawnState);
} }
void void
handle_event_enternotify(XEvent * e, awesome_config *awesomeconf) handle_event_enternotify(XEvent * e)
{ {
Client *c; Client *c;
XCrossingEvent *ev = &e->xcrossing; XCrossingEvent *ev = &e->xcrossing;
@ -233,35 +229,33 @@ handle_event_enternotify(XEvent * e, awesome_config *awesomeconf)
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
return; return;
if((c = get_client_bywin(awesomeconf->clients, ev->window))) if((c = get_client_bywin(globalconf.clients, ev->window)))
{ {
focus(c, ev->same_screen, awesomeconf, c->screen); focus(c, ev->same_screen, c->screen);
if (c->isfloating if (c->isfloating
|| get_current_layout(awesomeconf->screens[c->screen])->arrange == layout_floating) || get_current_layout(c->screen)->arrange == layout_floating)
window_grabbuttons(c->display, c->phys_screen, c->win, window_grabbuttons(c->display, c->phys_screen, c->win, True, False);
True, False, awesomeconf->buttons.root,
awesomeconf->buttons.client, awesomeconf->numlockmask);
} }
else else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if(ev->window == RootWindow(e->xany.display, screen)) if(ev->window == RootWindow(e->xany.display, screen))
focus(NULL, True, awesomeconf, screen); focus(NULL, True, screen);
} }
void void
handle_event_expose(XEvent * e, awesome_config *awesomeconf) handle_event_expose(XEvent * e)
{ {
XExposeEvent *ev = &e->xexpose; XExposeEvent *ev = &e->xexpose;
int screen; int screen;
if(!ev->count) if(!ev->count)
for(screen = 0; screen < get_screen_count(e->xany.display); screen++) for(screen = 0; screen < get_screen_count(e->xany.display); screen++)
if(awesomeconf->screens[screen].statusbar.window == ev->window) if(globalconf.screens[screen].statusbar.window == ev->window)
statusbar_draw(awesomeconf, screen); statusbar_draw(screen);
} }
void void
handle_event_keypress(XEvent * e, awesome_config *awesomeconf) handle_event_keypress(XEvent * e)
{ {
int screen, x, y, d; int screen, x, y, d;
unsigned int m; unsigned int m;
@ -285,28 +279,28 @@ handle_event_keypress(XEvent * e, awesome_config *awesomeconf)
break; break;
} }
for(k = awesomeconf->keys; k; k = k->next) for(k = globalconf.keys; k; k = k->next)
if(keysym == k->keysym && k->func if(keysym == k->keysym && k->func
&& CLEANMASK(k->mod, awesomeconf) == CLEANMASK(ev->state, awesomeconf)) && CLEANMASK(k->mod) == CLEANMASK(ev->state))
{ {
k->func(awesomeconf, screen, k->arg); k->func(screen, k->arg);
break; break;
} }
} }
void void
handle_event_leavenotify(XEvent * e, awesome_config *awesomeconf) handle_event_leavenotify(XEvent * e)
{ {
XCrossingEvent *ev = &e->xcrossing; XCrossingEvent *ev = &e->xcrossing;
int screen; int screen;
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if((ev->window == RootWindow(e->xany.display, screen)) && !ev->same_screen) if((ev->window == RootWindow(e->xany.display, screen)) && !ev->same_screen)
focus(NULL, ev->same_screen, awesomeconf, screen); focus(NULL, ev->same_screen, screen);
} }
void void
handle_event_mappingnotify(XEvent * e, awesome_config *awesomeconf) handle_event_mappingnotify(XEvent * e)
{ {
XMappingEvent *ev = &e->xmapping; XMappingEvent *ev = &e->xmapping;
int screen; int screen;
@ -314,11 +308,11 @@ handle_event_mappingnotify(XEvent * e, awesome_config *awesomeconf)
XRefreshKeyboardMapping(ev); XRefreshKeyboardMapping(ev);
if(ev->request == MappingKeyboard) if(ev->request == MappingKeyboard)
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
grabkeys(awesomeconf, get_phys_screen(awesomeconf->display, screen)); grabkeys(get_phys_screen(globalconf.display, screen));
} }
void void
handle_event_maprequest(XEvent * e, awesome_config *awesomeconf) handle_event_maprequest(XEvent * e)
{ {
static XWindowAttributes wa; static XWindowAttributes wa;
XMapRequestEvent *ev = &e->xmaprequest; XMapRequestEvent *ev = &e->xmaprequest;
@ -330,18 +324,18 @@ handle_event_maprequest(XEvent * e, awesome_config *awesomeconf)
return; return;
if(wa.override_redirect) if(wa.override_redirect)
return; return;
if(!get_client_bywin(awesomeconf->clients, ev->window)) if(!get_client_bywin(globalconf.clients, ev->window))
{ {
for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++); for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++);
if(screen == 0 && XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen), if(screen == 0 && XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen),
&dummy, &dummy, &x, &y, &d, &d, &m)) &dummy, &dummy, &x, &y, &d, &d, &m))
screen = get_screen_bycoord(e->xany.display, x, y); screen = get_screen_bycoord(e->xany.display, x, y);
client_manage(ev->window, &wa, awesomeconf, screen); client_manage(ev->window, &wa, screen);
} }
} }
void void
handle_event_propertynotify(XEvent * e, awesome_config *awesomeconf) handle_event_propertynotify(XEvent * e)
{ {
Client *c; Client *c;
Window trans; Window trans;
@ -349,14 +343,14 @@ handle_event_propertynotify(XEvent * e, awesome_config *awesomeconf)
if(ev->state == PropertyDelete) if(ev->state == PropertyDelete)
return; /* ignore */ return; /* ignore */
if((c = get_client_bywin(awesomeconf->clients, ev->window))) if((c = get_client_bywin(globalconf.clients, ev->window)))
{ {
switch (ev->atom) switch (ev->atom)
{ {
case XA_WM_TRANSIENT_FOR: case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(e->xany.display, c->win, &trans); XGetTransientForHint(e->xany.display, c->win, &trans);
if(!c->isfloating && (c->isfloating = (get_client_bywin(awesomeconf->clients, trans) != NULL))) if(!c->isfloating && (c->isfloating = (get_client_bywin(globalconf.clients, trans) != NULL)))
arrange(awesomeconf, c->screen); arrange(c->screen);
break; break;
case XA_WM_NORMAL_HINTS: case XA_WM_NORMAL_HINTS:
client_updatesizehints(c); client_updatesizehints(c);
@ -365,57 +359,55 @@ handle_event_propertynotify(XEvent * e, awesome_config *awesomeconf)
if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(c->display, "_NET_WM_NAME", False)) if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(c->display, "_NET_WM_NAME", False))
{ {
client_updatetitle(c); client_updatetitle(c);
if(c == awesomeconf->focus->client) if(c == globalconf.focus->client)
statusbar_draw(awesomeconf, c->screen); statusbar_draw(c->screen);
} }
} }
} }
void void
handle_event_unmapnotify(XEvent * e, awesome_config *awesomeconf) handle_event_unmapnotify(XEvent * e)
{ {
Client *c; Client *c;
XUnmapEvent *ev = &e->xunmap; XUnmapEvent *ev = &e->xunmap;
if((c = get_client_bywin(awesomeconf->clients, ev->window)) if((c = get_client_bywin(globalconf.clients, ev->window))
&& ev->event == RootWindow(e->xany.display, c->phys_screen) && ev->event == RootWindow(e->xany.display, c->phys_screen)
&& ev->send_event && window_getstate(c->display, c->win) == NormalState) && ev->send_event && window_getstate(c->display, c->win) == NormalState)
client_unmanage(c, WithdrawnState, awesomeconf); client_unmanage(c, WithdrawnState);
} }
void void
handle_event_shape(XEvent * e, handle_event_shape(XEvent * e)
awesome_config *awesomeconf __attribute__ ((unused)))
{ {
XShapeEvent *ev = (XShapeEvent *) e; XShapeEvent *ev = (XShapeEvent *) e;
Client *c = get_client_bywin(awesomeconf->clients, ev->window); Client *c = get_client_bywin(globalconf.clients, ev->window);
if(c) if(c)
window_setshape(c->display, c->phys_screen, c->win); window_setshape(c->display, c->phys_screen, c->win);
} }
void void
handle_event_randr_screen_change_notify(XEvent *e, handle_event_randr_screen_change_notify(XEvent *e)
awesome_config *awesomeconf __attribute__ ((unused)))
{ {
XRRUpdateConfiguration(e); XRRUpdateConfiguration(e);
} }
void void
grabkeys(awesome_config *awesomeconf, int phys_screen) grabkeys(int phys_screen)
{ {
Key *k; Key *k;
KeyCode code; KeyCode code;
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, phys_screen)); XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
for(k = awesomeconf->keys; k; k = k->next) for(k = globalconf.keys; k; k = k->next)
{ {
if((code = XKeysymToKeycode(awesomeconf->display, k->keysym)) == NoSymbol) if((code = XKeysymToKeycode(globalconf.display, k->keysym)) == NoSymbol)
continue; continue;
XGrabKey(awesomeconf->display, code, k->mod, RootWindow(awesomeconf->display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, code, k->mod, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(awesomeconf->display, code, k->mod | LockMask, RootWindow(awesomeconf->display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, code, k->mod | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(awesomeconf->display, code, k->mod | awesomeconf->numlockmask, RootWindow(awesomeconf->display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(awesomeconf->display, code, k->mod | awesomeconf->numlockmask | LockMask, RootWindow(awesomeconf->display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
} }
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

30
event.h
View File

@ -24,22 +24,22 @@
#include "config.h" #include "config.h"
void grabkeys(awesome_config *, int); void grabkeys(int);
void handle_event_buttonpress(XEvent *, awesome_config *); void handle_event_buttonpress(XEvent *);
void handle_event_configurerequest(XEvent *, awesome_config *); void handle_event_configurerequest(XEvent *);
void handle_event_configurenotify(XEvent *, awesome_config *); void handle_event_configurenotify(XEvent *);
void handle_event_destroynotify(XEvent *, awesome_config *); void handle_event_destroynotify(XEvent *);
void handle_event_enternotify(XEvent *, awesome_config *); void handle_event_enternotify(XEvent *);
void handle_event_expose(XEvent *, awesome_config *); void handle_event_expose(XEvent *);
void handle_event_keypress(XEvent *, awesome_config *); void handle_event_keypress(XEvent *);
void handle_event_leavenotify(XEvent *, awesome_config *); void handle_event_leavenotify(XEvent *);
void handle_event_mappingnotify(XEvent *, awesome_config *); void handle_event_mappingnotify(XEvent *);
void handle_event_maprequest(XEvent *, awesome_config *); void handle_event_maprequest(XEvent *);
void handle_event_propertynotify(XEvent *, awesome_config *); void handle_event_propertynotify(XEvent *);
void handle_event_unmapnotify(XEvent *, awesome_config *); void handle_event_unmapnotify(XEvent *);
void handle_event_shape(XEvent *, awesome_config *); void handle_event_shape(XEvent *);
void handle_event_randr_screen_change_notify(XEvent *, awesome_config *); void handle_event_randr_screen_change_notify(XEvent *);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

20
focus.c
View File

@ -24,6 +24,8 @@
#include "layout.h" #include "layout.h"
#include "focus.h" #include "focus.h"
extern awesome_config globalconf;
static FocusList * static FocusList *
focus_get_node_by_client(FocusList *head, Client *c) focus_get_node_by_client(FocusList *head, Client *c)
{ {
@ -93,25 +95,23 @@ focus_delete_client(FocusList **head, Client *c)
} }
Client * Client *
focus_get_latest_client_for_tag(FocusList *head, TagClientLink *tc, Tag *t) focus_get_latest_client_for_tag(FocusList *head, int screen, Tag *t)
{ {
FocusList *fl; FocusList *fl;
for(fl = head; fl; fl = fl->prev) for(fl = head; fl; fl = fl->prev)
if(is_client_tagged(tc, fl->client, t)) if(is_client_tagged(fl->client, t, screen))
return fl->client; return fl->client;
return NULL; return NULL;
} }
void void
uicb_focus_history(awesome_config *awesomeconf, uicb_focus_history(int screen, const char *arg)
int screen,
const char *arg)
{ {
int i; int i;
FocusList *fl = awesomeconf->focus; FocusList *fl = globalconf.focus;
Tag *curtag = get_current_tag(awesomeconf->screens[screen]); Tag *curtag = get_current_tag(screen);
if(arg) if(arg)
{ {
@ -120,12 +120,10 @@ uicb_focus_history(awesome_config *awesomeconf,
if(i < 0) if(i < 0)
{ {
for(; fl && i < 0; fl = fl->prev) for(; fl && i < 0; fl = fl->prev)
if(is_client_tagged(awesomeconf->screens[screen].tclink, if(is_client_tagged(fl->client, curtag, screen))
fl->client,
curtag))
i++; i++;
if(fl) if(fl)
focus(fl->client, True, awesomeconf, screen); focus(fl->client, True, screen);
} }
} }
} }

View File

@ -26,7 +26,7 @@
void focus_add_client(FocusList **, Client *); void focus_add_client(FocusList **, Client *);
void focus_delete_client(FocusList **, Client *); void focus_delete_client(FocusList **, Client *);
Client * focus_get_latest_client_for_tag(FocusList *, TagClientLink *, Tag *); Client * focus_get_latest_client_for_tag(FocusList *, int, Tag *);
UICB_PROTO(uicb_focus_history); UICB_PROTO(uicb_focus_history);

194
layout.c
View File

@ -31,16 +31,18 @@
#include "statusbar.h" #include "statusbar.h"
#include "layouts/floating.h" #include "layouts/floating.h"
extern awesome_config globalconf;
/** Find the index of the first currently selected tag /** Find the index of the first currently selected tag
* \param screen the screen to search * \param screen the screen to search
* \return tag * \return tag
*/ */
Tag * Tag *
get_current_tag(VirtScreen screen) get_current_tag(int screen)
{ {
Tag *tag; Tag *tag;
for(tag = screen.tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
if(tag->selected) if(tag->selected)
return tag; return tag;
@ -49,31 +51,30 @@ get_current_tag(VirtScreen screen)
/** Arrange windows following current selected layout /** Arrange windows following current selected layout
* \param disp display ref * \param disp display ref
* \param awesomeconf awesome config
*/ */
void void
arrange(awesome_config *awesomeconf, int screen) arrange(int screen)
{ {
Client *c; Client *c;
Tag *curtag = get_current_tag(awesomeconf->screens[screen]); Tag *curtag = get_current_tag(screen);
for(c = awesomeconf->clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
{ {
if(client_isvisible(c, &awesomeconf->screens[screen], screen)) if(client_isvisible(c, screen))
client_unban(c); client_unban(c);
/* we don't touch other screens windows */ /* we don't touch other screens windows */
else if(c->screen == screen) else if(c->screen == screen)
client_ban(c); client_ban(c);
} }
curtag->layout->arrange(awesomeconf, screen); curtag->layout->arrange(screen);
focus(focus_get_latest_client_for_tag(awesomeconf->focus, awesomeconf->screens[screen].tclink, curtag), focus(focus_get_latest_client_for_tag(globalconf.focus, screen, curtag),
True, awesomeconf, screen); True, screen);
restack(awesomeconf, screen); restack(screen);
} }
Layout * Layout *
get_current_layout(VirtScreen screen) get_current_layout(int screen)
{ {
Tag *curtag; Tag *curtag;
@ -84,62 +85,58 @@ get_current_layout(VirtScreen screen)
} }
void void
uicb_client_focusnext(awesome_config * awesomeconf, uicb_client_focusnext(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Client *c, *sel = awesomeconf->focus->client; Client *c, *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
for(c = sel->next; c && !client_isvisible(c, &awesomeconf->screens[screen], screen); c = c->next); for(c = sel->next; c && !client_isvisible(c, screen); c = c->next);
if(!c) if(!c)
for(c = awesomeconf->clients; c && !client_isvisible(c, &awesomeconf->screens[screen], screen); c = c->next); for(c = globalconf.clients; c && !client_isvisible(c, screen); c = c->next);
if(c) if(c)
{ {
focus(c, True, awesomeconf, screen); focus(c, True, screen);
restack(awesomeconf, screen); restack(screen);
} }
} }
void void
uicb_client_focusprev(awesome_config *awesomeconf, uicb_client_focusprev(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Client *c, *sel = awesomeconf->focus->client; Client *c, *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
for(c = sel->prev; c && !client_isvisible(c, &awesomeconf->screens[screen], screen); c = c->prev); for(c = sel->prev; c && !client_isvisible(c, screen); c = c->prev);
if(!c) if(!c)
{ {
for(c = awesomeconf->clients; c && c->next; c = c->next); for(c = globalconf.clients; c && c->next; c = c->next);
for(; c && !client_isvisible(c, &awesomeconf->screens[screen], screen); c = c->prev); for(; c && !client_isvisible(c, screen); c = c->prev);
} }
if(c) if(c)
{ {
focus(c, True, awesomeconf, screen); focus(c, True, screen);
restack(awesomeconf, screen); restack(screen);
} }
} }
void void
loadawesomeprops(awesome_config *awesomeconf, int screen) loadawesomeprops(int screen)
{ {
int i, ntags = 0; int i, ntags = 0;
char *prop; char *prop;
Tag *tag; Tag *tag;
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
ntags++; ntags++;
prop = p_new(char, ntags + 1); prop = p_new(char, ntags + 1);
if(xgettextprop(awesomeconf->display, if(xgettextprop(globalconf.display,
RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)), RootWindow(globalconf.display, get_phys_screen(globalconf.display, screen)),
AWESOMEPROPS_ATOM(awesomeconf->display), prop, ntags + 1)) AWESOMEPROPS_ATOM(globalconf.display), prop, ntags + 1))
for(i = 0, tag = awesomeconf->screens[screen].tags; tag && prop[i]; i++, tag = tag->next) for(i = 0, tag = globalconf.screens[screen].tags; tag && prop[i]; i++, tag = tag->next)
if(prop[i] == '1') if(prop[i] == '1')
tag->selected = True; tag->selected = True;
else else
@ -149,106 +146,104 @@ loadawesomeprops(awesome_config *awesomeconf, int screen)
} }
void void
restack(awesome_config *awesomeconf, int screen) restack(int screen)
{ {
Client *c, *sel = awesomeconf->focus->client; Client *c, *sel = globalconf.focus->client;
XEvent ev; XEvent ev;
XWindowChanges wc; XWindowChanges wc;
statusbar_draw(awesomeconf, screen); statusbar_draw(screen);
if(!sel) if(!sel)
return; return;
if(awesomeconf->screens[screen].allow_lower_floats) if(globalconf.screens[screen].allow_lower_floats)
XRaiseWindow(awesomeconf->display, sel->win); XRaiseWindow(globalconf.display, sel->win);
else else
{ {
if(sel->isfloating || if(sel->isfloating ||
get_current_layout(awesomeconf->screens[screen])->arrange == layout_floating) get_current_layout(screen)->arrange == layout_floating)
XRaiseWindow(sel->display, sel->win); XRaiseWindow(sel->display, sel->win);
if(!(get_current_layout(awesomeconf->screens[screen])->arrange == layout_floating)) if(!(get_current_layout(screen)->arrange == layout_floating))
{ {
wc.stack_mode = Below; wc.stack_mode = Below;
wc.sibling = awesomeconf->screens[screen].statusbar.window; wc.sibling = globalconf.screens[screen].statusbar.window;
if(!sel->isfloating) if(!sel->isfloating)
{ {
XConfigureWindow(sel->display, sel->win, CWSibling | CWStackMode, &wc); XConfigureWindow(sel->display, sel->win, CWSibling | CWStackMode, &wc);
wc.sibling = sel->win; wc.sibling = sel->win;
} }
for(c = awesomeconf->clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
{ {
if(!IS_TILED(c, &awesomeconf->screens[screen], screen) || c == sel) if(!IS_TILED(c, screen) || c == sel)
continue; continue;
XConfigureWindow(awesomeconf->display, c->win, CWSibling | CWStackMode, &wc); XConfigureWindow(globalconf.display, c->win, CWSibling | CWStackMode, &wc);
wc.sibling = c->win; wc.sibling = c->win;
} }
} }
} }
if(awesomeconf->screens[screen].focus_move_pointer) if(globalconf.screens[screen].focus_move_pointer)
XWarpPointer(awesomeconf->display, None, sel->win, 0, 0, 0, 0, sel->w / 2, sel->h / 2); XWarpPointer(globalconf.display, None, sel->win, 0, 0, 0, 0, sel->w / 2, sel->h / 2);
XSync(awesomeconf->display, False); XSync(globalconf.display, False);
while(XCheckMaskEvent(awesomeconf->display, EnterWindowMask, &ev)); while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &ev));
} }
void void
saveawesomeprops(awesome_config *awesomeconf, int screen) saveawesomeprops(int screen)
{ {
int i, ntags = 0; int i, ntags = 0;
char *prop; char *prop;
Tag *tag; Tag *tag;
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
ntags++; ntags++;
prop = p_new(char, ntags + 1); prop = p_new(char, ntags + 1);
for(i = 0, tag = awesomeconf->screens[screen].tags; tag; tag = tag->next, i++) for(i = 0, tag = globalconf.screens[screen].tags; tag; tag = tag->next, i++)
prop[i] = tag->selected ? '1' : '0'; prop[i] = tag->selected ? '1' : '0';
prop[i] = '\0'; prop[i] = '\0';
XChangeProperty(awesomeconf->display, XChangeProperty(globalconf.display,
RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)), RootWindow(globalconf.display, get_phys_screen(globalconf.display, screen)),
AWESOMEPROPS_ATOM(awesomeconf->display), XA_STRING, 8, AWESOMEPROPS_ATOM(globalconf.display), XA_STRING, 8,
PropModeReplace, (unsigned char *) prop, i); PropModeReplace, (unsigned char *) prop, i);
p_delete(&prop); p_delete(&prop);
} }
void void
uicb_tag_setlayout(awesome_config * awesomeconf, uicb_tag_setlayout(int screen, const char *arg)
int screen,
const char *arg)
{ {
Layout *l = awesomeconf->screens[screen].layouts; Layout *l = globalconf.screens[screen].layouts;
Tag *tag; Tag *tag;
int i; int i;
if(arg) if(arg)
{ {
for(i = 0; l && l != get_current_layout(awesomeconf->screens[screen]); i++, l = l->next); for(i = 0; l && l != get_current_layout(screen); i++, l = l->next);
if(!l) if(!l)
i = 0; i = 0;
for(i = compute_new_value_from_arg(arg, (double) i), for(i = compute_new_value_from_arg(arg, (double) i),
l = awesomeconf->screens[screen].layouts; l && i > 0; i--) l = globalconf.screens[screen].layouts; l && i > 0; i--)
l = l->next; l = l->next;
if(!l) if(!l)
l = awesomeconf->screens[screen].layouts; l = globalconf.screens[screen].layouts;
} }
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
if(tag->selected) if(tag->selected)
tag->layout = l; tag->layout = l;
if(awesomeconf->focus->client) if(globalconf.focus->client)
arrange(awesomeconf, screen); arrange(screen);
else else
statusbar_draw(awesomeconf, screen); statusbar_draw(screen);
saveawesomeprops(awesomeconf, screen); saveawesomeprops(screen);
} }
static void static void
maximize(int x, int y, int w, int h, awesome_config *awesomeconf, int screen) maximize(int x, int y, int w, int h, int screen)
{ {
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
@ -257,83 +252,76 @@ maximize(int x, int y, int w, int h, awesome_config *awesomeconf, int screen)
{ {
sel->wasfloating = sel->isfloating; sel->wasfloating = sel->isfloating;
sel->isfloating = True; sel->isfloating = True;
client_resize(sel, x, y, w, h, awesomeconf, True, !sel->isfloating); client_resize(sel, x, y, w, h, True, !sel->isfloating);
} }
else if(sel->wasfloating) else if(sel->wasfloating)
client_resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, awesomeconf, True, False); client_resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True, False);
else else
sel->isfloating = False; sel->isfloating = False;
arrange(awesomeconf, screen); arrange(screen);
} }
void void
uicb_client_togglemax(awesome_config *awesomeconf, uicb_client_togglemax(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
ScreenInfo *si = get_screen_info(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); ScreenInfo *si = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
maximize(si[screen].x_org, si[screen].y_org, maximize(si[screen].x_org, si[screen].y_org,
si[screen].width - 2 * awesomeconf->screens[screen].borderpx, si[screen].width - 2 * globalconf.screens[screen].borderpx,
si[screen].height - 2 * awesomeconf->screens[screen].borderpx, si[screen].height - 2 * globalconf.screens[screen].borderpx,
awesomeconf, screen); screen);
p_delete(&si); p_delete(&si);
} }
void void
uicb_client_toggleverticalmax(awesome_config *awesomeconf, uicb_client_toggleverticalmax(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
ScreenInfo *si = get_screen_info(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); ScreenInfo *si = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
if(sel) if(sel)
maximize(sel->x, maximize(sel->x,
si[screen].y_org, si[screen].y_org,
sel->w, sel->w,
si[screen].height - 2 * awesomeconf->screens[screen].borderpx, si[screen].height - 2 * globalconf.screens[screen].borderpx,
awesomeconf, screen); screen);
p_delete(&si); p_delete(&si);
} }
void void
uicb_client_togglehorizontalmax(awesome_config *awesomeconf, uicb_client_togglehorizontalmax(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
ScreenInfo *si = get_screen_info(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); ScreenInfo *si = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
if(sel) if(sel)
maximize(si[screen].x_org, maximize(si[screen].x_org,
sel->y, sel->y,
si[screen].height - 2 * awesomeconf->screens[screen].borderpx, si[screen].height - 2 * globalconf.screens[screen].borderpx,
sel->h, sel->h,
awesomeconf, screen); screen);
p_delete(&si); p_delete(&si);
} }
void void
uicb_client_zoom(awesome_config *awesomeconf, uicb_client_zoom(int screen,
int screen,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
if(awesomeconf->clients == sel) if(globalconf.clients == sel)
for(sel = sel->next; sel && !client_isvisible(sel, &awesomeconf->screens[screen], screen); sel = sel->next); for(sel = sel->next; sel && !client_isvisible(sel, screen); sel = sel->next);
if(!sel) if(!sel)
return; return;
client_detach(&awesomeconf->clients, sel); client_detach(sel);
client_attach(&awesomeconf->clients, sel); client_attach(sel);
focus(sel, True, awesomeconf, screen); focus(sel, True, screen);
arrange(awesomeconf, screen); arrange(screen);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -26,12 +26,12 @@
#define AWESOMEPROPS_ATOM(disp) XInternAtom(disp, "_AWESOME_PROPERTIES", False) #define AWESOMEPROPS_ATOM(disp) XInternAtom(disp, "_AWESOME_PROPERTIES", False)
void arrange(awesome_config *, int); void arrange(int);
Layout * get_current_layout(VirtScreen); Layout * get_current_layout(int);
Tag * get_current_tag(VirtScreen); Tag * get_current_tag(int);
void restack(awesome_config *, int); void restack(int);
void loadawesomeprops(awesome_config *, int); void loadawesomeprops(int);
void saveawesomeprops(awesome_config *, int); void saveawesomeprops(int);
UICB_PROTO(uicb_client_focusnext); UICB_PROTO(uicb_client_focusnext);
UICB_PROTO(uicb_client_focusprev); UICB_PROTO(uicb_client_focusprev);

View File

@ -24,25 +24,27 @@
#include "util.h" #include "util.h"
#include "layouts/fibonacci.h" #include "layouts/fibonacci.h"
extern awesome_config globalconf;
static void static void
layout_fibonacci(awesome_config *awesomeconf, int screen, int shape) layout_fibonacci(int screen, int shape)
{ {
int n = 0, i = 0, nx, ny, nw, nh; int n = 0, i = 0, nx, ny, nw, nh;
Client *c; Client *c;
ScreenInfo *si = get_screen_info(awesomeconf->display, screen, ScreenInfo *si = get_screen_info(globalconf.display, screen,
&awesomeconf->screens[screen].statusbar, &globalconf.screens[screen].statusbar,
&awesomeconf->screens[screen].padding); &globalconf.screens[screen].padding);
nx = si[screen].x_org; nx = si[screen].x_org;
ny = si[screen].y_org; ny = si[screen].y_org;
nw = si[screen].width; nw = si[screen].width;
nh = si[screen].height; nh = si[screen].height;
for(c = awesomeconf->clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(IS_TILED(c, &awesomeconf->screens[screen], screen)) if(IS_TILED(c, screen))
n++; n++;
for(c = awesomeconf->clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(IS_TILED(c, &awesomeconf->screens[screen], screen)) if(IS_TILED(c, screen))
{ {
c->ismax = False; c->ismax = False;
if((i % 2 && nh / 2 > 2 * c->border) if((i % 2 && nh / 2 > 2 * c->border)
@ -81,22 +83,22 @@ layout_fibonacci(awesome_config *awesomeconf, int screen, int shape)
ny = si[screen].y_org; ny = si[screen].y_org;
i++; i++;
} }
client_resize(c, nx, ny, nw - 2 * c->border, nh - 2 * c->border, awesomeconf, client_resize(c, nx, ny, nw - 2 * c->border, nh - 2 * c->border,
awesomeconf->screens[screen].resize_hints, False); globalconf.screens[screen].resize_hints, False);
} }
p_delete(&si); p_delete(&si);
} }
void void
layout_spiral(awesome_config *awesomeconf, int screen) layout_spiral(int screen)
{ {
layout_fibonacci(awesomeconf, screen, 0); layout_fibonacci(screen, 0);
} }
void void
layout_dwindle(awesome_config *awesomeconf, int screen) layout_dwindle(int screen)
{ {
layout_fibonacci(awesomeconf, screen, 1); layout_fibonacci(screen, 1);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -22,13 +22,15 @@
#include "tag.h" #include "tag.h"
#include "layouts/floating.h" #include "layouts/floating.h"
extern awesome_config globalconf;
void void
layout_floating(awesome_config *awesomeconf, int screen) layout_floating(int screen)
{ {
Client *c; Client *c;
for(c = awesomeconf->clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(client_isvisible(c, &awesomeconf->screens[screen], screen)) if(client_isvisible(c, screen))
client_resize(c, c->rx, c->ry, c->rw, c->rh, awesomeconf, True, False); client_resize(c, c->rx, c->ry, c->rw, c->rh, True, False);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -24,17 +24,19 @@
#include "util.h" #include "util.h"
#include "layouts/max.h" #include "layouts/max.h"
extern awesome_config globalconf;
void void
layout_max(awesome_config *awesomeconf, int screen) layout_max(int screen)
{ {
Client *c; Client *c;
ScreenInfo *si = get_screen_info(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); ScreenInfo *si = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
for(c = awesomeconf->clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(IS_TILED(c, &awesomeconf->screens[screen], screen)) if(IS_TILED(c, screen))
client_resize(c, si[screen].x_org, si[screen].y_org, client_resize(c, si[screen].x_org, si[screen].y_org,
si[screen].width - 2 * c->border, si[screen].width - 2 * c->border,
si[screen].height - 2 * c->border, awesomeconf, awesomeconf->screens[screen].resize_hints, False); si[screen].height - 2 * c->border, globalconf.screens[screen].resize_hints, False);
p_delete(&si); p_delete(&si);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -28,12 +28,12 @@
#include "layout.h" #include "layout.h"
#include "layouts/tile.h" #include "layouts/tile.h"
extern awesome_config globalconf;
void void
uicb_tag_setnmaster(awesome_config *awesomeconf, uicb_tag_setnmaster(int screen, const char * arg)
int screen,
const char * arg)
{ {
Tag *curtag = get_current_tag(awesomeconf->screens[screen]); Tag *curtag = get_current_tag(screen);
Layout *curlay = curtag->layout; Layout *curlay = curtag->layout;
if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft)) if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft))
@ -42,15 +42,13 @@ uicb_tag_setnmaster(awesome_config *awesomeconf,
if((curtag->nmaster = (int) compute_new_value_from_arg(arg, (double) curtag->nmaster)) < 0) if((curtag->nmaster = (int) compute_new_value_from_arg(arg, (double) curtag->nmaster)) < 0)
curtag->nmaster = 0; curtag->nmaster = 0;
arrange(awesomeconf, screen); arrange(screen);
} }
void void
uicb_tag_setncol(awesome_config *awesomeconf, uicb_tag_setncol(int screen, const char * arg)
int screen,
const char * arg)
{ {
Tag *curtag = get_current_tag(awesomeconf->screens[screen]); Tag *curtag = get_current_tag(screen);
Layout *curlay = curtag->layout; Layout *curlay = curtag->layout;
if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft)) if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft))
@ -59,16 +57,14 @@ uicb_tag_setncol(awesome_config *awesomeconf,
if((curtag->ncol = (int) compute_new_value_from_arg(arg, (double) curtag->ncol)) < 1) if((curtag->ncol = (int) compute_new_value_from_arg(arg, (double) curtag->ncol)) < 1)
curtag->ncol = 1; curtag->ncol = 1;
arrange(awesomeconf, screen); arrange(screen);
} }
void void
uicb_tag_setmwfact(awesome_config * awesomeconf, uicb_tag_setmwfact(int screen, const char *arg)
int screen,
const char *arg)
{ {
char *newarg; char *newarg;
Tag *curtag = get_current_tag(awesomeconf->screens[screen]); Tag *curtag = get_current_tag(screen);
Layout *curlay = curtag->layout; Layout *curlay = curtag->layout;
if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft)) if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft))
@ -88,12 +84,12 @@ uicb_tag_setmwfact(awesome_config * awesomeconf,
else if(curtag->mwfact > 0.9) else if(curtag->mwfact > 0.9)
curtag->mwfact = 0.9; curtag->mwfact = 0.9;
arrange(awesomeconf, screen); arrange(screen);
p_delete(&newarg); p_delete(&newarg);
} }
static void static void
_tile(awesome_config *awesomeconf, int screen, const Bool right) _tile(int screen, const Bool right)
{ {
/* windows area geometry */ /* windows area geometry */
int wah = 0, waw = 0, wax = 0, way = 0; int wah = 0, waw = 0, wax = 0, way = 0;
@ -105,12 +101,12 @@ _tile(awesome_config *awesomeconf, int screen, const Bool right)
int real_ncol = 1, win_by_col = 1, current_col = 0; int real_ncol = 1, win_by_col = 1, current_col = 0;
ScreenInfo *screens_info = NULL; ScreenInfo *screens_info = NULL;
Client *c; Client *c;
Tag *curtag = get_current_tag(awesomeconf->screens[screen]); Tag *curtag = get_current_tag(screen);
screens_info = get_screen_info(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); screens_info = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
for(n = 0, c = awesomeconf->clients; c; c = c->next) for(n = 0, c = globalconf.clients; c; c = c->next)
if(IS_TILED(c, &awesomeconf->screens[screen], screen)) if(IS_TILED(c, screen))
n++; n++;
wah = screens_info[screen].height; wah = screens_info[screen].height;
@ -135,9 +131,9 @@ _tile(awesome_config *awesomeconf, int screen, const Bool right)
real_ncol = MIN(otherwin, curtag->ncol); real_ncol = MIN(otherwin, curtag->ncol);
for(i = 0, c = awesomeconf->clients; c; c = c->next) for(i = 0, c = globalconf.clients; c; c = c->next)
{ {
if(!IS_TILED(c, &awesomeconf->screens[screen], screen)) if(!IS_TILED(c, screen))
continue; continue;
c->ismax = False; c->ismax = False;
@ -145,7 +141,7 @@ _tile(awesome_config *awesomeconf, int screen, const Bool right)
{ /* master */ { /* master */
ny = way + i * mh; ny = way + i * mh;
nx = wax + (right ? 0 : waw - mw); nx = wax + (right ? 0 : waw - mw);
client_resize(c, nx, ny, mw - 2 * c->border, mh - 2 * c->border, awesomeconf, awesomeconf->screens[screen].resize_hints, False); client_resize(c, nx, ny, mw - 2 * c->border, mh - 2 * c->border, globalconf.screens[screen].resize_hints, False);
} }
else else
{ /* tile window */ { /* tile window */
@ -171,7 +167,7 @@ _tile(awesome_config *awesomeconf, int screen, const Bool right)
ny = way + ((i - curtag->nmaster) % win_by_col) * (nh + 2 * c->border); ny = way + ((i - curtag->nmaster) % win_by_col) * (nh + 2 * c->border);
nx = wax + current_col * (nw + 2 * c->border) + (right ? mw : 0); nx = wax + current_col * (nw + 2 * c->border) + (right ? mw : 0);
client_resize(c, nx, ny, nw, nh, awesomeconf, awesomeconf->screens[screen].resize_hints, False); client_resize(c, nx, ny, nw, nh, globalconf.screens[screen].resize_hints, False);
} }
i++; i++;
} }
@ -179,15 +175,15 @@ _tile(awesome_config *awesomeconf, int screen, const Bool right)
} }
void void
layout_tile(awesome_config *awesomeconf, int screen) layout_tile(int screen)
{ {
_tile(awesomeconf, screen, True); _tile(screen, True);
} }
void void
layout_tileleft(awesome_config *awesomeconf, int screen) layout_tileleft(int screen)
{ {
_tile(awesomeconf, screen, False); _tile(screen, False);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

52
mouse.c
View File

@ -28,31 +28,33 @@
#include "window.h" #include "window.h"
#include "layouts/floating.h" #include "layouts/floating.h"
extern awesome_config globalconf;
void void
uicb_client_movemouse(awesome_config *awesomeconf, int screen, const char *arg __attribute__ ((unused))) uicb_client_movemouse(int screen, const char *arg __attribute__ ((unused)))
{ {
int x1, y1, ocx, ocy, di, nx, ny; int x1, y1, ocx, ocy, di, nx, ny;
unsigned int dui; unsigned int dui;
Window dummy; Window dummy;
XEvent ev; XEvent ev;
ScreenInfo *si; ScreenInfo *si;
Client *c = awesomeconf->focus->client; Client *c = globalconf.focus->client;
if(!c) if(!c)
return; return;
if((get_current_layout(awesomeconf->screens[screen])->arrange != layout_floating) if((get_current_layout(screen)->arrange != layout_floating)
&& !c->isfloating) && !c->isfloating)
uicb_client_togglefloating(awesomeconf, screen, "DUMMY"); uicb_client_togglefloating(screen, "DUMMY");
else else
restack(awesomeconf, screen); restack(screen);
si = get_screen_info(c->display, c->screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); si = get_screen_info(c->display, c->screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
ocx = nx = c->x; ocx = nx = c->x;
ocy = ny = c->y; ocy = ny = c->y;
if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync, if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, awesomeconf->cursor[CurMove], CurrentTime) != GrabSuccess) None, globalconf.cursor[CurMove], CurrentTime) != GrabSuccess)
return; return;
XQueryPointer(c->display, RootWindow(c->display, c->phys_screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui); XQueryPointer(c->display, RootWindow(c->display, c->phys_screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui);
for(;;) for(;;)
@ -65,53 +67,53 @@ uicb_client_movemouse(awesome_config *awesomeconf, int screen, const char *arg _
p_delete(&si); p_delete(&si);
return; return;
case ConfigureRequest: case ConfigureRequest:
handle_event_configurerequest(&ev, awesomeconf); handle_event_configurerequest(&ev);
break; break;
case Expose: case Expose:
handle_event_expose(&ev, awesomeconf); handle_event_expose(&ev);
break; break;
case MapRequest: case MapRequest:
handle_event_maprequest(&ev, awesomeconf); handle_event_maprequest(&ev);
break; break;
case MotionNotify: case MotionNotify:
XSync(c->display, False); XSync(c->display, False);
nx = ocx + (ev.xmotion.x - x1); nx = ocx + (ev.xmotion.x - x1);
ny = ocy + (ev.xmotion.y - y1); ny = ocy + (ev.xmotion.y - y1);
if(abs(nx) < awesomeconf->screens[screen].snap + si[c->screen].x_org && nx > si[c->screen].x_org) if(abs(nx) < globalconf.screens[screen].snap + si[c->screen].x_org && nx > si[c->screen].x_org)
nx = si[c->screen].x_org; nx = si[c->screen].x_org;
else if(abs((si[c->screen].x_org + si[c->screen].width) - (nx + c->w + 2 * c->border)) < awesomeconf->screens[screen].snap) else if(abs((si[c->screen].x_org + si[c->screen].width) - (nx + c->w + 2 * c->border)) < globalconf.screens[screen].snap)
nx = si[c->screen].x_org + si[c->screen].width - c->w - 2 * c->border; nx = si[c->screen].x_org + si[c->screen].width - c->w - 2 * c->border;
if(abs(ny) < awesomeconf->screens[screen].snap + si[c->screen].y_org && ny > si[c->screen].y_org) if(abs(ny) < globalconf.screens[screen].snap + si[c->screen].y_org && ny > si[c->screen].y_org)
ny = si[c->screen].y_org; ny = si[c->screen].y_org;
else if(abs((si[c->screen].y_org + si[c->screen].height) - (ny + c->h + 2 * c->border)) < awesomeconf->screens[screen].snap) else if(abs((si[c->screen].y_org + si[c->screen].height) - (ny + c->h + 2 * c->border)) < globalconf.screens[screen].snap)
ny = si[c->screen].y_org + si[c->screen].height - c->h - 2 * c->border; ny = si[c->screen].y_org + si[c->screen].height - c->h - 2 * c->border;
client_resize(c, nx, ny, c->w, c->h, awesomeconf, False, False); client_resize(c, nx, ny, c->w, c->h, False, False);
break; break;
} }
} }
} }
void void
uicb_client_resizemouse(awesome_config *awesomeconf, int screen, const char *arg __attribute__ ((unused))) uicb_client_resizemouse(int screen, const char *arg __attribute__ ((unused)))
{ {
int ocx, ocy, nw, nh; int ocx, ocy, nw, nh;
XEvent ev; XEvent ev;
Client *c = awesomeconf->focus->client; Client *c = globalconf.focus->client;
if(!c) if(!c)
return; return;
if((get_current_layout(awesomeconf->screens[screen])->arrange != layout_floating) if((get_current_layout(screen)->arrange != layout_floating)
&& !c->isfloating) && !c->isfloating)
uicb_client_togglefloating(awesomeconf, screen, "DUMMY"); uicb_client_togglefloating(screen, "DUMMY");
else else
restack(awesomeconf, screen); restack(screen);
ocx = c->x; ocx = c->x;
ocy = c->y; ocy = c->y;
if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen), if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen),
False, MOUSEMASK, GrabModeAsync, GrabModeAsync, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, awesomeconf->cursor[CurResize], CurrentTime) != GrabSuccess) None, globalconf.cursor[CurResize], CurrentTime) != GrabSuccess)
return; return;
c->ismax = False; c->ismax = False;
XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1); XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
@ -126,13 +128,13 @@ uicb_client_resizemouse(awesome_config *awesomeconf, int screen, const char *arg
while(XCheckMaskEvent(c->display, EnterWindowMask, &ev)); while(XCheckMaskEvent(c->display, EnterWindowMask, &ev));
return; return;
case ConfigureRequest: case ConfigureRequest:
handle_event_configurerequest(&ev, awesomeconf); handle_event_configurerequest(&ev);
break; break;
case Expose: case Expose:
handle_event_expose(&ev, awesomeconf); handle_event_expose(&ev);
break; break;
case MapRequest: case MapRequest:
handle_event_maprequest(&ev, awesomeconf); handle_event_maprequest(&ev);
break; break;
case MotionNotify: case MotionNotify:
XSync(c->display, False); XSync(c->display, False);
@ -140,7 +142,7 @@ uicb_client_resizemouse(awesome_config *awesomeconf, int screen, const char *arg
nw = 1; nw = 1;
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0) if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
nh = 1; nh = 1;
client_resize(c, c->x, c->y, nw, nh, awesomeconf, True, False); client_resize(c, c->x, c->y, nw, nh, True, False);
break; break;
} }
} }

View File

@ -26,6 +26,8 @@
#include "focus.h" #include "focus.h"
#include "statusbar.h" #include "statusbar.h"
extern awesome_config globalconf;
/** Get screens info /** Get screens info
* \param disp Display ref * \param disp Display ref
* \param screen Screen number * \param screen Screen number
@ -173,21 +175,20 @@ get_phys_screen(Display *disp, int screen)
/** Move a client to a virtual screen /** Move a client to a virtual screen
* \param c the client * \param c the client
* \param acf_new the awesome_config for the new screen
* \param doresize set to True if we also move the client to the new x_org and * \param doresize set to True if we also move the client to the new x_org and
* y_org of the new screen * y_org of the new screen
*/ */
void void
move_client_to_screen(Client *c, awesome_config *awesomeconf, int new_screen, Bool doresize) move_client_to_screen(Client *c, int new_screen, Bool doresize)
{ {
Tag *tag; Tag *tag;
int old_screen = c->screen; int old_screen = c->screen;
for(tag = awesomeconf->screens[old_screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[old_screen].tags; tag; tag = tag->next)
untag_client(&awesomeconf->screens[old_screen].tclink, c, tag); untag_client(c, tag, old_screen);
/* tag client with new screen tags */ /* tag client with new screen tags */
tag_client_with_current_selected(c, &awesomeconf->screens[new_screen]); tag_client_with_current_selected(c, new_screen);
c->screen = new_screen; c->screen = new_screen;
@ -211,17 +212,17 @@ move_client_to_screen(Client *c, awesome_config *awesomeconf, int new_screen, Bo
if(c->ry + c->rh >= si[c->screen].y_org + si[c->screen].height) if(c->ry + c->rh >= si[c->screen].y_org + si[c->screen].height)
c->ry = si[c->screen].y_org + si[c->screen].height - c->rh - 2 * c->border; c->ry = si[c->screen].y_org + si[c->screen].height - c->rh - 2 * c->border;
client_resize(c, c->rx, c->ry, c->rw, c->rh, awesomeconf, True, False); client_resize(c, c->rx, c->ry, c->rw, c->rh, True, False);
p_delete(&si); p_delete(&si);
p_delete(&si_old); p_delete(&si_old);
} }
focus(c, True, awesomeconf, c->screen); focus(c, True, c->screen);
/* redraw statusbar on all screens */ /* redraw statusbar on all screens */
statusbar_draw(awesomeconf, old_screen); statusbar_draw(old_screen);
statusbar_draw(awesomeconf, new_screen); statusbar_draw(new_screen);
} }
/** Move mouse pointer to x_org and y_xorg of specified screen /** Move mouse pointer to x_org and y_xorg of specified screen
@ -243,14 +244,13 @@ move_mouse_pointer_to_screen(Display *disp, int screen)
/** Switch focus to a specified screen /** Switch focus to a specified screen
* \param awesomeconf awesome config ref
* \param arg screen number * \param arg screen number
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_screen_focus(awesome_config *awesomeconf, int screen, const char *arg) uicb_screen_focus(int screen, const char *arg)
{ {
int new_screen, numscreens = get_screen_count(awesomeconf->display); int new_screen, numscreens = get_screen_count(globalconf.display);
if(arg) if(arg)
new_screen = compute_new_value_from_arg(arg, screen); new_screen = compute_new_value_from_arg(arg, screen);
@ -262,28 +262,25 @@ uicb_screen_focus(awesome_config *awesomeconf, int screen, const char *arg)
if (new_screen > (numscreens - 1)) if (new_screen > (numscreens - 1))
new_screen = 0; new_screen = 0;
focus(focus_get_latest_client_for_tag(awesomeconf->focus, focus(focus_get_latest_client_for_tag(globalconf.focus,
awesomeconf->screens[new_screen].tclink, new_screen,
get_current_tag(awesomeconf->screens[new_screen])), get_current_tag(new_screen)),
True, awesomeconf, new_screen); True, new_screen);
move_mouse_pointer_to_screen(awesomeconf->display, new_screen); move_mouse_pointer_to_screen(globalconf.display, new_screen);
} }
/** Move client to a virtual screen (if Xinerama is active) /** Move client to a virtual screen (if Xinerama is active)
* \param awesomeconf awesome config
* \param arg screen number * \param arg screen number
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_movetoscreen(awesome_config * awesomeconf, uicb_client_movetoscreen(int screen __attribute__ ((unused)), const char *arg)
int screen __attribute__ ((unused)),
const char *arg)
{ {
int new_screen, prev_screen; int new_screen, prev_screen;
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
if(!sel || !XineramaIsActive(awesomeconf->display)) if(!sel || !XineramaIsActive(globalconf.display))
return; return;
if(arg) if(arg)
@ -291,15 +288,15 @@ uicb_client_movetoscreen(awesome_config * awesomeconf,
else else
new_screen = sel->screen + 1; new_screen = sel->screen + 1;
if(new_screen >= get_screen_count(awesomeconf->display)) if(new_screen >= get_screen_count(globalconf.display))
new_screen = 0; new_screen = 0;
else if(new_screen < 0) else if(new_screen < 0)
new_screen = get_screen_count(awesomeconf->display) - 1; new_screen = get_screen_count(globalconf.display) - 1;
prev_screen = sel->screen; prev_screen = sel->screen;
move_client_to_screen(sel, awesomeconf, new_screen, True); move_client_to_screen(sel, new_screen, True);
move_mouse_pointer_to_screen(awesomeconf->display, new_screen); move_mouse_pointer_to_screen(globalconf.display, new_screen);
arrange(awesomeconf, prev_screen); arrange(prev_screen);
arrange(awesomeconf, new_screen); arrange(new_screen);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -33,7 +33,7 @@ ScreenInfo * get_display_info(Display *, int, Statusbar *, Padding *);
int get_screen_bycoord(Display *, int, int); int get_screen_bycoord(Display *, int, int);
int get_screen_count(Display *); int get_screen_count(Display *);
int get_phys_screen(Display *, int); int get_phys_screen(Display *, int);
void move_client_to_screen(Client *, awesome_config *, int, Bool); void move_client_to_screen(Client *, int, Bool);
UICB_PROTO(uicb_screen_focus); UICB_PROTO(uicb_screen_focus);
UICB_PROTO(uicb_client_movetoscreen); UICB_PROTO(uicb_client_movetoscreen);

View File

@ -30,31 +30,33 @@
#include "tag.h" #include "tag.h"
#include "widget.h" #include "widget.h"
extern awesome_config globalconf;
void void
statusbar_draw(awesome_config *awesomeconf, int screen) statusbar_draw(int screen)
{ {
int phys_screen = get_phys_screen(awesomeconf->display, screen); int phys_screen = get_phys_screen(globalconf.display, screen);
VirtScreen vscreen; VirtScreen vscreen;
Widget *widget; Widget *widget;
int left = 0, right = 0; int left = 0, right = 0;
vscreen = awesomeconf->screens[screen]; vscreen = globalconf.screens[screen];
/* don't waste our time */ /* don't waste our time */
if(vscreen.statusbar.position == BarOff) if(vscreen.statusbar.position == BarOff)
return; return;
DrawCtx *ctx = draw_get_context(awesomeconf->display, phys_screen, DrawCtx *ctx = draw_get_context(globalconf.display, phys_screen,
vscreen.statusbar.width, vscreen.statusbar.height); vscreen.statusbar.width, vscreen.statusbar.height);
for(widget = vscreen.statusbar.widgets; widget; widget = widget->next) for(widget = vscreen.statusbar.widgets; widget; widget = widget->next)
if (widget->alignment == AlignLeft) if (widget->alignment == AlignLeft)
left += widget->draw(ctx, awesomeconf, vscreen, screen, left, (left + right), AlignLeft); left += widget->draw(ctx, screen, left, (left + right), AlignLeft);
else if (widget->alignment == AlignRight) else if (widget->alignment == AlignRight)
right += widget->draw(ctx, awesomeconf, vscreen, screen, right, (left + right), AlignRight); right += widget->draw(ctx, screen, right, (left + right), AlignRight);
for(widget = vscreen.statusbar.widgets; widget; widget = widget->next) for(widget = vscreen.statusbar.widgets; widget; widget = widget->next)
if (widget->alignment == AlignFlex) if (widget->alignment == AlignFlex)
left += widget->draw(ctx, awesomeconf, vscreen, screen, left, (left + right), AlignFlex); left += widget->draw(ctx, screen, left, (left + right), AlignFlex);
if(vscreen.statusbar.position == BarRight || vscreen.statusbar.position == BarLeft) if(vscreen.statusbar.position == BarRight || vscreen.statusbar.position == BarLeft)
{ {
@ -63,21 +65,21 @@ statusbar_draw(awesome_config *awesomeconf, int screen)
d = draw_rotate(ctx, phys_screen, M_PI_2, vscreen.statusbar.height, 0); d = draw_rotate(ctx, phys_screen, M_PI_2, vscreen.statusbar.height, 0);
else else
d = draw_rotate(ctx, phys_screen, - M_PI_2, 0, vscreen.statusbar.width); d = draw_rotate(ctx, phys_screen, - M_PI_2, 0, vscreen.statusbar.width);
XCopyArea(awesomeconf->display, d, XCopyArea(globalconf.display, d,
vscreen.statusbar.window, vscreen.statusbar.window,
DefaultGC(awesomeconf->display, phys_screen), 0, 0, DefaultGC(globalconf.display, phys_screen), 0, 0,
vscreen.statusbar.height, vscreen.statusbar.height,
vscreen.statusbar.width, 0, 0); vscreen.statusbar.width, 0, 0);
XFreePixmap(awesomeconf->display, d); XFreePixmap(globalconf.display, d);
} }
else else
XCopyArea(awesomeconf->display, ctx->drawable, XCopyArea(globalconf.display, ctx->drawable,
vscreen.statusbar.window, vscreen.statusbar.window,
DefaultGC(awesomeconf->display, phys_screen), 0, 0, DefaultGC(globalconf.display, phys_screen), 0, 0,
vscreen.statusbar.width, vscreen.statusbar.height, 0, 0); vscreen.statusbar.width, vscreen.statusbar.height, 0, 0);
draw_free_context(ctx); draw_free_context(ctx);
XSync(awesomeconf->display, False); XSync(globalconf.display, False);
} }
void void
@ -168,38 +170,34 @@ statusbar_get_position_from_str(const char * pos)
} }
void void
uicb_statusbar_toggle(awesome_config *awesomeconf, uicb_statusbar_toggle(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
if(awesomeconf->screens[screen].statusbar.position == BarOff) if(globalconf.screens[screen].statusbar.position == BarOff)
awesomeconf->screens[screen].statusbar.position = (awesomeconf->screens[screen].statusbar.dposition == BarOff) ? BarTop : awesomeconf->screens[screen].statusbar.dposition; globalconf.screens[screen].statusbar.position = (globalconf.screens[screen].statusbar.dposition == BarOff) ? BarTop : globalconf.screens[screen].statusbar.dposition;
else else
awesomeconf->screens[screen].statusbar.position = BarOff; globalconf.screens[screen].statusbar.position = BarOff;
statusbar_update_position(awesomeconf->display, awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); statusbar_update_position(globalconf.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
arrange(awesomeconf, screen); arrange(screen);
} }
void void
uicb_statusbar_set_position(awesome_config *awesomeconf, uicb_statusbar_set_position(int screen, const char *arg)
int screen,
const char *arg)
{ {
awesomeconf->screens[screen].statusbar.dposition = globalconf.screens[screen].statusbar.dposition =
awesomeconf->screens[screen].statusbar.position = globalconf.screens[screen].statusbar.position =
statusbar_get_position_from_str(arg); statusbar_get_position_from_str(arg);
statusbar_update_position(awesomeconf->display, awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); statusbar_update_position(globalconf.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
} }
void void
uicb_statusbar_set_text(awesome_config *awesomeconf, int screen, const char *arg) uicb_statusbar_set_text(int screen, const char *arg)
{ {
if(!arg) if(!arg)
return; return;
a_strncpy(awesomeconf->screens[screen].statustext, a_strncpy(globalconf.screens[screen].statustext,
sizeof(awesomeconf->screens[screen].statustext), arg, a_strlen(arg)); sizeof(globalconf.screens[screen].statustext), arg, a_strlen(arg));
statusbar_draw(awesomeconf, screen); statusbar_draw(screen);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -25,7 +25,7 @@
#include "common.h" #include "common.h"
void statusbar_init(Display *, int, Statusbar *, Cursor, XftFont *, Padding *); void statusbar_init(Display *, int, Statusbar *, Cursor, XftFont *, Padding *);
void statusbar_draw(awesome_config *, int); void statusbar_draw(int);
int statusbar_get_position_from_str(const char *); int statusbar_get_position_from_str(const char *);
void statusbar_update_position(Display *, Statusbar, Padding *); void statusbar_update_position(Display *, Statusbar, Padding *);

181
tag.c
View File

@ -28,17 +28,18 @@
#include "util.h" #include "util.h"
#include "rules.h" #include "rules.h"
extern awesome_config globalconf;
static void static void
detach_tagclientlink(TagClientLink **head, TagClientLink *tc) detach_tagclientlink(int screen, TagClientLink *tc)
{ {
TagClientLink *tmp; TagClientLink *tmp;
if(*head == tc) if(globalconf.screens[screen].tclink == tc)
*head = tc->next; globalconf.screens[screen].tclink = tc->next;
else else
{ {
for(tmp = *head; tmp && tmp->next != tc; tmp = tmp->next); for(tmp = globalconf.screens[screen].tclink; tmp && tmp->next != tc; tmp = tmp->next);
tmp->next = tc->next; tmp->next = tc->next;
} }
@ -46,21 +47,21 @@ detach_tagclientlink(TagClientLink **head, TagClientLink *tc)
} }
void void
tag_client(TagClientLink **head, Client *c, Tag *t) tag_client(Client *c, Tag *t, int screen)
{ {
TagClientLink *tc, *new_tc; TagClientLink *tc, *new_tc;
/* don't tag twice */ /* don't tag twice */
if(is_client_tagged(*head, c, t)) if(is_client_tagged(c, t, screen))
return; return;
new_tc = p_new(TagClientLink, 1); new_tc = p_new(TagClientLink, 1);
if(!*head) if(!globalconf.screens[screen].tclink)
*head = new_tc; globalconf.screens[screen].tclink = new_tc;
else else
{ {
for(tc = *head; tc->next; tc = tc->next); for(tc = globalconf.screens[screen].tclink; tc->next; tc = tc->next);
tc->next = new_tc; tc->next = new_tc;
} }
@ -69,64 +70,66 @@ tag_client(TagClientLink **head, Client *c, Tag *t)
} }
void void
untag_client(TagClientLink **head, Client *c, Tag *t) untag_client(Client *c, Tag *t, int screen)
{ {
TagClientLink *tc; TagClientLink *tc;
for(tc = *head; tc; tc = tc->next) for(tc = globalconf.screens[screen].tclink; tc; tc = tc->next)
if(tc->client == c && tc->tag == t) if(tc->client == c && tc->tag == t)
detach_tagclientlink(head, tc); detach_tagclientlink(screen, tc);
} }
Bool Bool
is_client_tagged(TagClientLink *head, Client *c, Tag *t) is_client_tagged(Client *c, Tag *t, int screen)
{ {
TagClientLink *tc; TagClientLink *tc;
for(tc = head; tc; tc = tc->next) for(tc = globalconf.screens[screen].tclink; tc; tc = tc->next)
if(tc->client == c && tc->tag == t) if(tc->client == c && tc->tag == t)
return True; return True;
return False; return False;
} }
void void
tag_client_with_current_selected(Client *c, VirtScreen *screen) tag_client_with_current_selected(Client *c, int screen)
{ {
Tag *tag; Tag *tag;
VirtScreen vscreen;
for(tag = screen->tags; tag; tag = tag->next) vscreen = globalconf.screens[screen];
for(tag = vscreen.tags; tag; tag = tag->next)
if(tag->selected) if(tag->selected)
tag_client(&screen->tclink, c, tag); tag_client(c, tag, screen);
else else
untag_client(&screen->tclink, c, tag); untag_client(c, tag, screen);
} }
void void
tag_client_with_rules(Client *c, awesome_config *awesomeconf) tag_client_with_rules(Client *c)
{ {
Rule *r; Rule *r;
Tag *tag; Tag *tag;
Bool matched = False; Bool matched = False;
for(r = awesomeconf->rules; r; r = r->next) for(r = globalconf.rules; r; r = r->next)
if(client_match_rule(c, r)) if(client_match_rule(c, r))
{ {
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
if(r->screen != RULE_NOSCREEN && r->screen != c->screen) if(r->screen != RULE_NOSCREEN && r->screen != c->screen)
move_client_to_screen(c, awesomeconf, r->screen, True); move_client_to_screen(c, r->screen, True);
for(tag = awesomeconf->screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
if(is_tag_match_rules(tag, r)) if(is_tag_match_rules(tag, r))
{ {
matched = True; matched = True;
tag_client(&awesomeconf->screens[c->screen].tclink, c, tag); tag_client(c, tag, c->screen);
} }
else else
untag_client(&awesomeconf->screens[c->screen].tclink, c, tag); untag_client(c, tag, c->screen);
if(!matched) if(!matched)
tag_client_with_current_selected(c, &awesomeconf->screens[c->screen]); tag_client_with_current_selected(c, c->screen);
break; break;
} }
} }
@ -136,13 +139,11 @@ tag_client_with_rules(Client *c, awesome_config *awesomeconf)
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_tag(awesome_config *awesomeconf, uicb_client_tag(int screen, const char *arg)
int screen,
const char *arg)
{ {
int tag_id = -1; int tag_id = -1;
Tag *tag, *target_tag; Tag *tag, *target_tag;
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
@ -152,22 +153,22 @@ uicb_client_tag(awesome_config *awesomeconf,
tag_id = atoi(arg) - 1; tag_id = atoi(arg) - 1;
if(tag_id != -1) if(tag_id != -1)
{ {
for(target_tag = awesomeconf->screens[screen].tags; target_tag && tag_id > 0; for(target_tag = globalconf.screens[screen].tags; target_tag && tag_id > 0;
target_tag = target_tag->next, tag_id--); target_tag = target_tag->next, tag_id--);
if(target_tag) if(target_tag)
{ {
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
untag_client(&awesomeconf->screens[screen].tclink, sel, tag); untag_client(sel, tag, screen);
tag_client(&awesomeconf->screens[screen].tclink, sel, target_tag); tag_client(sel, target_tag, screen);
} }
} }
} }
else else
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag_client(&awesomeconf->screens[screen].tclink, sel, tag); tag_client(sel, tag, screen);
client_saveprops(sel, &awesomeconf->screens[screen]); client_saveprops(sel, screen);
arrange(awesomeconf, screen); arrange(screen);
} }
/** Toggle floating state of a client /** Toggle floating state of a client
@ -175,11 +176,9 @@ uicb_client_tag(awesome_config *awesomeconf,
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_togglefloating(awesome_config * awesomeconf, uicb_client_togglefloating(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
@ -187,12 +186,12 @@ uicb_client_togglefloating(awesome_config * awesomeconf,
sel->isfloating = !sel->isfloating; sel->isfloating = !sel->isfloating;
if (arg == NULL) if (arg == NULL)
client_resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, awesomeconf, True, False); client_resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True, False);
else else
client_resize(sel, sel->x, sel->y, sel->w, sel->h, awesomeconf, True, True); client_resize(sel, sel->x, sel->y, sel->w, sel->h, True, True);
client_saveprops(sel, &awesomeconf->screens[screen]); client_saveprops(sel, screen);
arrange(awesomeconf, screen); arrange(screen);
} }
/** Toggle a tag on client /** Toggle a tag on client
@ -200,11 +199,9 @@ uicb_client_togglefloating(awesome_config * awesomeconf,
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_toggletag(awesome_config *awesomeconf, uicb_client_toggletag(int screen, const char *arg)
int screen,
const char *arg)
{ {
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
int i; int i;
Tag *tag, *target_tag; Tag *tag, *target_tag;
@ -214,32 +211,32 @@ uicb_client_toggletag(awesome_config *awesomeconf,
if(arg) if(arg)
{ {
i = atoi(arg) - 1; i = atoi(arg) - 1;
for(target_tag = awesomeconf->screens[screen].tags; target_tag && i > 0; for(target_tag = globalconf.screens[screen].tags; target_tag && i > 0;
target_tag = target_tag->next, i--); target_tag = target_tag->next, i--);
if(target_tag) if(target_tag)
{ {
if(is_client_tagged(awesomeconf->screens[screen].tclink, sel, target_tag)) if(is_client_tagged(sel, target_tag, screen))
untag_client(&awesomeconf->screens[screen].tclink, sel, target_tag); untag_client(sel, target_tag, screen);
else else
tag_client(&awesomeconf->screens[screen].tclink, sel, target_tag); tag_client(sel, target_tag, screen);
} }
/* check that there's at least one tag selected for this client*/ /* check that there's at least one tag selected for this client*/
for(tag = awesomeconf->screens[screen].tags; tag for(tag = globalconf.screens[screen].tags; tag
&& !is_client_tagged(awesomeconf->screens[screen].tclink, sel, tag); tag = tag->next) && !is_client_tagged(sel, tag, screen); tag = tag->next)
if(!tag) if(!tag)
tag_client(&awesomeconf->screens[screen].tclink, sel, target_tag); tag_client(sel, target_tag, screen);
} }
else else
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
if(is_client_tagged(awesomeconf->screens[screen].tclink, sel, tag)) if(is_client_tagged(sel, tag, screen))
tag_client(&awesomeconf->screens[screen].tclink, sel, tag); tag_client(sel, tag, screen);
else else
untag_client(&awesomeconf->screens[screen].tclink, sel, tag); untag_client(sel, tag, screen);
client_saveprops(sel, &awesomeconf->screens[screen]); client_saveprops(sel, screen);
arrange(awesomeconf, screen); arrange(screen);
} }
/** Add a tag to viewed tags /** Add a tag to viewed tags
@ -247,9 +244,7 @@ uicb_client_toggletag(awesome_config *awesomeconf,
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_tag_toggleview(awesome_config *awesomeconf, uicb_tag_toggleview(int screen, const char *arg)
int screen,
const char *arg)
{ {
int i; int i;
Tag *tag, *target_tag; Tag *tag, *target_tag;
@ -257,34 +252,31 @@ uicb_tag_toggleview(awesome_config *awesomeconf,
if(arg) if(arg)
{ {
i = atoi(arg) - 1; i = atoi(arg) - 1;
for(target_tag = awesomeconf->screens[screen].tags; target_tag && i > 0; for(target_tag = globalconf.screens[screen].tags; target_tag && i > 0;
target_tag = target_tag->next, i--); target_tag = target_tag->next, i--);
if(target_tag) if(target_tag)
target_tag->selected = !target_tag->selected; target_tag->selected = !target_tag->selected;
/* check that there's at least one tag selected */ /* check that there's at least one tag selected */
for(tag = awesomeconf->screens[screen].tags; tag && !tag->selected; tag = tag->next); for(tag = globalconf.screens[screen].tags; tag && !tag->selected; tag = tag->next);
if(!tag) if(!tag)
target_tag->selected = True; target_tag->selected = True;
} }
else else
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag->selected = !tag->selected; tag->selected = !tag->selected;
saveawesomeprops(awesomeconf, screen); saveawesomeprops(screen);
arrange(awesomeconf, screen); arrange(screen);
} }
/** View tag /** View tag
* \param awesomeconf awesome config ref
* \param arg tag to view * \param arg tag to view
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_tag_view(awesome_config *awesomeconf, uicb_tag_view(int screen, const char *arg)
int screen,
const char *arg)
{ {
int i; int i;
Tag *tag, *target_tag; Tag *tag, *target_tag;
@ -292,43 +284,40 @@ uicb_tag_view(awesome_config *awesomeconf,
if(arg) if(arg)
{ {
i = atoi(arg) - 1; i = atoi(arg) - 1;
for(target_tag = awesomeconf->screens[screen].tags; target_tag && i > 0; for(target_tag = globalconf.screens[screen].tags; target_tag && i > 0;
target_tag = target_tag->next, i--); target_tag = target_tag->next, i--);
if(target_tag) if(target_tag)
{ {
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag->selected = False; tag->selected = False;
target_tag->selected = True; target_tag->selected = True;
} }
} }
else else
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag->selected = True; tag->selected = True;
saveawesomeprops(awesomeconf, screen); saveawesomeprops(screen);
arrange(awesomeconf, screen); arrange(screen);
} }
/** View previously selected tags /** View previously selected tags
* \param awesomeconf awesome config ref
* \param arg unused * \param arg unused
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_tag_prev_selected(awesome_config *awesomeconf, uicb_tag_prev_selected(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Tag *tag; Tag *tag;
Bool t; Bool t;
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
{ {
t = tag->selected; t = tag->selected;
tag->selected = tag->was_selected; tag->selected = tag->was_selected;
tag->was_selected = t; tag->was_selected = t;
} }
arrange(awesomeconf, screen); arrange(screen);
} }
/** View next tag /** View next tag
@ -336,11 +325,9 @@ uicb_tag_prev_selected(awesome_config *awesomeconf,
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_tag_viewnext(awesome_config *awesomeconf, uicb_tag_viewnext(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Tag *curtag = get_current_tag(awesomeconf->screens[screen]); Tag *curtag = get_current_tag(screen);
if(!curtag->next) if(!curtag->next)
return; return;
@ -348,8 +335,8 @@ uicb_tag_viewnext(awesome_config *awesomeconf,
curtag->selected = False; curtag->selected = False;
curtag->next->selected = True; curtag->next->selected = True;
saveawesomeprops(awesomeconf, screen); saveawesomeprops(screen);
arrange(awesomeconf, screen); arrange(screen);
} }
/** View previous tag /** View previous tag
@ -357,19 +344,17 @@ uicb_tag_viewnext(awesome_config *awesomeconf,
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_tag_viewprev(awesome_config *awesomeconf, uicb_tag_viewprev(int screen, const char *arg __attribute__ ((unused)))
int screen,
const char *arg __attribute__ ((unused)))
{ {
Tag *tag, *curtag = get_current_tag(awesomeconf->screens[screen]); Tag *tag, *curtag = get_current_tag(screen);
for(tag = awesomeconf->screens[screen].tags; tag && tag->next != curtag; tag = tag->next); for(tag = globalconf.screens[screen].tags; tag && tag->next != curtag; tag = tag->next);
if(tag) if(tag)
{ {
tag->selected = True; tag->selected = True;
curtag->selected = False; curtag->selected = False;
saveawesomeprops(awesomeconf, screen); saveawesomeprops(screen);
arrange(awesomeconf, screen); arrange(screen);
} }
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

12
tag.h
View File

@ -25,13 +25,13 @@
#include "client.h" #include "client.h"
/** Check if a client is tiled */ /** Check if a client is tiled */
#define IS_TILED(client, scr, screen) (client && !client->isfloating && client_isvisible(client, scr, screen)) #define IS_TILED(client, screen) (client && !client->isfloating && client_isvisible(client, screen))
void tag_client(TagClientLink **, Client *, Tag *); void tag_client(Client *, Tag *, int);
void untag_client(TagClientLink **, Client *, Tag *); void untag_client(Client *, Tag *, int);
Bool is_client_tagged(TagClientLink *, Client *, Tag *); Bool is_client_tagged(Client *, Tag *, int);
void tag_client_with_current_selected(Client *, VirtScreen *); void tag_client_with_current_selected(Client *, int);
void tag_client_with_rules(Client *, awesome_config *); void tag_client_with_rules(Client *);
UICB_PROTO(uicb_client_tag); UICB_PROTO(uicb_client_tag);
UICB_PROTO(uicb_client_togglefloating); UICB_PROTO(uicb_client_togglefloating);

10
uicb.c
View File

@ -31,6 +31,8 @@
#include "focus.h" #include "focus.h"
#include "layouts/tile.h" #include "layouts/tile.h"
extern awesome_config globalconf;
const NameFuncLink UicbList[] = const NameFuncLink UicbList[] =
{ {
/* xutil.c */ /* xutil.c */
@ -87,7 +89,7 @@ run_uicb(char *cmd, awesome_config *awesomeconf)
char *p; char *p;
const char *arg; const char *arg;
int screen, len; int screen, len;
void (*uicb) (awesome_config *, int, const char *); void (*uicb) (int, const char *);
len = strlen(cmd); len = strlen(cmd);
p = strtok(cmd, " "); p = strtok(cmd, " ");
@ -117,12 +119,12 @@ run_uicb(char *cmd, awesome_config *awesomeconf)
else else
arg = NULL; arg = NULL;
uicb(awesomeconf, screen, arg); uicb(screen, arg);
return 0; return 0;
} }
int int
parse_control(char *cmd, awesome_config *awesomeconf) parse_control(char *cmd)
{ {
char *p, *curcmd = cmd; char *p, *curcmd = cmd;
@ -132,7 +134,7 @@ parse_control(char *cmd, awesome_config *awesomeconf)
while((p = strchr(curcmd, '\n'))) while((p = strchr(curcmd, '\n')))
{ {
*p = '\0'; *p = '\0';
run_uicb(curcmd, awesomeconf); run_uicb(curcmd, &globalconf);
curcmd = p + 1; curcmd = p + 1;
} }

2
uicb.h
View File

@ -24,7 +24,7 @@
#include "config.h" #include "config.h"
int parse_control(char *, awesome_config *); int parse_control(char *);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

View File

@ -1,18 +1,15 @@
#include "util.h" #include "util.h"
#include "widget.h" #include "widget.h"
extern awesome_config globalconf;
static char name[] = "focustitle"; static char name[] = "focustitle";
static int static int
focustitle_draw(DrawCtx *ctx, focustitle_draw(DrawCtx *ctx, int screen, int offset, int used, int align)
awesome_config *awesomeconf __attribute__ ((unused)),
VirtScreen vscreen,
int screen __attribute__ ((unused)),
int offset,
int used,
int align)
{ {
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
VirtScreen vscreen = globalconf.screens[screen];
int location = calculate_offset(vscreen.statusbar.width, 0, offset, align); int location = calculate_offset(vscreen.statusbar.width, 0, offset, align);
if(sel) if(sel)

View File

@ -2,18 +2,17 @@
#include "util.h" #include "util.h"
#include "layout.h" #include "layout.h"
extern awesome_config globalconf;
static char name[] = "layoutinfo"; static char name[] = "layoutinfo";
static int static int
layoutinfo_draw(DrawCtx *ctx, layoutinfo_draw(DrawCtx *ctx, int screen, int offset,
awesome_config *awesomeconf __attribute__ ((unused)),
VirtScreen vscreen,
int screen __attribute__ ((unused)),
int offset,
int used __attribute__ ((unused)), int used __attribute__ ((unused)),
int align __attribute__ ((unused))) int align __attribute__ ((unused)))
{ {
int width = 0, location; int width = 0, location;
VirtScreen vscreen = globalconf.screens[screen];
Layout *l; Layout *l;
for(l = vscreen.layouts ; l; l = l->next) for(l = vscreen.layouts ; l; l = l->next)
width = MAX(width, (textwidth(ctx, vscreen.font, l->symbol))); width = MAX(width, (textwidth(ctx, vscreen.font, l->symbol)));
@ -22,7 +21,7 @@ layoutinfo_draw(DrawCtx *ctx,
width, width,
vscreen.statusbar.height, vscreen.statusbar.height,
vscreen.font, vscreen.font,
get_current_layout(vscreen)->symbol, get_current_layout(screen)->symbol,
vscreen.colors_normal); vscreen.colors_normal);
return width; return width;
} }

View File

@ -3,6 +3,8 @@
#include "widget.h" #include "widget.h"
#include "tag.h" #include "tag.h"
extern awesome_config globalconf;
static char name[] = "taglist"; static char name[] = "taglist";
/** Check if at least a client is tagged with tag number t and is on screen /** Check if at least a client is tagged with tag number t and is on screen
@ -17,22 +19,21 @@ isoccupied(TagClientLink *tc, int screen, Client *head, Tag *t)
Client *c; Client *c;
for(c = head; c; c = c->next) for(c = head; c; c = c->next)
if(c->screen == screen && is_client_tagged(tc, c, t)) if(c->screen == screen && is_client_tagged(c, t, screen))
return True; return True;
return False; return False;
} }
static int static int
taglist_draw(DrawCtx *ctx, taglist_draw(DrawCtx *ctx,
awesome_config *awesomeconf,
VirtScreen vscreen,
int screen, int screen,
int offset, int offset,
int used __attribute__ ((unused)), int used __attribute__ ((unused)),
int align __attribute__ ((unused))) int align __attribute__ ((unused)))
{ {
Tag *tag; Tag *tag;
Client *sel = awesomeconf->focus->client; Client *sel = globalconf.focus->client;
VirtScreen vscreen = globalconf.screens[screen];
int w = 0, width = 0, location; int w = 0, width = 0, location;
int flagsize; int flagsize;
XColor *colors; XColor *colors;
@ -55,9 +56,9 @@ taglist_draw(DrawCtx *ctx,
colors = vscreen.colors_normal; colors = vscreen.colors_normal;
drawtext(ctx, location + width, 0, w, drawtext(ctx, location + width, 0, w,
vscreen.statusbar.height, vscreen.font, tag->name, colors); vscreen.statusbar.height, vscreen.font, tag->name, colors);
if(isoccupied(vscreen.tclink, screen, awesomeconf->clients, tag)) if(isoccupied(vscreen.tclink, screen, globalconf.clients, tag))
drawrectangle(ctx, location + width, 0, flagsize, flagsize, drawrectangle(ctx, location + width, 0, flagsize, flagsize,
sel && is_client_tagged(vscreen.tclink, sel, tag), sel && is_client_tagged(sel, tag, screen),
colors[ColFG]); colors[ColFG]);
width += w; width += w;
} }

View File

@ -1,17 +1,18 @@
#include "util.h" #include "util.h"
#include "widget.h" #include "widget.h"
extern awesome_config globalconf;
static char name[] = "textbox"; static char name[] = "textbox";
static int static int
textbox_draw(DrawCtx *ctx, textbox_draw(DrawCtx *ctx,
awesome_config *awesomeconf __attribute__ ((unused)),
VirtScreen vscreen,
int screen __attribute__ ((unused)), int screen __attribute__ ((unused)),
int offset, int offset,
int used __attribute__ ((unused)), int used __attribute__ ((unused)),
int align) int align)
{ {
VirtScreen vscreen = globalconf.screens[screen];
int width = textwidth(ctx, vscreen.font, vscreen.statustext); int width = textwidth(ctx, vscreen.font, vscreen.statustext);
int location = calculate_offset(vscreen.statusbar.width, width, offset, align); int location = calculate_offset(vscreen.statusbar.width, width, offset, align);
drawtext(ctx, location, 0, width, vscreen.statusbar.height, drawtext(ctx, location, 0, width, vscreen.statusbar.height,

View File

@ -25,6 +25,8 @@
#include "window.h" #include "window.h"
#include "util.h" #include "util.h"
extern awesome_config globalconf;
/** Set client WM_STATE property /** Set client WM_STATE property
* \param disp Display ref * \param disp Display ref
* \param win Window * \param win Window
@ -89,11 +91,9 @@ window_configure(Display *disp, Window win, int x, int y, int w, int h, int bord
* \param focused True if client is focused * \param focused True if client is focused
* \param raised True if the client is above other clients * \param raised True if the client is above other clients
* \param modkey Mod key mask * \param modkey Mod key mask
* \param numlockmask Numlock mask
*/ */
void void
window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool raised, window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool raised)
Button *buttons_root, Button *buttons_client, unsigned int numlockmask)
{ {
Button *b; Button *b;
@ -105,15 +105,15 @@ window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool rai
XGrabButton(disp, Button1, NoSymbol, win, False, XGrabButton(disp, Button1, NoSymbol, win, False,
BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); BUTTONMASK, GrabModeSync, GrabModeAsync, None, None);
for(b = buttons_client; b; b = b->next) for(b = globalconf.buttons.client; b; b = b->next)
{ {
XGrabButton(disp, b->button, b->mod, win, False, BUTTONMASK, XGrabButton(disp, b->button, b->mod, win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, b->button, b->mod | LockMask, win, False, XGrabButton(disp, b->button, b->mod | LockMask, win, False,
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, b->button, b->mod | numlockmask, win, False, XGrabButton(disp, b->button, b->mod | globalconf.numlockmask, win, False,
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, b->button, b->mod | numlockmask | LockMask, XGrabButton(disp, b->button, b->mod | globalconf.numlockmask | LockMask,
win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
} }
@ -124,7 +124,7 @@ window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool rai
XGrabButton(disp, AnyButton, AnyModifier, win, False, BUTTONMASK, XGrabButton(disp, AnyButton, AnyModifier, win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
for(b = buttons_root; b; b = b->next) for(b = globalconf.buttons.root; b; b = b->next)
{ {
XGrabButton(disp, b->button, b->mod, XGrabButton(disp, b->button, b->mod,
RootWindow(disp, screen), False, BUTTONMASK, RootWindow(disp, screen), False, BUTTONMASK,
@ -132,10 +132,10 @@ window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool rai
XGrabButton(disp, b->button, b->mod | LockMask, XGrabButton(disp, b->button, b->mod | LockMask,
RootWindow(disp, screen), False, BUTTONMASK, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, b->button, b->mod | numlockmask, XGrabButton(disp, b->button, b->mod | globalconf.numlockmask,
RootWindow(disp, screen), False, BUTTONMASK, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, b->button, b->mod | numlockmask | LockMask, XGrabButton(disp, b->button, b->mod | globalconf.numlockmask | LockMask,
RootWindow(disp, screen), False, BUTTONMASK, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
} }

View File

@ -30,7 +30,7 @@
int window_setstate(Display *, Window, long); int window_setstate(Display *, Window, long);
long window_getstate(Display *, Window); long window_getstate(Display *, Window);
Status window_configure(Display *, Window, int, int, int, int, int); Status window_configure(Display *, Window, int, int, int, int, int);
void window_grabbuttons(Display *, int, Window, Bool, Bool, Button *, Button *, unsigned int); void window_grabbuttons(Display *, int, Window, Bool, Bool);
void window_setshape(Display *, int, Window); void window_setshape(Display *, int, Window);
void window_settrans(Display *, Window, double); void window_settrans(Display *, Window, double);

21
xutil.c
View File

@ -27,23 +27,22 @@
#include "util.h" #include "util.h"
#include "xutil.h" #include "xutil.h"
extern awesome_config globalconf;
void void
uicb_exec(awesome_config * awesomeconf, uicb_exec(int screen __attribute__ ((unused)), const char *arg)
int screen __attribute__ ((unused)),
const char *arg)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
if(awesomeconf->display) if(globalconf.display)
close(ConnectionNumber(awesomeconf->display)); close(ConnectionNumber(globalconf.display));
sscanf(arg, "%s", path); sscanf(arg, "%s", path);
execlp(path, arg, NULL); execlp(path, arg, NULL);
} }
void void
uicb_spawn(awesome_config * awesomeconf, uicb_spawn(int screen, const char *arg)
int screen,
const char *arg)
{ {
static char *shell = NULL; static char *shell = NULL;
char *display = NULL; char *display = NULL;
@ -54,7 +53,7 @@ uicb_spawn(awesome_config * awesomeconf,
if(!arg) if(!arg)
return; return;
if(!XineramaIsActive(awesomeconf->display) && (tmp = getenv("DISPLAY"))) if(!XineramaIsActive(globalconf.display) && (tmp = getenv("DISPLAY")))
{ {
display = a_strdup(tmp); display = a_strdup(tmp);
if((tmp = strrchr(display, '.'))) if((tmp = strrchr(display, '.')))
@ -70,8 +69,8 @@ uicb_spawn(awesome_config * awesomeconf,
{ {
if(fork() == 0) if(fork() == 0)
{ {
if(awesomeconf->display) if(globalconf.display)
close(ConnectionNumber(awesomeconf->display)); close(ConnectionNumber(globalconf.display));
setsid(); setsid();
execl(shell, shell, "-c", arg, (char *) NULL); execl(shell, shell, "-c", arg, (char *) NULL);
warn("execl '%s -c %s'", shell, arg); warn("execl '%s -c %s'", shell, arg);