mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
cvsimport
This commit is contained in:
commit
513c35dca9
3
Makefile
3
Makefile
@ -24,12 +24,11 @@ CFLAGS+= -Wall -O2 -g
|
|||||||
LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lxcb -lXau -lXdmcp \
|
LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lxcb -lXau -lXdmcp \
|
||||||
-lfontconfig -lexpat -lfreetype -lz -lXinerama -lXrandr -lXext
|
-lfontconfig -lexpat -lfreetype -lz -lXinerama -lXrandr -lXext
|
||||||
|
|
||||||
MANDIR= ${X11BASE}/man/cat
|
MANDIR= ${X11BASE}/man/man
|
||||||
MAN= cwm.1 cwmrc.5
|
MAN= cwm.1 cwmrc.5
|
||||||
|
|
||||||
CLEANFILES= cwm.cat1 cwmrc.cat5
|
CLEANFILES= cwm.cat1 cwmrc.cat5
|
||||||
|
|
||||||
|
|
||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
59
calmwm.c
59
calmwm.c
@ -35,22 +35,22 @@
|
|||||||
|
|
||||||
Display *X_Dpy;
|
Display *X_Dpy;
|
||||||
|
|
||||||
Cursor Cursor_move;
|
|
||||||
Cursor Cursor_resize;
|
|
||||||
Cursor Cursor_select;
|
|
||||||
Cursor Cursor_default;
|
Cursor Cursor_default;
|
||||||
|
Cursor Cursor_move;
|
||||||
|
Cursor Cursor_normal;
|
||||||
Cursor Cursor_question;
|
Cursor Cursor_question;
|
||||||
|
Cursor Cursor_resize;
|
||||||
|
|
||||||
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
|
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
|
||||||
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
|
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
|
||||||
|
|
||||||
int HasXinerama, HasRandr, Randr_ev;
|
int HasXinerama, HasRandr, Randr_ev;
|
||||||
int Starting;
|
|
||||||
struct conf Conf;
|
struct conf Conf;
|
||||||
|
|
||||||
static void sigchld_cb(int);
|
static void sigchld_cb(int);
|
||||||
static void dpy_init(const char *);
|
static void dpy_init(const char *);
|
||||||
static int x_errorhandler(Display *, XErrorEvent *);
|
static int x_errorhandler(Display *, XErrorEvent *);
|
||||||
|
static int x_wmerrorhandler(Display *, XErrorEvent *);
|
||||||
static void x_setup(void);
|
static void x_setup(void);
|
||||||
static void x_setupscreen(struct screen_ctx *, u_int);
|
static void x_setupscreen(struct screen_ctx *, u_int);
|
||||||
static void x_teardown(void);
|
static void x_teardown(void);
|
||||||
@ -80,14 +80,12 @@ main(int argc, char **argv)
|
|||||||
if (signal(SIGCHLD, sigchld_cb) == SIG_ERR)
|
if (signal(SIGCHLD, sigchld_cb) == SIG_ERR)
|
||||||
err(1, "signal");
|
err(1, "signal");
|
||||||
|
|
||||||
Starting = 1;
|
|
||||||
dpy_init(display_name);
|
dpy_init(display_name);
|
||||||
|
|
||||||
bzero(&Conf, sizeof(Conf));
|
bzero(&Conf, sizeof(Conf));
|
||||||
conf_setup(&Conf, conf_file);
|
conf_setup(&Conf, conf_file);
|
||||||
xu_getatoms();
|
xu_getatoms();
|
||||||
x_setup();
|
x_setup();
|
||||||
Starting = 0;
|
|
||||||
|
|
||||||
xev_loop();
|
xev_loop();
|
||||||
|
|
||||||
@ -101,10 +99,15 @@ dpy_init(const char *dpyname)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
XSetErrorHandler(x_errorhandler);
|
||||||
|
|
||||||
if ((X_Dpy = XOpenDisplay(dpyname)) == NULL)
|
if ((X_Dpy = XOpenDisplay(dpyname)) == NULL)
|
||||||
errx(1, "unable to open display \"%s\"",
|
errx(1, "unable to open display \"%s\"",
|
||||||
XDisplayName(dpyname));
|
XDisplayName(dpyname));
|
||||||
|
|
||||||
|
XSetErrorHandler(x_wmerrorhandler);
|
||||||
|
XSelectInput(X_Dpy, DefaultRootWindow(X_Dpy), SubstructureRedirectMask);
|
||||||
|
XSync(X_Dpy, False);
|
||||||
XSetErrorHandler(x_errorhandler);
|
XSetErrorHandler(x_errorhandler);
|
||||||
|
|
||||||
HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
|
HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
|
||||||
@ -117,6 +120,12 @@ x_setup(void)
|
|||||||
struct keybinding *kb;
|
struct keybinding *kb;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor);
|
||||||
|
Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur);
|
||||||
|
Cursor_normal = XCreateFontCursor(X_Dpy, XC_left_ptr);
|
||||||
|
Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow);
|
||||||
|
Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner);
|
||||||
|
|
||||||
for (i = 0; i < ScreenCount(X_Dpy); i++) {
|
for (i = 0; i < ScreenCount(X_Dpy); i++) {
|
||||||
sc = xcalloc(1, sizeof(*sc));
|
sc = xcalloc(1, sizeof(*sc));
|
||||||
x_setupscreen(sc, i);
|
x_setupscreen(sc, i);
|
||||||
@ -129,12 +138,6 @@ x_setup(void)
|
|||||||
*/
|
*/
|
||||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
||||||
conf_grab(&Conf, kb);
|
conf_grab(&Conf, kb);
|
||||||
|
|
||||||
Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur);
|
|
||||||
Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner);
|
|
||||||
Cursor_select = XCreateFontCursor(X_Dpy, XC_hand1);
|
|
||||||
Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor);
|
|
||||||
Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -176,11 +179,12 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
|||||||
|
|
||||||
xu_setwmname(sc);
|
xu_setwmname(sc);
|
||||||
|
|
||||||
rootattr.event_mask = ChildMask|PropertyChangeMask|EnterWindowMask|
|
rootattr.cursor = Cursor_normal;
|
||||||
LeaveWindowMask|ColormapChangeMask|ButtonMask;
|
rootattr.event_mask = CHILDMASK|PropertyChangeMask|EnterWindowMask|
|
||||||
|
LeaveWindowMask|ColormapChangeMask|BUTTONMASK;
|
||||||
|
|
||||||
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
||||||
CWEventMask, &rootattr);
|
CWEventMask|CWCursor, &rootattr);
|
||||||
|
|
||||||
/* Deal with existing clients. */
|
/* Deal with existing clients. */
|
||||||
XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins);
|
XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins);
|
||||||
@ -190,7 +194,7 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
|||||||
if (winattr.override_redirect ||
|
if (winattr.override_redirect ||
|
||||||
winattr.map_state != IsViewable)
|
winattr.map_state != IsViewable)
|
||||||
continue;
|
continue;
|
||||||
client_new(wins[i], sc, winattr.map_state != IsUnmapped);
|
(void)client_new(wins[i], sc, winattr.map_state != IsUnmapped);
|
||||||
}
|
}
|
||||||
XFree(wins);
|
XFree(wins);
|
||||||
|
|
||||||
@ -211,28 +215,26 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
|||||||
XSync(X_Dpy, False);
|
XSync(X_Dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
x_wmerrorhandler(Display *dpy, XErrorEvent *e)
|
||||||
|
{
|
||||||
|
errx(1, "root window unavailable - perhaps another wm is running?");
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
static int
|
static int
|
||||||
x_errorhandler(Display *dpy, XErrorEvent *e)
|
x_errorhandler(Display *dpy, XErrorEvent *e)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#if DEBUG
|
||||||
{
|
|
||||||
char msg[80], number[80], req[80];
|
char msg[80], number[80], req[80];
|
||||||
|
|
||||||
XGetErrorText(X_Dpy, e->error_code, msg, sizeof(msg));
|
XGetErrorText(X_Dpy, e->error_code, msg, sizeof(msg));
|
||||||
snprintf(number, sizeof(number), "%d", e->request_code);
|
(void)snprintf(number, sizeof(number), "%d", e->request_code);
|
||||||
XGetErrorDatabaseText(X_Dpy, "XRequest", number,
|
XGetErrorDatabaseText(X_Dpy, "XRequest", number,
|
||||||
"<unknown>", req, sizeof(req));
|
"<unknown>", req, sizeof(req));
|
||||||
|
|
||||||
warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg);
|
warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Starting &&
|
|
||||||
e->error_code == BadAccess &&
|
|
||||||
e->request_code == X_GrabKey)
|
|
||||||
errx(1, "root window unavailable - perhaps another "
|
|
||||||
"wm is running?");
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +258,7 @@ usage(void)
|
|||||||
{
|
{
|
||||||
extern char *__progname;
|
extern char *__progname;
|
||||||
|
|
||||||
fprintf(stderr, "usage: %s [-c file] [-d display]\n", __progname);
|
(void)fprintf(stderr, "usage: %s [-c file] [-d display]\n",
|
||||||
|
__progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
50
calmwm.h
50
calmwm.h
@ -51,15 +51,15 @@ size_t strlcat(char *, const char *, size_t);
|
|||||||
#define CONFFILE ".cwmrc"
|
#define CONFFILE ".cwmrc"
|
||||||
#define WMNAME "CWM"
|
#define WMNAME "CWM"
|
||||||
|
|
||||||
#define ChildMask (SubstructureRedirectMask|SubstructureNotifyMask)
|
#define CHILDMASK (SubstructureRedirectMask|SubstructureNotifyMask)
|
||||||
#define ButtonMask (ButtonPressMask|ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
#define MouseMask (ButtonMask|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
#define KeyMask (KeyPressMask|ExposureMask)
|
#define KEYMASK (KeyPressMask|ExposureMask)
|
||||||
#define MenuMask (ButtonMask|ButtonMotionMask|ExposureMask| \
|
#define MENUMASK (BUTTONMASK|ButtonMotionMask|ExposureMask| \
|
||||||
PointerMotionMask)
|
PointerMotionMask)
|
||||||
#define MenuGrabMask (ButtonMask|ButtonMotionMask|StructureNotifyMask|\
|
#define MENUGRABMASK (BUTTONMASK|ButtonMotionMask|StructureNotifyMask|\
|
||||||
PointerMotionMask)
|
PointerMotionMask)
|
||||||
#define SearchMask (KeyPressMask|ExposureMask)
|
#define SEARCHMASK (KeyPressMask|ExposureMask)
|
||||||
|
|
||||||
/* kb movement */
|
/* kb movement */
|
||||||
#define CWM_MOVE 0x0001
|
#define CWM_MOVE 0x0001
|
||||||
@ -75,14 +75,10 @@ size_t strlcat(char *, const char *, size_t);
|
|||||||
#define CWM_EXEC_PROGRAM 0x0001
|
#define CWM_EXEC_PROGRAM 0x0001
|
||||||
#define CWM_EXEC_WM 0x0002
|
#define CWM_EXEC_WM 0x0002
|
||||||
|
|
||||||
/* client cycle */
|
/* cycle */
|
||||||
#define CWM_CYCLE 0
|
#define CWM_CYCLE 0
|
||||||
#define CWM_RCYCLE 1
|
#define CWM_RCYCLE 1
|
||||||
|
|
||||||
/* group cycle */
|
|
||||||
#define CWM_CYCLEGROUP 0
|
|
||||||
#define CWM_RCYCLEGROUP 1
|
|
||||||
|
|
||||||
#define KBTOGROUP(X) ((X) - 1)
|
#define KBTOGROUP(X) ((X) - 1)
|
||||||
|
|
||||||
union arg {
|
union arg {
|
||||||
@ -91,7 +87,7 @@ union arg {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum cwmcolor {
|
enum cwmcolor {
|
||||||
CWM_COLOR_BORDOR_ACTIVE,
|
CWM_COLOR_BORDER_ACTIVE,
|
||||||
CWM_COLOR_BORDER_INACTIVE,
|
CWM_COLOR_BORDER_INACTIVE,
|
||||||
CWM_COLOR_BORDER_GROUP,
|
CWM_COLOR_BORDER_GROUP,
|
||||||
CWM_COLOR_BORDER_UNGROUP,
|
CWM_COLOR_BORDER_UNGROUP,
|
||||||
@ -152,13 +148,10 @@ struct client_ctx {
|
|||||||
int xproto;
|
int xproto;
|
||||||
#define CLIENT_HIDDEN 0x0001
|
#define CLIENT_HIDDEN 0x0001
|
||||||
#define CLIENT_IGNORE 0x0002
|
#define CLIENT_IGNORE 0x0002
|
||||||
#define CLIENT_DOMAXIMIZE 0x0004
|
#define CLIENT_MAXIMIZED 0x0004
|
||||||
#define CLIENT_MAXIMIZED 0x0008
|
#define CLIENT_VMAXIMIZED 0x0008
|
||||||
#define CLIENT_DOVMAXIMIZE 0x0010
|
#define CLIENT_HMAXIMIZED 0x0010
|
||||||
#define CLIENT_VMAXIMIZED 0x0020
|
#define CLIENT_FREEZE 0x0020
|
||||||
#define CLIENT_DOHMAXIMIZE 0x0040
|
|
||||||
#define CLIENT_HMAXIMIZED 0x0080
|
|
||||||
#define CLIENT_FREEZE 0x0100
|
|
||||||
int flags;
|
int flags;
|
||||||
int state;
|
int state;
|
||||||
int active;
|
int active;
|
||||||
@ -219,7 +212,6 @@ struct screen_ctx {
|
|||||||
XftColor xftcolor;
|
XftColor xftcolor;
|
||||||
XftDraw *xftdraw;
|
XftDraw *xftdraw;
|
||||||
XftFont *font;
|
XftFont *font;
|
||||||
u_int fontheight;
|
|
||||||
int xinerama_no;
|
int xinerama_no;
|
||||||
XineramaScreenInfo *xinerama;
|
XineramaScreenInfo *xinerama;
|
||||||
#define CALMWM_NGROUPS 9
|
#define CALMWM_NGROUPS 9
|
||||||
@ -289,6 +281,8 @@ struct conf {
|
|||||||
int bwidth;
|
int bwidth;
|
||||||
#define CONF_MAMOUNT 1
|
#define CONF_MAMOUNT 1
|
||||||
int mamount;
|
int mamount;
|
||||||
|
#define CONF_SNAPDIST 0
|
||||||
|
int snapdist;
|
||||||
struct gap gap;
|
struct gap gap;
|
||||||
#define CONF_COLOR_ACTIVEBORDER "#CCCCCC"
|
#define CONF_COLOR_ACTIVEBORDER "#CCCCCC"
|
||||||
#define CONF_COLOR_INACTIVEBORDER "#666666"
|
#define CONF_COLOR_INACTIVEBORDER "#666666"
|
||||||
@ -319,8 +313,8 @@ __dead void usage(void);
|
|||||||
|
|
||||||
void client_applysizehints(struct client_ctx *);
|
void client_applysizehints(struct client_ctx *);
|
||||||
struct client_ctx *client_current(void);
|
struct client_ctx *client_current(void);
|
||||||
struct client_ctx *client_cycle(struct screen_ctx *, int);
|
void client_cycle(struct screen_ctx *, int);
|
||||||
int client_delete(struct client_ctx *);
|
void client_delete(struct client_ctx *);
|
||||||
void client_draw_border(struct client_ctx *);
|
void client_draw_border(struct client_ctx *);
|
||||||
struct client_ctx *client_find(Window);
|
struct client_ctx *client_find(Window);
|
||||||
void client_freeze(struct client_ctx *);
|
void client_freeze(struct client_ctx *);
|
||||||
@ -341,6 +335,7 @@ void client_resize(struct client_ctx *);
|
|||||||
void client_send_delete(struct client_ctx *);
|
void client_send_delete(struct client_ctx *);
|
||||||
void client_setactive(struct client_ctx *, int);
|
void client_setactive(struct client_ctx *, int);
|
||||||
void client_setname(struct client_ctx *);
|
void client_setname(struct client_ctx *);
|
||||||
|
int client_snapcalc(int, int, int, int, int);
|
||||||
void client_unhide(struct client_ctx *);
|
void client_unhide(struct client_ctx *);
|
||||||
void client_vertmaximize(struct client_ctx *);
|
void client_vertmaximize(struct client_ctx *);
|
||||||
void client_warp(struct client_ctx *);
|
void client_warp(struct client_ctx *);
|
||||||
@ -418,6 +413,7 @@ void mousefunc_window_grouptoggle(struct client_ctx *,
|
|||||||
void mousefunc_window_hide(struct client_ctx *, void *);
|
void mousefunc_window_hide(struct client_ctx *, void *);
|
||||||
void mousefunc_window_lower(struct client_ctx *, void *);
|
void mousefunc_window_lower(struct client_ctx *, void *);
|
||||||
void mousefunc_window_move(struct client_ctx *, void *);
|
void mousefunc_window_move(struct client_ctx *, void *);
|
||||||
|
void mousefunc_window_raise(struct client_ctx *, void *);
|
||||||
void mousefunc_window_resize(struct client_ctx *, void *);
|
void mousefunc_window_resize(struct client_ctx *, void *);
|
||||||
|
|
||||||
struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
||||||
@ -475,7 +471,7 @@ void xu_setstate(struct client_ctx *, int);
|
|||||||
void xu_setwmname(struct screen_ctx *);
|
void xu_setwmname(struct screen_ctx *);
|
||||||
|
|
||||||
void u_exec(char *);
|
void u_exec(char *);
|
||||||
int u_spawn(char *);
|
void u_spawn(char *);
|
||||||
|
|
||||||
void *xcalloc(size_t, size_t);
|
void *xcalloc(size_t, size_t);
|
||||||
void xfree(void *);
|
void xfree(void *);
|
||||||
@ -485,11 +481,11 @@ char *xstrdup(const char *);
|
|||||||
/* Externs */
|
/* Externs */
|
||||||
extern Display *X_Dpy;
|
extern Display *X_Dpy;
|
||||||
|
|
||||||
extern Cursor Cursor_move;
|
|
||||||
extern Cursor Cursor_resize;
|
|
||||||
extern Cursor Cursor_select;
|
|
||||||
extern Cursor Cursor_default;
|
extern Cursor Cursor_default;
|
||||||
|
extern Cursor Cursor_move;
|
||||||
|
extern Cursor Cursor_normal;
|
||||||
extern Cursor Cursor_question;
|
extern Cursor Cursor_question;
|
||||||
|
extern Cursor Cursor_resize;
|
||||||
|
|
||||||
extern struct screen_ctx_q Screenq;
|
extern struct screen_ctx_q Screenq;
|
||||||
extern struct client_ctx_q Clientq;
|
extern struct client_ctx_q Clientq;
|
||||||
|
89
client.c
89
client.c
@ -137,7 +137,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
|||||||
return (cc);
|
return (cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
client_delete(struct client_ctx *cc)
|
client_delete(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
@ -189,8 +189,6 @@ client_delete(struct client_ctx *cc)
|
|||||||
|
|
||||||
client_freehints(cc);
|
client_freehints(cc);
|
||||||
xfree(cc);
|
xfree(cc);
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -285,6 +283,8 @@ client_maximize(struct client_ctx *cc)
|
|||||||
|
|
||||||
if (cc->flags & CLIENT_MAXIMIZED) {
|
if (cc->flags & CLIENT_MAXIMIZED) {
|
||||||
cc->geom = cc->savegeom;
|
cc->geom = cc->savegeom;
|
||||||
|
cc->bwidth = Conf.bwidth;
|
||||||
|
cc->flags &= ~CLIENT_MAXIMIZED;
|
||||||
} else {
|
} else {
|
||||||
if (!(cc->flags & (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)))
|
if (!(cc->flags & (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)))
|
||||||
cc->savegeom = cc->geom;
|
cc->savegeom = cc->geom;
|
||||||
@ -310,7 +310,8 @@ calc:
|
|||||||
cc->geom.y = y_org + sc->gap.top;
|
cc->geom.y = y_org + sc->gap.top;
|
||||||
cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom);
|
cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom);
|
||||||
cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
|
cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
|
||||||
cc->flags |= CLIENT_DOMAXIMIZE;
|
cc->bwidth = 0;
|
||||||
|
cc->flags |= CLIENT_MAXIMIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_resize(cc);
|
client_resize(cc);
|
||||||
@ -326,7 +327,10 @@ client_vertmaximize(struct client_ctx *cc)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (cc->flags & CLIENT_VMAXIMIZED) {
|
if (cc->flags & CLIENT_VMAXIMIZED) {
|
||||||
cc->geom = cc->savegeom;
|
cc->geom.y = cc->savegeom.y;
|
||||||
|
cc->geom.height = cc->savegeom.height;
|
||||||
|
cc->bwidth = Conf.bwidth;
|
||||||
|
cc->flags &= ~CLIENT_VMAXIMIZED;
|
||||||
} else {
|
} else {
|
||||||
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_HMAXIMIZED)))
|
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_HMAXIMIZED)))
|
||||||
cc->savegeom = cc->geom;
|
cc->savegeom = cc->geom;
|
||||||
@ -344,7 +348,7 @@ calc:
|
|||||||
cc->geom.y = y_org + sc->gap.top;
|
cc->geom.y = y_org + sc->gap.top;
|
||||||
cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top +
|
cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top +
|
||||||
sc->gap.bottom);
|
sc->gap.bottom);
|
||||||
cc->flags |= CLIENT_DOVMAXIMIZE;
|
cc->flags |= CLIENT_VMAXIMIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_resize(cc);
|
client_resize(cc);
|
||||||
@ -360,7 +364,10 @@ client_horizmaximize(struct client_ctx *cc)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (cc->flags & CLIENT_HMAXIMIZED) {
|
if (cc->flags & CLIENT_HMAXIMIZED) {
|
||||||
cc->geom = cc->savegeom;
|
cc->geom.x = cc->savegeom.x;
|
||||||
|
cc->geom.width = cc->savegeom.width;
|
||||||
|
cc->bwidth = Conf.bwidth;
|
||||||
|
cc->flags &= ~CLIENT_HMAXIMIZED;
|
||||||
} else {
|
} else {
|
||||||
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED)))
|
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED)))
|
||||||
cc->savegeom = cc->geom;
|
cc->savegeom = cc->geom;
|
||||||
@ -378,7 +385,7 @@ calc:
|
|||||||
cc->geom.x = x_org + sc->gap.left;
|
cc->geom.x = x_org + sc->gap.left;
|
||||||
cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left +
|
cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left +
|
||||||
sc->gap.right);
|
sc->gap.right);
|
||||||
cc->flags |= CLIENT_DOHMAXIMIZE;
|
cc->flags |= CLIENT_HMAXIMIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_resize(cc);
|
client_resize(cc);
|
||||||
@ -387,23 +394,6 @@ calc:
|
|||||||
void
|
void
|
||||||
client_resize(struct client_ctx *cc)
|
client_resize(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
cc->flags &= ~(CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED |
|
|
||||||
CLIENT_HMAXIMIZED);
|
|
||||||
|
|
||||||
if (cc->flags & CLIENT_DOMAXIMIZE) {
|
|
||||||
cc->bwidth = 0;
|
|
||||||
cc->flags &= ~CLIENT_DOMAXIMIZE;
|
|
||||||
cc->flags |= CLIENT_MAXIMIZED;
|
|
||||||
} else if (cc->flags & CLIENT_DOVMAXIMIZE) {
|
|
||||||
cc->flags &= ~CLIENT_DOVMAXIMIZE;
|
|
||||||
cc->flags |= CLIENT_VMAXIMIZED;
|
|
||||||
} else if (cc->flags & CLIENT_DOHMAXIMIZE) {
|
|
||||||
cc->flags &= ~CLIENT_DOHMAXIMIZE;
|
|
||||||
cc->flags |= CLIENT_HMAXIMIZED;
|
|
||||||
} else {
|
|
||||||
cc->bwidth = Conf.bwidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
client_draw_border(cc);
|
client_draw_border(cc);
|
||||||
|
|
||||||
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
||||||
@ -414,11 +404,6 @@ client_resize(struct client_ctx *cc)
|
|||||||
void
|
void
|
||||||
client_move(struct client_ctx *cc)
|
client_move(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
if (cc->flags & CLIENT_VMAXIMIZED)
|
|
||||||
cc->savegeom.x = cc->geom.x;
|
|
||||||
if (cc->flags & CLIENT_HMAXIMIZED)
|
|
||||||
cc->savegeom.y = cc->geom.y;
|
|
||||||
|
|
||||||
XMoveWindow(X_Dpy, cc->win, cc->geom.x, cc->geom.y);
|
XMoveWindow(X_Dpy, cc->win, cc->geom.x, cc->geom.y);
|
||||||
xu_configure(cc);
|
xu_configure(cc);
|
||||||
}
|
}
|
||||||
@ -504,7 +489,7 @@ client_draw_border(struct client_ctx *cc)
|
|||||||
pixel = sc->color[CWM_COLOR_BORDER_UNGROUP].pixel;
|
pixel = sc->color[CWM_COLOR_BORDER_UNGROUP].pixel;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pixel = sc->color[CWM_COLOR_BORDOR_ACTIVE].pixel;
|
pixel = sc->color[CWM_COLOR_BORDER_ACTIVE].pixel;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -550,8 +535,7 @@ client_setname(struct client_ctx *cc)
|
|||||||
char *newname;
|
char *newname;
|
||||||
|
|
||||||
if (!xu_getstrprop(cc->win, _NET_WM_NAME, &newname))
|
if (!xu_getstrprop(cc->win, _NET_WM_NAME, &newname))
|
||||||
xu_getstrprop(cc->win, XA_WM_NAME, &newname);
|
if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname))
|
||||||
if (newname == NULL)
|
|
||||||
newname = emptystring;
|
newname = emptystring;
|
||||||
|
|
||||||
TAILQ_FOREACH(wn, &cc->nameq, entry)
|
TAILQ_FOREACH(wn, &cc->nameq, entry)
|
||||||
@ -580,11 +564,9 @@ match:
|
|||||||
xfree(wn);
|
xfree(wn);
|
||||||
cc->nameqlen--;
|
cc->nameqlen--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct client_ctx *
|
void
|
||||||
client_cycle(struct screen_ctx *sc, int reverse)
|
client_cycle(struct screen_ctx *sc, int reverse)
|
||||||
{
|
{
|
||||||
struct client_ctx *oldcc, *newcc;
|
struct client_ctx *oldcc, *newcc;
|
||||||
@ -594,7 +576,7 @@ client_cycle(struct screen_ctx *sc, int reverse)
|
|||||||
|
|
||||||
/* If no windows then you cant cycle */
|
/* If no windows then you cant cycle */
|
||||||
if (TAILQ_EMPTY(&sc->mruq))
|
if (TAILQ_EMPTY(&sc->mruq))
|
||||||
return (NULL);
|
return;
|
||||||
|
|
||||||
if (oldcc == NULL)
|
if (oldcc == NULL)
|
||||||
oldcc = (reverse ? TAILQ_LAST(&sc->mruq, cycle_entry_q) :
|
oldcc = (reverse ? TAILQ_LAST(&sc->mruq, cycle_entry_q) :
|
||||||
@ -614,7 +596,7 @@ client_cycle(struct screen_ctx *sc, int reverse)
|
|||||||
/* Is oldcc the only non-hidden window? */
|
/* Is oldcc the only non-hidden window? */
|
||||||
if (newcc == oldcc) {
|
if (newcc == oldcc) {
|
||||||
if (again)
|
if (again)
|
||||||
return (NULL); /* No windows visible. */
|
return; /* No windows visible. */
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -624,8 +606,6 @@ client_cycle(struct screen_ctx *sc, int reverse)
|
|||||||
sc->altpersist = 1;
|
sc->altpersist = 1;
|
||||||
client_ptrsave(oldcc);
|
client_ptrsave(oldcc);
|
||||||
client_ptrwarp(newcc);
|
client_ptrwarp(newcc);
|
||||||
|
|
||||||
return (newcc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct client_ctx *
|
static struct client_ctx *
|
||||||
@ -862,3 +842,32 @@ client_inbound(struct client_ctx *cc, int x, int y)
|
|||||||
return (x < cc->geom.width && x >= 0 &&
|
return (x < cc->geom.width && x >= 0 &&
|
||||||
y < cc->geom.height && y >= 0);
|
y < cc->geom.height && y >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
client_snapcalc(int n, int dn, int nmax, int bwidth, int snapdist)
|
||||||
|
{
|
||||||
|
int n0, n1, s0, s1;
|
||||||
|
|
||||||
|
s0 = s1 = 0;
|
||||||
|
n0 = n;
|
||||||
|
n1 = n + dn + (bwidth * 2);
|
||||||
|
|
||||||
|
if (abs(n0) <= snapdist)
|
||||||
|
s0 = -n0;
|
||||||
|
|
||||||
|
if (nmax - snapdist <= n1 && n1 <= nmax + snapdist)
|
||||||
|
s1 = nmax - n1;
|
||||||
|
|
||||||
|
/* possible to snap in both directions */
|
||||||
|
if (s0 != 0 && s1 != 0)
|
||||||
|
if (abs(s0) < abs(s1))
|
||||||
|
return s0;
|
||||||
|
else
|
||||||
|
return s1;
|
||||||
|
else if (s0 != 0)
|
||||||
|
return s0;
|
||||||
|
else if (s1 != 0)
|
||||||
|
return s1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
42
conf.c
42
conf.c
@ -48,14 +48,14 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags)
|
|||||||
/* "term" and "lock" have special meanings. */
|
/* "term" and "lock" have special meanings. */
|
||||||
|
|
||||||
if (strcmp(label, "term") == 0)
|
if (strcmp(label, "term") == 0)
|
||||||
strlcpy(c->termpath, image, sizeof(c->termpath));
|
(void)strlcpy(c->termpath, image, sizeof(c->termpath));
|
||||||
else if (strcmp(label, "lock") == 0)
|
else if (strcmp(label, "lock") == 0)
|
||||||
strlcpy(c->lockpath, image, sizeof(c->lockpath));
|
(void)strlcpy(c->lockpath, image, sizeof(c->lockpath));
|
||||||
else {
|
else {
|
||||||
struct cmd *cmd = xmalloc(sizeof(*cmd));
|
struct cmd *cmd = xmalloc(sizeof(*cmd));
|
||||||
cmd->flags = flags;
|
cmd->flags = flags;
|
||||||
strlcpy(cmd->image, image, sizeof(cmd->image));
|
(void)strlcpy(cmd->image, image, sizeof(cmd->image));
|
||||||
strlcpy(cmd->label, label, sizeof(cmd->label));
|
(void)strlcpy(cmd->label, label, sizeof(cmd->label));
|
||||||
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +70,6 @@ void
|
|||||||
conf_font(struct conf *c, struct screen_ctx *sc)
|
conf_font(struct conf *c, struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
sc->font = font_make(sc, c->DefaultFontName);
|
sc->font = font_make(sc, c->DefaultFontName);
|
||||||
sc->fontheight = font_ascent(sc) + font_descent(sc) + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -95,13 +94,13 @@ conf_reload(struct conf *c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
|
||||||
client_draw_border(cc);
|
|
||||||
TAILQ_FOREACH(sc, &Screenq, entry) {
|
TAILQ_FOREACH(sc, &Screenq, entry) {
|
||||||
conf_gap(c, sc);
|
conf_gap(c, sc);
|
||||||
conf_color(c, sc);
|
conf_color(c, sc);
|
||||||
conf_font(c, sc);
|
conf_font(c, sc);
|
||||||
}
|
}
|
||||||
|
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||||
|
client_draw_border(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@ -185,6 +184,7 @@ conf_init(struct conf *c)
|
|||||||
c->flags = 0;
|
c->flags = 0;
|
||||||
c->bwidth = CONF_BWIDTH;
|
c->bwidth = CONF_BWIDTH;
|
||||||
c->mamount = CONF_MAMOUNT;
|
c->mamount = CONF_MAMOUNT;
|
||||||
|
c->snapdist = CONF_SNAPDIST;
|
||||||
|
|
||||||
TAILQ_INIT(&c->ignoreq);
|
TAILQ_INIT(&c->ignoreq);
|
||||||
TAILQ_INIT(&c->cmdq);
|
TAILQ_INIT(&c->cmdq);
|
||||||
@ -199,10 +199,10 @@ conf_init(struct conf *c)
|
|||||||
conf_mousebind(c, m_binds[i].key, m_binds[i].func);
|
conf_mousebind(c, m_binds[i].key, m_binds[i].func);
|
||||||
|
|
||||||
/* Default term/lock */
|
/* Default term/lock */
|
||||||
strlcpy(c->termpath, "xterm", sizeof(c->termpath));
|
(void)strlcpy(c->termpath, "xterm", sizeof(c->termpath));
|
||||||
strlcpy(c->lockpath, "xlock", sizeof(c->lockpath));
|
(void)strlcpy(c->lockpath, "xlock", sizeof(c->lockpath));
|
||||||
|
|
||||||
c->color[CWM_COLOR_BORDOR_ACTIVE].name =
|
c->color[CWM_COLOR_BORDER_ACTIVE].name =
|
||||||
xstrdup(CONF_COLOR_ACTIVEBORDER);
|
xstrdup(CONF_COLOR_ACTIVEBORDER);
|
||||||
c->color[CWM_COLOR_BORDER_INACTIVE].name =
|
c->color[CWM_COLOR_BORDER_INACTIVE].name =
|
||||||
xstrdup(CONF_COLOR_INACTIVEBORDER);
|
xstrdup(CONF_COLOR_INACTIVEBORDER);
|
||||||
@ -273,17 +273,19 @@ conf_setup(struct conf *c, const char *conf_file)
|
|||||||
if (home == NULL)
|
if (home == NULL)
|
||||||
errx(1, "No HOME directory.");
|
errx(1, "No HOME directory.");
|
||||||
|
|
||||||
snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", home,
|
(void)snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s",
|
||||||
CONFFILE);
|
home, CONFFILE);
|
||||||
} else
|
} else
|
||||||
if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG))
|
if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG))
|
||||||
errx(1, "%s: %s", conf_file, strerror(errno));
|
errx(1, "%s: %s", conf_file, strerror(errno));
|
||||||
else
|
else
|
||||||
strlcpy(c->conf_path, conf_file, sizeof(c->conf_path));
|
(void)strlcpy(c->conf_path, conf_file,
|
||||||
|
sizeof(c->conf_path));
|
||||||
|
|
||||||
conf_init(c);
|
conf_init(c);
|
||||||
|
|
||||||
(void)parse_config(c->conf_path, c);
|
if (parse_config(c->conf_path, c) == -1)
|
||||||
|
warnx("config file %s has errors, not loading", c->conf_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -356,8 +358,8 @@ static struct {
|
|||||||
{ "movetogroup9", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
{ "movetogroup9", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
||||||
{.i = 9} },
|
{.i = 9} },
|
||||||
{ "nogroup", kbfunc_client_nogroup, 0, {0} },
|
{ "nogroup", kbfunc_client_nogroup, 0, {0} },
|
||||||
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLEGROUP} },
|
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
|
||||||
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLEGROUP} },
|
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
|
||||||
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
|
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
|
||||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
|
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
|
||||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },
|
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },
|
||||||
@ -415,7 +417,6 @@ static struct {
|
|||||||
{.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
{.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
||||||
{ "bigptrmoveright", kbfunc_moveresize, 0,
|
{ "bigptrmoveright", kbfunc_moveresize, 0,
|
||||||
{.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
{.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
||||||
{ NULL, NULL, 0, {0}},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -504,7 +505,7 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
|||||||
if (strcmp("unmap", binding) == 0)
|
if (strcmp("unmap", binding) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (iter = 0; name_to_kbfunc[iter].tag != NULL; iter++) {
|
for (iter = 0; iter < nitems(name_to_kbfunc); iter++) {
|
||||||
if (strcmp(name_to_kbfunc[iter].tag, binding) != 0)
|
if (strcmp(name_to_kbfunc[iter].tag, binding) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -521,7 +522,6 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
|||||||
current_binding->flags = 0;
|
current_binding->flags = 0;
|
||||||
conf_grab(c, current_binding);
|
conf_grab(c, current_binding);
|
||||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -556,11 +556,11 @@ static struct {
|
|||||||
{ "window_grouptoggle", mousefunc_window_grouptoggle,
|
{ "window_grouptoggle", mousefunc_window_grouptoggle,
|
||||||
MOUSEBIND_CTX_WIN },
|
MOUSEBIND_CTX_WIN },
|
||||||
{ "window_lower", mousefunc_window_lower, MOUSEBIND_CTX_WIN },
|
{ "window_lower", mousefunc_window_lower, MOUSEBIND_CTX_WIN },
|
||||||
|
{ "window_raise", mousefunc_window_raise, MOUSEBIND_CTX_WIN },
|
||||||
{ "window_hide", mousefunc_window_hide, MOUSEBIND_CTX_WIN },
|
{ "window_hide", mousefunc_window_hide, MOUSEBIND_CTX_WIN },
|
||||||
{ "menu_group", mousefunc_menu_group, MOUSEBIND_CTX_ROOT },
|
{ "menu_group", mousefunc_menu_group, MOUSEBIND_CTX_ROOT },
|
||||||
{ "menu_unhide", mousefunc_menu_unhide, MOUSEBIND_CTX_ROOT },
|
{ "menu_unhide", mousefunc_menu_unhide, MOUSEBIND_CTX_ROOT },
|
||||||
{ "menu_cmd", mousefunc_menu_cmd, MOUSEBIND_CTX_ROOT },
|
{ "menu_cmd", mousefunc_menu_cmd, MOUSEBIND_CTX_ROOT },
|
||||||
{ NULL, NULL, 0 },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -596,7 +596,7 @@ conf_mousebind(struct conf *c, char *name, char *binding)
|
|||||||
if (strcmp("unmap", binding) == 0)
|
if (strcmp("unmap", binding) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (iter = 0; name_to_mousefunc[iter].tag != NULL; iter++) {
|
for (iter = 0; iter < nitems(name_to_mousefunc); iter++) {
|
||||||
if (strcmp(name_to_mousefunc[iter].tag, binding) != 0)
|
if (strcmp(name_to_mousefunc[iter].tag, binding) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
20
cwmrc.5
20
cwmrc.5
@ -14,7 +14,7 @@
|
|||||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: September 25 2010 $
|
.Dd $Mdocdate: June 24 2011 $
|
||||||
.Dt CWMRC 5
|
.Dt CWMRC 5
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -24,7 +24,19 @@
|
|||||||
This manual page describes the
|
This manual page describes the
|
||||||
.Xr cwm 1
|
.Xr cwm 1
|
||||||
configuration file.
|
configuration file.
|
||||||
The following options are accepted in the configuration file:
|
.Pp
|
||||||
|
The current line can be extended over multiple lines using a backslash
|
||||||
|
.Pq Sq \e .
|
||||||
|
Comments can be put anywhere in the file using a hash mark
|
||||||
|
.Pq Sq # ,
|
||||||
|
and extend to the end of the current line.
|
||||||
|
Care should be taken when commenting out multi-line text:
|
||||||
|
the comment is effective until the end of the entire block.
|
||||||
|
.Pp
|
||||||
|
Arguments containing whitespace should be surrounded by double quotes
|
||||||
|
.Pq \&" .
|
||||||
|
.Pp
|
||||||
|
The following options are accepted:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag -width Ds -compact
|
.Bl -tag -width Ds -compact
|
||||||
.It Ic autogroup Ar group windowname
|
.It Ic autogroup Ar group windowname
|
||||||
@ -277,6 +289,8 @@ Reverse cycle through groups.
|
|||||||
Forward cycle through windows.
|
Forward cycle through windows.
|
||||||
.It rcycle
|
.It rcycle
|
||||||
Reverse cycle through windows.
|
Reverse cycle through windows.
|
||||||
|
.It snapdist
|
||||||
|
Minimum distance to snap-to adjacent edge.
|
||||||
.It delete
|
.It delete
|
||||||
Delete current window.
|
Delete current window.
|
||||||
.It hide
|
.It hide
|
||||||
@ -400,6 +414,8 @@ Move current window.
|
|||||||
Resize current window.
|
Resize current window.
|
||||||
.It window_lower
|
.It window_lower
|
||||||
Lower current window.
|
Lower current window.
|
||||||
|
.It window_raise
|
||||||
|
Raise current window.
|
||||||
.It window_hide
|
.It window_hide
|
||||||
Hide current window.
|
Hide current window.
|
||||||
.It window_grouptoggle
|
.It window_grouptoggle
|
||||||
|
7
font.c
7
font.c
@ -45,7 +45,7 @@ font_descent(struct screen_ctx *sc)
|
|||||||
u_int
|
u_int
|
||||||
font_height(struct screen_ctx *sc)
|
font_height(struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
return (sc->fontheight);
|
return (sc->font->height + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -66,7 +66,7 @@ font_width(struct screen_ctx *sc, const char *text, int len)
|
|||||||
{
|
{
|
||||||
XGlyphInfo extents;
|
XGlyphInfo extents;
|
||||||
|
|
||||||
XftTextExtents8(X_Dpy, sc->font, (const XftChar8*)text,
|
XftTextExtentsUtf8(X_Dpy, sc->font, (const FcChar8*)text,
|
||||||
len, &extents);
|
len, &extents);
|
||||||
|
|
||||||
return (extents.xOff);
|
return (extents.xOff);
|
||||||
@ -77,8 +77,7 @@ font_draw(struct screen_ctx *sc, const char *text, int len,
|
|||||||
Drawable d, int x, int y)
|
Drawable d, int x, int y)
|
||||||
{
|
{
|
||||||
XftDrawChange(sc->xftdraw, d);
|
XftDrawChange(sc->xftdraw, d);
|
||||||
/* Really needs to be UTF8'd. */
|
XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
|
||||||
XftDrawString8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
|
|
||||||
(const FcChar8*)text, len);
|
(const FcChar8*)text, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
group.c
6
group.c
@ -377,10 +377,10 @@ group_menu(XButtonEvent *e)
|
|||||||
|
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
mi = xcalloc(1, sizeof(*mi));
|
||||||
if (gc->hidden)
|
if (gc->hidden)
|
||||||
snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
|
(void)snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
|
||||||
gc->shortcut, sc->group_names[i]);
|
gc->shortcut, sc->group_names[i]);
|
||||||
else
|
else
|
||||||
snprintf(mi->text, sizeof(mi->text), "%d: %s",
|
(void)snprintf(mi->text, sizeof(mi->text), "%d: %s",
|
||||||
gc->shortcut, sc->group_names[i]);
|
gc->shortcut, sc->group_names[i]);
|
||||||
mi->ctx = gc;
|
mi->ctx = gc;
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
@ -533,7 +533,7 @@ group_set_names(struct screen_ctx *sc)
|
|||||||
tlen = len;
|
tlen = len;
|
||||||
for (i = 0; i < sc->group_nonames; i++) {
|
for (i = 0; i < sc->group_nonames; i++) {
|
||||||
slen = strlen(sc->group_names[i]) + 1;
|
slen = strlen(sc->group_names[i]) + 1;
|
||||||
strlcpy(q, sc->group_names[i], tlen);
|
(void)strlcpy(q, sc->group_names[i], tlen);
|
||||||
tlen -= slen;
|
tlen -= slen;
|
||||||
q += slen;
|
q += slen;
|
||||||
}
|
}
|
||||||
|
33
kbfunc.c
33
kbfunc.c
@ -25,6 +25,7 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -35,7 +36,7 @@
|
|||||||
#define KNOWN_HOSTS ".ssh/known_hosts"
|
#define KNOWN_HOSTS ".ssh/known_hosts"
|
||||||
#define HASH_MARKER "|1|"
|
#define HASH_MARKER "|1|"
|
||||||
|
|
||||||
extern int _xev_quit;
|
extern sig_atomic_t xev_quit;
|
||||||
|
|
||||||
void
|
void
|
||||||
kbfunc_client_lower(struct client_ctx *cc, union arg *arg)
|
kbfunc_client_lower(struct client_ctx *cc, union arg *arg)
|
||||||
@ -49,8 +50,8 @@ kbfunc_client_raise(struct client_ctx *cc, union arg *arg)
|
|||||||
client_raise(cc);
|
client_raise(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define typemask (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE)
|
#define TYPEMASK (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE)
|
||||||
#define movemask (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
|
#define MOVEMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
|
||||||
void
|
void
|
||||||
kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||||
{
|
{
|
||||||
@ -72,7 +73,7 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
|||||||
amt = amt * 10;
|
amt = amt * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (flags & movemask) {
|
switch (flags & MOVEMASK) {
|
||||||
case CWM_UP:
|
case CWM_UP:
|
||||||
my -= amt;
|
my -= amt;
|
||||||
break;
|
break;
|
||||||
@ -86,7 +87,7 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
|||||||
mx -= amt;
|
mx -= amt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (flags & typemask) {
|
switch (flags & TYPEMASK) {
|
||||||
case CWM_MOVE:
|
case CWM_MOVE:
|
||||||
cc->geom.y += my;
|
cc->geom.y += my;
|
||||||
if (cc->geom.y + cc->geom.height < 0)
|
if (cc->geom.y + cc->geom.height < 0)
|
||||||
@ -100,6 +101,13 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
|||||||
if (cc->geom.x > cc->sc->xmax - 1)
|
if (cc->geom.x > cc->sc->xmax - 1)
|
||||||
cc->geom.x = cc->sc->xmax - 1;
|
cc->geom.x = cc->sc->xmax - 1;
|
||||||
|
|
||||||
|
cc->geom.x += client_snapcalc(cc->geom.x,
|
||||||
|
cc->geom.width, cc->sc->xmax,
|
||||||
|
cc->bwidth, Conf.snapdist);
|
||||||
|
cc->geom.y += client_snapcalc(cc->geom.y,
|
||||||
|
cc->geom.height, cc->sc->ymax,
|
||||||
|
cc->bwidth, Conf.snapdist);
|
||||||
|
|
||||||
client_move(cc);
|
client_move(cc);
|
||||||
xu_ptr_getpos(cc->win, &x, &y);
|
xu_ptr_getpos(cc->win, &x, &y);
|
||||||
cc->ptr.y = y + my;
|
cc->ptr.y = y + my;
|
||||||
@ -150,7 +158,7 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg)
|
|||||||
|
|
||||||
TAILQ_FOREACH(cc, &Clientq, entry) {
|
TAILQ_FOREACH(cc, &Clientq, entry) {
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
mi = xcalloc(1, sizeof(*mi));
|
||||||
strlcpy(mi->text, cc->name, sizeof(mi->text));
|
(void)strlcpy(mi->text, cc->name, sizeof(mi->text));
|
||||||
mi->ctx = cc;
|
mi->ctx = cc;
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
}
|
}
|
||||||
@ -185,7 +193,7 @@ kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
|
|||||||
|
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
mi = xcalloc(1, sizeof(*mi));
|
||||||
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
(void)strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||||
mi->ctx = cmd;
|
mi->ctx = cmd;
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
}
|
}
|
||||||
@ -284,7 +292,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
|||||||
/* skip everything but regular files and symlinks */
|
/* skip everything but regular files and symlinks */
|
||||||
if (dp->d_type != DT_REG && dp->d_type != DT_LNK)
|
if (dp->d_type != DT_REG && dp->d_type != DT_LNK)
|
||||||
continue;
|
continue;
|
||||||
memset(tpath, '\0', sizeof(tpath));
|
(void)memset(tpath, '\0', sizeof(tpath));
|
||||||
l = snprintf(tpath, sizeof(tpath), "%s/%s", paths[i],
|
l = snprintf(tpath, sizeof(tpath), "%s/%s", paths[i],
|
||||||
dp->d_name);
|
dp->d_name);
|
||||||
/* check for truncation etc */
|
/* check for truncation etc */
|
||||||
@ -292,7 +300,8 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
|||||||
continue;
|
continue;
|
||||||
if (access(tpath, X_OK) == 0) {
|
if (access(tpath, X_OK) == 0) {
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
mi = xcalloc(1, sizeof(*mi));
|
||||||
strlcpy(mi->text, dp->d_name, sizeof(mi->text));
|
(void)strlcpy(mi->text,
|
||||||
|
dp->d_name, sizeof(mi->text));
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,7 +368,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
|||||||
else {
|
else {
|
||||||
/* EOF without EOL, copy and add the NUL */
|
/* EOF without EOL, copy and add the NUL */
|
||||||
lbuf = xmalloc(len + 1);
|
lbuf = xmalloc(len + 1);
|
||||||
memcpy(lbuf, buf, len);
|
(void)memcpy(lbuf, buf, len);
|
||||||
lbuf[len] = '\0';
|
lbuf[len] = '\0';
|
||||||
buf = lbuf;
|
buf = lbuf;
|
||||||
}
|
}
|
||||||
@ -378,7 +387,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
|||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
}
|
}
|
||||||
xfree(lbuf);
|
xfree(lbuf);
|
||||||
fclose(fp);
|
(void)fclose(fp);
|
||||||
|
|
||||||
if ((mi = menu_filter(sc, &menuq, "ssh", NULL, 1,
|
if ((mi = menu_filter(sc, &menuq, "ssh", NULL, 1,
|
||||||
search_match_exec, NULL)) != NULL) {
|
search_match_exec, NULL)) != NULL) {
|
||||||
@ -491,7 +500,7 @@ kbfunc_client_freeze(struct client_ctx *cc, union arg *arg)
|
|||||||
void
|
void
|
||||||
kbfunc_quit_wm(struct client_ctx *cc, union arg *arg)
|
kbfunc_quit_wm(struct client_ctx *cc, union arg *arg)
|
||||||
{
|
{
|
||||||
_xev_quit = 1;
|
xev_quit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
33
menu.c
33
menu.c
@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
#include "calmwm.h"
|
#include "calmwm.h"
|
||||||
|
|
||||||
#define PROMPT_SCHAR '»'
|
#define PROMPT_SCHAR "\xc2\xbb"
|
||||||
#define PROMPT_ECHAR '«'
|
#define PROMPT_ECHAR "\xc2\xab"
|
||||||
|
|
||||||
enum ctltype {
|
enum ctltype {
|
||||||
CTL_NONE = -1,
|
CTL_NONE = -1,
|
||||||
@ -76,8 +76,9 @@ menu_init(struct screen_ctx *sc)
|
|||||||
{
|
{
|
||||||
XGCValues gv;
|
XGCValues gv;
|
||||||
|
|
||||||
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, 0,
|
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1,
|
||||||
sc->color[CWM_COLOR_BG_MENU].pixel,
|
Conf.bwidth,
|
||||||
|
sc->color[CWM_COLOR_FG_MENU].pixel,
|
||||||
sc->color[CWM_COLOR_BG_MENU].pixel);
|
sc->color[CWM_COLOR_BG_MENU].pixel);
|
||||||
|
|
||||||
gv.foreground =
|
gv.foreground =
|
||||||
@ -113,21 +114,21 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
|||||||
ysave = mc.y;
|
ysave = mc.y;
|
||||||
|
|
||||||
if (prompt == NULL) {
|
if (prompt == NULL) {
|
||||||
evmask = MenuMask;
|
evmask = MENUMASK;
|
||||||
mc.promptstr[0] = '\0';
|
mc.promptstr[0] = '\0';
|
||||||
mc.list = 1;
|
mc.list = 1;
|
||||||
} else {
|
} else {
|
||||||
evmask = MenuMask | KeyMask; /* only accept keys if prompt */
|
evmask = MENUMASK | KEYMASK; /* only accept keys if prompt */
|
||||||
snprintf(mc.promptstr, sizeof(mc.promptstr), "%s%c", prompt,
|
(void)snprintf(mc.promptstr, sizeof(mc.promptstr), "%s%s",
|
||||||
PROMPT_SCHAR);
|
prompt, PROMPT_SCHAR);
|
||||||
snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%c", mc.promptstr,
|
(void)snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%s",
|
||||||
mc.searchstr, PROMPT_ECHAR);
|
mc.promptstr, mc.searchstr, PROMPT_ECHAR);
|
||||||
mc.width = font_width(sc, mc.dispstr, strlen(mc.dispstr));
|
mc.width = font_width(sc, mc.dispstr, strlen(mc.dispstr));
|
||||||
mc.hasprompt = 1;
|
mc.hasprompt = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initial != NULL)
|
if (initial != NULL)
|
||||||
strlcpy(mc.searchstr, initial, sizeof(mc.searchstr));
|
(void)strlcpy(mc.searchstr, initial, sizeof(mc.searchstr));
|
||||||
else
|
else
|
||||||
mc.searchstr[0] = '\0';
|
mc.searchstr[0] = '\0';
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
|||||||
XSelectInput(X_Dpy, sc->menuwin, evmask);
|
XSelectInput(X_Dpy, sc->menuwin, evmask);
|
||||||
XMapRaised(X_Dpy, sc->menuwin);
|
XMapRaised(X_Dpy, sc->menuwin);
|
||||||
|
|
||||||
if (xu_ptr_grab(sc->menuwin, MenuGrabMask, Cursor_question) < 0) {
|
if (xu_ptr_grab(sc->menuwin, MENUGRABMASK, Cursor_question) < 0) {
|
||||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -268,7 +269,7 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
|
|||||||
str[0] = chr;
|
str[0] = chr;
|
||||||
str[1] = '\0';
|
str[1] = '\0';
|
||||||
mc->changed = 1;
|
mc->changed = 1;
|
||||||
strlcat(mc->searchstr, str, sizeof(mc->searchstr));
|
(void)strlcat(mc->searchstr, str, sizeof(mc->searchstr));
|
||||||
}
|
}
|
||||||
|
|
||||||
mc->noresult = 0;
|
mc->noresult = 0;
|
||||||
@ -312,7 +313,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
|
|||||||
mc->width = 0;
|
mc->width = 0;
|
||||||
dy = 0;
|
dy = 0;
|
||||||
if (mc->hasprompt) {
|
if (mc->hasprompt) {
|
||||||
snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%c",
|
(void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s",
|
||||||
mc->promptstr, mc->searchstr, PROMPT_ECHAR);
|
mc->promptstr, mc->searchstr, PROMPT_ECHAR);
|
||||||
mc->width = font_width(sc, mc->dispstr, strlen(mc->dispstr));
|
mc->width = font_width(sc, mc->dispstr, strlen(mc->dispstr));
|
||||||
dy = font_height(sc);
|
dy = font_height(sc);
|
||||||
@ -405,11 +406,11 @@ menu_handle_move(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc)
|
|||||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
|
XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
|
||||||
font_height(sc) * mc->prev, mc->width, font_height(sc));
|
font_height(sc) * mc->prev, mc->width, font_height(sc));
|
||||||
if (mc->entry != -1) {
|
if (mc->entry != -1) {
|
||||||
xu_ptr_regrab(MenuGrabMask, Cursor_select);
|
(void)xu_ptr_regrab(MENUGRABMASK, Cursor_normal);
|
||||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
|
XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
|
||||||
font_height(sc) * mc->entry, mc->width, font_height(sc));
|
font_height(sc) * mc->entry, mc->width, font_height(sc));
|
||||||
} else
|
} else
|
||||||
xu_ptr_regrab(MenuGrabMask, Cursor_default);
|
(void)xu_ptr_regrab(MENUGRABMASK, Cursor_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct menu *
|
static struct menu *
|
||||||
|
37
mousefunc.c
37
mousefunc.c
@ -55,25 +55,23 @@ mousefunc_sweep_draw(struct client_ctx *cc)
|
|||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
char asize[10]; /* fits "nnnnxnnnn\0" */
|
char asize[10]; /* fits "nnnnxnnnn\0" */
|
||||||
int width, height, width_size, width_name;
|
int width, width_size, width_name;
|
||||||
|
|
||||||
snprintf(asize, sizeof(asize), "%dx%d",
|
(void)snprintf(asize, sizeof(asize), "%dx%d",
|
||||||
(cc->geom.width - cc->geom.basew) / cc->geom.incw,
|
(cc->geom.width - cc->geom.basew) / cc->geom.incw,
|
||||||
(cc->geom.height - cc->geom.baseh) / cc->geom.inch);
|
(cc->geom.height - cc->geom.baseh) / cc->geom.inch);
|
||||||
width_size = font_width(sc, asize, strlen(asize)) + 4;
|
width_size = font_width(sc, asize, strlen(asize)) + 4;
|
||||||
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
|
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
|
||||||
width = MAX(width_size, width_name);
|
width = MAX(width_size, width_name);
|
||||||
height = font_ascent(sc) + font_descent(sc) + 1;
|
|
||||||
|
|
||||||
XMoveResizeWindow(X_Dpy, sc->menuwin, cc->geom.x, cc->geom.y,
|
|
||||||
width, height * 2);
|
|
||||||
XMapWindow(X_Dpy, sc->menuwin);
|
|
||||||
XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
|
XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
|
||||||
|
XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, width, font_height(sc) * 2);
|
||||||
|
XMapWindow(X_Dpy, sc->menuwin);
|
||||||
XClearWindow(X_Dpy, sc->menuwin);
|
XClearWindow(X_Dpy, sc->menuwin);
|
||||||
font_draw(sc, cc->name, strlen(cc->name), sc->menuwin,
|
font_draw(sc, cc->name, strlen(cc->name), sc->menuwin,
|
||||||
2, font_ascent(sc) + 1);
|
2, font_ascent(sc) + 1);
|
||||||
font_draw(sc, asize, strlen(asize), sc->menuwin,
|
font_draw(sc, asize, strlen(asize), sc->menuwin,
|
||||||
width / 2 - width_size / 2, height + font_ascent(sc) + 1);
|
width / 2 - width_size / 2, font_height(sc) + font_ascent(sc) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -90,14 +88,14 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
|||||||
client_raise(cc);
|
client_raise(cc);
|
||||||
client_ptrsave(cc);
|
client_ptrsave(cc);
|
||||||
|
|
||||||
if (xu_ptr_grab(cc->win, MouseMask, Cursor_resize) < 0)
|
if (xu_ptr_grab(cc->win, MOUSEMASK, Cursor_resize) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
|
xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
|
||||||
mousefunc_sweep_draw(cc);
|
mousefunc_sweep_draw(cc);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
|
XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev);
|
||||||
|
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
@ -146,13 +144,13 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
|
|||||||
if (cc->flags & CLIENT_FREEZE)
|
if (cc->flags & CLIENT_FREEZE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (xu_ptr_grab(cc->win, MouseMask, Cursor_move) < 0)
|
if (xu_ptr_grab(cc->win, MOUSEMASK, Cursor_move) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xu_ptr_getpos(cc->win, &px, &py);
|
xu_ptr_getpos(cc->win, &px, &py);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
|
XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev);
|
||||||
|
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
@ -162,6 +160,13 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
|
|||||||
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
|
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
|
||||||
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
|
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
|
||||||
|
|
||||||
|
cc->geom.x += client_snapcalc(cc->geom.x,
|
||||||
|
cc->geom.width, cc->sc->xmax,
|
||||||
|
cc->bwidth, Conf.snapdist);
|
||||||
|
cc->geom.y += client_snapcalc(cc->geom.y,
|
||||||
|
cc->geom.height, cc->sc->ymax,
|
||||||
|
cc->bwidth, Conf.snapdist);
|
||||||
|
|
||||||
/* don't move more than 60 times / second */
|
/* don't move more than 60 times / second */
|
||||||
if ((ev.xmotion.time - time) > (1000 / 60)) {
|
if ((ev.xmotion.time - time) > (1000 / 60)) {
|
||||||
time = ev.xmotion.time;
|
time = ev.xmotion.time;
|
||||||
@ -191,6 +196,12 @@ mousefunc_window_lower(struct client_ctx *cc, void *arg)
|
|||||||
client_lower(cc);
|
client_lower(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mousefunc_window_raise(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_raise(cc);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mousefunc_window_hide(struct client_ctx *cc, void *arg)
|
mousefunc_window_hide(struct client_ctx *cc, void *arg)
|
||||||
{
|
{
|
||||||
@ -223,7 +234,7 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
mi = xcalloc(1, sizeof(*mi));
|
||||||
strlcpy(mi->text, wname, sizeof(mi->text));
|
(void)strlcpy(mi->text, wname, sizeof(mi->text));
|
||||||
mi->ctx = cc;
|
mi->ctx = cc;
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
}
|
}
|
||||||
@ -260,7 +271,7 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
|
|||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||||
mi = xcalloc(1, sizeof(*mi));
|
mi = xcalloc(1, sizeof(*mi));
|
||||||
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
(void)strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||||
mi->ctx = cmd;
|
mi->ctx = cmd;
|
||||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
}
|
}
|
||||||
|
19
parse.y
19
parse.y
@ -70,7 +70,7 @@ typedef struct {
|
|||||||
%token FONTNAME STICKY GAP MOUSEBIND
|
%token FONTNAME STICKY GAP MOUSEBIND
|
||||||
%token AUTOGROUP BIND COMMAND IGNORE
|
%token AUTOGROUP BIND COMMAND IGNORE
|
||||||
%token YES NO BORDERWIDTH MOVEAMOUNT
|
%token YES NO BORDERWIDTH MOVEAMOUNT
|
||||||
%token COLOR
|
%token COLOR SNAPDIST
|
||||||
%token ACTIVEBORDER INACTIVEBORDER
|
%token ACTIVEBORDER INACTIVEBORDER
|
||||||
%token GROUPBORDER UNGROUPBORDER
|
%token GROUPBORDER UNGROUPBORDER
|
||||||
%token ERROR
|
%token ERROR
|
||||||
@ -120,6 +120,9 @@ main : FONTNAME STRING {
|
|||||||
| MOVEAMOUNT NUMBER {
|
| MOVEAMOUNT NUMBER {
|
||||||
conf->mamount = $2;
|
conf->mamount = $2;
|
||||||
}
|
}
|
||||||
|
| SNAPDIST NUMBER {
|
||||||
|
conf->snapdist = $2;
|
||||||
|
}
|
||||||
| COMMAND STRING string {
|
| COMMAND STRING string {
|
||||||
conf_cmd_add(conf, $3, $2, 0);
|
conf_cmd_add(conf, $3, $2, 0);
|
||||||
free($2);
|
free($2);
|
||||||
@ -139,7 +142,7 @@ main : FONTNAME STRING {
|
|||||||
struct winmatch *wm;
|
struct winmatch *wm;
|
||||||
|
|
||||||
wm = xcalloc(1, sizeof(*wm));
|
wm = xcalloc(1, sizeof(*wm));
|
||||||
strlcpy(wm->title, $2, sizeof(wm->title));
|
(void)strlcpy(wm->title, $2, sizeof(wm->title));
|
||||||
TAILQ_INSERT_TAIL(&conf->ignoreq, wm, entry);
|
TAILQ_INSERT_TAIL(&conf->ignoreq, wm, entry);
|
||||||
|
|
||||||
free($2);
|
free($2);
|
||||||
@ -166,8 +169,8 @@ color : COLOR colors
|
|||||||
;
|
;
|
||||||
|
|
||||||
colors : ACTIVEBORDER STRING {
|
colors : ACTIVEBORDER STRING {
|
||||||
free(conf->color[CWM_COLOR_BORDOR_ACTIVE].name);
|
free(conf->color[CWM_COLOR_BORDER_ACTIVE].name);
|
||||||
conf->color[CWM_COLOR_BORDOR_ACTIVE].name = $2;
|
conf->color[CWM_COLOR_BORDER_ACTIVE].name = $2;
|
||||||
}
|
}
|
||||||
| INACTIVEBORDER STRING {
|
| INACTIVEBORDER STRING {
|
||||||
free(conf->color[CWM_COLOR_BORDER_INACTIVE].name);
|
free(conf->color[CWM_COLOR_BORDER_INACTIVE].name);
|
||||||
@ -228,6 +231,7 @@ lookup(char *s)
|
|||||||
{ "mousebind", MOUSEBIND},
|
{ "mousebind", MOUSEBIND},
|
||||||
{ "moveamount", MOVEAMOUNT},
|
{ "moveamount", MOVEAMOUNT},
|
||||||
{ "no", NO},
|
{ "no", NO},
|
||||||
|
{ "snapdist", SNAPDIST},
|
||||||
{ "sticky", STICKY},
|
{ "sticky", STICKY},
|
||||||
{ "ungroupborder", UNGROUPBORDER},
|
{ "ungroupborder", UNGROUPBORDER},
|
||||||
{ "yes", YES}
|
{ "yes", YES}
|
||||||
@ -498,7 +502,7 @@ parse_config(const char *filename, struct conf *xconf)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
strlcpy(conf->conf_path, filename, sizeof(conf->conf_path));
|
(void)strlcpy(conf->conf_path, filename, sizeof(conf->conf_path));
|
||||||
|
|
||||||
conf_init(conf);
|
conf_init(conf);
|
||||||
|
|
||||||
@ -523,6 +527,7 @@ parse_config(const char *filename, struct conf *xconf)
|
|||||||
xconf->flags = conf->flags;
|
xconf->flags = conf->flags;
|
||||||
xconf->bwidth = conf->bwidth;
|
xconf->bwidth = conf->bwidth;
|
||||||
xconf->mamount = conf->mamount;
|
xconf->mamount = conf->mamount;
|
||||||
|
xconf->snapdist = conf->snapdist;
|
||||||
xconf->gap = conf->gap;
|
xconf->gap = conf->gap;
|
||||||
|
|
||||||
while ((cmd = TAILQ_FIRST(&conf->cmdq)) != NULL) {
|
while ((cmd = TAILQ_FIRST(&conf->cmdq)) != NULL) {
|
||||||
@ -550,9 +555,9 @@ parse_config(const char *filename, struct conf *xconf)
|
|||||||
TAILQ_INSERT_TAIL(&xconf->mousebindingq, mb, entry);
|
TAILQ_INSERT_TAIL(&xconf->mousebindingq, mb, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
strlcpy(xconf->termpath, conf->termpath,
|
(void)strlcpy(xconf->termpath, conf->termpath,
|
||||||
sizeof(xconf->termpath));
|
sizeof(xconf->termpath));
|
||||||
strlcpy(xconf->lockpath, conf->lockpath,
|
(void)strlcpy(xconf->lockpath, conf->lockpath,
|
||||||
sizeof(xconf->lockpath));
|
sizeof(xconf->lockpath));
|
||||||
|
|
||||||
for (i = 0; i < CWM_COLOR_MAX; i++)
|
for (i = 0; i < CWM_COLOR_MAX; i++)
|
||||||
|
9
search.c
9
search.c
@ -46,7 +46,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
|||||||
|
|
||||||
TAILQ_INIT(resultq);
|
TAILQ_INIT(resultq);
|
||||||
|
|
||||||
memset(tierp, 0, sizeof(tierp));
|
(void)memset(tierp, 0, sizeof(tierp));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In order of rank:
|
* In order of rank:
|
||||||
@ -134,7 +134,8 @@ search_print_client(struct menu *mi, int list)
|
|||||||
if (list)
|
if (list)
|
||||||
cc->matchname = cc->name;
|
cc->matchname = cc->name;
|
||||||
|
|
||||||
snprintf(mi->print, sizeof(mi->print), "%c%s", flag, cc->matchname);
|
(void)snprintf(mi->print, sizeof(mi->print), "%c%s", flag,
|
||||||
|
cc->matchname);
|
||||||
|
|
||||||
if (!list && cc->matchname != cc->name &&
|
if (!list && cc->matchname != cc->name &&
|
||||||
strlen(mi->print) < sizeof(mi->print) - 1) {
|
strlen(mi->print) < sizeof(mi->print) - 1) {
|
||||||
@ -154,8 +155,8 @@ search_print_client(struct menu *mi, int list)
|
|||||||
diff = strlen(cc->name);
|
diff = strlen(cc->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
strlcpy(buf, mi->print, sizeof(buf));
|
(void)strlcpy(buf, mi->print, sizeof(buf));
|
||||||
snprintf(mi->print, sizeof(mi->print),
|
(void)snprintf(mi->print, sizeof(mi->print),
|
||||||
"%s:%.*s%s", buf, diff, cc->name, marker);
|
"%s:%.*s%s", buf, diff, cc->name, marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
util.c
9
util.c
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#define MAXARGLEN 20
|
#define MAXARGLEN 20
|
||||||
|
|
||||||
int
|
void
|
||||||
u_spawn(char *argstr)
|
u_spawn(char *argstr)
|
||||||
{
|
{
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
@ -42,12 +42,9 @@ u_spawn(char *argstr)
|
|||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
warn("fork");
|
warn("fork");
|
||||||
return (-1);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -79,6 +76,6 @@ u_exec(char *argstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*ap = NULL;
|
*ap = NULL;
|
||||||
setsid();
|
(void)setsid();
|
||||||
execvp(args[0], args);
|
(void)execvp(args[0], args);
|
||||||
}
|
}
|
||||||
|
@ -411,14 +411,14 @@ xev_handle_expose(XEvent *ee)
|
|||||||
client_draw_border(cc);
|
client_draw_border(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile sig_atomic_t _xev_quit = 0;
|
volatile sig_atomic_t xev_quit = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
xev_loop(void)
|
xev_loop(void)
|
||||||
{
|
{
|
||||||
XEvent e;
|
XEvent e;
|
||||||
|
|
||||||
while (_xev_quit == 0) {
|
while (xev_quit == 0) {
|
||||||
XNextEvent(X_Dpy, &e);
|
XNextEvent(X_Dpy, &e);
|
||||||
if (e.type - Randr_ev == RRScreenChangeNotify)
|
if (e.type - Randr_ev == RRScreenChangeNotify)
|
||||||
xev_handle_randr(&e);
|
xev_handle_randr(&e);
|
||||||
|
4
xutil.c
4
xutil.c
@ -59,7 +59,7 @@ xu_btn_grab(Window win, int mask, u_int btn)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < nitems(ign_mods); i++)
|
for (i = 0; i < nitems(ign_mods); i++)
|
||||||
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
|
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
|
||||||
False, ButtonMask, GrabModeAsync,
|
False, BUTTONMASK, GrabModeAsync,
|
||||||
GrabModeSync, None, None);
|
GrabModeSync, None, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ xu_sendmsg(Window win, Atom atm, long val)
|
|||||||
{
|
{
|
||||||
XEvent e;
|
XEvent e;
|
||||||
|
|
||||||
memset(&e, 0, sizeof(e));
|
(void)memset(&e, 0, sizeof(e));
|
||||||
e.xclient.type = ClientMessage;
|
e.xclient.type = ClientMessage;
|
||||||
e.xclient.window = win;
|
e.xclient.window = win;
|
||||||
e.xclient.message_type = atm;
|
e.xclient.message_type = atm;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user