From c62c0ee9dbc3603558da76d48379edc1c29688dc Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 5 May 2011 15:32:24 +0000 Subject: [PATCH 1/5] make the menu window aware of xinerama info; this makes the menu stay within the current screen, like other cwm window placements and mutations (vmax/hmax/max) - from Sviatoslav Chagaev. ok oga@ --- menu.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/menu.c b/menu.c index e757665..dd858d8 100644 --- a/menu.c +++ b/menu.c @@ -287,8 +287,10 @@ static void menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq) { - struct menu *mi; - int n, dy, xsave, ysave; + struct menu *mi; + XineramaScreenInfo *xine; + int xmin, xmax, ymin, ymax; + int n, dy, xsave, ysave; if (mc->list) { if (TAILQ_EMPTY(resultq) && mc->list) { @@ -330,18 +332,33 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, mc->num++; } + xine = screen_find_xinerama(sc, mc->x, mc->y); + if (xine) { + xmin = xine->x_org; + xmax = xine->x_org + xine->width; + ymin = xine->y_org; + ymax = xine->y_org + xine->height; + } else { + xmin = ymin = 0; + xmax = sc->xmax; + ymax = sc->ymax; + } + xsave = mc->x; ysave = mc->y; - if (mc->x < 0) - mc->x = 0; - else if (mc->x + mc->width >= sc->xmax) - mc->x = sc->xmax - mc->width; - if (mc->y + dy >= sc->ymax) - mc->y = sc->ymax - dy; + if (mc->x < xmin) + mc->x = xmin; + else if (mc->x + mc->width >= xmax) + mc->x = xmax - mc->width; + + if (mc->y + dy >= ymax) + mc->y = ymax - dy; /* never hide the top of the menu */ - if (mc->y < 0) - mc->y = 0; + if (mc->y < ymin) { + mc->y = ymin; + dy = ymax - ymin; + } if (mc->x != xsave || mc->y != ysave) xu_ptr_setpos(sc->rootwin, mc->x, mc->y); From 8ed968601e207b31a21dbec19e61b17580d456b7 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 5 May 2011 16:40:37 +0000 Subject: [PATCH 2/5] re-org. ok oga@ --- calmwm.h | 662 ++++++++++++++++++++++++++----------------------------- 1 file changed, 311 insertions(+), 351 deletions(-) diff --git a/calmwm.h b/calmwm.h index 87c54f8..b213312 100644 --- a/calmwm.h +++ b/calmwm.h @@ -31,13 +31,15 @@ #include #include -#define CALMWM_MAXNAMELEN 256 - #undef MIN #undef MAX #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) +#ifndef nitems +#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) +#endif + #define CONFFILE ".cwmrc" #define WMNAME "CWM" @@ -51,9 +53,34 @@ PointerMotionMask) #define SearchMask (KeyPressMask|ExposureMask) -#ifndef nitems -#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) -#endif +/* kb movement */ +#define CWM_MOVE 0x0001 +#define CWM_RESIZE 0x0002 +#define CWM_PTRMOVE 0x0004 +#define CWM_BIGMOVE 0x0008 +#define CWM_UP 0x0010 +#define CWM_DOWN 0x0020 +#define CWM_LEFT 0x0040 +#define CWM_RIGHT 0x0080 + +/* exec */ +#define CWM_EXEC_PROGRAM 0x0001 +#define CWM_EXEC_WM 0x0002 + +/* client cycle */ +#define CWM_CYCLE 0x0001 +#define CWM_RCYCLE 0x0002 + +/* group cycle */ +#define CWM_CYCLEGROUP 0x0001 +#define CWM_RCYCLEGROUP 0x0002 + +#define KBTOGROUP(X) ((X) - 1) + +union arg { + char *c; + int i; +}; enum cwmcolor { CWM_COLOR_BORDOR_ACTIVE, @@ -69,6 +96,7 @@ struct color { unsigned long pixel; char *name; }; + struct gap { int top; int bottom; @@ -76,13 +104,79 @@ struct gap { int right; }; -struct client_ctx; +struct winname { + TAILQ_ENTRY(winname) entry; + char *name; +}; +TAILQ_HEAD(winname_q, winname); -TAILQ_HEAD(cycle_entry_q, client_ctx); -TAILQ_HEAD(group_ctx_q, group_ctx); +struct client_ctx { + TAILQ_ENTRY(client_ctx) entry; + TAILQ_ENTRY(client_ctx) group_entry; + TAILQ_ENTRY(client_ctx) mru_entry; + struct screen_ctx *sc; + Window win; + XSizeHints *size; + Colormap cmap; + u_int bwidth; /* border width */ + struct { + int x; /* x position */ + int y; /* y position */ + int width; /* width */ + int height;/* height */ + int basew; /* desired width */ + int baseh; /* desired height */ + int minw; /* minimum width */ + int minh; /* minimum height */ + int maxw; /* maximum width */ + int maxh; /* maximum height */ + int incw; /* width increment progression */ + int inch; /* height increment progression */ + float mina; /* minimum aspect ratio */ + float maxa; /* maximum aspect ratio */ + } geom, savegeom; + struct { + int x; /* x position */ + int y; /* y position */ + } ptr; +#define CLIENT_PROTO_DELETE 0x0001 +#define CLIENT_PROTO_TAKEFOCUS 0x0002 + int xproto; +#define CLIENT_HIDDEN 0x0001 +#define CLIENT_IGNORE 0x0002 +#define CLIENT_DOMAXIMIZE 0x0004 +#define CLIENT_MAXIMIZED 0x0008 +#define CLIENT_DOVMAXIMIZE 0x0010 +#define CLIENT_VMAXIMIZED 0x0020 +#define CLIENT_DOHMAXIMIZE 0x0040 +#define CLIENT_HMAXIMIZED 0x0080 + int flags; + int state; + int active; + int stackingorder; +#define CLIENT_HIGHLIGHT_GROUP 0x0001 +#define CLIENT_HIGHLIGHT_UNGROUP 0x0002 + int highlight; + struct winname_q nameq; +#define CLIENT_MAXNAMEQLEN 5 + int nameqlen; + char *name; + char *label; + char *matchname; + struct group_ctx *group; + char *app_class; + char *app_name; +}; TAILQ_HEAD(client_ctx_q, client_ctx); +TAILQ_HEAD(cycle_entry_q, client_ctx); + +struct winmatch { + TAILQ_ENTRY(winmatch) entry; +#define WIN_MAXTITLELEN 256 + char title[WIN_MAXTITLELEN]; +}; +TAILQ_HEAD(winmatch_q, winmatch); -#define CALMWM_NGROUPS 9 struct group_ctx { TAILQ_ENTRY(group_ctx) entry; struct client_ctx_q clients; @@ -91,160 +185,43 @@ struct group_ctx { int nhidden; int highstack; }; +TAILQ_HEAD(group_ctx_q, group_ctx); -struct screen_ctx { - TAILQ_ENTRY(screen_ctx) entry; - - u_int which; - Window rootwin; - Window menuwin; - - struct color color[CWM_COLOR_MAX]; - GC gc; - - int altpersist; - - int xmax; - int ymax; - - struct gap gap; - struct cycle_entry_q mruq; - - XftDraw *xftdraw; - XftColor xftcolor; - XftFont *font; - u_int fontheight; - - int xinerama_no; - XineramaScreenInfo *xinerama; - struct group_ctx *group_active; - struct group_ctx groups[CALMWM_NGROUPS]; - int group_hideall; - struct group_ctx_q groupq; - char **group_names; - int group_nonames; -}; - -TAILQ_HEAD(screen_ctx_q, screen_ctx); - -#define CLIENT_PROTO_DELETE 0x01 -#define CLIENT_PROTO_TAKEFOCUS 0x02 - -#define CLIENT_MAXNAMEQLEN 5 - -#define CLIENT_HIDDEN 0x01 -#define CLIENT_IGNORE 0x02 -#define CLIENT_DOMAXIMIZE 0x04 -#define CLIENT_MAXIMIZED 0x08 -#define CLIENT_DOVMAXIMIZE 0x10 -#define CLIENT_VMAXIMIZED 0x20 -#define CLIENT_DOHMAXIMIZE 0x40 -#define CLIENT_HMAXIMIZED 0x80 - -#define CLIENT_HIGHLIGHT_GROUP 1 -#define CLIENT_HIGHLIGHT_UNGROUP 2 - -struct winname { - TAILQ_ENTRY(winname) entry; - char *name; -}; - -TAILQ_HEAD(winname_q, winname); - -struct client_ctx { - TAILQ_ENTRY(client_ctx) entry; - TAILQ_ENTRY(client_ctx) searchentry; - TAILQ_ENTRY(client_ctx) group_entry; - TAILQ_ENTRY(client_ctx) mru_entry; - - struct screen_ctx *sc; - Window win; - XSizeHints *size; - - Colormap cmap; - - u_int bwidth; - struct { - int x, y, width, height, basew, baseh, - minw, minh, maxw, maxh, incw, inch; - float mina, maxa; - } geom, savegeom; - - struct { - int x,y; - } ptr; - - int xproto; - - int flags; - int state; - char *name; - struct winname_q nameq; - size_t nameqlen; - - char *label; - int active; - int highlight; - - char *matchname; - struct group_ctx *group; - - int stackingorder; - - char *app_class; - char *app_name; -}; - -extern const char *shortcut_to_name[]; - -/* Autogroups */ struct autogroupwin { TAILQ_ENTRY(autogroupwin) entry; char *class; char *name; int num; }; - TAILQ_HEAD(autogroupwin_q, autogroupwin); -#define CWM_MOVE 0x01 -#define CWM_RESIZE 0x02 -#define CWM_PTRMOVE 0x04 -#define CWM_BIGMOVE 0x08 -#define CWM_UP 0x10 -#define CWM_DOWN 0x20 -#define CWM_LEFT 0x40 -#define CWM_RIGHT 0x80 - -/* - * Match a window. - */ -#define CONF_MAX_WINTITLE 256 -struct winmatch { - TAILQ_ENTRY(winmatch) entry; - char title[CONF_MAX_WINTITLE]; -}; - -TAILQ_HEAD(winmatch_q, winmatch); - -/* for cwm_exec */ -#define CWM_EXEC_PROGRAM 0x1 -#define CWM_EXEC_WM 0x2 -/* for alt-tab */ -#define CWM_CYCLE 0x0 -#define CWM_RCYCLE 0x1 -/* for group cycle */ -#define CWM_CYCLEGROUP 0x0 -#define CWM_RCYCLEGROUP 0x1 - -#define KBFLAG_NEEDCLIENT 0x01 - -#define KBTOGROUP(X) ((X) - 1) - -union arg { - char *c; - int i; +struct screen_ctx { + TAILQ_ENTRY(screen_ctx) entry; + u_int which; + Window rootwin; + Window menuwin; + struct color color[CWM_COLOR_MAX]; + GC gc; + int altpersist; + int xmax; + int ymax; + struct gap gap; + struct cycle_entry_q mruq; + XftColor xftcolor; + XftDraw *xftdraw; + XftFont *font; + u_int fontheight; + int xinerama_no; + XineramaScreenInfo *xinerama; +#define CALMWM_NGROUPS 9 + struct group_ctx groups[CALMWM_NGROUPS]; + struct group_ctx_q groupq; + int group_hideall; + int group_nonames; + struct group_ctx *group_active; + char **group_names; }; +TAILQ_HEAD(screen_ctx_q, screen_ctx); struct keybinding { TAILQ_ENTRY(keybinding) entry; @@ -253,33 +230,43 @@ struct keybinding { int modmask; int keysym; int keycode; +#define KBFLAG_NEEDCLIENT 0x0001 int flags; }; +TAILQ_HEAD(keybinding_q, keybinding); + +struct mousebinding { + TAILQ_ENTRY(mousebinding) entry; + void (*callback)(struct client_ctx *, void *); + int modmask; + int button; +#define MOUSEBIND_CTX_ROOT 0x0001 +#define MOUSEBIND_CTX_WIN 0x0002 + int context; +}; +TAILQ_HEAD(mousebinding_q, mousebinding); struct cmd { TAILQ_ENTRY(cmd) entry; int flags; char image[MAXPATHLEN]; - char label[256]; - /* (argv) */ +#define CMD_MAXLABELLEN 256 + char label[CMD_MAXLABELLEN]; }; - -struct mousebinding { - int modmask; - int button; - int context; - void (*callback)(struct client_ctx *, void *); - TAILQ_ENTRY(mousebinding) entry; -}; - -#define MOUSEBIND_CTX_ROOT 1 -#define MOUSEBIND_CTX_WIN 2 - -TAILQ_HEAD(keybinding_q, keybinding); TAILQ_HEAD(cmd_q, cmd); -TAILQ_HEAD(mousebinding_q, mousebinding); -/* Global configuration */ +struct menu { + TAILQ_ENTRY(menu) entry; + TAILQ_ENTRY(menu) resultentry; +#define MENU_MAXENTRY 50 + char text[MENU_MAXENTRY + 1]; + char print[MENU_MAXENTRY + 1]; + void *ctx; + short dummy; + short abort; +}; +TAILQ_HEAD(menu_q, menu); + struct conf { struct keybinding_q keybindingq; struct autogroupwin_q autogroupq; @@ -287,15 +274,13 @@ struct conf { char conf_path[MAXPATHLEN]; struct cmd_q cmdq; struct mousebinding_q mousebindingq; - -#define CONF_STICKY_GROUPS 0x0001 +#define CONF_STICKY_GROUPS 0x0001 int flags; -#define CONF_BWIDTH 1 +#define CONF_BWIDTH 1 int bwidth; -#define CONF_MAMOUNT 1 +#define CONF_MAMOUNT 1 int mamount; struct gap gap; - #define CONF_COLOR_ACTIVEBORDER "#CCCCCC" #define CONF_COLOR_INACTIVEBORDER "#666666" #define CONF_COLOR_GROUPBORDER "blue" @@ -303,74 +288,126 @@ struct conf { #define CONF_COLOR_MENUFG "black" #define CONF_COLOR_MENUBG "white" struct color color[CWM_COLOR_MAX]; - char termpath[MAXPATHLEN]; char lockpath[MAXPATHLEN]; - -#define DEFAULTFONTNAME "sans-serif:pixelsize=14:bold" +#define DEFAULTFONTNAME "sans-serif:pixelsize=14:bold" char *DefaultFontName; }; -/* Menu stuff */ - -#define MENU_MAXENTRY 50 - -struct menu { - TAILQ_ENTRY(menu) entry; - TAILQ_ENTRY(menu) resultentry; - - char text[MENU_MAXENTRY + 1]; - char print[MENU_MAXENTRY + 1]; - void *ctx; - short dummy; - short abort; -}; - -TAILQ_HEAD(menu_q, menu); - /* MWM hints */ - struct mwm_hints { u_long flags; u_long functions; u_long decorations; }; - -#define MWM_NUMHINTS 3 - +#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) +#define MWM_HINTS_DECORATIONS (1<<1) +#define MWM_DECOR_ALL (1<<0) +#define MWM_DECOR_BORDER (1<<1) __dead void usage(void); -struct client_ctx *client_find(Window); -struct client_ctx *client_new(Window, struct screen_ctx *, int); -int client_delete(struct client_ctx *); -void client_setactive(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_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_maximize(struct client_ctx *); -void client_vertmaximize(struct client_ctx *); -void client_horizmaximize(struct client_ctx *); -void client_map(struct client_ctx *); -void client_mtf(struct client_ctx *); -struct client_ctx *client_cycle(struct screen_ctx *, int); -void client_getsizehints(struct client_ctx *); void client_applysizehints(struct client_ctx *); +struct client_ctx *client_current(void); +struct client_ctx *client_cycle(struct screen_ctx *, int); +int client_delete(struct client_ctx *); +void client_draw_border(struct client_ctx *); +struct client_ctx *client_find(Window); +void client_getsizehints(struct client_ctx *); +void client_hide(struct client_ctx *); +void client_horizmaximize(struct client_ctx *); +void client_leave(struct client_ctx *); +void client_lower(struct client_ctx *); +void client_map(struct client_ctx *); +void client_maximize(struct client_ctx *); +void client_move(struct client_ctx *); +void client_mtf(struct client_ctx *); +struct client_ctx *client_new(Window, struct screen_ctx *, int); +void client_ptrsave(struct client_ctx *); +void client_ptrwarp(struct client_ctx *); +void client_raise(struct client_ctx *); +void client_resize(struct client_ctx *); +void client_send_delete(struct client_ctx *); +void client_setactive(struct client_ctx *, int); +void client_setname(struct client_ctx *); +void client_unhide(struct client_ctx *); +void client_vertmaximize(struct client_ctx *); +void client_warp(struct client_ctx *); + +void group_alltoggle(struct screen_ctx *); +void group_autogroup(struct client_ctx *); +void group_client_delete(struct client_ctx *); +void group_cycle(struct screen_ctx *, int); +void group_hidetoggle(struct screen_ctx *, int); +void group_init(struct screen_ctx *); +void group_make_autogroup(struct conf *, char *, int); +void group_menu(XButtonEvent *); +void group_movetogroup(struct client_ctx *, int); +void group_only(struct screen_ctx *, int); +void group_sticky(struct client_ctx *); +void group_sticky_toggle_enter(struct client_ctx *); +void group_sticky_toggle_exit(struct client_ctx *); +void group_update_names(struct screen_ctx *); + +void search_match_client(struct menu_q *, struct menu_q *, + char *); +void search_match_exec(struct menu_q *, struct menu_q *, + char *); +void search_match_text(struct menu_q *, struct menu_q *, + char *); +void search_print_client(struct menu *, int); + +XineramaScreenInfo *screen_find_xinerama(struct screen_ctx *, int, int); +struct screen_ctx *screen_fromroot(Window); +void screen_init_xinerama(struct screen_ctx *); +void screen_update_geometry(struct screen_ctx *, int, int); +void screen_updatestackingorder(struct screen_ctx *); + +void kbfunc_client_cycle(struct client_ctx *, union arg *); +void kbfunc_client_cyclegroup(struct client_ctx *, + union arg *); +void kbfunc_client_delete(struct client_ctx *, union arg *); +void kbfunc_client_group(struct client_ctx *, union arg *); +void kbfunc_client_grouponly(struct client_ctx *, + union arg *); +void kbfunc_client_grouptoggle(struct client_ctx *, + union arg *); +void kbfunc_client_hide(struct client_ctx *, union arg *); +void kbfunc_client_hmaximize(struct client_ctx *, + union arg *); +void kbfunc_client_label(struct client_ctx *, union arg *); +void kbfunc_client_lower(struct client_ctx *, union arg *); +void kbfunc_client_maximize(struct client_ctx *, + union arg *); +void kbfunc_client_movetogroup(struct client_ctx *, + union arg *); +void kbfunc_client_nogroup(struct client_ctx *, + union arg *); +void kbfunc_client_raise(struct client_ctx *, union arg *); +void kbfunc_client_rcycle(struct client_ctx *, union arg *); +void kbfunc_client_search(struct client_ctx *, union arg *); +void kbfunc_client_vmaximize(struct client_ctx *, + union arg *); +void kbfunc_cmdexec(struct client_ctx *, union arg *); +void kbfunc_exec(struct client_ctx *, union arg *); +void kbfunc_lock(struct client_ctx *, union arg *); +void kbfunc_menu_search(struct client_ctx *, union arg *); +void kbfunc_moveresize(struct client_ctx *, union arg *); +void kbfunc_quit_wm(struct client_ctx *, union arg *); +void kbfunc_reload(struct client_ctx *, union arg *); +void kbfunc_ssh(struct client_ctx *, union arg *); +void kbfunc_term(struct client_ctx *, union arg *); + +void mousefunc_menu_cmd(struct client_ctx *, void *); +void mousefunc_menu_group(struct client_ctx *, void *); +void mousefunc_menu_unhide(struct client_ctx *, void *); +void mousefunc_window_grouptoggle(struct client_ctx *, + void *); +void mousefunc_window_hide(struct client_ctx *, void *); +void mousefunc_window_lower(struct client_ctx *, void *); +void mousefunc_window_move(struct client_ctx *, void *); +void mousefunc_window_resize(struct client_ctx *, void *); struct menu *menu_filter(struct screen_ctx *, struct menu_q *, char *, char *, int, @@ -378,138 +415,63 @@ struct menu *menu_filter(struct screen_ctx *, struct menu_q *, void (*)(struct menu *, int)); void menu_init(struct screen_ctx *); -void xev_loop(void); - -void xu_getatoms(void); -int xu_ptr_grab(Window, int, Cursor); -void 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_key_ungrab(Window, int, int); -void xu_configure(struct client_ctx *); -void xu_sendmsg(Window, Atom, long); -int xu_getprop(Window, Atom, Atom, long, u_char **); -int xu_getstrprop(Window, Atom, char **); -void xu_setstate(struct client_ctx *, int); -int xu_getstate(struct client_ctx *, int *); -unsigned long xu_getcolor(struct screen_ctx *, char *); -void xu_freecolor(struct screen_ctx *, unsigned long); -void xu_setwmname(struct screen_ctx *); - -int u_spawn(char *); -void u_exec(char *); - -void xfree(void *); -void *xmalloc(size_t); -void *xcalloc(size_t, size_t); -char *xstrdup(const char *); - -struct screen_ctx *screen_fromroot(Window); -void screen_updatestackingorder(struct screen_ctx *); -void screen_update_geometry(struct screen_ctx *, int, int); -void screen_init_xinerama(struct screen_ctx *); -XineramaScreenInfo *screen_find_xinerama(struct screen_ctx *, int, int); - -void conf_setup(struct conf *, const char *); -void conf_client(struct client_ctx *); -void conf_grab(struct conf *, struct keybinding *); -void conf_ungrab(struct conf *, struct keybinding *); -void conf_bindname(struct conf *, char *, char *); -void conf_mousebind(struct conf *, char *, char *); -void conf_grab_mouse(struct client_ctx *); -void conf_reload(struct conf *); -void conf_gap(struct conf *, struct screen_ctx *); -void conf_font(struct conf *, struct screen_ctx *); -void conf_color(struct conf *, struct screen_ctx *); -void conf_init(struct conf *); -void conf_clear(struct conf *); -void conf_cmd_add(struct conf *, char *, char *, int); - int parse_config(const char *, struct conf *); -void kbfunc_client_lower(struct client_ctx *, union arg *); -void kbfunc_client_raise(struct client_ctx *, union arg *); -void kbfunc_client_search(struct client_ctx *, union arg *); -void kbfunc_client_hide(struct client_ctx *, union arg *); -void kbfunc_client_cycle(struct client_ctx *, union arg *); -void kbfunc_client_rcycle(struct client_ctx *, union arg *); -void kbfunc_cmdexec(struct client_ctx *, union arg *); -void kbfunc_client_label(struct client_ctx *, union arg *); -void kbfunc_client_delete(struct client_ctx *, union arg *); -void kbfunc_client_group(struct client_ctx *, union arg *); -void kbfunc_client_grouponly(struct client_ctx *, - union arg *); -void kbfunc_client_cyclegroup(struct client_ctx *, - union arg *); -void kbfunc_client_nogroup(struct client_ctx *, - union arg *); -void kbfunc_client_grouptoggle(struct client_ctx *, - union arg *); -void kbfunc_client_movetogroup(struct client_ctx *, - union arg *); -void kbfunc_client_maximize(struct client_ctx *, - union arg *); -void kbfunc_client_vmaximize(struct client_ctx *, - union arg *); -void kbfunc_client_hmaximize(struct client_ctx *, - union arg *); -void kbfunc_reload(struct client_ctx *, union arg *); -void kbfunc_quit_wm(struct client_ctx *, union arg *); -void kbfunc_moveresize(struct client_ctx *, union arg *); -void kbfunc_menu_search(struct client_ctx *, union arg *); -void kbfunc_exec(struct client_ctx *, union arg *); -void kbfunc_ssh(struct client_ctx *, union arg *); -void kbfunc_term(struct client_ctx *, union arg *); -void kbfunc_lock(struct client_ctx *, union arg *); - -void mousefunc_window_resize(struct client_ctx *, void *); -void mousefunc_window_move(struct client_ctx *, void *); -void mousefunc_window_grouptoggle(struct client_ctx *, - void *); -void mousefunc_window_lower(struct client_ctx *, void *); -void mousefunc_window_hide(struct client_ctx *, void *); -void mousefunc_menu_group(struct client_ctx *, void *); -void mousefunc_menu_unhide(struct client_ctx *, void *); -void mousefunc_menu_cmd(struct client_ctx *, void *); - -void search_match_client(struct menu_q *, struct menu_q *, - char *); -void search_print_client(struct menu *, int); -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(struct screen_ctx *); -void group_make_autogroup(struct conf *, char *, int); -void group_update_names(struct screen_ctx *); -void group_hidetoggle(struct screen_ctx *, int); -void group_only(struct screen_ctx *, int); -void group_cycle(struct screen_ctx *, int); -void group_sticky(struct client_ctx *); -void group_client_delete(struct client_ctx *); -void group_menu(XButtonEvent *); -void group_alltoggle(struct screen_ctx *); -void group_sticky_toggle_enter(struct client_ctx *); -void group_sticky_toggle_exit(struct client_ctx *); -void group_autogroup(struct client_ctx *); -void group_movetogroup(struct client_ctx *, int); +void conf_bindname(struct conf *, char *, char *); +void conf_clear(struct conf *); +void conf_client(struct client_ctx *); +void conf_cmd_add(struct conf *, char *, char *, int); +void conf_color(struct conf *, struct screen_ctx *); +void conf_font(struct conf *, struct screen_ctx *); +void conf_gap(struct conf *, struct screen_ctx *); +void conf_grab(struct conf *, struct keybinding *); +void conf_grab_mouse(struct client_ctx *); +void conf_init(struct conf *); +void conf_mousebind(struct conf *, char *, char *); +void conf_reload(struct conf *); +void conf_setup(struct conf *, const char *); +void conf_ungrab(struct conf *, struct keybinding *); int font_ascent(struct screen_ctx *); int font_descent(struct screen_ctx *); +void font_draw(struct screen_ctx *, const char *, int, + Drawable, int, int); u_int font_height(struct screen_ctx *); void font_init(struct screen_ctx *); int font_width(struct screen_ctx *, const char *, int); -void font_draw(struct screen_ctx *, const char *, int, - Drawable, int, int); XftFont *font_make(struct screen_ctx *, const char *); -/* Externs */ +void xev_loop(void); +void xu_btn_grab(Window, int, u_int); +void xu_btn_ungrab(Window, int, u_int); +void xu_configure(struct client_ctx *); +void xu_freecolor(struct screen_ctx *, unsigned long); +void xu_getatoms(void); +unsigned long xu_getcolor(struct screen_ctx *, char *); +int xu_getprop(Window, Atom, Atom, long, u_char **); +int xu_getstate(struct client_ctx *, int *); +int xu_getstrprop(Window, Atom, char **); +void xu_key_grab(Window, int, int); +void xu_key_ungrab(Window, int, int); +void xu_ptr_getpos(Window, int *, int *); +int xu_ptr_grab(Window, int, Cursor); +int xu_ptr_regrab(int, Cursor); +void xu_ptr_setpos(Window, int, int); +void xu_ptr_ungrab(void); +void xu_sendmsg(Window, Atom, long); +void xu_setstate(struct client_ctx *, int); +void xu_setwmname(struct screen_ctx *); + +void u_exec(char *); +int u_spawn(char *); + +void *xcalloc(size_t, size_t); +void xfree(void *); +void *xmalloc(size_t); +char *xstrdup(const char *); + +/* Externs */ extern Display *X_Dpy; extern Cursor Cursor_move; @@ -519,12 +481,10 @@ extern Cursor Cursor_default; extern Cursor Cursor_question; extern struct screen_ctx_q Screenq; -extern struct screen_ctx *curscreen; - extern struct client_ctx_q Clientq; +extern struct conf Conf; extern int HasXinerama, HasRandr, Randr_ev; -extern struct conf Conf; #define WM_STATE cwm_atoms[0] #define WM_DELETE_WINDOW cwm_atoms[1] From 604a5d07a47ef516e83ac68d02861188d725951c Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 5 May 2011 19:52:52 +0000 Subject: [PATCH 3/5] bump window resize back to 60hz. instead, we should not need to sync every time we move/resize a window, so remove XSync in both mouse move and resize events. tested by Brynet as well. ok oga@ --- mousefunc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mousefunc.c b/mousefunc.c index 074f090..30eed53 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -106,10 +106,9 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg) /* Recompute window output */ mousefunc_sweep_draw(cc); - /* don't sync more than 10 times / second */ - if ((ev.xmotion.time - time) > (1000 / 10)) { + /* don't resize more than 60 times / second */ + if ((ev.xmotion.time - time) > (1000 / 60)) { time = ev.xmotion.time; - XSync(X_Dpy, False); client_resize(cc); } break; @@ -159,10 +158,9 @@ mousefunc_window_move(struct client_ctx *cc, void *arg) cc->geom.x = ev.xmotion.x_root - px - cc->bwidth; cc->geom.y = ev.xmotion.y_root - py - cc->bwidth; - /* don't sync more than 60 times / second */ + /* don't move more than 60 times / second */ if ((ev.xmotion.time - time) > (1000 / 60)) { time = ev.xmotion.time; - XSync(X_Dpy, False); client_move(cc); } break; From 760c6b5522626145662eb423ec77ccf4d19da584 Mon Sep 17 00:00:00 2001 From: oga Date: Fri, 6 May 2011 19:39:44 +0000 Subject: [PATCH 4/5] On map, don't warp to windows that are marked as ignored. Requested by Christian Neukirchen last august. He provided a patch but the one I wrote was significantly simpler (1 - 2 + in the whole diff). makes sense to okan@. --- xevents.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xevents.c b/xevents.c index 0d9799d..17c11aa 100644 --- a/xevents.c +++ b/xevents.c @@ -90,8 +90,8 @@ xev_handle_maprequest(XEvent *ee) if (strncasecmp(wm->title, cc->name, strlen(wm->title)) == 0) return; } - - client_ptrwarp(cc); + if ((cc->flags & CLIENT_IGNORE) == 0) + client_ptrwarp(cc); } static void From 43450c8fd744b85aaed80da3f6132acfd4dafd8c Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 7 May 2011 17:15:37 +0000 Subject: [PATCH 5/5] introduce a new 'freeze' flag (CMS-f by default) which may be applied to any window, after which all move/resize requests will be ignored, essentially freezing the window in place. there's a possibility to merge this with the 'ignore' concept, pending on how ignore+freeze should behave (really more ewmh stuff), but punting for now since ponies are on the line. requested and tested by thib at k2k11 with ponies, unicorns and rainbows. 'save the unicorns' todd@, ok oga@ --- calmwm.h | 3 +++ client.c | 18 ++++++++++++++++++ conf.c | 2 ++ cwm.1 | 4 +++- cwmrc.5 | 2 ++ kbfunc.c | 9 +++++++++ mousefunc.c | 6 ++++++ 7 files changed, 43 insertions(+), 1 deletion(-) diff --git a/calmwm.h b/calmwm.h index b213312..7a758d1 100644 --- a/calmwm.h +++ b/calmwm.h @@ -150,6 +150,7 @@ struct client_ctx { #define CLIENT_VMAXIMIZED 0x0020 #define CLIENT_DOHMAXIMIZE 0x0040 #define CLIENT_HMAXIMIZED 0x0080 +#define CLIENT_FREEZE 0x0100 int flags; int state; int active; @@ -314,6 +315,7 @@ struct client_ctx *client_cycle(struct screen_ctx *, int); int client_delete(struct client_ctx *); void client_draw_border(struct client_ctx *); struct client_ctx *client_find(Window); +void client_freeze(struct client_ctx *); void client_getsizehints(struct client_ctx *); void client_hide(struct client_ctx *); void client_horizmaximize(struct client_ctx *); @@ -368,6 +370,7 @@ void kbfunc_client_cycle(struct client_ctx *, union arg *); void kbfunc_client_cyclegroup(struct client_ctx *, union arg *); void kbfunc_client_delete(struct client_ctx *, union arg *); +void kbfunc_client_freeze(struct client_ctx *, union arg *); void kbfunc_client_group(struct client_ctx *, union arg *); void kbfunc_client_grouponly(struct client_ctx *, union arg *); diff --git a/client.c b/client.c index 237c0ce..1767f44 100644 --- a/client.c +++ b/client.c @@ -264,6 +264,15 @@ client_current(void) return (_curcc); } +void +client_freeze(struct client_ctx *cc) +{ + if (cc->flags & CLIENT_FREEZE) + cc->flags &= ~CLIENT_FREEZE; + else + cc->flags |= CLIENT_FREEZE; +} + void client_maximize(struct client_ctx *cc) { @@ -271,6 +280,9 @@ client_maximize(struct client_ctx *cc) int xmax = sc->xmax, ymax = sc->ymax; int x_org = 0, y_org = 0; + if (cc->flags & CLIENT_FREEZE) + return; + if (cc->flags & CLIENT_MAXIMIZED) { cc->geom = cc->savegeom; } else { @@ -310,6 +322,9 @@ client_vertmaximize(struct client_ctx *cc) struct screen_ctx *sc = cc->sc; int y_org = 0, ymax = sc->ymax; + if (cc->flags & CLIENT_FREEZE) + return; + if (cc->flags & CLIENT_VMAXIMIZED) { cc->geom = cc->savegeom; } else { @@ -341,6 +356,9 @@ client_horizmaximize(struct client_ctx *cc) struct screen_ctx *sc = cc->sc; int x_org = 0, xmax = sc->xmax; + if (cc->flags & CLIENT_FREEZE) + return; + if (cc->flags & CLIENT_HMAXIMIZED) { cc->geom = cc->savegeom; } else { diff --git a/conf.c b/conf.c index b453405..f61099d 100644 --- a/conf.c +++ b/conf.c @@ -138,6 +138,7 @@ static struct { { "CM-f", "maximize" }, { "CM-equal", "vmaximize" }, { "CMS-equal", "hmaximize" }, + { "CMS-f", "freeze" }, { "CMS-r", "reload" }, { "CMS-q", "quit" }, { "M-h", "moveleft" }, @@ -361,6 +362,7 @@ static struct { { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} }, { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} }, { "hmaximize", kbfunc_client_hmaximize, KBFLAG_NEEDCLIENT, {0} }, + { "freeze", kbfunc_client_freeze, KBFLAG_NEEDCLIENT, {0} }, { "reload", kbfunc_reload, 0, {0} }, { "quit", kbfunc_quit_wm, 0, {0} }, { "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} }, diff --git a/cwm.1 b/cwm.1 index 1282798..1b82f12 100644 --- a/cwm.1 +++ b/cwm.1 @@ -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. .\" -.Dd $Mdocdate: August 24 2009 $ +.Dd $Mdocdate: September 25 2010 $ .Dt CWM 1 .Os .Sh NAME @@ -88,6 +88,8 @@ Toggle group membership of current window. Cycle through active groups. .It Ic M-Left Reverse cycle through active groups. +.It Ic CMS-f +Toggle freezing geometry of current window. .It Ic CM-f Toggle full-screen size of current window. .It Ic CM-= diff --git a/cwmrc.5 b/cwmrc.5 index 800e253..a0544ff 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -287,6 +287,8 @@ Lower current window. Raise current window. .It label Label current window. +.It freeze +Freeze current window geometry. .It maximize Maximize current window full-screen. .It vmaximize diff --git a/kbfunc.c b/kbfunc.c index c4ee7ed..fc2aede 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -58,6 +58,9 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg) int x, y, flags, amt; u_int mx, my; + if (cc->flags & CLIENT_FREEZE) + return; + sc = cc->sc; mx = my = 0; @@ -479,6 +482,12 @@ kbfunc_client_hmaximize(struct client_ctx *cc, union arg *arg) client_horizmaximize(cc); } +void +kbfunc_client_freeze(struct client_ctx *cc, union arg *arg) +{ + client_freeze(cc); +} + void kbfunc_quit_wm(struct client_ctx *cc, union arg *arg) { diff --git a/mousefunc.c b/mousefunc.c index 30eed53..c5537fa 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -84,6 +84,9 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg) struct screen_ctx *sc = cc->sc; int x = cc->geom.x, y = cc->geom.y; + if (cc->flags & CLIENT_FREEZE) + return; + client_raise(cc); client_ptrsave(cc); @@ -142,6 +145,9 @@ mousefunc_window_move(struct client_ctx *cc, void *arg) client_raise(cc); + if (cc->flags & CLIENT_FREEZE) + return; + if (xu_ptr_grab(cc->win, MouseMask, Cursor_move) < 0) return;