diff options
author | oga | 2008-04-15 20:24:41 +0000 |
---|---|---|
committer | oga | 2008-04-15 20:24:41 +0000 |
commit | b31333397785733587b3bfe3adb27ff2761702b5 (patch) | |
tree | b4fdd1360ef1add5766452793034ef73bec0ebc4 | |
parent | 137723ad08c9062a346b29d72b4b2ce55971c217 (diff) | |
download | cwm-b31333397785733587b3bfe3adb27ff2761702b5.tar.gz |
hit it with the knf stick.
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | calmwm.c | 46 | ||||
-rw-r--r-- | calmwm.h | 475 | ||||
-rw-r--r-- | client.c | 47 | ||||
-rw-r--r-- | conf.c | 31 | ||||
-rw-r--r-- | cwmrc | 3 | ||||
-rw-r--r-- | cwmrc.5 | 12 | ||||
-rw-r--r-- | font.c | 31 | ||||
-rw-r--r-- | grab.c | 23 | ||||
-rw-r--r-- | group.c | 44 | ||||
-rw-r--r-- | hash.h | 6 | ||||
-rw-r--r-- | headers.h | 4 | ||||
-rw-r--r-- | kbfunc.c | 42 | ||||
-rw-r--r-- | parse.y | 49 | ||||
-rw-r--r-- | screen.c | 7 | ||||
-rw-r--r-- | search.c | 18 | ||||
-rw-r--r-- | util.c | 40 | ||||
-rw-r--r-- | xevents.c | 41 | ||||
-rw-r--r-- | xutil.c | 8 |
20 files changed, 470 insertions, 461 deletions
@@ -17,7 +17,7 @@ DESCRIPTION base of evilwm did not accomodate well for the new features added. So calmwm was written from scratch. - Its main goal is to be as efficient as possible, while providing + Its main goal is to be as efficient as possible, while providing a very clean, simple & attractive aesthetic. cwm has several novel features, including the ability to search @@ -9,7 +9,7 @@ register handlers, with the ability to select, for example, a window, or an event, etc. (no, maybe not...) -- ignoreq, always lower them. perhaps implement by lowering the entire +- ignoreq, always lower them. perhaps implement by lowering the entire queue on each XLower... - search window should try to stay inside of the screen boundaries. @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.c,v 1.15 2008/04/15 18:22:08 okan Exp $ + * $Id: calmwm.c,v 1.16 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" @@ -38,7 +38,7 @@ struct client_ctx_q Clientq; int Doshape, Shape_ev; int Starting; struct conf Conf; -struct fontdesc *DefaultFont = NULL; +struct fontdesc *DefaultFont = NULL; /* From TWM */ #define gray_width 2 @@ -46,7 +46,7 @@ struct fontdesc *DefaultFont = NULL; static char gray_bits[] = {0x02, 0x01}; -static void _sigchld_cb(int); +static void _sigchld_cb(int); int main(int argc, char **argv) @@ -72,11 +72,11 @@ main(int argc, char **argv) argv += optind; /* Ignore a few signals. */ - if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) - err(1, "signal"); + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) + err(1, "signal"); - if (signal(SIGCHLD, _sigchld_cb) == SIG_ERR) - err(1, "signal"); + if (signal(SIGCHLD, _sigchld_cb) == SIG_ERR) + err(1, "signal"); group_init(); @@ -176,16 +176,16 @@ x_setupscreen(struct screen_ctx *sc, u_int which) sc->redpixl = sc->redcolor.pixel; sc->cyanpixl = sc->cyancolor.pixel; - sc->gray = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, - gray_bits, gray_width, gray_height, - sc->blackpixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which)); + sc->gray = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, + gray_bits, gray_width, gray_height, + sc->blackpixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which)); - sc->blue = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, - gray_bits, gray_width, gray_height, - sc->bluepixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which)); + sc->blue = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, + gray_bits, gray_width, gray_height, + sc->bluepixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which)); - sc->red = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, - gray_bits, gray_width, gray_height, + sc->red = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, + gray_bits, gray_width, gray_height, sc->redpixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which)); gv.foreground = sc->blackpixl^sc->whitepixl; @@ -216,7 +216,7 @@ x_setupscreen(struct screen_ctx *sc, u_int which) search_init(sc); /* Deal with existing clients. */ - XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins); + XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins); for (i = 0; i < nwins; i++) { XGetWindowAttributes(X_Dpy, wins[i], &winattr); @@ -287,11 +287,11 @@ x_errorhandler(Display *dpy, XErrorEvent *e) } #endif - if (Starting && - e->error_code == BadAccess && - e->request_code == X_GrabKey) + if (Starting && + e->error_code == BadAccess && + e->request_code == X_GrabKey) errx(1, "root window unavailable - perhaps another " - "wm is running?"); + "wm is running?"); return (0); } @@ -302,9 +302,9 @@ _sigchld_cb(int which) pid_t pid; int status; -/* Collect dead children. */ - while ((pid = waitpid(-1, &status, WNOHANG)) > 0 || - (pid < 0 && errno == EINTR)) + /* Collect dead children. */ + while ((pid = waitpid(-1, &status, WNOHANG)) > 0 || + (pid < 0 && errno == EINTR)) ; } @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.29 2008/04/15 18:46:58 oga Exp $ + * $Id: calmwm.h,v 1.30 2008/04/15 20:24:41 oga Exp $ */ #ifndef _CALMWM_H_ @@ -44,15 +44,13 @@ struct client_ctx; TAILQ_HEAD(cycle_entry_q, client_ctx); -/* #define CYCLE_FOREACH_MRU(cy, ctx) TAILQ_FOREACH((ctx), */ - struct screen_ctx; struct fontdesc { - const char *name; - XftFont *fn; - struct screen_ctx *sc; - HASH_ENTRY(fontdesc) node; + const char *name; + XftFont *fn; + struct screen_ctx *sc; + HASH_ENTRY(fontdesc) node; }; int fontdesc_cmp(struct fontdesc *a, struct fontdesc *b); @@ -88,9 +86,9 @@ struct screen_ctx { struct client_ctx* cycle_client; - struct fonthash fonthash; - XftDraw *xftdraw; - XftColor xftcolor; + struct fonthash fonthash; + XftDraw *xftdraw; + XftColor xftcolor; }; TAILQ_HEAD(screen_ctx_q, screen_ctx); @@ -108,7 +106,7 @@ TAILQ_HEAD(screen_ctx_q, screen_ctx); #define CLIENT_VMAXIMIZED 0x20 #define CLIENT_HIGHLIGHT_BLUE 1 -#define CLIENT_HIGHLIGHT_RED 2 +#define CLIENT_HIGHLIGHT_RED 2 struct winname { @@ -128,7 +126,7 @@ struct client_ctx { Window win; XSizeHints *size; - Colormap cmap; + Colormap cmap; Window pwin; @@ -157,13 +155,13 @@ struct client_ctx { int highlight; char *matchname; - struct group_ctx *group; + struct group_ctx *group; - int stackingorder; + int stackingorder; - char *app_class; - char *app_name; - char *app_cliarg; + char *app_class; + char *app_name; + char *app_cliarg; }; TAILQ_HEAD(client_ctx_q, client_ctx); @@ -175,14 +173,14 @@ static char *shortcut_to_name[] = { }; struct group_ctx { - TAILQ_ENTRY(group_ctx) entry; - struct client_ctx_q clients; - char *name; - int shortcut; - int hidden; - int nhidden; - int highstack; -}; + TAILQ_ENTRY(group_ctx) entry; + struct client_ctx_q clients; + char *name; + int shortcut; + int hidden; + int nhidden; + int highstack; +}; TAILQ_HEAD(group_ctx_q, group_ctx); @@ -199,31 +197,31 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin); /* NULL/0 values indicate match any. */ struct xevent { - TAILQ_ENTRY(xevent) entry; - Window *xev_win; - Window *xev_root; - int xev_type; - void (*xev_cb)(struct xevent *, XEvent *); - void *xev_arg; + TAILQ_ENTRY(xevent) entry; + Window *xev_win; + Window *xev_root; + int xev_type; + void (*xev_cb)(struct xevent *, XEvent *); + void *xev_arg; }; TAILQ_HEAD(xevent_q, xevent); #define CWM_BIGMOVE 0x1000 enum directions { - CWM_UP=0, CWM_DOWN, CWM_LEFT, CWM_RIGHT, + CWM_UP = 0, CWM_DOWN, CWM_LEFT, CWM_RIGHT, }; /* * Match a window. */ -#define CONF_MAX_WINTITLE 256 -#define CONF_IGNORECASE 0x01 +#define CONF_MAX_WINTITLE 256 +#define CONF_IGNORECASE 0x01 struct winmatch { - TAILQ_ENTRY(winmatch) entry; + TAILQ_ENTRY(winmatch) entry; - char title[CONF_MAX_WINTITLE]; - int opts; + char title[CONF_MAX_WINTITLE]; + int opts; }; TAILQ_HEAD(winmatch_q, winmatch); @@ -237,21 +235,20 @@ TAILQ_HEAD(winmatch_q, winmatch); #define KBTOGROUP(X) ((X) - 1) struct keybinding { - int modmask; - int keysym; - int keycode; - int flags; - void (*callback)(struct client_ctx *, void *); - void *argument; - TAILQ_ENTRY(keybinding) entry; + int modmask; + int keysym; + int keycode; + int flags; + void (*callback)(struct client_ctx *, void *); + void *argument; + TAILQ_ENTRY(keybinding) entry; }; struct cmd { - TAILQ_ENTRY(cmd) entry; - int flags; -#define CMD_STATIC 0x01 /* static configuration in conf.c */ - char image[MAXPATHLEN]; - char label[256]; + TAILQ_ENTRY(cmd) entry; + int flags; + char image[MAXPATHLEN]; + char label[256]; /* (argv) */ }; @@ -266,15 +263,15 @@ struct conf { char conf_path[MAXPATHLEN]; struct cmd_q cmdq; +#define CONF_STICKY_GROUPS 0x0001 int flags; -#define CONF_STICKY_GROUPS 0x0001 char termpath[MAXPATHLEN]; char lockpath[MAXPATHLEN]; -#define DEFAULTFONTNAME "sans-serif:pixelsize=14:bold" +#define DEFAULTFONTNAME "sans-serif:pixelsize=14:bold" char *DefaultFontName; - int gap_top, gap_bottom, gap_left, gap_right; + int gap_top, gap_bottom, gap_left, gap_right; }; /* Menu stuff */ @@ -282,13 +279,13 @@ struct conf { #define MENU_MAXENTRY 50 struct menu { - TAILQ_ENTRY(menu) entry; - TAILQ_ENTRY(menu) resultentry; + TAILQ_ENTRY(menu) entry; + TAILQ_ENTRY(menu) resultentry; - char text[MENU_MAXENTRY + 1]; - char print[MENU_MAXENTRY + 1]; - void *ctx; - short dummy; + char text[MENU_MAXENTRY + 1]; + char print[MENU_MAXENTRY + 1]; + void *ctx; + short dummy; }; TAILQ_HEAD(menu_q, menu); @@ -302,196 +299,202 @@ enum ctltype { /* MWM hints */ struct mwm_hints { - u_long flags; - u_long functions; - u_long decorations; + u_long flags; + u_long functions; + u_long decorations; }; #define MWM_NUMHINTS 3 -#define PROP_MWM_HINTS_ELEMENTS 3 -#define MWM_HINTS_DECORATIONS (1 << 1) -#define MWM_DECOR_ALL (1 << 0) -#define MWM_DECOR_BORDER (1 << 1) - -int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int); - -int x_errorhandler(Display *, XErrorEvent *); -void x_setup(char *display_name); -char *x_screenname(int); -void x_setupscreen(struct screen_ctx *, u_int); -__dead void usage(void); - -struct client_ctx *client_find(Window); -void client_setup(void); -struct client_ctx *client_new(Window, struct screen_ctx *, int); -int client_delete(struct client_ctx *, int, int); -void client_setactive(struct client_ctx *, int); -void client_gravitate(struct client_ctx *, int); -void client_resize(struct client_ctx *); -void client_lower(struct client_ctx *); -void client_raise(struct client_ctx *); -void client_move(struct client_ctx *); -void client_leave(struct client_ctx *); -void client_send_delete(struct client_ctx *); -struct client_ctx *client_current(void); -void client_hide(struct client_ctx *); -void client_unhide(struct client_ctx *); -void client_nocurrent(void); -void client_setname(struct client_ctx *); -void client_warp(struct client_ctx *); -void client_ptrwarp(struct client_ctx *); -void client_ptrsave(struct client_ctx *); -void client_draw_border(struct client_ctx *); -void client_update(struct client_ctx *); -void client_cycle(struct client_ctx *); -void client_placecalc(struct client_ctx *); -void client_maximize(struct client_ctx *); -void client_vertmaximize(struct client_ctx *); -u_long client_bg_pixel(struct client_ctx *); -Pixmap client_bg_pixmap(struct client_ctx *); -void client_map(struct client_ctx *cc); -void client_mtf(struct client_ctx *cc); -struct client_ctx *client_cyclenext(int reverse); -void client_altrelease(); -struct client_ctx *client_mrunext(struct client_ctx *cc); -struct client_ctx *client_mruprev(struct client_ctx *cc); -void client_gethints(struct client_ctx *cc); -void client_freehints(struct client_ctx *cc); - -void xev_handle_maprequest(struct xevent *, XEvent *); -void xev_handle_unmapnotify(struct xevent *, XEvent *); -void xev_handle_destroynotify(struct xevent *, XEvent *); -void xev_handle_configurerequest(struct xevent *, XEvent *); -void xev_handle_propertynotify(struct xevent *, XEvent *); -void xev_handle_enternotify(struct xevent *, XEvent *); -void xev_handle_leavenotify(struct xevent *, XEvent *); -void xev_handle_buttonpress(struct xevent *, XEvent *); -void xev_handle_buttonrelease(struct xevent *, XEvent *); -void xev_handle_keypress(struct xevent *, XEvent *); -void xev_handle_keyrelease(struct xevent *, XEvent *); -void xev_handle_expose(struct xevent *, XEvent *); -void xev_handle_clientmessage(struct xevent *, XEvent *); +#define PROP_MWM_HINTS_ELEMENTS 3 +#define MWM_HINTS_DECORATIONS (1 << 1) +#define MWM_DECOR_ALL (1 << 0) +#define MWM_DECOR_BORDER (1 << 1) + +int input_keycodetrans(KeyCode, u_int, enum ctltype *, + char *, int); + +int x_errorhandler(Display *, XErrorEvent *); +void x_setup(char *display_name); +char *x_screenname(int); +void x_setupscreen(struct screen_ctx *, u_int); +__dead void usage(void); + +struct client_ctx *client_find(Window); +void client_setup(void); +struct client_ctx *client_new(Window, struct screen_ctx *, int); +int client_delete(struct client_ctx *, int, int); +void client_setactive(struct client_ctx *, int); +void client_gravitate(struct client_ctx *, int); +void client_resize(struct client_ctx *); +void client_lower(struct client_ctx *); +void client_raise(struct client_ctx *); +void client_move(struct client_ctx *); +void client_leave(struct client_ctx *); +void client_send_delete(struct client_ctx *); +struct client_ctx *client_current(void); +void client_hide(struct client_ctx *); +void client_unhide(struct client_ctx *); +void client_nocurrent(void); +void client_setname(struct client_ctx *); +void client_warp(struct client_ctx *); +void client_ptrwarp(struct client_ctx *); +void client_ptrsave(struct client_ctx *); +void client_draw_border(struct client_ctx *); +void client_update(struct client_ctx *); +void client_cycle(struct client_ctx *); +void client_placecalc(struct client_ctx *); +void client_maximize(struct client_ctx *); +void client_vertmaximize(struct client_ctx *); +u_long client_bg_pixel(struct client_ctx *); +Pixmap client_bg_pixmap(struct client_ctx *); +void client_map(struct client_ctx *cc); +void client_mtf(struct client_ctx *cc); +struct client_ctx *client_cyclenext(int reverse); +void client_altrelease(); +struct client_ctx *client_mrunext(struct client_ctx *cc); +struct client_ctx *client_mruprev(struct client_ctx *cc); +void client_gethints(struct client_ctx *cc); +void client_freehints(struct client_ctx *cc); + +void xev_handle_maprequest(struct xevent *, XEvent *); +void xev_handle_unmapnotify(struct xevent *, XEvent *); +void xev_handle_destroynotify(struct xevent *, XEvent *); +void xev_handle_configurerequest(struct xevent *, XEvent *); +void xev_handle_propertynotify(struct xevent *, XEvent *); +void xev_handle_enternotify(struct xevent *, XEvent *); +void xev_handle_leavenotify(struct xevent *, XEvent *); +void xev_handle_buttonpress(struct xevent *, XEvent *); +void xev_handle_buttonrelease(struct xevent *, XEvent *); +void xev_handle_keypress(struct xevent *, XEvent *); +void xev_handle_keyrelease(struct xevent *, XEvent *); +void xev_handle_expose(struct xevent *, XEvent *); +void xev_handle_clientmessage(struct xevent *, XEvent *); #define XEV_QUICK(a, b, c, d, e) do { \ xev_register(xev_new(a, b, c, d, e)); \ } while (0) -void xev_reconfig(struct client_ctx *); /* XXX should be xu_ */ - -void xev_init(void); -struct xevent *xev_new(Window *, Window *, int, void (*)(struct xevent *, XEvent *), void *); -void xev_register(struct xevent *); -void xev_loop(void); - -int xu_ptr_grab(Window, int, Cursor); -int xu_btn_grab(Window, int, u_int); -int xu_ptr_regrab(int, Cursor); -void xu_btn_ungrab(Window, int, u_int); -void xu_ptr_ungrab(void); -void xu_ptr_setpos(Window, int, int); -void xu_ptr_getpos(Window, int *, int *); -void xu_key_grab(Window, int, int); -void xu_sendmsg(struct client_ctx *, Atom, long); -int xu_getprop(struct client_ctx *, Atom, Atom, long, u_char **); -char *xu_getstrprop(struct client_ctx *, Atom atm); -void xu_setstate(struct client_ctx *, int); -int xu_getstate(struct client_ctx *, int *); -void xu_key_grab_keycode(Window, int, int); - -int dirent_exists(char *); -int dirent_isdir(char *); -int dirent_islink(char *); -int u_spawn(char *); -void exec_wm(char *); - -void grab_sweep(struct client_ctx *); -void grab_drag(struct client_ctx *); -void grab_menuinit(struct screen_ctx *); -void *grab_menu(XButtonEvent *, struct menu_q *); -void grab_label(struct client_ctx *); - -void xfree(void *); -void *xmalloc(size_t); -void *xcalloc(size_t); -char *xstrdup(const char *); +/* XXX should be xu_ */ +void xev_reconfig(struct client_ctx *); + +void xev_init(void); +struct xevent *xev_new(Window *, Window *, int, + void (*)(struct xevent *, XEvent *), void *); +void xev_register(struct xevent *); +void xev_loop(void); + +int xu_ptr_grab(Window, int, Cursor); +int xu_btn_grab(Window, int, u_int); +int xu_ptr_regrab(int, Cursor); +void xu_btn_ungrab(Window, int, u_int); +void xu_ptr_ungrab(void); +void xu_ptr_setpos(Window, int, int); +void xu_ptr_getpos(Window, int *, int *); +void xu_key_grab(Window, int, int); +void xu_sendmsg(struct client_ctx *, Atom, long); +int xu_getprop(struct client_ctx *, Atom, Atom, long, + u_char **); +char *xu_getstrprop(struct client_ctx *, Atom atm); +void xu_setstate(struct client_ctx *, int); +int xu_getstate(struct client_ctx *, int *); +void xu_key_grab_keycode(Window, int, int); + +int dirent_exists(char *); +int dirent_isdir(char *); +int dirent_islink(char *); +int u_spawn(char *); +void exec_wm(char *); + +void grab_sweep(struct client_ctx *); +void grab_drag(struct client_ctx *); +void grab_menuinit(struct screen_ctx *); +void *grab_menu(XButtonEvent *, struct menu_q *); +void grab_label(struct client_ctx *); + +void xfree(void *); +void *xmalloc(size_t); +void *xcalloc(size_t); +char *xstrdup(const char *); #define XMALLOC(p, t) ((p) = (t *)xmalloc(sizeof * (p))) #define XCALLOC(p, t) ((p) = (t *)xcalloc(sizeof * (p))) -void screen_init(void); -struct screen_ctx *screen_fromroot(Window); -struct screen_ctx *screen_current(void); -void screen_updatestackingorder(void); -void screen_infomsg(char *); - -void conf_setup(struct conf *, const char *); -int conf_get_int(struct client_ctx *, enum conftype); -void conf_client(struct client_ctx *); -void conf_bindkey(struct conf *, void (*)(struct client_ctx *, void *), - int, int, int, void *); -void conf_bindname(struct conf *, char *, char *); -void conf_unbind(struct conf *, struct keybinding *); -int conf_changed(char *); -void conf_reload(struct conf *c); -char *conf_get_str(struct client_ctx *, enum conftype); - -void kbfunc_client_lower(struct client_ctx *, void *); -void kbfunc_client_raise(struct client_ctx *, void *); -void kbfunc_client_search(struct client_ctx *, void *); -void kbfunc_client_hide(struct client_ctx *, void *); -void kbfunc_client_cycle(struct client_ctx *, void *); -void kbfunc_client_rcycle(struct client_ctx *cc, void *arg); -void kbfunc_cmdexec(struct client_ctx *, void *); -void kbfunc_client_label(struct client_ctx *, void *); -void kbfunc_client_delete(struct client_ctx *, void *); -void kbfunc_client_group(struct client_ctx *, void *); -void kbfunc_client_nextgroup(struct client_ctx *, void *); -void kbfunc_client_prevgroup(struct client_ctx *, void *); -void kbfunc_client_nogroup(struct client_ctx *, void *); -void kbfunc_client_maximize(struct client_ctx *, void *); -void kbfunc_client_vmaximize(struct client_ctx *, void *); -void kbfunc_quit_wm(struct client_ctx *, void *); -void kbfunc_client_move(struct client_ctx *, void *); -void kbfunc_client_resize(struct client_ctx *, void *); -void kbfunc_menu_search(struct client_ctx *, void *); -void kbfunc_exec(struct client_ctx *, void *); -void kbfunc_ptrmove(struct client_ctx *, void *); -void kbfunc_ssh(struct client_ctx *, void *); -void kbfunc_term(struct client_ctx *cc, void *arg); -void kbfunc_lock(struct client_ctx *cc, void *arg); - -void search_init(struct screen_ctx *); -struct menu *search_start(struct menu_q *menuq, - void (*match)(struct menu_q *, struct menu_q *, char *), - void (*print)(struct menu *mi, int), - char *, int); -void search_match_client(struct menu_q *, struct menu_q *, char *); -void search_print_client(struct menu *mi, int list); -void search_match_text(struct menu_q *, struct menu_q *, char *); -void search_match_exec(struct menu_q *, struct menu_q *, char *); - -void group_init(void); -void group_hidetoggle(int); -void group_slide(int); -void group_sticky(struct client_ctx *); -void group_client_delete(struct client_ctx *); -void group_menu(XButtonEvent *); -void group_alltoggle(void); -void group_sticky_toggle_enter(struct client_ctx *); -void group_sticky_toggle_exit(struct client_ctx *); -void group_autogroup(struct client_ctx *); - -void notification_init(struct screen_ctx *); - -void font_init(struct screen_ctx *sc); -struct fontdesc *font_get(struct screen_ctx *sc, const char *name); -int font_width(struct fontdesc *fdp, const char *text, int len); -void font_draw(struct fontdesc *fdp, const char *text, int len, - Drawable d, int x, int y); -int font_ascent(struct fontdesc *fdp); -int font_descent(struct fontdesc *fdp); -struct fontdesc *font_getx(struct screen_ctx *sc, const char *name); +void screen_init(void); +struct screen_ctx *screen_fromroot(Window); +struct screen_ctx *screen_current(void); +void screen_updatestackingorder(void); +void screen_infomsg(char *); + +void conf_setup(struct conf *, const char *); +int conf_get_int(struct client_ctx *, enum conftype); +void conf_client(struct client_ctx *); +void conf_bindkey(struct conf *, + void (*)(struct client_ctx *, void *), + int, int, int, void *); +void conf_bindname(struct conf *, char *, char *); +void conf_unbind(struct conf *, struct keybinding *); +int conf_changed(char *); +void conf_reload(struct conf *); +char *conf_get_str(struct client_ctx *, enum conftype); + +void kbfunc_client_lower(struct client_ctx *, void *); +void kbfunc_client_raise(struct client_ctx *, void *); +void kbfunc_client_search(struct client_ctx *, void *); +void kbfunc_client_hide(struct client_ctx *, void *); +void kbfunc_client_cycle(struct client_ctx *, void *); +void kbfunc_client_rcycle(struct client_ctx *, void *); +void kbfunc_cmdexec(struct client_ctx *, void *); +void kbfunc_client_label(struct client_ctx *, void *); +void kbfunc_client_delete(struct client_ctx *, void *); +void kbfunc_client_group(struct client_ctx *, void *); +void kbfunc_client_nextgroup(struct client_ctx *, void *); +void kbfunc_client_prevgroup(struct client_ctx *, void *); +void kbfunc_client_nogroup(struct client_ctx *, void *); +void kbfunc_client_maximize(struct client_ctx *, void *); +void kbfunc_client_vmaximize(struct client_ctx *, void *); +void kbfunc_quit_wm(struct client_ctx *, void *); +void kbfunc_client_move(struct client_ctx *, void *); +void kbfunc_client_resize(struct client_ctx *, void *); +void kbfunc_menu_search(struct client_ctx *, void *); +void kbfunc_exec(struct client_ctx *, void *); +void kbfunc_ptrmove(struct client_ctx *, void *); +void kbfunc_ssh(struct client_ctx *, void *); +void kbfunc_term(struct client_ctx *, void *); +void kbfunc_lock(struct client_ctx *, void *); + +void search_init(struct screen_ctx *); +struct menu *search_start(struct menu_q *menuq, + void (*match)(struct menu_q *, struct menu_q *, char *), + void (*print)(struct menu *mi, int), + char *, int); +void search_match_client(struct menu_q *, struct menu_q *, + char *); +void search_print_client(struct menu *mi, int list); +void search_match_text(struct menu_q *, struct menu_q *, + char *); +void search_match_exec(struct menu_q *, struct menu_q *, + char *); + +void group_init(void); +void group_hidetoggle(int); +void group_slide(int); +void group_sticky(struct client_ctx *); +void group_client_delete(struct client_ctx *); +void group_menu(XButtonEvent *); +void group_alltoggle(void); +void group_sticky_toggle_enter(struct client_ctx *); +void group_sticky_toggle_exit(struct client_ctx *); +void group_autogroup(struct client_ctx *); + +void font_init(struct screen_ctx *); +struct fontdesc *font_get(struct screen_ctx *, const char *); +int font_width(struct fontdesc *, const char *, int); +void font_draw(struct fontdesc *, const char *, int, + Drawable, int, int); +int font_ascent(struct fontdesc *); +int font_descent(struct fontdesc *); +struct fontdesc *font_getx(struct screen_ctx *, const char *); #define CCTOSC(cc) (cc->sc) @@ -514,7 +517,7 @@ extern struct client_ctx_q Clientq; extern int Doshape, Shape_ev; extern struct conf Conf; -extern struct fontdesc *DefaultFont; +extern struct fontdesc *DefaultFont; #endif /* _CALMWM_H_ */ @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: client.c,v 1.16 2008/04/15 18:46:58 oga Exp $ + * $Id: client.c,v 1.17 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" @@ -23,11 +23,11 @@ static struct client_ctx *client__cycle(struct client_ctx *cc, struct client_ctx *(*iter)(struct client_ctx *)); -int _inwindowbounds(struct client_ctx *, int, int); +int _inwindowbounds(struct client_ctx *, int, int); -static char emptystring[] = ""; +static char emptystring[] = ""; -struct client_ctx *_curcc = NULL; +struct client_ctx *_curcc = NULL; void client_setup(void) @@ -53,7 +53,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) struct client_ctx *cc; long tmp; XSetWindowAttributes pxattr; - XWindowAttributes wattr; + XWindowAttributes wattr; int x, y, height, width, state; XWMHints *wmhints; @@ -67,7 +67,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) cc->state = mapped ? NormalState : IconicState; cc->sc = sc; cc->win = win; - cc->size= XAllocSizeHints(); + cc->size = XAllocSizeHints(); if (cc->size->width_inc == 0) cc->size->width_inc = 1; if (cc->size->height_inc == 0) @@ -137,7 +137,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) ExposureMask|EnterWindowMask; /* pxattr.border_pixel = sc->blackpix; */ /* pxattr.background_pixel = sc->whitepix; */ - + /* cc->pwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, */ /* x, y, width, height, 1, sc->blackpix, sc->whitepix); */ @@ -154,7 +154,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped) XShapeSelectInput(X_Dpy, cc->win, ShapeNotifyMask); - r = XShapeGetRectangles(X_Dpy, cc->win, ShapeBounding, &n, &tmp); + r = XShapeGetRectangles(X_Dpy, cc->win, ShapeBounding, + &n, &tmp); if (n > 1) XShapeCombineShape(X_Dpy, cc->pwin, ShapeBounding, 0, 0, /* XXX border */ @@ -189,7 +190,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) client_gethints(cc); client_update(cc); - + if (mapped) { group_autogroup(cc); } @@ -308,11 +309,11 @@ client_current(void) void client_gravitate(struct client_ctx *cc, int yes) { - int dx = 0, dy = 0, mult = yes ? 1 : -1; - int gravity = (cc->size->flags & PWinGravity) ? + int dx = 0, dy = 0, mult = yes ? 1 : -1; + int gravity = (cc->size->flags & PWinGravity) ? cc->size->win_gravity : NorthWestGravity; - switch (gravity) { + switch (gravity) { case NorthWestGravity: case SouthWestGravity: case NorthEastGravity: @@ -321,10 +322,10 @@ client_gravitate(struct client_ctx *cc, int yes) case NorthGravity: dy = cc->bwidth; break; - } + } - cc->geom.x += mult*dx; - cc->geom.y += mult*dy; + cc->geom.x += mult*dx; + cc->geom.y += mult*dy; } void @@ -419,10 +420,10 @@ client_ptrsave(struct client_ctx *cc) int x, y; xu_ptr_getpos(cc->pwin, &x, &y); - if (_inwindowbounds(cc, x, y)) { + if (_inwindowbounds(cc, x, y)) { cc->ptr.x = x; cc->ptr.y = y; - } + } } void @@ -591,7 +592,7 @@ match: cc->nameqlen--; } - return; + return; } /* @@ -635,7 +636,7 @@ client_cyclenext(int reverse) /* Do the actual warp. */ client_ptrsave(cc); client_ptrwarp(sc->cycle_client); - sc->altpersist = 1; /* This is reset when alt is let go... */ + sc->altpersist = 1; /* This is reset when alt is let go... */ return (sc->cycle_client); } @@ -671,7 +672,7 @@ client__cycle(struct client_ctx *cc, break; } while (cc != save); - return cc != save ? cc : NULL; + return (cc != save ? cc : NULL); } void @@ -764,8 +765,8 @@ client_vertmaximize(struct client_ctx *cc) struct screen_ctx *sc = CCTOSC(cc); int display_height = DisplayHeight(X_Dpy, sc->which) - cc->bwidth*2; - - if (!(cc->flags & CLIENT_MAXIMIZED)) + + if (!(cc->flags & CLIENT_MAXIMIZED)) cc->savegeom = cc->geom; cc->geom.y = cc->bwidth + Conf.gap_top; cc->geom.height = display_height - @@ -831,7 +832,7 @@ client_gethints(struct client_ctx *cc) break; strlcat(buf, argv[i], len); o += strlen(buf); - strlcat(buf, ARG_SEP_, len); + strlcat(buf, ARG_SEP_, len); o += strlen(ARG_SEP_); } @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: conf.c,v 1.25 2008/04/08 14:12:28 okan Exp $ + * $Id: conf.c,v 1.26 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" @@ -23,9 +23,9 @@ #ifndef timespeccmp #define timespeccmp(tsp, usp, cmp) \ - (((tsp)->tv_sec == (usp)->tv_sec) ? \ - ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ - ((tsp)->tv_sec cmp (usp)->tv_sec)) + (((tsp)->tv_sec == (usp)->tv_sec) ? \ + ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ + ((tsp)->tv_sec cmp (usp)->tv_sec)) #endif extern struct screen_ctx *Curscreen; @@ -88,7 +88,7 @@ conf_init(struct conf *c) TAILQ_INIT(&c->ignoreq); TAILQ_INIT(&c->cmdq); - TAILQ_INIT(&c->keybindingq); + TAILQ_INIT(&c->keybindingq); TAILQ_INIT(&c->autogroupq); conf_bindname(c, "CM-Return", "terminal"); @@ -166,8 +166,7 @@ conf_setup(struct conf *c, const char *conffile) snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", home, CONFFILE); - } - else + } else snprintf(c->conf_path, sizeof(c->conf_path), "%s", conffile); conf_init(c); @@ -195,7 +194,7 @@ conf_get_int(struct client_ctx *cc, enum conftype ctype) break; } } - + } else ignore = 1; @@ -300,23 +299,23 @@ conf_bindname(struct conf *c, char *name, char *binding) current_binding->modmask |= ControlMask; if (strchr(name, 'M') != NULL && - strchr(name, 'M') < strchr(name, '-')) + strchr(name, 'M') < strchr(name, '-')) current_binding->modmask |= Mod1Mask; if (strchr(name, '2') != NULL && - strchr(name, '2') < strchr(name, '-')) + strchr(name, '2') < strchr(name, '-')) current_binding->modmask |= Mod2Mask; if (strchr(name, '3') != NULL && - strchr(name, '3') < strchr(name, '-')) + strchr(name, '3') < strchr(name, '-')) current_binding->modmask |= Mod3Mask; if (strchr(name, '4') != NULL && - strchr(name, '4') < strchr(name, '-')) + strchr(name, '4') < strchr(name, '-')) current_binding->modmask |= Mod4Mask; if (strchr(name, 'S') != NULL && - strchr(name, 'S') < strchr(name, '-')) + strchr(name, 'S') < strchr(name, '-')) current_binding->modmask |= ShiftMask; substring = strchr(name, '-') + 1; @@ -335,13 +334,13 @@ conf_bindname(struct conf *c, char *name, char *binding) } if (current_binding->keysym == NoSymbol && - current_binding->keycode == 0 ) { + current_binding->keycode == 0) { xfree(current_binding); return; } /* We now have the correct binding, remove duplicates. */ - conf_unbind(c, current_binding); + conf_unbind(c, current_binding); if (strcmp("unmap",binding) == 0) return; @@ -376,7 +375,7 @@ void conf_unbind(struct conf *c, struct keybinding *unbind) continue; if ((key->keycode != 0 && key->keysym == NoSymbol && - key->keycode == unbind->keycode) || + key->keycode == unbind->keycode) || key->keysym == unbind->keysym) TAILQ_REMOVE(&c->keybindingq, key, entry); } @@ -1,4 +1,4 @@ -# $OpenBSD: cwmrc,v 1.1 2008/03/23 15:09:21 simon Exp $ +# $OpenBSD: cwmrc,v 1.2 2008/04/15 20:24:41 oga Exp $ # Makes the Xft(3) font string fontname the default font #fontname "sans-serif:pixelsize=14:bold" @@ -25,4 +25,3 @@ #bind CM-r "label" #bind CS-Return "xterm -e top" #bind 4-o "unmap" - @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.2 2008/04/15 18:46:58 oga Exp $ +.\" $OpenBSD: cwmrc.5,v 1.3 2008/04/15 20:24:41 oga Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org> .\" @@ -90,8 +90,8 @@ will cause any instances of to not have borders. .It Ic bind Ar keys Ar command Cause the creation of keyboard shortcuts. -The default shortcuts will always be created. In case of conflict, -user-defined shortcuts take precidence. +The default shortcuts will always be created. +In case of conflict, user-defined shortcuts take precidence. The modifier keys come first, followed by a ``-''. The following modifiers are recognised: .Bl -tag -width Ds @@ -116,9 +116,9 @@ The command should be either the name of a task from the structure in .Pa conf.c , or, alternatively it should be the commandline that is wished to be executed. -A special case is the ``unmap'' keyword, which causes any bindings using the -named shortcut to be removed. This can be used to remove a binding which conflicts -with an application. +A special case is the ``unmap'' keyword, which causes any bindings using the +named shortcut to be removed. +This can be used to remove a binding which conflicts with an application. .Pp For example, to cause .Ic C-M-r @@ -27,7 +27,7 @@ HASH_GENERATE(fonthash, fontdesc, node, fontdesc_cmp); int fontdesc_cmp(struct fontdesc *a, struct fontdesc *b) { - return strcmp(a->name, b->name); + return (strcmp(a->name, b->name)); } /* @@ -35,24 +35,24 @@ fontdesc_cmp(struct fontdesc *a, struct fontdesc *b) * http://www.isthe.com/chongo/tech/comp/fnv/ */ -#define FNV_P_32 ((unsigned int)0x01000193) /* 16777619 */ -#define FNV_1_32 ((unsigned int)0x811c9dc5) /* 2166136261 */ +#define FNV_P_32 ((unsigned int)0x01000193) /* 16777619 */ +#define FNV_1_32 ((unsigned int)0x811c9dc5) /* 2166136261 */ unsigned int fontdesc_hash(struct fontdesc *fdp) { - const unsigned char *p, *end, *start; - unsigned int hash = FNV_1_32; + const unsigned char *p, *end, *start; + unsigned int hash = FNV_1_32; start = fdp->name; end = (const unsigned char *)fdp->name + strlen(fdp->name); - for (p = start; p < end; p++) { - hash *= FNV_P_32; - hash ^= (unsigned int)*p; - } + for (p = start; p < end; p++) { + hash *= FNV_P_32; + hash ^= (unsigned int)*p; + } - return (hash); + return (hash); } void @@ -111,10 +111,10 @@ font_get(struct screen_ctx *sc, const char *name) int font_width(struct fontdesc *fdp, const char *text, int len) { - XGlyphInfo extents; - XftTextExtents8(X_Dpy, fdp->fn, (const XftChar8*)text, len, &extents); + XGlyphInfo extents; + XftTextExtents8(X_Dpy, fdp->fn, (const XftChar8*)text, len, &extents); - return (extents.xOff); + return (extents.xOff); } void @@ -130,13 +130,13 @@ font_draw(struct fontdesc *fdp, const char *text, int len, int font_ascent(struct fontdesc *fdp) { - return fdp->fn->ascent; + return (fdp->fn->ascent); } int font_descent(struct fontdesc *fdp) { - return fdp->fn->descent; + return (fdp->fn->descent); } static XftFont * @@ -156,4 +156,3 @@ _make_font(struct screen_ctx *sc, struct fontdesc *fdp) return (fn); } - @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: grab.c,v 1.8 2008/01/16 11:39:20 oga Exp $ + * $Id: grab.c,v 1.9 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" @@ -83,7 +83,7 @@ grab_sweep(struct client_ctx *cc) break; case MotionNotify: if (_sweepcalc(cc, x0, y0, ev.xmotion.x, ev.xmotion.y)) - /* Recompute window output */ + /* Recompute window output */ grab_sweep_draw(cc, dx, dy); XMoveResizeWindow(X_Dpy, cc->pwin, @@ -144,9 +144,9 @@ grab_drag(struct client_ctx *cc) /* NOTREACHED */ } -#define MenuMask (ButtonMask|ButtonMotionMask|ExposureMask) -#define MenuGrabMask (ButtonMask|ButtonMotionMask|StructureNotifyMask) -#define AllButtonMask (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) +#define MenuMask (ButtonMask|ButtonMotionMask|ExposureMask) +#define MenuGrabMask (ButtonMask|ButtonMotionMask|StructureNotifyMask) +#define AllButtonMask (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) void * grab_menu(XButtonEvent *e, struct menu_q *menuq) @@ -197,7 +197,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, width, tothigh); XSelectInput(X_Dpy, sc->menuwin, MenuMask); XMapRaised(X_Dpy, sc->menuwin); - + if (xu_ptr_grab(sc->menuwin, MenuGrabMask, Cursor_select) < 0) { XUnmapWindow(X_Dpy, sc->menuwin); return (NULL); @@ -207,7 +207,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) for (;;) { XMaskEvent(X_Dpy, MenuMask, &event); - switch (event.type) { + switch (event.type) { case Expose: XClearWindow(X_Dpy, sc->menuwin); i = 0; @@ -237,7 +237,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) case ButtonRelease: if (event.xbutton.button != e->button) break; - entry = menu_calc_entry(event.xbutton.x, + entry = menu_calc_entry(event.xbutton.x, event.xbutton.y, width, height, no); xu_ptr_ungrab(); XUnmapWindow(X_Dpy, sc->menuwin); @@ -247,7 +247,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) if (entry == i++) break; return (mi); - default: + default: break; } } @@ -334,7 +334,8 @@ grab_label(struct client_ctx *cc) } case Expose: - snprintf(dispstr, sizeof(dispstr), "label>%s", labelstr); + snprintf(dispstr, sizeof(dispstr), "label>%s", + labelstr); dx = font_width(font, dispstr, strlen(dispstr)); dy = fontheight; @@ -397,5 +398,5 @@ menu_calc_entry(int x, int y, int width, int height, int noentries) entry < 0 || entry >= noentries) entry = -1; - return entry; + return (entry); } @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: group.c,v 1.8 2008/03/23 15:09:21 simon Exp $ + * $Id: group.c,v 1.9 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" @@ -24,18 +24,18 @@ #define CALMWM_NGROUPS 9 -int Groupnamemode = 0; -struct group_ctx *Group_active = NULL; -struct group_ctx Groups[CALMWM_NGROUPS]; -char Group_name[256]; -int Grouphideall = 0; -struct group_ctx_q Groupq; +int Groupnamemode = 0; +struct group_ctx *Group_active = NULL; +struct group_ctx Groups[CALMWM_NGROUPS]; +char Group_name[256]; +int Grouphideall = 0; +struct group_ctx_q Groupq; static void _group_add(struct group_ctx *gc, struct client_ctx *cc) { if (cc == NULL || gc == NULL) - errx(1, "_group_add: a ctx is NULL"); + errx(1, "_group_add: a ctx is NULL"); if (cc->group == gc) return; @@ -51,7 +51,7 @@ static void _group_remove(struct client_ctx *cc) { if (cc == NULL || cc->group == NULL) - errx(1, "_group_remove: a ctx is NULL"); + errx(1, "_group_remove: a ctx is NULL"); TAILQ_REMOVE(&cc->group->clients, cc, group_entry); cc->group = NULL; @@ -62,7 +62,7 @@ _group_remove(struct client_ctx *cc) static void _group_hide(struct group_ctx *gc) { - struct client_ctx *cc; + struct client_ctx *cc; screen_updatestackingorder(); @@ -117,7 +117,7 @@ _group_show(struct group_ctx *gc) void group_init(void) { - int i; + int i; TAILQ_INIT(&Groupq); @@ -158,7 +158,7 @@ group_sticky_toggle_exit(struct client_ctx *cc) } /* - * selection list display + * selection list display */ /* if group_hidetoggle would produce no effect, toggle the group's hidden state @@ -166,7 +166,7 @@ group_sticky_toggle_exit(struct client_ctx *cc) void _group_fix_hidden_state(struct group_ctx *gc) { - struct client_ctx *cc; + struct client_ctx *cc; int same = 0; TAILQ_FOREACH(cc, &gc->clients, group_entry) { @@ -252,7 +252,7 @@ void group_client_delete(struct client_ctx *cc) { if (cc->group == NULL) - return; + return; TAILQ_REMOVE(&cc->group->clients, cc, group_entry); cc->group = NULL; /* he he */ @@ -261,10 +261,10 @@ group_client_delete(struct client_ctx *cc) void group_menu(XButtonEvent *e) { - struct menu_q menuq; - struct menu *mi; - int i; - struct group_ctx *gc; + struct menu_q menuq; + struct menu *mi; + int i; + struct group_ctx *gc; TAILQ_INIT(&menuq); @@ -280,10 +280,10 @@ group_menu(XButtonEvent *e) XCALLOC(mi, struct menu); if (gc->hidden) snprintf(mi->text, sizeof(mi->text), "%d: [%s]", - gc->shortcut, gc->name); + gc->shortcut, gc->name); else snprintf(mi->text, sizeof(mi->text), "%d: %s", - gc->shortcut, gc->name); + gc->shortcut, gc->name); mi->ctx = gc; TAILQ_INSERT_TAIL(&menuq, mi, entry); } @@ -315,11 +315,11 @@ group_alltoggle(void) { int i; - for (i=0; i < CALMWM_NGROUPS; i++) { + for (i = 0; i < CALMWM_NGROUPS; i++) { if (Grouphideall) _group_show(&Groups[i]); else - _group_hide(&Groups[i]); + _group_hide(&Groups[i]); } if (Grouphideall) @@ -21,9 +21,9 @@ #include <sys/tree.h> -#define HASH_ENTRY SPLAY_ENTRY +#define HASH_ENTRY SPLAY_ENTRY -#define HASH_HEAD(name, type, nbuckets) \ +#define HASH_HEAD(name, type, nbuckets) \ SPLAY_HEAD(name##_HASH_TREE, type); \ struct name { \ struct name##_HASH_TREE buckets[nbuckets]; \ @@ -52,7 +52,7 @@ struct type *name##_HASH_TREE_FIND(struct name *head, struct type *find) \ { \ struct name##_HASH_TREE *bucket = \ &head->buckets[(*head->hashfn)(find) % HASH_NBUCKETS(head)]; \ - return SPLAY_FIND(name##_HASH_TREE, bucket, find); \ + return (SPLAY_FIND(name##_HASH_TREE, bucket, find)); \ } \ void name##_HASH_TREE_INSERT(struct name *head, struct type *insert) \ { \ @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: headers.h,v 1.4 2008/01/11 16:06:44 oga Exp $ + * $Id: headers.h,v 1.5 2008/04/15 20:24:41 oga Exp $ */ #ifndef _CALMWM_HEADERS_H_ @@ -41,7 +41,7 @@ #include <X11/cursorfont.h> #include <X11/extensions/shape.h> -#include <X11/Xlib.h> +#include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/keysym.h> #include <X11/Xatom.h> @@ -1,6 +1,6 @@ /* * calmwm - the calm window manager - * + * * Copyright (c) 2004 Martin Murray <mmurray@monkey.org> * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: kbfunc.c,v 1.19 2008/04/08 17:38:27 oga Exp $ + * $Id: kbfunc.c,v 1.20 2008/04/15 20:24:41 oga Exp $ */ #include <paths.h> @@ -23,11 +23,11 @@ #include "headers.h" #include "calmwm.h" -#define KNOWN_HOSTS ".ssh/known_hosts" -#define HASH_MARKER "|1|" -#define MOVE_AMOUNT 1 +#define KNOWN_HOSTS ".ssh/known_hosts" +#define HASH_MARKER "|1|" +#define MOVE_AMOUNT 1 -extern int _xev_quit; +extern int _xev_quit; void kbfunc_client_lower(struct client_ctx *cc, void *arg) @@ -57,11 +57,11 @@ kbfunc_client_move(struct client_ctx *cc, void *arg) amt = amt*10; } - switch(flags) { + switch (flags) { case CWM_UP: my -= amt; break; - case CWM_DOWN: + case CWM_DOWN: my += amt; break; case CWM_RIGHT: @@ -97,11 +97,11 @@ kbfunc_client_resize(struct client_ctx *cc, void *arg) amt = amt*10; } - switch(flags) { + switch (flags) { case CWM_UP: my -= amt; break; - case CWM_DOWN: + case CWM_DOWN: my += amt; break; case CWM_RIGHT: @@ -139,11 +139,11 @@ kbfunc_ptrmove(struct client_ctx *cc, void *arg) flags -= CWM_BIGMOVE; amt = amt * 10; } - switch(flags) { + switch (flags) { case CWM_UP: my -= amt; break; - case CWM_DOWN: + case CWM_DOWN: my += amt; break; case CWM_RIGHT: @@ -167,11 +167,11 @@ void kbfunc_client_search(struct client_ctx *scratch, void *arg) { struct menu_q menuq; - struct client_ctx *cc, *old_cc = client_current(); + struct client_ctx *cc, *old_cc = client_current(); struct menu *mi; - + TAILQ_INIT(&menuq); - + TAILQ_FOREACH(cc, &Clientq, entry) { XCALLOC(mi, struct menu); strlcpy(mi->text, cc->name, sizeof(mi->text)); @@ -180,8 +180,8 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg) } if ((mi = search_start(&menuq, - search_match_client, search_print_client, - "window", 0)) != NULL) { + search_match_client, search_print_client, + "window", 0)) != NULL) { cc = (struct client_ctx *)mi->ctx; if (cc->flags & CLIENT_HIDDEN) client_unhide(cc); @@ -215,7 +215,7 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg) } if ((mi = search_start(&menuq, - search_match_text, NULL, "application", 0)) != NULL) + search_match_text, NULL, "application", 0)) != NULL) u_spawn(((struct cmd *)mi->ctx)->image); while ((mi = TAILQ_FIRST(&menuq)) != NULL) { @@ -278,7 +278,7 @@ kbfunc_exec(struct client_ctx *scratch, void *arg) char *label; int cmd = (int)arg; - switch(cmd) { + switch (cmd) { case CWM_EXEC_PROGRAM: label = "exec"; break; @@ -353,7 +353,7 @@ kbfunc_exec(struct client_ctx *scratch, void *arg) xfree(path); if ((mi = search_start(&menuq, - search_match_exec, NULL, label, 1)) != NULL) { + search_match_exec, NULL, label, 1)) != NULL) { switch (cmd) { case CWM_EXEC_PROGRAM: u_spawn(mi->text); @@ -427,7 +427,7 @@ kbfunc_ssh(struct client_ctx *scratch, void *arg) if ((mi = search_start(&menuq, - search_match_exec, NULL, "ssh", 1)) != NULL) { + search_match_exec, NULL, "ssh", 1)) != NULL) { conf_reload(&Conf); l = snprintf(cmd, sizeof(cmd), "%s -e ssh %s", Conf.termpath, mi->text); @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.3 2008/04/15 18:46:58 oga Exp $ */ +/* $OpenBSD: parse.y,v 1.4 2008/04/15 20:24:41 oga Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -40,16 +40,17 @@ static struct file { int lineno; int errors; } *file; -struct file *pushfile(const char *); -int popfile(void); -int yyparse(void); -int yylex(void); -int yyerror(const char *, ...); -int kw_cmp(const void *, const void *); -int lookup(char *); -int lgetc(int); -int lungetc(int); -int findeol(void); + +struct file *pushfile(const char *); +int popfile(void); +int yyparse(void); +int yylex(void); +int yyerror(const char *, ...); +int kw_cmp(const void *, const void *); +int lookup(char *); +int lgetc(int); +int lungetc(int); +int findeol(void); static struct conf *conf; @@ -97,7 +98,7 @@ string : string STRING { yesno : YES { $$ = 1; } | NO { $$ = 0; } ; - + main : FONTNAME STRING { if (conf->DefaultFontName != NULL && conf->DefaultFontName != DEFAULTFONTNAME) @@ -178,9 +179,9 @@ struct keywords { int yyerror(const char *fmt, ...) { - va_list ap; - - file->errors++; + va_list ap; + + file->errors++; va_start(ap, fmt); fprintf(stderr, "%s:%d: ", file->name, yylval.lineno); vfprintf(stderr, fmt, ap); @@ -548,36 +549,42 @@ parse_config(const char *filename, struct conf *xconf) xconf->flags = conf->flags; - for (cmd = TAILQ_FIRST(&conf->cmdq); cmd != NULL; cmd = cmdnext) { + for (cmd = TAILQ_FIRST(&conf->cmdq); cmd != NULL; + cmd = cmdnext) { cmdnext = TAILQ_NEXT(cmd, entry); TAILQ_REMOVE(&conf->cmdq, cmd, entry); TAILQ_INSERT_TAIL(&xconf->cmdq, cmd, entry); } - for (kb = TAILQ_FIRST(&conf->keybindingq); kb != NULL; kb = kbnext) { + for (kb = TAILQ_FIRST(&conf->keybindingq); kb != NULL; + kb = kbnext) { kbnext = TAILQ_NEXT(kb, entry); TAILQ_REMOVE(&conf->keybindingq, kb, entry); TAILQ_INSERT_TAIL(&xconf->keybindingq, kb, entry); } - for (ag = TAILQ_FIRST(&conf->autogroupq); ag != NULL; ag = agnext) { + for (ag = TAILQ_FIRST(&conf->autogroupq); ag != NULL; + ag = agnext) { agnext = TAILQ_NEXT(ag, entry); TAILQ_REMOVE(&conf->autogroupq, ag, entry); TAILQ_INSERT_TAIL(&xconf->autogroupq, ag, entry); } - for (wm = TAILQ_FIRST(&conf->ignoreq); wm != NULL; wm = wmnext) { + for (wm = TAILQ_FIRST(&conf->ignoreq); wm != NULL; + wm = wmnext) { wmnext = TAILQ_NEXT(wm, entry); TAILQ_REMOVE(&conf->ignoreq, wm, entry); TAILQ_INSERT_TAIL(&xconf->ignoreq, wm, entry); } - strlcpy(xconf->termpath, conf->termpath, sizeof(xconf->termpath)); - strlcpy(xconf->lockpath, conf->lockpath, sizeof(xconf->lockpath)); + strlcpy(xconf->termpath, conf->termpath, + sizeof(xconf->termpath)); + strlcpy(xconf->lockpath, conf->lockpath, + sizeof(xconf->lockpath)); xconf->DefaultFontName = conf->DefaultFontName; @@ -15,14 +15,14 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: screen.c,v 1.3 2008/01/11 16:06:44 oga Exp $ + * $Id: screen.c,v 1.4 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" #include "calmwm.h" -extern struct screen_ctx_q Screenq; -extern struct screen_ctx *Curscreen; +extern struct screen_ctx_q Screenq; +extern struct screen_ctx *Curscreen; static void _clearwindow_cb(int sig) @@ -76,7 +76,6 @@ screen_updatestackingorder(void) void screen_init(void) { - struct screen_ctx *sc = screen_current(); sc->cycle_client = NULL; @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: search.c,v 1.7 2008/03/22 14:09:02 oga Exp $ + * $Id: search.c,v 1.8 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" @@ -22,7 +22,7 @@ #define SearchMask (KeyPressMask|ExposureMask) -static int _strsubmatch(char *, char *, int); +static int _strsubmatch(char *, char *, int); void search_init(struct screen_ctx *sc) @@ -39,7 +39,7 @@ search_init(struct screen_ctx *sc) struct menu * search_start(struct menu_q *menuq, - void (*match)(struct menu_q *, struct menu_q *, char *), + void (*match)(struct menu_q *, struct menu_q *, char *), void (*print)(struct menu *mi, int print), char *prompt, int dummy) { @@ -320,16 +320,16 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search) if (cc->label != NULL && _strsubmatch(search, cc->label, 0)) { cc->matchname = cc->label; tier = 0; - } + } /* Then, on window names. */ if (tier < 0) { TAILQ_FOREACH_REVERSE(wn, &cc->nameq, winname_q, entry) - if (_strsubmatch(search, wn->name, 0)) { - cc->matchname = wn->name; - tier = 2; - break; - } + if (_strsubmatch(search, wn->name, 0)) { + cc->matchname = wn->name; + tier = 2; + break; + } } /* @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: util.c,v 1.5 2008/02/20 13:00:18 oga Exp $ + * $Id: util.c,v 1.6 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" @@ -65,28 +65,30 @@ exec_wm(char *argstr) warn(args[0]); } -int dirent_isdir(char *filename) { - struct stat buffer; - int return_value; +int +dirent_isdir(char *filename) +{ + struct stat buffer; + int return_value; - return_value = stat(filename, &buffer); + return_value = stat(filename, &buffer); - if(return_value == -1) - return 0; - else - return S_ISDIR(buffer.st_mode); + if (return_value == -1) + return (0); + else + return (S_ISDIR(buffer.st_mode)); } -int dirent_islink(char *filename) { - struct stat buffer; - int return_value; +int +dirent_islink(char *filename) +{ + struct stat buffer; + int return_value; - return_value = lstat(filename, &buffer); + return_value = lstat(filename, &buffer); - if(return_value == -1) - return 0; - else - return S_ISLNK(buffer.st_mode); + if (return_value == -1) + return (0); + else + return (S_ISLNK(buffer.st_mode)); } - - @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xevents.c,v 1.10 2008/04/08 00:09:50 simon Exp $ + * $Id: xevents.c,v 1.11 2008/04/15 20:24:41 oga Exp $ */ /* @@ -46,13 +46,12 @@ xev_handle_maprequest(struct xevent *xev, XEvent *ee) if (old_cc != NULL) client_ptrsave(old_cc); - if ((cc = client_find(e->window)) == NULL) { + if ((cc = client_find(e->window)) == NULL) { XGetWindowAttributes(X_Dpy, e->window, &xattr); cc = client_new(e->window, screen_fromroot(xattr.root), 1); sc = CCTOSC(cc); - } else { + } else cc->beepbeep = 1; - } #ifdef notyet /* XXX - possibly, we shouldn't map if * the window is withdrawn. */ @@ -80,7 +79,7 @@ xev_handle_unmapnotify(struct xevent *xev, XEvent *ee) #ifdef notyet /* XXX disable the ptrwarp until we handle it * better. */ - if (!client_delete(cc, e->send_event, 0) && wascurrent) + if (!client_delete(cc, e->send_event, 0) && wascurrent) ;/* client_ptrwarp(new_cc); */ #endif } @@ -121,13 +120,13 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee) if (e->value_mask & CWY) cc->geom.y = e->y; - if (cc->geom.x == 0 && + if (cc->geom.x == 0 && cc->geom.width >= DisplayWidth(X_Dpy, sc->which)) cc->geom.x -= cc->bwidth; - if (cc->geom.y == 0 && + if (cc->geom.y == 0 && cc->geom.height >= DisplayHeight(X_Dpy, sc->which)) - cc->geom.y -= cc->bwidth; + cc->geom.y -= cc->bwidth; client_gravitate(cc, 1); @@ -164,7 +163,7 @@ xev_handle_propertynotify(struct xevent *xev, XEvent *ee) long tmp; if ((cc = client_find(e->window)) != NULL) { - switch(e->atom) { + switch (e->atom) { case XA_WM_NORMAL_HINTS: XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp); break; @@ -260,7 +259,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee) if (cc->label != NULL) wname = cc->label; else - wname = cc->name; + wname = cc->name; if (wname == NULL) continue; @@ -370,8 +369,8 @@ xev_handle_keypress(struct xevent *xev, XEvent *ee) keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1); - - TAILQ_FOREACH(kb, &Conf.keybindingq, entry) { + + TAILQ_FOREACH(kb, &Conf.keybindingq, entry) { if (keysym != kb->keysym && skeysym == kb->keysym) modshift = ShiftMask; else @@ -381,15 +380,15 @@ xev_handle_keypress(struct xevent *xev, XEvent *ee) continue; if ((kb->keycode != 0 && kb->keysym == NoSymbol && - kb->keycode == e->keycode) || kb->keysym == - (modshift == 0 ? keysym : skeysym)) + kb->keycode == e->keycode) || kb->keysym == + (modshift == 0 ? keysym : skeysym)) break; - } + } if (kb == NULL) goto out; - if ((kb->flags & (KBFLAG_NEEDCLIENT)) && + if ((kb->flags & (KBFLAG_NEEDCLIENT)) && (cc = client_find(e->window)) == NULL && (cc = client_current()) == NULL) if (kb->flags & KBFLAG_NEEDCLIENT) @@ -416,7 +415,7 @@ xev_handle_keyrelease(struct xevent *xev, XEvent *ee) goto out; sc->altpersist = 0; - + /* * XXX - better interface... xevents should not know about * how/when to mtf. @@ -449,9 +448,9 @@ out: * X Event handling */ -static struct xevent_q _xevq, _xevq_putaway; -static short _xev_q_lock = 0; -volatile sig_atomic_t _xev_quit = 0; +static struct xevent_q _xevq, _xevq_putaway; +static short _xev_q_lock = 0; +volatile sig_atomic_t _xev_quit = 0; void xev_init(void) @@ -529,7 +528,7 @@ xev_loop(void) #ifdef DIAGNOSTIC if (TAILQ_EMPTY(&_xevq)) errx(1, "X event queue empty"); -#endif +#endif XNextEvent(X_Dpy, &e); type = e.type; @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xutil.c,v 1.4 2008/01/16 11:39:20 oga Exp $ + * $Id: xutil.c,v 1.5 2008/04/15 20:24:41 oga Exp $ */ #include "headers.h" @@ -45,7 +45,7 @@ xu_ptr_ungrab(void) int xu_btn_grab(Window win, int mask, u_int btn) { - return (XGrabButton(X_Dpy, btn, mask, win, + return (XGrabButton(X_Dpy, btn, mask, win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None) == GrabSuccess ? 0 : -1); } @@ -63,7 +63,7 @@ xu_ptr_getpos(Window rootwin, int *x, int *y) u_int tmp2; Window w0, w1; - XQueryPointer(X_Dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); + XQueryPointer(X_Dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); } void @@ -82,7 +82,7 @@ xu_key_grab(Window win, int mask, int keysym) (XKeycodeToKeysym(X_Dpy, code, 1) == keysym)) mask |= ShiftMask; - XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True, + XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True, GrabModeAsync, GrabModeAsync); } |