diff --git a/client.c b/client.c index 14fd33905..01c41822c 100644 --- a/client.c +++ b/client.c @@ -850,4 +850,106 @@ uicb_client_kill(int screen __attribute__ ((unused)), char *arg __attribute__ (( if(sel) client_kill(sel); } + +void +client_maximize(Client *c, int x, int y, int w, int h) +{ + if((c->ismax = !c->ismax)) + { + c->oldborder = c->border; + c->border = 0; + c->wasfloating = c->isfloating; + c->isfloating = True; + client_resize(c, x, y, w, h, False, True); + } + else if(c->wasfloating) + client_resize(c, c->rx, c->ry, c->rw, c->rh, True, False); + else + c->isfloating = False; + + c->border = c->oldborder; + + arrange(c->screen); +} + +/** Toggle maximize for client + * \param screen Screen ID + * \param arg Unused + * \ingroup ui_callback + */ +void +uicb_client_togglemax(int screen, char *arg __attribute__ ((unused))) +{ + Client *sel = globalconf.focus->client; + Area area = get_screen_area(screen, + globalconf.screens[screen].statusbar, + &globalconf.screens[screen].padding); + if(sel) + client_maximize(sel, area.x, area.y, + area.width - 2 * globalconf.screens[screen].borderpx, + area.height - 2 * globalconf.screens[screen].borderpx); +} + +/** Toggle vertical maximize for client + * \param screen Screen ID + * \param arg Unused + * \ingroup ui_callback + */ +void +uicb_client_toggleverticalmax(int screen, char *arg __attribute__ ((unused))) +{ + Client *sel = globalconf.focus->client; + Area area = get_screen_area(screen, + globalconf.screens[screen].statusbar, + &globalconf.screens[screen].padding); + + if(sel) + client_maximize(sel, sel->x, area.y, + sel->w, + area.height - 2 * globalconf.screens[screen].borderpx); +} + + +/** Toggle horizontal maximize for client + * \param screen Screen ID + * \param arg Unused + * \ingroup ui_callback + */ +void +uicb_client_togglehorizontalmax(int screen, char *arg __attribute__ ((unused))) +{ + Client *sel = globalconf.focus->client; + Area area = get_screen_area(screen, + globalconf.screens[screen].statusbar, + &globalconf.screens[screen].padding); + + if(sel) + client_maximize(sel, area.x, sel->y, + area.height - 2 * globalconf.screens[screen].borderpx, + sel->h); +} + +/** Zoom client + * \param screen Screen ID + * \param arg Unused + * \ingroup ui_callback + */ +void +uicb_client_zoom(int screen, char *arg __attribute__ ((unused))) +{ + Client *sel = globalconf.focus->client; + + if(globalconf.clients == sel) + for(sel = sel->next; sel && !client_isvisible(sel, screen); sel = sel->next); + + if(!sel) + return; + + client_detach(sel); + client_attach(sel); + + focus(sel, True, screen); + arrange(screen); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/client.h b/client.h index 2990b6b3e..0ebcad4fe 100644 --- a/client.h +++ b/client.h @@ -41,6 +41,7 @@ void client_updatesizehints(Client *); void client_updatetitle(Client *); void client_saveprops(Client *); void client_kill(Client *); +void client_maximize(Client *c, int, int, int, int); Uicb uicb_client_kill; Uicb uicb_client_moveresize; @@ -48,6 +49,10 @@ Uicb uicb_client_settrans; Uicb uicb_setborder; Uicb uicb_client_swapnext; Uicb uicb_client_swapprev; +Uicb uicb_client_togglemax; +Uicb uicb_client_toggleverticalmax; +Uicb uicb_client_togglehorizontalmax; +Uicb uicb_client_zoom; #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/config.h b/config.h index cfb500f73..58669e5de 100644 --- a/config.h +++ b/config.h @@ -26,6 +26,8 @@ #include #include #include "draw.h" +#include "uicb.h" +#include "layout.h" /** Bar possible position */ enum @@ -57,7 +59,7 @@ typedef struct Layout Layout; struct Layout { char *image; - void (*arrange) (int); + LayoutArrange *arrange; Layout *next; }; @@ -66,7 +68,7 @@ struct Key { unsigned long mod; KeySym keysym; - void (*func) (int, char *); + Uicb *func; char *arg; Key *next; }; @@ -76,7 +78,7 @@ struct Button { unsigned long mod; unsigned int button; - void (*func) (int, char *); + Uicb *func; char *arg; Button *next; }; diff --git a/draw.c b/draw.c index f15a1259d..89744231f 100644 --- a/draw.c +++ b/draw.c @@ -23,6 +23,7 @@ #include #include #include +#include "config.h" #include "layout.h" #include "util.h" #include "draw.h" diff --git a/layout.c b/layout.c index 7ca4e0687..e77420b51 100644 --- a/layout.c +++ b/layout.c @@ -248,105 +248,4 @@ uicb_tag_setlayout(int screen, char *arg) saveawesomeprops(screen); } -void -client_maximize(Client *c, int x, int y, int w, int h) -{ - if((c->ismax = !c->ismax)) - { - c->oldborder = c->border; - c->border = 0; - c->wasfloating = c->isfloating; - c->isfloating = True; - client_resize(c, x, y, w, h, False, True); - } - else if(c->wasfloating) - client_resize(c, c->rx, c->ry, c->rw, c->rh, True, False); - else - c->isfloating = False; - - c->border = c->oldborder; - - arrange(c->screen); -} - -/** Toggle maximize for client - * \param screen Screen ID - * \param arg Unused - * \ingroup ui_callback - */ -void -uicb_client_togglemax(int screen, char *arg __attribute__ ((unused))) -{ - Client *sel = globalconf.focus->client; - Area area = get_screen_area(screen, - globalconf.screens[screen].statusbar, - &globalconf.screens[screen].padding); - if(sel) - client_maximize(sel, area.x, area.y, - area.width - 2 * globalconf.screens[screen].borderpx, - area.height - 2 * globalconf.screens[screen].borderpx); -} - -/** Toggle vertical maximize for client - * \param screen Screen ID - * \param arg Unused - * \ingroup ui_callback - */ -void -uicb_client_toggleverticalmax(int screen, char *arg __attribute__ ((unused))) -{ - Client *sel = globalconf.focus->client; - Area area = get_screen_area(screen, - globalconf.screens[screen].statusbar, - &globalconf.screens[screen].padding); - - if(sel) - client_maximize(sel, sel->x, area.y, - sel->w, - area.height - 2 * globalconf.screens[screen].borderpx); -} - - -/** Toggle horizontal maximize for client - * \param screen Screen ID - * \param arg Unused - * \ingroup ui_callback - */ -void -uicb_client_togglehorizontalmax(int screen, char *arg __attribute__ ((unused))) -{ - Client *sel = globalconf.focus->client; - Area area = get_screen_area(screen, - globalconf.screens[screen].statusbar, - &globalconf.screens[screen].padding); - - if(sel) - client_maximize(sel, area.x, sel->y, - area.height - 2 * globalconf.screens[screen].borderpx, - sel->h); -} - -/** Zoom client - * \param screen Screen ID - * \param arg Unused - * \ingroup ui_callback - */ -void -uicb_client_zoom(int screen, char *arg __attribute__ ((unused))) -{ - Client *sel = globalconf.focus->client; - - if(globalconf.clients == sel) - for(sel = sel->next; sel && !client_isvisible(sel, screen); sel = sel->next); - - if(!sel) - return; - - client_detach(sel); - client_attach(sel); - - focus(sel, True, screen); - arrange(screen); -} - // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/layout.h b/layout.h index 22f2296af..6e2f16c76 100644 --- a/layout.h +++ b/layout.h @@ -22,7 +22,6 @@ #ifndef AWESOME_LAYOUT_H #define AWESOME_LAYOUT_H -#include "config.h" #include "uicb.h" #define AWESOMEPROPS_ATOM(disp) XInternAtom(disp, "_AWESOME_PROPERTIES", False) @@ -33,15 +32,10 @@ void arrange(int); void restack(int); void loadawesomeprops(int); void saveawesomeprops(int); -void client_maximize(Client *c, int, int, int, int); Uicb uicb_client_focusnext; Uicb uicb_client_focusprev; Uicb uicb_tag_setlayout; -Uicb uicb_client_togglemax; -Uicb uicb_client_toggleverticalmax; -Uicb uicb_client_togglehorizontalmax; -Uicb uicb_client_zoom; #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80