mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Compare commits
6 Commits
OPENBSD_5_
...
ignorewarp
Author | SHA1 | Date | |
---|---|---|---|
a119fe5240 | |||
f2e8fad75c | |||
e0c9657773 | |||
f769df540d | |||
d90ab51111 | |||
50aff37f50 |
46
Makefile
46
Makefile
@ -1,24 +1,54 @@
|
||||
# $OpenBSD$
|
||||
|
||||
.include <bsd.xconf.mk>
|
||||
#.include <bsd.xconf.mk>
|
||||
|
||||
PROG= cwm
|
||||
|
||||
BINDIR= /usr/bin
|
||||
|
||||
SRCS= calmwm.c screen.c xmalloc.c client.c menu.c \
|
||||
search.c util.c xutil.c conf.c xevents.c group.c \
|
||||
search.c util.c xutil.c conf.c input.c xevents.c group.c \
|
||||
kbfunc.c mousefunc.c font.c parse.y
|
||||
|
||||
CPPFLAGS+= -I${X11BASE}/include -I${X11BASE}/include/freetype2 -I${.CURDIR}
|
||||
OBJS= calmwm.o screen.o xmalloc.o client.o menu.o \
|
||||
search.o util.o xutil.o conf.o input.o xevents.o group.o \
|
||||
kbfunc.o mousefunc.o font.o strlcpy.o strlcat.o y.tab.o \
|
||||
strtonum.o fgetln.o
|
||||
|
||||
X11BASE= /usr
|
||||
|
||||
CPPFLAGS+= -I${X11BASE}/include -I${X11BASE}/include/freetype2 -I.
|
||||
|
||||
CFLAGS+= -Wall
|
||||
|
||||
LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lxcb -lXau -lXdmcp \
|
||||
LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lXau -lXdmcp \
|
||||
-lfontconfig -lexpat -lfreetype -lz -lXinerama -lXrandr -lXext
|
||||
|
||||
MANDIR= ${X11BASE}/man/man
|
||||
MANDIR= ${X11BASE}/man/cat
|
||||
MAN= cwm.1 cwmrc.5
|
||||
|
||||
obj: _xenocara_obj
|
||||
CLEANFILES= cwm.cat1 cwmrc.cat5
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <bsd.xorg.mk>
|
||||
|
||||
all: $(PROG)
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJS) $(PROG) y.tab.c
|
||||
|
||||
y.tab.c: parse.y
|
||||
byacc parse.y
|
||||
|
||||
|
||||
$(PROG): $(OBJS) y.tab.o
|
||||
$(CC) $(OBJS) ${LDADD} -o ${PROG}
|
||||
|
||||
$(OBJS): %.o: %.c
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $<
|
||||
|
||||
install: ${PROG}
|
||||
install -m 755 cwm /usr/local/bin/
|
||||
install -m 644 cwm.1 /usr/local/man/man1
|
||||
install -m 644 cwmrc.5 /usr/local/man/man5
|
||||
|
||||
#.include <bsd.prog.mk>
|
||||
#.include <bsd.xorg.mk>
|
||||
|
85
calmwm.c
85
calmwm.c
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -35,22 +35,22 @@
|
||||
|
||||
Display *X_Dpy;
|
||||
|
||||
Cursor Cursor_default;
|
||||
Cursor Cursor_move;
|
||||
Cursor Cursor_normal;
|
||||
Cursor Cursor_question;
|
||||
Cursor Cursor_resize;
|
||||
Cursor Cursor_select;
|
||||
Cursor Cursor_default;
|
||||
Cursor Cursor_question;
|
||||
|
||||
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
|
||||
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
|
||||
|
||||
int HasRandr, Randr_ev;
|
||||
int HasXinerama, HasRandr, Randr_ev;
|
||||
int Starting;
|
||||
struct conf Conf;
|
||||
|
||||
static void sigchld_cb(int);
|
||||
static void dpy_init(const char *);
|
||||
static int x_errorhandler(Display *, XErrorEvent *);
|
||||
static int x_wmerrorhandler(Display *, XErrorEvent *);
|
||||
static void x_setup(void);
|
||||
static void x_setupscreen(struct screen_ctx *, u_int);
|
||||
static void x_teardown(void);
|
||||
@ -80,12 +80,14 @@ main(int argc, char **argv)
|
||||
if (signal(SIGCHLD, sigchld_cb) == SIG_ERR)
|
||||
err(1, "signal");
|
||||
|
||||
Starting = 1;
|
||||
dpy_init(display_name);
|
||||
|
||||
bzero(&Conf, sizeof(Conf));
|
||||
conf_setup(&Conf, conf_file);
|
||||
xu_getatoms();
|
||||
x_setup();
|
||||
Starting = 0;
|
||||
|
||||
xev_loop();
|
||||
|
||||
@ -99,15 +101,10 @@ dpy_init(const char *dpyname)
|
||||
{
|
||||
int i;
|
||||
|
||||
XSetErrorHandler(x_errorhandler);
|
||||
|
||||
if ((X_Dpy = XOpenDisplay(dpyname)) == NULL)
|
||||
errx(1, "unable to open display \"%s\"",
|
||||
XDisplayName(dpyname));
|
||||
|
||||
XSetErrorHandler(x_wmerrorhandler);
|
||||
XSelectInput(X_Dpy, DefaultRootWindow(X_Dpy), SubstructureRedirectMask);
|
||||
XSync(X_Dpy, False);
|
||||
XSetErrorHandler(x_errorhandler);
|
||||
|
||||
HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
|
||||
@ -120,12 +117,6 @@ x_setup(void)
|
||||
struct keybinding *kb;
|
||||
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++) {
|
||||
sc = xcalloc(1, sizeof(*sc));
|
||||
x_setupscreen(sc, i);
|
||||
@ -138,6 +129,12 @@ x_setup(void)
|
||||
*/
|
||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
||||
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
|
||||
@ -157,21 +154,19 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
Window *wins, w0, w1;
|
||||
XWindowAttributes winattr;
|
||||
XSetWindowAttributes rootattr;
|
||||
int fake;
|
||||
u_int nwins, i;
|
||||
|
||||
sc->which = which;
|
||||
sc->rootwin = RootWindow(X_Dpy, sc->which);
|
||||
|
||||
xu_ewmh_net_supported(sc);
|
||||
xu_ewmh_net_supported_wm_check(sc);
|
||||
|
||||
conf_gap(&Conf, sc);
|
||||
|
||||
screen_update_geometry(sc);
|
||||
screen_update_geometry(sc, DisplayWidth(X_Dpy, sc->which),
|
||||
DisplayHeight(X_Dpy, sc->which));
|
||||
|
||||
conf_color(&Conf, sc);
|
||||
|
||||
group_init(sc);
|
||||
font_init(sc);
|
||||
conf_font(&Conf, sc);
|
||||
|
||||
TAILQ_INIT(&sc->mruq);
|
||||
@ -179,12 +174,13 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
/* Initialize menu window. */
|
||||
menu_init(sc);
|
||||
|
||||
rootattr.cursor = Cursor_normal;
|
||||
rootattr.event_mask = CHILDMASK|PropertyChangeMask|EnterWindowMask|
|
||||
LeaveWindowMask|ColormapChangeMask|BUTTONMASK;
|
||||
xu_setwmname(sc);
|
||||
|
||||
rootattr.event_mask = ChildMask|PropertyChangeMask|EnterWindowMask|
|
||||
LeaveWindowMask|ColormapChangeMask|ButtonMask;
|
||||
|
||||
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
||||
CWEventMask|CWCursor, &rootattr);
|
||||
CWEventMask, &rootattr);
|
||||
|
||||
/* Deal with existing clients. */
|
||||
XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins);
|
||||
@ -194,39 +190,49 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
if (winattr.override_redirect ||
|
||||
winattr.map_state != IsViewable)
|
||||
continue;
|
||||
(void)client_new(wins[i], sc, winattr.map_state != IsUnmapped);
|
||||
client_new(wins[i], sc, winattr.map_state != IsUnmapped);
|
||||
}
|
||||
XFree(wins);
|
||||
|
||||
screen_updatestackingorder(sc);
|
||||
|
||||
if (XineramaQueryExtension(X_Dpy, &fake, &fake) == 1 &&
|
||||
((HasXinerama = XineramaIsActive(X_Dpy)) == 1))
|
||||
HasXinerama = 1;
|
||||
if (HasRandr)
|
||||
XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);
|
||||
/*
|
||||
* initial setup of xinerama screens, if we're using RandR then we'll
|
||||
* redo this whenever the screen changes since a CTRC may have been
|
||||
* added or removed
|
||||
*/
|
||||
screen_init_xinerama(sc);
|
||||
|
||||
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
|
||||
x_errorhandler(Display *dpy, XErrorEvent *e)
|
||||
{
|
||||
#if DEBUG
|
||||
#ifdef DEBUG
|
||||
{
|
||||
char msg[80], number[80], req[80];
|
||||
|
||||
XGetErrorText(X_Dpy, e->error_code, msg, sizeof(msg));
|
||||
(void)snprintf(number, sizeof(number), "%d", e->request_code);
|
||||
snprintf(number, sizeof(number), "%d", e->request_code);
|
||||
XGetErrorDatabaseText(X_Dpy, "XRequest", number,
|
||||
"<unknown>", req, sizeof(req));
|
||||
|
||||
warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Starting &&
|
||||
e->error_code == BadAccess &&
|
||||
e->request_code == X_GrabKey)
|
||||
errx(1, "root window unavailable - perhaps another "
|
||||
"wm is running?");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -250,7 +256,6 @@ usage(void)
|
||||
{
|
||||
extern char *__progname;
|
||||
|
||||
(void)fprintf(stderr, "usage: %s [-c file] [-d display]\n",
|
||||
__progname);
|
||||
fprintf(stderr, "usage: %s [-c file] [-d display]\n", __progname);
|
||||
exit(1);
|
||||
}
|
||||
|
763
calmwm.h
763
calmwm.h
@ -15,13 +15,16 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _CALMWM_H_
|
||||
#define _CALMWM_H_
|
||||
|
||||
#include <X11/XKBlib.h>
|
||||
/* ugly stuff */
|
||||
#define TAILQ_END(head) NULL
|
||||
#define __dead
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/Xlib.h>
|
||||
@ -32,77 +35,40 @@
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#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"
|
||||
|
||||
#define CHILDMASK (SubstructureRedirectMask|SubstructureNotifyMask)
|
||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
#define KEYMASK (KeyPressMask|ExposureMask)
|
||||
#define MENUMASK (BUTTONMASK|ButtonMotionMask|ExposureMask| \
|
||||
#define ChildMask (SubstructureRedirectMask|SubstructureNotifyMask)
|
||||
#define ButtonMask (ButtonPressMask|ButtonReleaseMask)
|
||||
#define MouseMask (ButtonMask|PointerMotionMask)
|
||||
#define KeyMask (KeyPressMask|ExposureMask)
|
||||
#define MenuMask (ButtonMask|ButtonMotionMask|ExposureMask| \
|
||||
PointerMotionMask)
|
||||
#define MENUGRABMASK (BUTTONMASK|ButtonMotionMask|StructureNotifyMask|\
|
||||
#define MenuGrabMask (ButtonMask|ButtonMotionMask|StructureNotifyMask|\
|
||||
PointerMotionMask)
|
||||
#define SEARCHMASK (KeyPressMask|ExposureMask)
|
||||
|
||||
/* 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
|
||||
|
||||
/* cycle */
|
||||
#define CWM_CYCLE 0x0001
|
||||
#define CWM_RCYCLE 0x0002
|
||||
#define CWM_INGROUP 0x0004
|
||||
|
||||
#define KBTOGROUP(X) ((X) - 1)
|
||||
|
||||
union arg {
|
||||
char *c;
|
||||
int i;
|
||||
};
|
||||
#define SearchMask (KeyPressMask|ExposureMask)
|
||||
|
||||
enum cwmcolor {
|
||||
CWM_COLOR_BORDER_ACTIVE,
|
||||
CWM_COLOR_BORDOR_ACTIVE,
|
||||
CWM_COLOR_BORDER_INACTIVE,
|
||||
CWM_COLOR_BORDER_GROUP,
|
||||
CWM_COLOR_BORDER_UNGROUP,
|
||||
CWM_COLOR_FG_MENU,
|
||||
CWM_COLOR_BG_MENU,
|
||||
CWM_COLOR_FONT,
|
||||
CWM_COLOR_MAX
|
||||
};
|
||||
|
||||
struct color {
|
||||
char *name;
|
||||
unsigned long pixel;
|
||||
char *name;
|
||||
};
|
||||
|
||||
struct geom {
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
struct gap {
|
||||
int top;
|
||||
int bottom;
|
||||
@ -110,76 +76,13 @@ struct gap {
|
||||
int right;
|
||||
};
|
||||
|
||||
struct winname {
|
||||
TAILQ_ENTRY(winname) entry;
|
||||
char *name;
|
||||
};
|
||||
TAILQ_HEAD(winname_q, winname);
|
||||
struct client_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 geom geom, savegeom;
|
||||
struct {
|
||||
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 */
|
||||
} hint;
|
||||
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_VMAXIMIZED 0x0004
|
||||
#define CLIENT_HMAXIMIZED 0x0008
|
||||
#define CLIENT_FREEZE 0x0010
|
||||
|
||||
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
|
||||
#define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
|
||||
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);
|
||||
TAILQ_HEAD(group_ctx_q, group_ctx);
|
||||
TAILQ_HEAD(client_ctx_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;
|
||||
@ -188,42 +91,161 @@ 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;
|
||||
char *app_cliarg;
|
||||
};
|
||||
|
||||
extern const char *shortcut_to_name[];
|
||||
|
||||
/* Autogroups */
|
||||
struct autogroupwin {
|
||||
TAILQ_ENTRY(autogroupwin) entry;
|
||||
char *class;
|
||||
char *name;
|
||||
int num;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(autogroupwin_q, autogroupwin);
|
||||
|
||||
struct screen_ctx {
|
||||
TAILQ_ENTRY(screen_ctx) entry;
|
||||
u_int which;
|
||||
Window rootwin;
|
||||
Window menuwin;
|
||||
struct color color[CWM_COLOR_MAX];
|
||||
GC gc;
|
||||
int cycling;
|
||||
struct geom view; /* viewable area */
|
||||
struct geom work; /* workable area, gap-applied */
|
||||
struct gap gap;
|
||||
struct cycle_entry_q mruq;
|
||||
XftColor xftcolor;
|
||||
XftDraw *xftdraw;
|
||||
XftFont *font;
|
||||
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;
|
||||
#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;
|
||||
};
|
||||
TAILQ_HEAD(screen_ctx_q, screen_ctx);
|
||||
|
||||
struct keybinding {
|
||||
TAILQ_ENTRY(keybinding) entry;
|
||||
@ -232,43 +254,33 @@ 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];
|
||||
#define CMD_MAXLABELLEN 256
|
||||
char label[CMD_MAXLABELLEN];
|
||||
char label[256];
|
||||
/* (argv) */
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
/* Global configuration */
|
||||
struct conf {
|
||||
struct keybinding_q keybindingq;
|
||||
struct autogroupwin_q autogroupq;
|
||||
@ -276,141 +288,99 @@ struct conf {
|
||||
char conf_path[MAXPATHLEN];
|
||||
struct cmd_q cmdq;
|
||||
struct mousebinding_q mousebindingq;
|
||||
|
||||
#define CONF_STICKY_GROUPS 0x0001
|
||||
int flags;
|
||||
#define CONF_BWIDTH 1
|
||||
int bwidth;
|
||||
#define CONF_MAMOUNT 1
|
||||
int mamount;
|
||||
#define CONF_SNAPDIST 0
|
||||
int snapdist;
|
||||
struct gap gap;
|
||||
|
||||
#define CONF_COLOR_ACTIVEBORDER "#CCCCCC"
|
||||
#define CONF_COLOR_INACTIVEBORDER "#666666"
|
||||
#define CONF_COLOR_GROUPBORDER "blue"
|
||||
#define CONF_COLOR_UNGROUPBORDER "red"
|
||||
#define CONF_COLOR_MENUFG "black"
|
||||
#define CONF_COLOR_MENUBG "white"
|
||||
struct color color[CWM_COLOR_MAX];
|
||||
|
||||
char termpath[MAXPATHLEN];
|
||||
char lockpath[MAXPATHLEN];
|
||||
#define CONF_FONT "sans-serif:pixelsize=14:bold"
|
||||
char *font;
|
||||
|
||||
#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);
|
||||
|
||||
enum ctltype {
|
||||
CTL_NONE = -1,
|
||||
CTL_ERASEONE = 0, CTL_WIPE, CTL_UP, CTL_DOWN, CTL_RETURN,
|
||||
CTL_ABORT, CTL_ALL
|
||||
};
|
||||
|
||||
/* MWM hints */
|
||||
|
||||
struct mwm_hints {
|
||||
u_long flags;
|
||||
u_long functions;
|
||||
u_long decorations;
|
||||
};
|
||||
|
||||
#define MWM_NUMHINTS 3
|
||||
|
||||
#define PROP_MWM_HINTS_ELEMENTS 3
|
||||
#define MWM_HINTS_DECORATIONS (1 << 1)
|
||||
#define MWM_DECOR_ALL (1 << 0)
|
||||
#define MWM_DECOR_BORDER (1 << 1)
|
||||
|
||||
int input_keycodetrans(KeyCode, u_int, enum ctltype *,
|
||||
char *);
|
||||
|
||||
__dead void usage(void);
|
||||
|
||||
void client_applysizehints(struct client_ctx *);
|
||||
struct client_ctx *client_current(void);
|
||||
void client_cycle(struct screen_ctx *, int);
|
||||
void client_cycle_leave(struct screen_ctx *, struct client_ctx *);
|
||||
void 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 *);
|
||||
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 *);
|
||||
int client_delete(struct client_ctx *);
|
||||
void client_setactive(struct client_ctx *, int);
|
||||
void client_setname(struct client_ctx *);
|
||||
int client_snapcalc(int, int, int, int, int);
|
||||
void client_transient(struct client_ctx *);
|
||||
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_vertmaximize(struct client_ctx *);
|
||||
void client_setname(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_update_geometry(struct screen_ctx *);
|
||||
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_freeze(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_raise(struct client_ctx *, void *);
|
||||
void mousefunc_window_resize(struct client_ctx *, void *);
|
||||
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 menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
||||
char *, char *, int,
|
||||
@ -418,123 +388,184 @@ struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
||||
void (*)(struct menu *, int));
|
||||
void menu_init(struct screen_ctx *);
|
||||
|
||||
int parse_config(const char *, struct conf *);
|
||||
|
||||
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 *, const char *);
|
||||
int font_width(struct screen_ctx *, const char *, int);
|
||||
XftFont *font_make(struct screen_ctx *, const char *);
|
||||
/* XXX should be xu_ */
|
||||
void xev_reconfig(struct client_ctx *);
|
||||
|
||||
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 **);
|
||||
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_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);
|
||||
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 *);
|
||||
|
||||
void xu_ewmh_net_supported(struct screen_ctx *);
|
||||
void xu_ewmh_net_supported_wm_check(struct screen_ctx *);
|
||||
void xu_ewmh_net_desktop_geometry(struct screen_ctx *);
|
||||
void xu_ewmh_net_workarea(struct screen_ctx *);
|
||||
void xu_ewmh_net_client_list(struct screen_ctx *);
|
||||
void xu_ewmh_net_active_window(struct screen_ctx *, Window);
|
||||
void xu_ewmh_net_wm_desktop_viewport(struct screen_ctx *);
|
||||
void xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *);
|
||||
void xu_ewmh_net_showing_desktop(struct screen_ctx *);
|
||||
void xu_ewmh_net_virtual_roots(struct screen_ctx *);
|
||||
void xu_ewmh_net_current_desktop(struct screen_ctx *, long);
|
||||
void xu_ewmh_net_desktop_names(struct screen_ctx *, unsigned char *, int);
|
||||
|
||||
void xu_ewmh_net_wm_desktop(struct client_ctx *);
|
||||
|
||||
|
||||
int u_spawn(char *);
|
||||
void u_exec(char *);
|
||||
void u_spawn(char *);
|
||||
|
||||
void *xcalloc(size_t, size_t);
|
||||
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);
|
||||
|
||||
int font_ascent(struct screen_ctx *);
|
||||
int font_descent(struct screen_ctx *);
|
||||
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 */
|
||||
|
||||
extern Display *X_Dpy;
|
||||
|
||||
extern Cursor Cursor_default;
|
||||
extern Cursor Cursor_move;
|
||||
extern Cursor Cursor_normal;
|
||||
extern Cursor Cursor_question;
|
||||
extern Cursor Cursor_resize;
|
||||
extern Cursor Cursor_select;
|
||||
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;
|
||||
|
||||
enum {
|
||||
WM_STATE,
|
||||
WM_DELETE_WINDOW,
|
||||
WM_TAKE_FOCUS,
|
||||
WM_PROTOCOLS,
|
||||
_MOTIF_WM_HINTS,
|
||||
UTF8_STRING,
|
||||
CWMH_NITEMS
|
||||
};
|
||||
enum {
|
||||
_NET_SUPPORTED,
|
||||
_NET_SUPPORTING_WM_CHECK,
|
||||
_NET_ACTIVE_WINDOW,
|
||||
_NET_CLIENT_LIST,
|
||||
_NET_NUMBER_OF_DESKTOPS,
|
||||
_NET_CURRENT_DESKTOP,
|
||||
_NET_DESKTOP_VIEWPORT,
|
||||
_NET_DESKTOP_GEOMETRY,
|
||||
_NET_VIRTUAL_ROOTS,
|
||||
_NET_SHOWING_DESKTOP,
|
||||
_NET_DESKTOP_NAMES,
|
||||
_NET_WORKAREA,
|
||||
_NET_WM_NAME,
|
||||
_NET_WM_DESKTOP,
|
||||
EWMH_NITEMS
|
||||
};
|
||||
struct atom_ctx {
|
||||
char *name;
|
||||
Atom atom;
|
||||
};
|
||||
extern struct atom_ctx cwmh[CWMH_NITEMS];
|
||||
extern struct atom_ctx ewmh[EWMH_NITEMS];
|
||||
#define WM_STATE cwm_atoms[0]
|
||||
#define WM_DELETE_WINDOW cwm_atoms[1]
|
||||
#define WM_TAKE_FOCUS cwm_atoms[2]
|
||||
#define WM_PROTOCOLS cwm_atoms[3]
|
||||
#define _MOTIF_WM_HINTS cwm_atoms[4]
|
||||
#define UTF8_STRING cwm_atoms[5]
|
||||
/*
|
||||
* please make all hints below this point netwm hints, starting with
|
||||
* _NET_SUPPORTED. If you change other hints make sure you update
|
||||
* CWM_NETWM_START
|
||||
*/
|
||||
#define _NET_SUPPORTED cwm_atoms[6]
|
||||
#define _NET_SUPPORTING_WM_CHECK cwm_atoms[7]
|
||||
#define _NET_WM_NAME cwm_atoms[8]
|
||||
#define _NET_ACTIVE_WINDOW cwm_atoms[9]
|
||||
#define _NET_CLIENT_LIST cwm_atoms[10]
|
||||
#define _NET_NUMBER_OF_DESKTOPS cwm_atoms[11]
|
||||
#define _NET_CURRENT_DESKTOP cwm_atoms[12]
|
||||
#define _NET_DESKTOP_VIEWPORT cwm_atoms[13]
|
||||
#define _NET_DESKTOP_GEOMETRY cwm_atoms[14]
|
||||
#define _NET_VIRTUAL_ROOTS cwm_atoms[15]
|
||||
#define _NET_SHOWING_DESKTOP cwm_atoms[16]
|
||||
#define _NET_DESKTOP_NAMES cwm_atoms[17]
|
||||
#define _NET_WM_DESKTOP cwm_atoms[18]
|
||||
#define _NET_WORKAREA cwm_atoms[19]
|
||||
#define CWM_NO_ATOMS 20
|
||||
#define CWM_NETWM_START 6
|
||||
|
||||
extern Atom cwm_atoms[CWM_NO_ATOMS];
|
||||
|
||||
#endif /* _CALMWM_H_ */
|
||||
|
475
client.c
475
client.c
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -89,8 +89,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
XGetWindowAttributes(X_Dpy, cc->win, &wattr);
|
||||
cc->geom.x = wattr.x;
|
||||
cc->geom.y = wattr.y;
|
||||
cc->geom.w = wattr.width;
|
||||
cc->geom.h = wattr.height;
|
||||
cc->geom.width = wattr.width;
|
||||
cc->geom.height = wattr.height;
|
||||
cc->cmap = wattr.colormap;
|
||||
|
||||
if (wattr.map_state != IsViewable) {
|
||||
@ -113,10 +113,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
|
||||
XAddToSaveSet(X_Dpy, cc->win);
|
||||
|
||||
client_transient(cc);
|
||||
|
||||
/* Notify client of its configuration. */
|
||||
xu_configure(cc);
|
||||
xev_reconfig(cc);
|
||||
|
||||
(state == IconicState) ? client_hide(cc) : client_unhide(cc);
|
||||
xu_setstate(cc, cc->state);
|
||||
@ -126,8 +124,9 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
|
||||
TAILQ_INSERT_TAIL(&sc->mruq, cc, mru_entry);
|
||||
TAILQ_INSERT_TAIL(&Clientq, cc, entry);
|
||||
|
||||
xu_ewmh_net_client_list(sc);
|
||||
/* append to the client list */
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_CLIENT_LIST, XA_WINDOW, 32,
|
||||
PropModeAppend, (unsigned char *)&cc->win, 1);
|
||||
|
||||
client_gethints(cc);
|
||||
client_update(cc);
|
||||
@ -138,11 +137,14 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
return (cc);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
client_delete(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct client_ctx *tcc;
|
||||
struct winname *wn;
|
||||
Window *winlist;
|
||||
int i, j;
|
||||
|
||||
group_client_delete(cc);
|
||||
|
||||
@ -155,8 +157,23 @@ client_delete(struct client_ctx *cc)
|
||||
|
||||
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
|
||||
TAILQ_REMOVE(&Clientq, cc, entry);
|
||||
|
||||
xu_ewmh_net_client_list(sc);
|
||||
/*
|
||||
* Sadly we can't remove just one entry from a property, so we must
|
||||
* redo the whole thing from scratch. this is the stupid way, the other
|
||||
* way incurs many roundtrips to the server.
|
||||
*/
|
||||
i = j = 0;
|
||||
TAILQ_FOREACH(tcc, &Clientq, entry)
|
||||
i++;
|
||||
if (i > 0) {
|
||||
winlist = xmalloc(i * sizeof(*winlist));
|
||||
TAILQ_FOREACH(tcc, &Clientq, entry)
|
||||
winlist[j++] = tcc->win;
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_CLIENT_LIST,
|
||||
XA_WINDOW, 32, PropModeReplace,
|
||||
(unsigned char *)winlist, i);
|
||||
xfree(winlist);
|
||||
}
|
||||
|
||||
if (_curcc == cc)
|
||||
client_none(sc);
|
||||
@ -172,6 +189,8 @@ client_delete(struct client_ctx *cc)
|
||||
|
||||
client_freehints(cc);
|
||||
xfree(cc);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -209,7 +228,7 @@ client_setactive(struct client_ctx *cc, int fg)
|
||||
* If we're in the middle of alt-tabbing, don't change
|
||||
* the order please.
|
||||
*/
|
||||
if (!sc->cycling)
|
||||
if (!sc->altpersist)
|
||||
client_mtf(cc);
|
||||
} else
|
||||
client_leave(cc);
|
||||
@ -217,7 +236,9 @@ client_setactive(struct client_ctx *cc, int fg)
|
||||
if (fg && _curcc != cc) {
|
||||
client_setactive(NULL, 0);
|
||||
_curcc = cc;
|
||||
xu_ewmh_net_active_window(sc, cc->win);
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_ACTIVE_WINDOW,
|
||||
XA_WINDOW, 32, PropModeReplace,
|
||||
(unsigned char *)&cc->win, 1);
|
||||
}
|
||||
|
||||
cc->active = fg;
|
||||
@ -232,8 +253,8 @@ client_none(struct screen_ctx *sc)
|
||||
{
|
||||
Window none = None;
|
||||
|
||||
xu_ewmh_net_active_window(sc, none);
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_ACTIVE_WINDOW,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&none, 1);
|
||||
_curcc = NULL;
|
||||
}
|
||||
|
||||
@ -243,69 +264,43 @@ 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)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
int x_org, y_org, xmax, ymax;
|
||||
XineramaScreenInfo *xine;
|
||||
int xmax = sc->xmax, ymax = sc->ymax;
|
||||
int x_org = 0, y_org = 0;
|
||||
|
||||
if (cc->flags & CLIENT_FREEZE)
|
||||
return;
|
||||
|
||||
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) {
|
||||
cc->flags &= ~CLIENT_MAXIMIZED;
|
||||
if (cc->flags & CLIENT_MAXIMIZED) {
|
||||
cc->geom = cc->savegeom;
|
||||
cc->bwidth = Conf.bwidth;
|
||||
goto resize;
|
||||
}
|
||||
|
||||
if ((cc->flags & CLIENT_VMAXIMIZED) == 0) {
|
||||
cc->savegeom.h = cc->geom.h;
|
||||
cc->savegeom.y = cc->geom.y;
|
||||
}
|
||||
|
||||
if ((cc->flags & CLIENT_HMAXIMIZED) == 0) {
|
||||
cc->savegeom.w = cc->geom.w;
|
||||
cc->savegeom.x = cc->geom.x;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!(cc->flags & (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)))
|
||||
cc->savegeom = cc->geom;
|
||||
if (HasXinerama) {
|
||||
XineramaScreenInfo *xine;
|
||||
/*
|
||||
* pick screen that the middle of the window is on.
|
||||
* that's probably more fair than if just the origin of
|
||||
* a window is poking over a boundary
|
||||
*/
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.w / 2,
|
||||
cc->geom.y + cc->geom.h / 2);
|
||||
if (xine) {
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
x_org = xine->x_org;
|
||||
y_org = xine->y_org;
|
||||
xmax = xine->width;
|
||||
ymax = xine->height;
|
||||
} else {
|
||||
x_org = y_org = 0;
|
||||
xmax = sc->view.w;
|
||||
ymax = sc->view.h;
|
||||
}
|
||||
|
||||
calc:
|
||||
cc->geom.x = x_org + sc->gap.left;
|
||||
cc->geom.y = y_org + sc->gap.top;
|
||||
cc->geom.h = ymax - (sc->gap.top + sc->gap.bottom);
|
||||
cc->geom.w = xmax - (sc->gap.left + sc->gap.right);
|
||||
cc->bwidth = 0;
|
||||
cc->flags |= CLIENT_MAXIMIZED;
|
||||
cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom);
|
||||
cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
|
||||
cc->flags |= CLIENT_DOMAXIMIZE;
|
||||
}
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
@ -313,48 +308,30 @@ void
|
||||
client_vertmaximize(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
int y_org, ymax;
|
||||
XineramaScreenInfo *xine;
|
||||
|
||||
if (cc->flags & CLIENT_FREEZE)
|
||||
return;
|
||||
int y_org = 0, ymax = sc->ymax;
|
||||
|
||||
if (cc->flags & CLIENT_VMAXIMIZED) {
|
||||
cc->geom.y = cc->savegeom.y;
|
||||
cc->geom.h = cc->savegeom.h;
|
||||
cc->bwidth = Conf.bwidth;
|
||||
if (cc->flags & CLIENT_HMAXIMIZED)
|
||||
cc->geom.w -= cc->bwidth * 2;
|
||||
cc->flags &= ~CLIENT_VMAXIMIZED;
|
||||
goto resize;
|
||||
}
|
||||
|
||||
cc->savegeom.y = cc->geom.y;
|
||||
cc->savegeom.h = cc->geom.h;
|
||||
|
||||
/* if this will make us fully maximized then remove boundary */
|
||||
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) {
|
||||
cc->geom.w += Conf.bwidth * 2;
|
||||
cc->bwidth = 0;
|
||||
}
|
||||
|
||||
cc->geom = cc->savegeom;
|
||||
} else {
|
||||
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_HMAXIMIZED)))
|
||||
cc->savegeom = cc->geom;
|
||||
if (HasXinerama) {
|
||||
XineramaScreenInfo *xine;
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.w / 2,
|
||||
cc->geom.y + cc->geom.h / 2);
|
||||
if (xine) {
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
y_org = xine->y_org;
|
||||
ymax = xine->height;
|
||||
} else {
|
||||
y_org = 0;
|
||||
ymax = sc->view.h;
|
||||
}
|
||||
calc:
|
||||
cc->geom.y = y_org + sc->gap.top;
|
||||
cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top +
|
||||
sc->gap.bottom);
|
||||
cc->flags |= CLIENT_DOVMAXIMIZE;
|
||||
}
|
||||
|
||||
cc->geom.y = y_org + sc->gap.top;
|
||||
cc->geom.h = ymax - (cc->bwidth * 2) - (sc->gap.top +
|
||||
sc->gap.bottom);
|
||||
cc->flags |= CLIENT_VMAXIMIZED;
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
@ -362,66 +339,65 @@ void
|
||||
client_horizmaximize(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
int x_org, xmax;
|
||||
XineramaScreenInfo *xine;
|
||||
|
||||
if (cc->flags & CLIENT_FREEZE)
|
||||
return;
|
||||
int x_org = 0, xmax = sc->xmax;
|
||||
|
||||
if (cc->flags & CLIENT_HMAXIMIZED) {
|
||||
cc->geom.x = cc->savegeom.x;
|
||||
cc->geom.w = cc->savegeom.w;
|
||||
cc->bwidth = Conf.bwidth;
|
||||
if (cc->flags & CLIENT_VMAXIMIZED)
|
||||
cc->geom.h -= cc->bwidth * 2;
|
||||
cc->flags &= ~CLIENT_HMAXIMIZED;
|
||||
goto resize;
|
||||
}
|
||||
|
||||
cc->savegeom.x = cc->geom.x;
|
||||
cc->savegeom.w = cc->geom.w;
|
||||
|
||||
/* if this will make us fully maximized then remove boundary */
|
||||
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_VMAXIMIZED) {
|
||||
cc->geom.h += cc->bwidth * 2;
|
||||
cc->bwidth = 0;
|
||||
}
|
||||
|
||||
cc->geom = cc->savegeom;
|
||||
} else {
|
||||
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED)))
|
||||
cc->savegeom = cc->geom;
|
||||
if (HasXinerama) {
|
||||
XineramaScreenInfo *xine;
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.w / 2,
|
||||
cc->geom.y + cc->geom.h / 2);
|
||||
if (xine) {
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
x_org = xine->x_org;
|
||||
xmax = xine->width;
|
||||
} else {
|
||||
x_org = 0;
|
||||
xmax = sc->view.w;
|
||||
}
|
||||
calc:
|
||||
cc->geom.x = x_org + sc->gap.left;
|
||||
cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left +
|
||||
sc->gap.right);
|
||||
cc->flags |= CLIENT_DOHMAXIMIZE;
|
||||
}
|
||||
|
||||
cc->geom.x = x_org + sc->gap.left;
|
||||
cc->geom.w = xmax - (cc->bwidth * 2) - (sc->gap.left +
|
||||
sc->gap.right);
|
||||
cc->flags |= CLIENT_HMAXIMIZED;
|
||||
|
||||
resize:
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
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);
|
||||
|
||||
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
||||
cc->geom.y, cc->geom.w, cc->geom.h);
|
||||
xu_configure(cc);
|
||||
cc->geom.y, cc->geom.width, cc->geom.height);
|
||||
xev_reconfig(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_move(struct client_ctx *cc)
|
||||
{
|
||||
XMoveWindow(X_Dpy, cc->win, cc->geom.x, cc->geom.y);
|
||||
xu_configure(cc);
|
||||
xev_reconfig(cc);
|
||||
}
|
||||
|
||||
void
|
||||
@ -442,8 +418,8 @@ client_ptrwarp(struct client_ctx *cc)
|
||||
int x = cc->ptr.x, y = cc->ptr.y;
|
||||
|
||||
if (x == -1 || y == -1) {
|
||||
x = cc->geom.w / 2;
|
||||
y = cc->geom.h / 2;
|
||||
x = cc->geom.width / 2;
|
||||
y = cc->geom.height / 2;
|
||||
}
|
||||
|
||||
(cc->state == IconicState) ? client_unhide(cc) : client_raise(cc);
|
||||
@ -459,9 +435,6 @@ client_ptrsave(struct client_ctx *cc)
|
||||
if (client_inbound(cc, x, y)) {
|
||||
cc->ptr.x = x;
|
||||
cc->ptr.y = y;
|
||||
} else {
|
||||
cc->ptr.x = -1;
|
||||
cc->ptr.y = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,7 +478,7 @@ client_draw_border(struct client_ctx *cc)
|
||||
pixel = sc->color[CWM_COLOR_BORDER_UNGROUP].pixel;
|
||||
break;
|
||||
default:
|
||||
pixel = sc->color[CWM_COLOR_BORDER_ACTIVE].pixel;
|
||||
pixel = sc->color[CWM_COLOR_BORDOR_ACTIVE].pixel;
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -522,14 +495,14 @@ client_update(struct client_ctx *cc)
|
||||
int i;
|
||||
long n;
|
||||
|
||||
if ((n = xu_getprop(cc->win, cwmh[WM_PROTOCOLS].atom,
|
||||
if ((n = xu_getprop(cc->win, WM_PROTOCOLS,
|
||||
XA_ATOM, 20L, (u_char **)&p)) <= 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (p[i] == cwmh[WM_DELETE_WINDOW].atom)
|
||||
if (p[i] == WM_DELETE_WINDOW)
|
||||
cc->xproto |= CLIENT_PROTO_DELETE;
|
||||
else if (p[i] == cwmh[WM_TAKE_FOCUS].atom)
|
||||
else if (p[i] == WM_TAKE_FOCUS)
|
||||
cc->xproto |= CLIENT_PROTO_TAKEFOCUS;
|
||||
|
||||
XFree(p);
|
||||
@ -539,8 +512,7 @@ void
|
||||
client_send_delete(struct client_ctx *cc)
|
||||
{
|
||||
if (cc->xproto & CLIENT_PROTO_DELETE)
|
||||
xu_sendmsg(cc->win,
|
||||
cwmh[WM_PROTOCOLS].atom, cwmh[WM_DELETE_WINDOW].atom);
|
||||
xu_sendmsg(cc->win, WM_PROTOCOLS, WM_DELETE_WINDOW);
|
||||
else
|
||||
XKillClient(X_Dpy, cc->win);
|
||||
}
|
||||
@ -551,8 +523,9 @@ client_setname(struct client_ctx *cc)
|
||||
struct winname *wn;
|
||||
char *newname;
|
||||
|
||||
if (!xu_getstrprop(cc->win, ewmh[_NET_WM_NAME].atom, &newname))
|
||||
if (!xu_getstrprop(cc->win, XA_WM_NAME, &newname))
|
||||
if (!xu_getstrprop(cc->win, _NET_WM_NAME, &newname))
|
||||
xu_getstrprop(cc->win, XA_WM_NAME, &newname);
|
||||
if (newname == NULL)
|
||||
newname = emptystring;
|
||||
|
||||
TAILQ_FOREACH(wn, &cc->nameq, entry)
|
||||
@ -581,10 +554,12 @@ match:
|
||||
xfree(wn);
|
||||
cc->nameqlen--;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
client_cycle(struct screen_ctx *sc, int flags)
|
||||
struct client_ctx *
|
||||
client_cycle(struct screen_ctx *sc, int reverse)
|
||||
{
|
||||
struct client_ctx *oldcc, *newcc;
|
||||
int again = 1;
|
||||
@ -593,50 +568,38 @@ client_cycle(struct screen_ctx *sc, int flags)
|
||||
|
||||
/* If no windows then you cant cycle */
|
||||
if (TAILQ_EMPTY(&sc->mruq))
|
||||
return;
|
||||
return (NULL);
|
||||
|
||||
if (oldcc == NULL)
|
||||
oldcc = (flags & CWM_RCYCLE ?
|
||||
TAILQ_LAST(&sc->mruq, cycle_entry_q) :
|
||||
oldcc = (reverse ? TAILQ_LAST(&sc->mruq, cycle_entry_q) :
|
||||
TAILQ_FIRST(&sc->mruq));
|
||||
|
||||
newcc = oldcc;
|
||||
while (again) {
|
||||
again = 0;
|
||||
|
||||
newcc = (flags & CWM_RCYCLE ? client_mruprev(newcc) :
|
||||
newcc = (reverse ? client_mruprev(newcc) :
|
||||
client_mrunext(newcc));
|
||||
|
||||
/* Only cycle visible and non-ignored windows. */
|
||||
if ((newcc->flags & (CLIENT_HIDDEN|CLIENT_IGNORE))
|
||||
|| ((flags & CWM_INGROUP) && (newcc->group != oldcc->group)))
|
||||
if (newcc->flags & (CLIENT_HIDDEN|CLIENT_IGNORE))
|
||||
again = 1;
|
||||
|
||||
/* Is oldcc the only non-hidden window? */
|
||||
if (newcc == oldcc) {
|
||||
if (again)
|
||||
return; /* No windows visible. */
|
||||
return (NULL); /* No windows visible. */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset when cycling mod is released. XXX I hate this hack */
|
||||
sc->cycling = 1;
|
||||
/* reset when alt is released. XXX I hate this hack */
|
||||
sc->altpersist = 1;
|
||||
client_ptrsave(oldcc);
|
||||
client_ptrwarp(newcc);
|
||||
}
|
||||
|
||||
void
|
||||
client_cycle_leave(struct screen_ctx *sc, struct client_ctx *cc)
|
||||
{
|
||||
sc->cycling = 0;
|
||||
|
||||
client_mtf(NULL);
|
||||
if (cc) {
|
||||
group_sticky_toggle_exit(cc);
|
||||
XUngrabKeyboard(X_Dpy, CurrentTime);
|
||||
}
|
||||
return (newcc);
|
||||
}
|
||||
|
||||
static struct client_ctx *
|
||||
@ -673,8 +636,8 @@ client_placecalc(struct client_ctx *cc)
|
||||
* XRandR bits mean that {x,y}max shouldn't be outside what's
|
||||
* currently there.
|
||||
*/
|
||||
xslack = sc->view.w - cc->geom.w - cc->bwidth * 2;
|
||||
yslack = sc->view.h - cc->geom.h - cc->bwidth * 2;
|
||||
xslack = sc->xmax - cc->geom.width - cc->bwidth * 2;
|
||||
yslack = sc->ymax - cc->geom.height - cc->bwidth * 2;
|
||||
if (cc->size->x > 0)
|
||||
cc->geom.x = MIN(cc->size->x, xslack);
|
||||
if (cc->size->y > 0)
|
||||
@ -685,25 +648,28 @@ client_placecalc(struct client_ctx *cc)
|
||||
int xmax, ymax;
|
||||
|
||||
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
|
||||
if (HasXinerama) {
|
||||
info = screen_find_xinerama(sc, xmouse, ymouse);
|
||||
if (info) {
|
||||
if (info == NULL)
|
||||
goto noxine;
|
||||
xorig = info->x_org;
|
||||
yorig = info->y_org;
|
||||
xmax = xorig + info->width;
|
||||
ymax = yorig + info->height;
|
||||
} else {
|
||||
noxine:
|
||||
xorig = yorig = 0;
|
||||
xmax = sc->view.w;
|
||||
ymax = sc->view.h;
|
||||
xmax = sc->xmax;
|
||||
ymax = sc->ymax;
|
||||
}
|
||||
xmouse = MAX(xmouse, xorig) - cc->geom.w / 2;
|
||||
ymouse = MAX(ymouse, yorig) - cc->geom.h / 2;
|
||||
xmouse = MAX(xmouse, xorig) - cc->geom.width / 2;
|
||||
ymouse = MAX(ymouse, yorig) - cc->geom.height / 2;
|
||||
|
||||
xmouse = MAX(xmouse, xorig);
|
||||
ymouse = MAX(ymouse, yorig);
|
||||
|
||||
xslack = xmax - cc->geom.w - cc->bwidth * 2;
|
||||
yslack = ymax - cc->geom.h - cc->bwidth * 2;
|
||||
xslack = xmax - cc->geom.width - cc->bwidth * 2;
|
||||
yslack = ymax - cc->geom.height - cc->bwidth * 2;
|
||||
|
||||
if (xslack >= xorig) {
|
||||
cc->geom.x = MAX(MIN(xmouse, xslack),
|
||||
@ -712,7 +678,7 @@ client_placecalc(struct client_ctx *cc)
|
||||
cc->geom.x -= sc->gap.right;
|
||||
} else {
|
||||
cc->geom.x = xorig + sc->gap.left;
|
||||
cc->geom.w = xmax - sc->gap.left;
|
||||
cc->geom.width = xmax - sc->gap.left;
|
||||
}
|
||||
if (yslack >= yorig) {
|
||||
cc->geom.y = MAX(MIN(ymouse, yslack),
|
||||
@ -721,7 +687,7 @@ client_placecalc(struct client_ctx *cc)
|
||||
cc->geom.y -= sc->gap.bottom;
|
||||
} else {
|
||||
cc->geom.y = yorig + sc->gap.top;
|
||||
cc->geom.h = ymax - sc->gap.top;
|
||||
cc->geom.height = ymax - sc->gap.top;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -752,93 +718,94 @@ client_getsizehints(struct client_ctx *cc)
|
||||
cc->size->flags = PSize;
|
||||
|
||||
if (cc->size->flags & PBaseSize) {
|
||||
cc->hint.basew = cc->size->base_width;
|
||||
cc->hint.baseh = cc->size->base_height;
|
||||
cc->geom.basew = cc->size->base_width;
|
||||
cc->geom.baseh = cc->size->base_height;
|
||||
} else if (cc->size->flags & PMinSize) {
|
||||
cc->hint.basew = cc->size->min_width;
|
||||
cc->hint.baseh = cc->size->min_height;
|
||||
cc->geom.basew = cc->size->min_width;
|
||||
cc->geom.baseh = cc->size->min_height;
|
||||
}
|
||||
if (cc->size->flags & PMinSize) {
|
||||
cc->hint.minw = cc->size->min_width;
|
||||
cc->hint.minh = cc->size->min_height;
|
||||
cc->geom.minw = cc->size->min_width;
|
||||
cc->geom.minh = cc->size->min_height;
|
||||
} else if (cc->size->flags & PBaseSize) {
|
||||
cc->hint.minw = cc->size->base_width;
|
||||
cc->hint.minh = cc->size->base_height;
|
||||
cc->geom.minw = cc->size->base_width;
|
||||
cc->geom.minh = cc->size->base_height;
|
||||
}
|
||||
if (cc->size->flags & PMaxSize) {
|
||||
cc->hint.maxw = cc->size->max_width;
|
||||
cc->hint.maxh = cc->size->max_height;
|
||||
cc->geom.maxw = cc->size->max_width;
|
||||
cc->geom.maxh = cc->size->max_height;
|
||||
}
|
||||
if (cc->size->flags & PResizeInc) {
|
||||
cc->hint.incw = cc->size->width_inc;
|
||||
cc->hint.inch = cc->size->height_inc;
|
||||
cc->geom.incw = cc->size->width_inc;
|
||||
cc->geom.inch = cc->size->height_inc;
|
||||
}
|
||||
cc->hint.incw = MAX(1, cc->hint.incw);
|
||||
cc->hint.inch = MAX(1, cc->hint.inch);
|
||||
cc->geom.incw = MAX(1, cc->geom.incw);
|
||||
cc->geom.inch = MAX(1, cc->geom.inch);
|
||||
|
||||
if (cc->size->flags & PAspect) {
|
||||
if (cc->size->min_aspect.x > 0)
|
||||
cc->hint.mina = (float)cc->size->min_aspect.y /
|
||||
cc->geom.mina = (float)cc->size->min_aspect.y /
|
||||
cc->size->min_aspect.x;
|
||||
if (cc->size->max_aspect.y > 0)
|
||||
cc->hint.maxa = (float)cc->size->max_aspect.x /
|
||||
cc->geom.maxa = (float)cc->size->max_aspect.x /
|
||||
cc->size->max_aspect.y;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
client_applysizehints(struct client_ctx *cc)
|
||||
{
|
||||
Bool baseismin;
|
||||
|
||||
baseismin = (cc->hint.basew == cc->hint.minw) &&
|
||||
(cc->hint.baseh == cc->hint.minh);
|
||||
baseismin = (cc->geom.basew == cc->geom.minw) &&
|
||||
(cc->geom.baseh == cc->geom.minh);
|
||||
|
||||
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */
|
||||
if (!baseismin) {
|
||||
cc->geom.w -= cc->hint.basew;
|
||||
cc->geom.h -= cc->hint.baseh;
|
||||
cc->geom.width -= cc->geom.basew;
|
||||
cc->geom.height -= cc->geom.baseh;
|
||||
}
|
||||
|
||||
/* adjust for aspect limits */
|
||||
if (cc->hint.mina > 0 && cc->hint.maxa > 0) {
|
||||
if (cc->hint.maxa <
|
||||
(float)cc->geom.w / cc->geom.h)
|
||||
cc->geom.w = cc->geom.h * cc->hint.maxa;
|
||||
else if (cc->hint.mina <
|
||||
(float)cc->geom.h / cc->geom.w)
|
||||
cc->geom.h = cc->geom.w * cc->hint.mina;
|
||||
if (cc->geom.mina > 0 && cc->geom.maxa > 0) {
|
||||
if (cc->geom.maxa <
|
||||
(float)cc->geom.width / cc->geom.height)
|
||||
cc->geom.width = cc->geom.height * cc->geom.maxa;
|
||||
else if (cc->geom.mina <
|
||||
(float)cc->geom.height / cc->geom.width)
|
||||
cc->geom.height = cc->geom.width * cc->geom.mina;
|
||||
}
|
||||
|
||||
/* remove base dimensions for increment */
|
||||
if (baseismin) {
|
||||
cc->geom.w -= cc->hint.basew;
|
||||
cc->geom.h -= cc->hint.baseh;
|
||||
cc->geom.width -= cc->geom.basew;
|
||||
cc->geom.height -= cc->geom.baseh;
|
||||
}
|
||||
|
||||
/* adjust for increment value */
|
||||
cc->geom.w -= cc->geom.w % cc->hint.incw;
|
||||
cc->geom.h -= cc->geom.h % cc->hint.inch;
|
||||
cc->geom.width -= cc->geom.width % cc->geom.incw;
|
||||
cc->geom.height -= cc->geom.height % cc->geom.inch;
|
||||
|
||||
/* restore base dimensions */
|
||||
cc->geom.w += cc->hint.basew;
|
||||
cc->geom.h += cc->hint.baseh;
|
||||
cc->geom.width += cc->geom.basew;
|
||||
cc->geom.height += cc->geom.baseh;
|
||||
|
||||
/* adjust for min width/height */
|
||||
cc->geom.w = MAX(cc->geom.w, cc->hint.minw);
|
||||
cc->geom.h = MAX(cc->geom.h, cc->hint.minh);
|
||||
cc->geom.width = MAX(cc->geom.width, cc->geom.minw);
|
||||
cc->geom.height = MAX(cc->geom.height, cc->geom.minh);
|
||||
|
||||
/* adjust for max width/height */
|
||||
if (cc->hint.maxw)
|
||||
cc->geom.w = MIN(cc->geom.w, cc->hint.maxw);
|
||||
if (cc->hint.maxh)
|
||||
cc->geom.h = MIN(cc->geom.h, cc->hint.maxh);
|
||||
if (cc->geom.maxw)
|
||||
cc->geom.width = MIN(cc->geom.width, cc->geom.maxw);
|
||||
if (cc->geom.maxh)
|
||||
cc->geom.height = MIN(cc->geom.height, cc->geom.maxh);
|
||||
}
|
||||
|
||||
static void
|
||||
client_gethints(struct client_ctx *cc)
|
||||
{
|
||||
XClassHint xch;
|
||||
int argc;
|
||||
char **argv;
|
||||
struct mwm_hints *mwmh;
|
||||
|
||||
if (XGetClassHint(X_Dpy, cc->win, &xch)) {
|
||||
@ -848,12 +815,35 @@ client_gethints(struct client_ctx *cc)
|
||||
cc->app_class = xch.res_class;
|
||||
}
|
||||
|
||||
if (xu_getprop(cc->win, cwmh[_MOTIF_WM_HINTS].atom, _MOTIF_WM_HINTS,
|
||||
if (xu_getprop(cc->win, _MOTIF_WM_HINTS, _MOTIF_WM_HINTS,
|
||||
PROP_MWM_HINTS_ELEMENTS, (u_char **)&mwmh) == MWM_NUMHINTS)
|
||||
if (mwmh->flags & MWM_HINTS_DECORATIONS &&
|
||||
!(mwmh->decorations & MWM_DECOR_ALL) &&
|
||||
!(mwmh->decorations & MWM_DECOR_BORDER))
|
||||
cc->bwidth = 0;
|
||||
if (XGetCommand(X_Dpy, cc->win, &argv, &argc)) {
|
||||
#define MAX_ARGLEN 512
|
||||
#define ARG_SEP_ " "
|
||||
int i, o, len = MAX_ARGLEN;
|
||||
char *buf;
|
||||
|
||||
buf = xmalloc(len);
|
||||
buf[0] = '\0';
|
||||
|
||||
for (o = 0, i = 0; o < len && i < argc; i++) {
|
||||
if (argv[i] == NULL)
|
||||
break;
|
||||
strlcat(buf, argv[i], len);
|
||||
o += strlen(buf);
|
||||
strlcat(buf, ARG_SEP_, len);
|
||||
o += strlen(ARG_SEP_);
|
||||
}
|
||||
|
||||
if (strlen(buf) > 0)
|
||||
cc->app_cliarg = buf;
|
||||
|
||||
XFreeStringList(argv);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -863,55 +853,12 @@ client_freehints(struct client_ctx *cc)
|
||||
XFree(cc->app_name);
|
||||
if (cc->app_class != NULL)
|
||||
XFree(cc->app_class);
|
||||
}
|
||||
|
||||
void
|
||||
client_transient(struct client_ctx *cc)
|
||||
{
|
||||
struct client_ctx *tc;
|
||||
Window trans;
|
||||
|
||||
if (XGetTransientForHint(X_Dpy, cc->win, &trans)) {
|
||||
if ((tc = client_find(trans)) && tc->group) {
|
||||
group_movetogroup(cc, tc->group->shortcut - 1);
|
||||
if (tc->flags & CLIENT_IGNORE)
|
||||
cc->flags |= CLIENT_IGNORE;
|
||||
}
|
||||
}
|
||||
xfree(cc->app_cliarg);
|
||||
}
|
||||
|
||||
static int
|
||||
client_inbound(struct client_ctx *cc, int x, int y)
|
||||
{
|
||||
return (x < cc->geom.w && x >= 0 &&
|
||||
y < cc->geom.h && 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);
|
||||
return (x < cc->geom.width && x >= 0 &&
|
||||
y < cc->geom.height && y >= 0);
|
||||
}
|
||||
|
127
conf.c
127
conf.c
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -31,6 +31,13 @@
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
#ifndef timespeccmp
|
||||
#define timespeccmp(tsp, usp, cmp) \
|
||||
(((tsp)->tv_sec == (usp)->tv_sec) ? \
|
||||
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
|
||||
((tsp)->tv_sec cmp (usp)->tv_sec))
|
||||
#endif
|
||||
|
||||
static void conf_mouseunbind(struct conf *, struct mousebinding *);
|
||||
static void conf_unbind(struct conf *, struct keybinding *);
|
||||
|
||||
@ -41,14 +48,14 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags)
|
||||
/* "term" and "lock" have special meanings. */
|
||||
|
||||
if (strcmp(label, "term") == 0)
|
||||
(void)strlcpy(c->termpath, image, sizeof(c->termpath));
|
||||
strlcpy(c->termpath, image, sizeof(c->termpath));
|
||||
else if (strcmp(label, "lock") == 0)
|
||||
(void)strlcpy(c->lockpath, image, sizeof(c->lockpath));
|
||||
strlcpy(c->lockpath, image, sizeof(c->lockpath));
|
||||
else {
|
||||
struct cmd *cmd = xmalloc(sizeof(*cmd));
|
||||
cmd->flags = flags;
|
||||
(void)strlcpy(cmd->image, image, sizeof(cmd->image));
|
||||
(void)strlcpy(cmd->label, label, sizeof(cmd->label));
|
||||
strlcpy(cmd->image, image, sizeof(cmd->image));
|
||||
strlcpy(cmd->label, label, sizeof(cmd->label));
|
||||
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
||||
}
|
||||
}
|
||||
@ -62,20 +69,10 @@ conf_gap(struct conf *c, struct screen_ctx *sc)
|
||||
void
|
||||
conf_font(struct conf *c, struct screen_ctx *sc)
|
||||
{
|
||||
font_init(sc, c->color[CWM_COLOR_FONT].name);
|
||||
sc->font = font_make(sc, c->font);
|
||||
sc->font = font_make(sc, c->DefaultFontName);
|
||||
sc->fontheight = font_ascent(sc) + font_descent(sc) + 1;
|
||||
}
|
||||
|
||||
static struct color color_binds[] = {
|
||||
{ "#CCCCCC", 0 }, /* CWM_COLOR_BORDER_ACTIVE */
|
||||
{ "#666666", 0 }, /* CWM_COLOR_BORDER_INACTIVE */
|
||||
{ "blue", 0 }, /* CWM_COLOR_BORDER_GROUP */
|
||||
{ "red", 0 }, /* CWM_COLOR_BORDER_UNGROUP */
|
||||
{ "black", 0 }, /* CWM_COLOR_FG_MENU */
|
||||
{ "white", 0 }, /* CWM_COLOR_BG_MENU */
|
||||
{ "black", 0 }, /* CWM_COLOR_FONT */
|
||||
};
|
||||
|
||||
void
|
||||
conf_color(struct conf *c, struct screen_ctx *sc)
|
||||
{
|
||||
@ -98,14 +95,13 @@ conf_reload(struct conf *c)
|
||||
return;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
client_draw_border(cc);
|
||||
TAILQ_FOREACH(sc, &Screenq, entry) {
|
||||
conf_gap(c, sc);
|
||||
conf_color(c, sc);
|
||||
conf_font(c, sc);
|
||||
menu_init(sc);
|
||||
}
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
client_draw_border(cc);
|
||||
}
|
||||
|
||||
static struct {
|
||||
@ -142,7 +138,6 @@ static struct {
|
||||
{ "CM-f", "maximize" },
|
||||
{ "CM-equal", "vmaximize" },
|
||||
{ "CMS-equal", "hmaximize" },
|
||||
{ "CMS-f", "freeze" },
|
||||
{ "CMS-r", "reload" },
|
||||
{ "CMS-q", "quit" },
|
||||
{ "M-h", "moveleft" },
|
||||
@ -189,7 +184,6 @@ conf_init(struct conf *c)
|
||||
c->flags = 0;
|
||||
c->bwidth = CONF_BWIDTH;
|
||||
c->mamount = CONF_MAMOUNT;
|
||||
c->snapdist = CONF_SNAPDIST;
|
||||
|
||||
TAILQ_INIT(&c->ignoreq);
|
||||
TAILQ_INIT(&c->cmdq);
|
||||
@ -197,20 +191,30 @@ conf_init(struct conf *c)
|
||||
TAILQ_INIT(&c->autogroupq);
|
||||
TAILQ_INIT(&c->mousebindingq);
|
||||
|
||||
for (i = 0; i < nitems(kb_binds); i++)
|
||||
for (i = 0; i < sizeof(kb_binds) / sizeof(kb_binds[0]); i++)
|
||||
conf_bindname(c, kb_binds[i].key, kb_binds[i].func);
|
||||
|
||||
for (i = 0; i < nitems(m_binds); i++)
|
||||
for (i = 0; i < sizeof(m_binds) / sizeof(m_binds[0]); i++)
|
||||
conf_mousebind(c, m_binds[i].key, m_binds[i].func);
|
||||
|
||||
for (i = 0; i < nitems(color_binds); i++)
|
||||
c->color[i].name = xstrdup(color_binds[i].name);
|
||||
|
||||
/* Default term/lock */
|
||||
(void)strlcpy(c->termpath, "xterm", sizeof(c->termpath));
|
||||
(void)strlcpy(c->lockpath, "xlock", sizeof(c->lockpath));
|
||||
strlcpy(c->termpath, "xterm", sizeof(c->termpath));
|
||||
strlcpy(c->lockpath, "xlock", sizeof(c->lockpath));
|
||||
|
||||
c->font = xstrdup(CONF_FONT);
|
||||
c->color[CWM_COLOR_BORDOR_ACTIVE].name =
|
||||
xstrdup(CONF_COLOR_ACTIVEBORDER);
|
||||
c->color[CWM_COLOR_BORDER_INACTIVE].name =
|
||||
xstrdup(CONF_COLOR_INACTIVEBORDER);
|
||||
c->color[CWM_COLOR_BORDER_GROUP].name =
|
||||
xstrdup(CONF_COLOR_GROUPBORDER);
|
||||
c->color[CWM_COLOR_BORDER_UNGROUP].name =
|
||||
xstrdup(CONF_COLOR_UNGROUPBORDER);
|
||||
c->color[CWM_COLOR_FG_MENU].name =
|
||||
xstrdup(CONF_COLOR_MENUFG);
|
||||
c->color[CWM_COLOR_BG_MENU].name =
|
||||
xstrdup(CONF_COLOR_MENUBG);
|
||||
|
||||
c->DefaultFontName = xstrdup(DEFAULTFONTNAME);
|
||||
}
|
||||
|
||||
void
|
||||
@ -254,39 +258,31 @@ conf_clear(struct conf *c)
|
||||
for (i = 0; i < CWM_COLOR_MAX; i++)
|
||||
xfree(c->color[i].name);
|
||||
|
||||
xfree(c->font);
|
||||
xfree(c->DefaultFontName);
|
||||
}
|
||||
|
||||
void
|
||||
conf_setup(struct conf *c, const char *conf_file)
|
||||
{
|
||||
char *home;
|
||||
struct stat sb;
|
||||
int parse = 0;
|
||||
|
||||
if (conf_file == NULL) {
|
||||
char *home = getenv("HOME");
|
||||
|
||||
if (home == NULL)
|
||||
errx(1, "No HOME directory.");
|
||||
|
||||
snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", home,
|
||||
CONFFILE);
|
||||
} else
|
||||
if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG))
|
||||
errx(1, "%s: %s", conf_file, strerror(errno));
|
||||
else
|
||||
strlcpy(c->conf_path, conf_file, sizeof(c->conf_path));
|
||||
|
||||
conf_init(c);
|
||||
|
||||
if (conf_file == NULL) {
|
||||
if ((home = getenv("HOME")) == NULL)
|
||||
errx(1, "No HOME directory.");
|
||||
|
||||
(void)snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s",
|
||||
home, CONFFILE);
|
||||
|
||||
if (stat(c->conf_path, &sb) == 0 && (sb.st_mode & S_IFREG))
|
||||
parse = 1;
|
||||
} else {
|
||||
if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG))
|
||||
errx(1, "%s: %s", conf_file, strerror(errno));
|
||||
else {
|
||||
(void)strlcpy(c->conf_path, conf_file,
|
||||
sizeof(c->conf_path));
|
||||
parse = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (parse && (parse_config(c->conf_path, c) == -1))
|
||||
warnx("config file %s has errors, not loading", c->conf_path);
|
||||
(void)parse_config(c->conf_path, c);
|
||||
}
|
||||
|
||||
void
|
||||
@ -359,17 +355,12 @@ static struct {
|
||||
{ "movetogroup9", kbfunc_client_movetogroup, KBFLAG_NEEDCLIENT,
|
||||
{.i = 9} },
|
||||
{ "nogroup", kbfunc_client_nogroup, 0, {0} },
|
||||
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
|
||||
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
|
||||
{ "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
|
||||
{.i = CWM_CYCLE|CWM_INGROUP} },
|
||||
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
|
||||
{.i = CWM_RCYCLE|CWM_INGROUP} },
|
||||
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLEGROUP} },
|
||||
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLEGROUP} },
|
||||
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
|
||||
{ "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} },
|
||||
@ -422,6 +413,7 @@ static struct {
|
||||
{.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
||||
{ "bigptrmoveright", kbfunc_moveresize, 0,
|
||||
{.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
|
||||
{ NULL, NULL, 0, {0}},
|
||||
};
|
||||
|
||||
/*
|
||||
@ -475,7 +467,8 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
||||
current_binding = xcalloc(1, sizeof(*current_binding));
|
||||
|
||||
if ((substring = strchr(name, '-')) != NULL) {
|
||||
for (iter = 0; iter < nitems(bind_mods); iter++) {
|
||||
for (iter = 0; iter < (sizeof(bind_mods) /
|
||||
sizeof(bind_mods[0])); iter++) {
|
||||
if ((tmp = strchr(name, bind_mods[iter].chr)) !=
|
||||
NULL && tmp < substring) {
|
||||
current_binding->modmask |=
|
||||
@ -510,7 +503,7 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
||||
if (strcmp("unmap", binding) == 0)
|
||||
return;
|
||||
|
||||
for (iter = 0; iter < nitems(name_to_kbfunc); iter++) {
|
||||
for (iter = 0; name_to_kbfunc[iter].tag != NULL; iter++) {
|
||||
if (strcmp(name_to_kbfunc[iter].tag, binding) != 0)
|
||||
continue;
|
||||
|
||||
@ -527,6 +520,7 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
||||
current_binding->flags = 0;
|
||||
conf_grab(c, current_binding);
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -561,11 +555,11 @@ static struct {
|
||||
{ "window_grouptoggle", mousefunc_window_grouptoggle,
|
||||
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 },
|
||||
{ "menu_group", mousefunc_menu_group, MOUSEBIND_CTX_ROOT },
|
||||
{ "menu_unhide", mousefunc_menu_unhide, MOUSEBIND_CTX_ROOT },
|
||||
{ "menu_cmd", mousefunc_menu_cmd, MOUSEBIND_CTX_ROOT },
|
||||
{ NULL, NULL, 0 },
|
||||
};
|
||||
|
||||
void
|
||||
@ -579,7 +573,8 @@ conf_mousebind(struct conf *c, char *name, char *binding)
|
||||
current_binding = xcalloc(1, sizeof(*current_binding));
|
||||
|
||||
if ((substring = strchr(name, '-')) != NULL) {
|
||||
for (iter = 0; iter < nitems(bind_mods); iter++) {
|
||||
for (iter = 0; iter < (sizeof(bind_mods) /
|
||||
sizeof(bind_mods[0])); iter++) {
|
||||
if ((tmp = strchr(name, bind_mods[iter].chr)) !=
|
||||
NULL && tmp < substring) {
|
||||
current_binding->modmask |=
|
||||
@ -601,7 +596,7 @@ conf_mousebind(struct conf *c, char *name, char *binding)
|
||||
if (strcmp("unmap", binding) == 0)
|
||||
return;
|
||||
|
||||
for (iter = 0; iter < nitems(name_to_mousefunc); iter++) {
|
||||
for (iter = 0; name_to_mousefunc[iter].tag != NULL; iter++) {
|
||||
if (strcmp(name_to_mousefunc[iter].tag, binding) != 0)
|
||||
continue;
|
||||
|
||||
|
27
cwm.1
27
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: May 7 2012 $
|
||||
.Dd $Mdocdate: August 24 2009 $
|
||||
.Dt CWM 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -88,8 +88,6 @@ 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-=
|
||||
@ -258,6 +256,18 @@ option is given.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr cwmrc 5
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
.Pp
|
||||
.Nm
|
||||
was developed by
|
||||
.An Marius Aamodt Eriksen Aq marius@monkey.org
|
||||
with contributions from
|
||||
.An Andy Adamson Aq dros@monkey.org ,
|
||||
.An Niels Provos Aq provos@monkey.org ,
|
||||
and
|
||||
.An Antti Nyk\(:anen Aq aon@iki.fi .
|
||||
Ideas, discussion with many others.
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
was originally inspired by evilwm, but was rewritten from scratch
|
||||
@ -268,14 +278,3 @@ has since been removed or rewritten.
|
||||
.Nm
|
||||
first appeared in
|
||||
.Ox 4.2 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
.Nm
|
||||
was developed by
|
||||
.An Marius Aamodt Eriksen Aq marius@monkey.org
|
||||
with contributions from
|
||||
.An Andy Adamson Aq dros@monkey.org ,
|
||||
.An Niels Provos Aq provos@monkey.org ,
|
||||
and
|
||||
.An Antti Nyk\(:anen Aq aon@iki.fi .
|
||||
Ideas, discussion with many others.
|
||||
|
41
cwmrc.5
41
cwmrc.5
@ -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: November 6 2011 $
|
||||
.Dd $Mdocdate: September 25 2010 $
|
||||
.Dt CWMRC 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -24,19 +24,7 @@
|
||||
This manual page describes the
|
||||
.Xr cwm 1
|
||||
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:
|
||||
The following options are accepted in the configuration file:
|
||||
.Pp
|
||||
.Bl -tag -width Ds -compact
|
||||
.It Ic autogroup Ar group windowname
|
||||
@ -99,21 +87,12 @@ Set the window border width to
|
||||
.It Ic color activeborder Ar color
|
||||
Set the color of the active border.
|
||||
.Pp
|
||||
.It Ic color font Ar color
|
||||
Set menu font color.
|
||||
.Pp
|
||||
.It Ic color groupborder Ar color
|
||||
Set the color of the border while grouping a window.
|
||||
.Pp
|
||||
.It Ic color inactiveborder Ar color
|
||||
Set the color of the inactive border.
|
||||
.Pp
|
||||
.It Ic color menubg Ar color
|
||||
Set menu background color.
|
||||
.Pp
|
||||
.It Ic color menufg Ar color
|
||||
Set menu foreground color.
|
||||
.Pp
|
||||
.It Ic color ungroupborder Ar color
|
||||
Set the color of the border while ungrouping a window.
|
||||
.Pp
|
||||
@ -206,10 +185,6 @@ Set a default size for the keyboard movement bindings,
|
||||
in pixels.
|
||||
The default is 1.
|
||||
.Pp
|
||||
.It Ic snapdist Ar pixels
|
||||
Minimum distance to snap-to adjacent edge, in pixels.
|
||||
The default is 0.
|
||||
.Pp
|
||||
.It Ic sticky Ic yes Ns \&| Ns Ic no
|
||||
Toggle sticky group mode.
|
||||
The default behavior for new windows is to not assign any group.
|
||||
@ -244,10 +219,6 @@ ignore xclock
|
||||
bind CM-r label
|
||||
bind CS-Return "xterm -e top"
|
||||
bind 4-o unmap
|
||||
bind CM-equal unmap
|
||||
bind CMS-equal unmap
|
||||
bind C4-equal vmaximize
|
||||
bind C4S-equal hmaximize
|
||||
bind M-1 grouponly1
|
||||
bind M-2 grouponly2
|
||||
bind M-3 grouponly3
|
||||
@ -306,10 +277,6 @@ Reverse cycle through groups.
|
||||
Forward cycle through windows.
|
||||
.It rcycle
|
||||
Reverse cycle through windows.
|
||||
.It cycleingroup
|
||||
Forward cycle through windows in current group.
|
||||
.It rcycleingroup
|
||||
Reverse cycle through windows in current group.
|
||||
.It delete
|
||||
Delete current window.
|
||||
.It hide
|
||||
@ -320,8 +287,6 @@ 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
|
||||
@ -433,8 +398,6 @@ Move current window.
|
||||
Resize current window.
|
||||
.It window_lower
|
||||
Lower current window.
|
||||
.It window_raise
|
||||
Raise current window.
|
||||
.It window_hide
|
||||
Hide current window.
|
||||
.It window_grouptoggle
|
||||
|
106
fgetln.c
Normal file
106
fgetln.c
Normal file
@ -0,0 +1,106 @@
|
||||
/* $NetBSD: fgetln.c,v 1.9 2008/04/29 06:53:03 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_NBTOOL_CONFIG_H
|
||||
#include "nbtool_config.h"
|
||||
#endif
|
||||
|
||||
#if !HAVE_FGETLN
|
||||
#include <stdlib.h>
|
||||
#ifndef HAVE_NBTOOL_CONFIG_H
|
||||
/* These headers are required, but included from nbtool_config.h */
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
fgetln(FILE *fp, size_t *len)
|
||||
{
|
||||
static char *buf = NULL;
|
||||
static size_t bufsiz = 0;
|
||||
char *ptr;
|
||||
|
||||
|
||||
if (buf == NULL) {
|
||||
bufsiz = BUFSIZ;
|
||||
if ((buf = malloc(bufsiz)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fgets(buf, bufsiz, fp) == NULL)
|
||||
return NULL;
|
||||
|
||||
*len = 0;
|
||||
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
|
||||
size_t nbufsiz = bufsiz + BUFSIZ;
|
||||
char *nbuf = realloc(buf, nbufsiz);
|
||||
|
||||
if (nbuf == NULL) {
|
||||
int oerrno = errno;
|
||||
free(buf);
|
||||
errno = oerrno;
|
||||
buf = NULL;
|
||||
return NULL;
|
||||
} else
|
||||
buf = nbuf;
|
||||
|
||||
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) {
|
||||
buf[bufsiz] = '\0';
|
||||
*len = strlen(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
*len = bufsiz;
|
||||
bufsiz = nbufsiz;
|
||||
}
|
||||
|
||||
*len = (ptr - buf) + 1;
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *p;
|
||||
size_t len;
|
||||
|
||||
while ((p = fgetln(stdin, &len)) != NULL) {
|
||||
(void)printf("%zu %s", len, p);
|
||||
free(p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
20
font.c
20
font.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* calmwm - the calm window manager
|
||||
* font.c - cwm font abstraction
|
||||
*
|
||||
* Copyright (c) 2005 Marius Eriksen <marius@monkey.org>
|
||||
*
|
||||
@ -14,8 +14,6 @@
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -45,24 +43,19 @@ font_descent(struct screen_ctx *sc)
|
||||
u_int
|
||||
font_height(struct screen_ctx *sc)
|
||||
{
|
||||
return (sc->font->height + 1);
|
||||
return (sc->fontheight);
|
||||
}
|
||||
|
||||
void
|
||||
font_init(struct screen_ctx *sc, const char *color)
|
||||
font_init(struct screen_ctx *sc)
|
||||
{
|
||||
if (sc->xftdraw)
|
||||
XftDrawDestroy(sc->xftdraw);
|
||||
sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
|
||||
DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which));
|
||||
if (sc->xftdraw == NULL)
|
||||
errx(1, "XftDrawCreate");
|
||||
|
||||
if (sc->xftcolor.pixel)
|
||||
XftColorFree(X_Dpy, DefaultVisual(X_Dpy, sc->which),
|
||||
DefaultColormap(X_Dpy, sc->which), &sc->xftcolor);
|
||||
if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which),
|
||||
DefaultColormap(X_Dpy, sc->which), color, &sc->xftcolor))
|
||||
DefaultColormap(X_Dpy, sc->which), "black", &sc->xftcolor))
|
||||
errx(1, "XftColorAllocName");
|
||||
}
|
||||
|
||||
@ -71,7 +64,7 @@ font_width(struct screen_ctx *sc, const char *text, int len)
|
||||
{
|
||||
XGlyphInfo extents;
|
||||
|
||||
XftTextExtentsUtf8(X_Dpy, sc->font, (const FcChar8*)text,
|
||||
XftTextExtents8(X_Dpy, sc->font, (const XftChar8*)text,
|
||||
len, &extents);
|
||||
|
||||
return (extents.xOff);
|
||||
@ -82,7 +75,8 @@ font_draw(struct screen_ctx *sc, const char *text, int len,
|
||||
Drawable d, int x, int y)
|
||||
{
|
||||
XftDrawChange(sc->xftdraw, d);
|
||||
XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
|
||||
/* Really needs to be UTF8'd. */
|
||||
XftDrawString8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
|
||||
(const FcChar8*)text, len);
|
||||
}
|
||||
|
||||
|
98
group.c
98
group.c
@ -16,7 +16,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -48,31 +48,38 @@ const char *shortcut_to_name[] = {
|
||||
static void
|
||||
group_add(struct group_ctx *gc, struct client_ctx *cc)
|
||||
{
|
||||
long no;
|
||||
if (cc == NULL || gc == NULL)
|
||||
errx(1, "group_add: a ctx is NULL");
|
||||
|
||||
no = gc->shortcut - 1;
|
||||
|
||||
if (cc->group == gc)
|
||||
return;
|
||||
|
||||
if (cc->group != NULL)
|
||||
TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
|
||||
|
||||
XChangeProperty(X_Dpy, cc->win, _NET_WM_DESKTOP, XA_CARDINAL,
|
||||
32, PropModeReplace, (unsigned char *)&no, 1);
|
||||
|
||||
TAILQ_INSERT_TAIL(&gc->clients, cc, group_entry);
|
||||
cc->group = gc;
|
||||
|
||||
xu_ewmh_net_wm_desktop(cc);
|
||||
}
|
||||
|
||||
static void
|
||||
group_remove(struct client_ctx *cc)
|
||||
{
|
||||
long no = 0xffffffff;
|
||||
|
||||
if (cc == NULL || cc->group == NULL)
|
||||
errx(1, "group_remove: a ctx is NULL");
|
||||
|
||||
XChangeProperty(X_Dpy, cc->win, _NET_WM_DESKTOP, XA_CARDINAL,
|
||||
32, PropModeReplace, (unsigned char *)&no, 1);
|
||||
|
||||
TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
|
||||
cc->group = NULL;
|
||||
|
||||
xu_ewmh_net_wm_desktop(cc);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -101,11 +108,6 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc)
|
||||
u_int i;
|
||||
int lastempty = -1;
|
||||
|
||||
gc->highstack = 0;
|
||||
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||
if (cc->stackingorder > gc->highstack)
|
||||
gc->highstack = cc->stackingorder;
|
||||
}
|
||||
winlist = (Window *) xcalloc(sizeof(*winlist), (gc->highstack + 1));
|
||||
|
||||
/*
|
||||
@ -139,12 +141,13 @@ void
|
||||
group_init(struct screen_ctx *sc)
|
||||
{
|
||||
int i;
|
||||
long viewports[2] = {0, 0};
|
||||
long ndesks = CALMWM_NGROUPS, zero = 0;
|
||||
|
||||
TAILQ_INIT(&sc->groupq);
|
||||
sc->group_hideall = 0;
|
||||
/*
|
||||
* See if any group names have already been set and update the
|
||||
* property with ours if they'll have changed.
|
||||
/* see if any group names have already been set and update the property
|
||||
* with ours if they'll have changed.
|
||||
*/
|
||||
group_update_names(sc);
|
||||
|
||||
@ -155,11 +158,23 @@ group_init(struct screen_ctx *sc)
|
||||
TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry);
|
||||
}
|
||||
|
||||
xu_ewmh_net_wm_desktop_viewport(sc);
|
||||
xu_ewmh_net_wm_number_of_desktops(sc);
|
||||
xu_ewmh_net_showing_desktop(sc);
|
||||
xu_ewmh_net_virtual_roots(sc);
|
||||
|
||||
/* we don't support large desktops, so this is always (0, 0) */
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_VIEWPORT,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)viewports, 2);
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_NUMBER_OF_DESKTOPS,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&ndesks, 1);
|
||||
/*
|
||||
* we don't use virtual roots, so make sure it's not there from a
|
||||
* previous wm.
|
||||
*/
|
||||
XDeleteProperty(X_Dpy, sc->rootwin, _NET_VIRTUAL_ROOTS);
|
||||
/*
|
||||
* We don't really have a ``showing desktop'' mode, so this is zero
|
||||
* always. XXX Note that when we hide all groups, or when all groups
|
||||
* are hidden we could technically set this later on.
|
||||
*/
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_SHOWING_DESKTOP,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&zero, 1);
|
||||
group_setactive(sc, 0);
|
||||
}
|
||||
|
||||
@ -188,27 +203,21 @@ static void
|
||||
group_setactive(struct screen_ctx *sc, long idx)
|
||||
{
|
||||
sc->group_active = &sc->groups[idx];
|
||||
|
||||
xu_ewmh_net_current_desktop(sc, idx);
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_CURRENT_DESKTOP,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&idx, 1);
|
||||
}
|
||||
|
||||
void
|
||||
group_movetogroup(struct client_ctx *cc, int idx)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct group_ctx *gc;
|
||||
|
||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||
err(1, "group_movetogroup: index out of range (%d)", idx);
|
||||
|
||||
gc = &sc->groups[idx];
|
||||
if (cc->group == gc)
|
||||
return;
|
||||
if (gc->hidden) {
|
||||
if(sc->group_active != &sc->groups[idx])
|
||||
client_hide(cc);
|
||||
gc->nhidden++;
|
||||
}
|
||||
group_add(gc, cc);
|
||||
group_add(&sc->groups[idx], cc);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -299,7 +308,7 @@ group_only(struct screen_ctx *sc, int idx)
|
||||
* Cycle through active groups. If none exist, then just stay put.
|
||||
*/
|
||||
void
|
||||
group_cycle(struct screen_ctx *sc, int flags)
|
||||
group_cycle(struct screen_ctx *sc, int reverse)
|
||||
{
|
||||
struct group_ctx *gc, *showgroup = NULL;
|
||||
|
||||
@ -307,11 +316,11 @@ group_cycle(struct screen_ctx *sc, int flags)
|
||||
|
||||
gc = sc->group_active;
|
||||
for (;;) {
|
||||
gc = (flags & CWM_RCYCLE) ? TAILQ_PREV(gc, group_ctx_q,
|
||||
entry) : TAILQ_NEXT(gc, entry);
|
||||
gc = reverse ? TAILQ_PREV(gc, group_ctx_q, entry) :
|
||||
TAILQ_NEXT(gc, entry);
|
||||
if (gc == NULL)
|
||||
gc = (flags & CWM_RCYCLE) ? TAILQ_LAST(&sc->groupq,
|
||||
group_ctx_q) : TAILQ_FIRST(&sc->groupq);
|
||||
gc = reverse ? TAILQ_LAST(&sc->groupq, group_ctx_q) :
|
||||
TAILQ_FIRST(&sc->groupq);
|
||||
if (gc == sc->group_active)
|
||||
break;
|
||||
|
||||
@ -363,10 +372,10 @@ group_menu(XButtonEvent *e)
|
||||
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
if (gc->hidden)
|
||||
(void)snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
|
||||
snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
|
||||
gc->shortcut, sc->group_names[i]);
|
||||
else
|
||||
(void)snprintf(mi->text, sizeof(mi->text), "%d: %s",
|
||||
snprintf(mi->text, sizeof(mi->text), "%d: %s",
|
||||
gc->shortcut, sc->group_names[i]);
|
||||
mi->ctx = gc;
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
@ -418,8 +427,8 @@ group_autogroup(struct client_ctx *cc)
|
||||
if (cc->app_class == NULL || cc->app_name == NULL)
|
||||
return;
|
||||
|
||||
if (xu_getprop(cc->win, ewmh[_NET_WM_DESKTOP].atom,
|
||||
XA_CARDINAL, 1, (unsigned char **)&grpno) > 0) {
|
||||
if (xu_getprop(cc->win, _NET_WM_DESKTOP, XA_CARDINAL,
|
||||
1, (unsigned char **)&grpno) > 0) {
|
||||
if (*grpno == 0xffffffff)
|
||||
no = 0;
|
||||
else if (*grpno > CALMWM_NGROUPS || *grpno < 0)
|
||||
@ -459,12 +468,11 @@ group_update_names(struct screen_ctx *sc)
|
||||
char **strings, *p;
|
||||
unsigned char *prop_ret;
|
||||
Atom type_ret;
|
||||
int format_ret, i = 0, nstrings = 0, n = 0, setnames = 0;
|
||||
int format_ret, i = 0, nstrings = 0, n, setnames = 0;
|
||||
unsigned long bytes_after, num_ret;
|
||||
|
||||
if (XGetWindowProperty(X_Dpy, sc->rootwin,
|
||||
ewmh[_NET_DESKTOP_NAMES].atom, 0, 0xffffff, False,
|
||||
cwmh[UTF8_STRING].atom, &type_ret, &format_ret,
|
||||
if (XGetWindowProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_NAMES, 0,
|
||||
0xffffff, False, UTF8_STRING, &type_ret, &format_ret,
|
||||
&num_ret, &bytes_after, &prop_ret) == Success &&
|
||||
prop_ret != NULL && format_ret == 8) {
|
||||
/* failure, just set defaults */
|
||||
@ -478,6 +486,7 @@ group_update_names(struct screen_ctx *sc)
|
||||
strings = xmalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS :
|
||||
nstrings) * sizeof(*strings));
|
||||
|
||||
i = n = 0;
|
||||
p = prop_ret;
|
||||
while (n < nstrings) {
|
||||
strings[n++] = xstrdup(p);
|
||||
@ -497,7 +506,7 @@ group_update_names(struct screen_ctx *sc)
|
||||
if (prop_ret != NULL)
|
||||
XFree(prop_ret);
|
||||
if (sc->group_nonames != 0)
|
||||
xfree(sc->group_names);
|
||||
free(sc->group_names);
|
||||
|
||||
sc->group_names = strings;
|
||||
sc->group_nonames = n;
|
||||
@ -519,10 +528,11 @@ group_set_names(struct screen_ctx *sc)
|
||||
tlen = len;
|
||||
for (i = 0; i < sc->group_nonames; i++) {
|
||||
slen = strlen(sc->group_names[i]) + 1;
|
||||
(void)strlcpy(q, sc->group_names[i], tlen);
|
||||
strlcpy(q, sc->group_names[i], tlen);
|
||||
tlen -= slen;
|
||||
q += slen;
|
||||
}
|
||||
|
||||
xu_ewmh_net_desktop_names(sc, p, len);
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_NAMES,
|
||||
UTF8_STRING, 8, PropModeReplace, p, len);
|
||||
}
|
||||
|
117
input.c
Normal file
117
input.c
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
int
|
||||
input_keycodetrans(KeyCode kc, u_int state, enum ctltype *ctl, char *chr)
|
||||
{
|
||||
int ks;
|
||||
|
||||
*ctl = CTL_NONE;
|
||||
*chr = '\0';
|
||||
|
||||
ks = XKeycodeToKeysym(X_Dpy, kc, (state & ShiftMask) ? 1 : 0);
|
||||
|
||||
/* Look for control characters. */
|
||||
switch (ks) {
|
||||
case XK_BackSpace:
|
||||
*ctl = CTL_ERASEONE;
|
||||
break;
|
||||
case XK_Return:
|
||||
*ctl = CTL_RETURN;
|
||||
break;
|
||||
case XK_Up:
|
||||
*ctl = CTL_UP;
|
||||
break;
|
||||
case XK_Down:
|
||||
*ctl = CTL_DOWN;
|
||||
break;
|
||||
case XK_Escape:
|
||||
*ctl = CTL_ABORT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*ctl == CTL_NONE && (state & ControlMask)) {
|
||||
switch (ks) {
|
||||
case XK_s:
|
||||
case XK_S:
|
||||
/* Emacs "next" */
|
||||
*ctl = CTL_DOWN;
|
||||
break;
|
||||
case XK_r:
|
||||
case XK_R:
|
||||
/* Emacs "previous" */
|
||||
*ctl = CTL_UP;
|
||||
break;
|
||||
case XK_u:
|
||||
case XK_U:
|
||||
*ctl = CTL_WIPE;
|
||||
break;
|
||||
case XK_h:
|
||||
case XK_H:
|
||||
*ctl = CTL_ERASEONE;
|
||||
break;
|
||||
case XK_a:
|
||||
case XK_A:
|
||||
*ctl = CTL_ALL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*ctl == CTL_NONE && (state & Mod1Mask)) {
|
||||
switch (ks) {
|
||||
case XK_j:
|
||||
case XK_J:
|
||||
/* Vi "down" */
|
||||
*ctl = CTL_DOWN;
|
||||
break;
|
||||
case XK_k:
|
||||
case XK_K:
|
||||
/* Vi "up" */
|
||||
*ctl = CTL_UP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*ctl != CTL_NONE)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* For regular characters, only (part of, actually) Latin 1
|
||||
* for now.
|
||||
*/
|
||||
if (ks < 0x20 || ks > 0x07e)
|
||||
return (-1);
|
||||
|
||||
*chr = (char)ks;
|
||||
|
||||
return (0);
|
||||
}
|
100
kbfunc.c
100
kbfunc.c
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -35,7 +35,7 @@
|
||||
#define KNOWN_HOSTS ".ssh/known_hosts"
|
||||
#define HASH_MARKER "|1|"
|
||||
|
||||
extern sig_atomic_t xev_quit;
|
||||
extern int _xev_quit;
|
||||
|
||||
void
|
||||
kbfunc_client_lower(struct client_ctx *cc, union arg *arg)
|
||||
@ -49,18 +49,16 @@ kbfunc_client_raise(struct client_ctx *cc, union arg *arg)
|
||||
client_raise(cc);
|
||||
}
|
||||
|
||||
#define TYPEMASK (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE)
|
||||
#define MOVEMASK (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
|
||||
#define typemask (CWM_MOVE | CWM_RESIZE | CWM_PTRMOVE)
|
||||
#define movemask (CWM_UP | CWM_DOWN | CWM_LEFT | CWM_RIGHT)
|
||||
void
|
||||
kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct screen_ctx *sc;
|
||||
int x, y, flags, amt;
|
||||
u_int mx, my;
|
||||
|
||||
if (cc->flags & CLIENT_FREEZE)
|
||||
return;
|
||||
|
||||
sc = cc->sc;
|
||||
mx = my = 0;
|
||||
|
||||
flags = arg->i;
|
||||
@ -71,7 +69,7 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
amt = amt * 10;
|
||||
}
|
||||
|
||||
switch (flags & MOVEMASK) {
|
||||
switch (flags & movemask) {
|
||||
case CWM_UP:
|
||||
my -= amt;
|
||||
break;
|
||||
@ -85,26 +83,19 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
mx -= amt;
|
||||
break;
|
||||
}
|
||||
switch (flags & TYPEMASK) {
|
||||
switch (flags & typemask) {
|
||||
case CWM_MOVE:
|
||||
cc->geom.y += my;
|
||||
if (cc->geom.y + cc->geom.h < 0)
|
||||
cc->geom.y = -cc->geom.h;
|
||||
if (cc->geom.y > sc->view.h - 1)
|
||||
cc->geom.y = sc->view.h - 1;
|
||||
if (cc->geom.y + cc->geom.height < 0)
|
||||
cc->geom.y = -cc->geom.height;
|
||||
if (cc->geom.y > cc->sc->ymax - 1)
|
||||
cc->geom.y = cc->sc->ymax - 1;
|
||||
|
||||
cc->geom.x += mx;
|
||||
if (cc->geom.x + cc->geom.w < 0)
|
||||
cc->geom.x = -cc->geom.w;
|
||||
if (cc->geom.x > sc->view.w - 1)
|
||||
cc->geom.x = sc->view.w - 1;
|
||||
|
||||
cc->geom.x += client_snapcalc(cc->geom.x,
|
||||
cc->geom.w, sc->view.w,
|
||||
cc->bwidth, Conf.snapdist);
|
||||
cc->geom.y += client_snapcalc(cc->geom.y,
|
||||
cc->geom.h, sc->view.h,
|
||||
cc->bwidth, Conf.snapdist);
|
||||
if (cc->geom.x + cc->geom.width < 0)
|
||||
cc->geom.x = -cc->geom.width;
|
||||
if (cc->geom.x > cc->sc->xmax - 1)
|
||||
cc->geom.x = cc->sc->xmax - 1;
|
||||
|
||||
client_move(cc);
|
||||
xu_ptr_getpos(cc->win, &x, &y);
|
||||
@ -113,23 +104,28 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
client_ptrwarp(cc);
|
||||
break;
|
||||
case CWM_RESIZE:
|
||||
if ((cc->geom.h += my) < 1)
|
||||
cc->geom.h = 1;
|
||||
if ((cc->geom.w += mx) < 1)
|
||||
cc->geom.w = 1;
|
||||
if ((cc->geom.height += my) < 1)
|
||||
cc->geom.height = 1;
|
||||
if ((cc->geom.width += mx) < 1)
|
||||
cc->geom.width = 1;
|
||||
client_resize(cc);
|
||||
|
||||
/* Make sure the pointer stays within the window. */
|
||||
xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y);
|
||||
if (cc->ptr.x > cc->geom.w)
|
||||
cc->ptr.x = cc->geom.w - cc->bwidth;
|
||||
if (cc->ptr.y > cc->geom.h)
|
||||
cc->ptr.y = cc->geom.h - cc->bwidth;
|
||||
if (cc->ptr.x > cc->geom.width)
|
||||
cc->ptr.x = cc->geom.width - cc->bwidth;
|
||||
if (cc->ptr.y > cc->geom.height)
|
||||
cc->ptr.y = cc->geom.height - cc->bwidth;
|
||||
client_ptrwarp(cc);
|
||||
break;
|
||||
case CWM_PTRMOVE:
|
||||
if (cc) {
|
||||
xu_ptr_getpos(cc->win, &x, &y);
|
||||
xu_ptr_setpos(cc->win, x + mx, y + my);
|
||||
} else {
|
||||
xu_ptr_getpos(sc->rootwin, &x, &y);
|
||||
xu_ptr_setpos(sc->rootwin, x + mx, y + my);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warnx("invalid flags passed to kbfunc_client_moveresize");
|
||||
@ -139,18 +135,19 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
void
|
||||
kbfunc_client_search(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct screen_ctx *sc;
|
||||
struct client_ctx *old_cc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
|
||||
sc = cc->sc;
|
||||
old_cc = client_current();
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
TAILQ_FOREACH(cc, &Clientq, entry) {
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text, cc->name, sizeof(mi->text));
|
||||
strlcpy(mi->text, cc->name, sizeof(mi->text));
|
||||
mi->ctx = cc;
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
@ -175,16 +172,17 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg)
|
||||
void
|
||||
kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct screen_ctx *sc;
|
||||
struct cmd *cmd;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
|
||||
sc = cc->sc;
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||
mi->ctx = cmd;
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
@ -202,7 +200,9 @@ kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
|
||||
void
|
||||
kbfunc_client_cycle(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct screen_ctx *sc;
|
||||
|
||||
sc = cc->sc;
|
||||
|
||||
/* XXX for X apps that ignore events */
|
||||
XGrabKeyboard(X_Dpy, sc->rootwin, True,
|
||||
@ -239,7 +239,7 @@ void
|
||||
kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
#define NPATHS 256
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct screen_ctx *sc;
|
||||
char **ap, *paths[NPATHS], *path, *pathcpy, *label;
|
||||
char tpath[MAXPATHLEN];
|
||||
DIR *dirp;
|
||||
@ -248,6 +248,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||
struct menu_q menuq;
|
||||
int l, i, cmd = arg->i;
|
||||
|
||||
sc = cc->sc;
|
||||
switch (cmd) {
|
||||
case CWM_EXEC_PROGRAM:
|
||||
label = "exec";
|
||||
@ -280,7 +281,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||
/* skip everything but regular files and symlinks */
|
||||
if (dp->d_type != DT_REG && dp->d_type != DT_LNK)
|
||||
continue;
|
||||
(void)memset(tpath, '\0', sizeof(tpath));
|
||||
memset(tpath, '\0', sizeof(tpath));
|
||||
l = snprintf(tpath, sizeof(tpath), "%s/%s", paths[i],
|
||||
dp->d_name);
|
||||
/* check for truncation etc */
|
||||
@ -288,8 +289,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||
continue;
|
||||
if (access(tpath, X_OK) == 0) {
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text,
|
||||
dp->d_name, sizeof(mi->text));
|
||||
strlcpy(mi->text, dp->d_name, sizeof(mi->text));
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
}
|
||||
@ -326,7 +326,7 @@ out:
|
||||
void
|
||||
kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct screen_ctx *sc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
FILE *fp;
|
||||
@ -336,6 +336,8 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||
int l;
|
||||
size_t len;
|
||||
|
||||
sc = cc->sc;
|
||||
|
||||
if ((home = getenv("HOME")) == NULL)
|
||||
return;
|
||||
|
||||
@ -354,7 +356,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||
else {
|
||||
/* EOF without EOL, copy and add the NUL */
|
||||
lbuf = xmalloc(len + 1);
|
||||
(void)memcpy(lbuf, buf, len);
|
||||
memcpy(lbuf, buf, len);
|
||||
lbuf[len] = '\0';
|
||||
buf = lbuf;
|
||||
}
|
||||
@ -373,7 +375,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
xfree(lbuf);
|
||||
(void)fclose(fp);
|
||||
fclose(fp);
|
||||
|
||||
if ((mi = menu_filter(sc, &menuq, "ssh", NULL, 1,
|
||||
search_match_exec, NULL)) != NULL) {
|
||||
@ -477,16 +479,10 @@ 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)
|
||||
{
|
||||
xev_quit = 1;
|
||||
_xev_quit = 1;
|
||||
}
|
||||
|
||||
void
|
||||
|
193
menu.c
193
menu.c
@ -1,6 +1,4 @@
|
||||
/*
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2008 Owain G. Ainsworth <oga@openbsd.org>
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
*
|
||||
@ -15,8 +13,6 @@
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -31,14 +27,8 @@
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
#define PROMPT_SCHAR "\xc2\xbb"
|
||||
#define PROMPT_ECHAR "\xc2\xab"
|
||||
|
||||
enum ctltype {
|
||||
CTL_NONE = -1,
|
||||
CTL_ERASEONE = 0, CTL_WIPE, CTL_UP, CTL_DOWN, CTL_RETURN,
|
||||
CTL_ABORT, CTL_ALL
|
||||
};
|
||||
#define PROMPT_SCHAR '<27>'
|
||||
#define PROMPT_ECHAR '<27>'
|
||||
|
||||
struct menu_ctx {
|
||||
char searchstr[MENU_MAXENTRY + 1];
|
||||
@ -68,19 +58,14 @@ static void menu_draw(struct screen_ctx *, struct menu_ctx *,
|
||||
struct menu_q *, struct menu_q *);
|
||||
static int menu_calc_entry(struct screen_ctx *, struct menu_ctx *,
|
||||
int, int);
|
||||
static int menu_keycode(KeyCode, u_int, enum ctltype *,
|
||||
char *);
|
||||
|
||||
void
|
||||
menu_init(struct screen_ctx *sc)
|
||||
{
|
||||
XGCValues gv;
|
||||
|
||||
if (sc->menuwin)
|
||||
XDestroyWindow(X_Dpy, sc->menuwin);
|
||||
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1,
|
||||
Conf.bwidth,
|
||||
sc->color[CWM_COLOR_FG_MENU].pixel,
|
||||
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, 0,
|
||||
sc->color[CWM_COLOR_BG_MENU].pixel,
|
||||
sc->color[CWM_COLOR_BG_MENU].pixel);
|
||||
|
||||
gv.foreground =
|
||||
@ -88,8 +73,6 @@ menu_init(struct screen_ctx *sc)
|
||||
gv.background = sc->color[CWM_COLOR_BG_MENU].pixel;
|
||||
gv.function = GXxor;
|
||||
|
||||
if (sc->gc)
|
||||
XFreeGC(X_Dpy, sc->gc);
|
||||
sc->gc = XCreateGC(X_Dpy, sc->menuwin,
|
||||
GCForeground|GCBackground|GCFunction, &gv);
|
||||
}
|
||||
@ -106,7 +89,6 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
||||
XEvent e;
|
||||
Window focuswin;
|
||||
int evmask, focusrevert;
|
||||
int xsave, ysave, xcur, ycur;
|
||||
|
||||
TAILQ_INIT(&resultq);
|
||||
|
||||
@ -114,25 +96,22 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
||||
|
||||
xu_ptr_getpos(sc->rootwin, &mc.x, &mc.y);
|
||||
|
||||
xsave = mc.x;
|
||||
ysave = mc.y;
|
||||
|
||||
if (prompt == NULL) {
|
||||
evmask = MENUMASK;
|
||||
evmask = MenuMask;
|
||||
mc.promptstr[0] = '\0';
|
||||
mc.list = 1;
|
||||
} else {
|
||||
evmask = MENUMASK | KEYMASK; /* only accept keys if prompt */
|
||||
(void)snprintf(mc.promptstr, sizeof(mc.promptstr), "%s%s",
|
||||
prompt, PROMPT_SCHAR);
|
||||
(void)snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%s",
|
||||
mc.promptstr, mc.searchstr, PROMPT_ECHAR);
|
||||
evmask = MenuMask | KeyMask; /* only accept keys if prompt */
|
||||
snprintf(mc.promptstr, sizeof(mc.promptstr), "%s%c", prompt,
|
||||
PROMPT_SCHAR);
|
||||
snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%c", mc.promptstr,
|
||||
mc.searchstr, PROMPT_ECHAR);
|
||||
mc.width = font_width(sc, mc.dispstr, strlen(mc.dispstr));
|
||||
mc.hasprompt = 1;
|
||||
}
|
||||
|
||||
if (initial != NULL)
|
||||
(void)strlcpy(mc.searchstr, initial, sizeof(mc.searchstr));
|
||||
strlcpy(mc.searchstr, initial, sizeof(mc.searchstr));
|
||||
else
|
||||
mc.searchstr[0] = '\0';
|
||||
|
||||
@ -145,7 +124,7 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
||||
XSelectInput(X_Dpy, sc->menuwin, evmask);
|
||||
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);
|
||||
return (NULL);
|
||||
}
|
||||
@ -163,6 +142,8 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
||||
XWindowEvent(X_Dpy, sc->menuwin, evmask, &e);
|
||||
|
||||
switch (e.type) {
|
||||
default:
|
||||
break;
|
||||
case KeyPress:
|
||||
if ((mi = menu_handle_key(&e, &mc, menuq, &resultq))
|
||||
!= NULL)
|
||||
@ -179,22 +160,15 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
||||
!= NULL)
|
||||
goto out;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
if (dummy == 0 && mi->dummy) { /* no mouse based match */
|
||||
if (dummy == 0 && mi->dummy) { /* no match */
|
||||
xfree (mi);
|
||||
mi = NULL;
|
||||
}
|
||||
|
||||
XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
|
||||
/* restore if user didn't move */
|
||||
xu_ptr_getpos(sc->rootwin, &xcur, &ycur);
|
||||
if (xcur == mc.x && ycur == mc.y)
|
||||
xu_ptr_setpos(sc->rootwin, xsave, ysave);
|
||||
xu_ptr_ungrab();
|
||||
XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
|
||||
}
|
||||
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
XUngrabKeyboard(X_Dpy, CurrentTime);
|
||||
@ -211,7 +185,8 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
char chr;
|
||||
size_t len;
|
||||
|
||||
if (menu_keycode(e->xkey.keycode, e->xkey.state, &ctl, &chr) < 0)
|
||||
if (input_keycodetrans(e->xkey.keycode, e->xkey.state,
|
||||
&ctl, &chr) < 0)
|
||||
return (NULL);
|
||||
|
||||
switch (ctl) {
|
||||
@ -273,7 +248,7 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
str[0] = chr;
|
||||
str[1] = '\0';
|
||||
mc->changed = 1;
|
||||
(void)strlcat(mc->searchstr, str, sizeof(mc->searchstr));
|
||||
strlcat(mc->searchstr, str, sizeof(mc->searchstr));
|
||||
}
|
||||
|
||||
mc->noresult = 0;
|
||||
@ -297,8 +272,6 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
struct menu_q *resultq)
|
||||
{
|
||||
struct menu *mi;
|
||||
XineramaScreenInfo *xine;
|
||||
int xmin, xmax, ymin, ymax;
|
||||
int n, dy, xsave, ysave;
|
||||
|
||||
if (mc->list) {
|
||||
@ -317,7 +290,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
mc->width = 0;
|
||||
dy = 0;
|
||||
if (mc->hasprompt) {
|
||||
(void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s",
|
||||
snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%c",
|
||||
mc->promptstr, mc->searchstr, PROMPT_ECHAR);
|
||||
mc->width = font_width(sc, mc->dispstr, strlen(mc->dispstr));
|
||||
dy = font_height(sc);
|
||||
@ -341,33 +314,18 @@ 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->view.w;
|
||||
ymax = sc->view.h;
|
||||
}
|
||||
|
||||
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->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;
|
||||
if (mc->y + dy >= sc->ymax)
|
||||
mc->y = sc->ymax - dy;
|
||||
/* never hide the top of the menu */
|
||||
if (mc->y < ymin) {
|
||||
mc->y = ymin;
|
||||
dy = ymax - ymin;
|
||||
}
|
||||
if (mc->y < 0)
|
||||
mc->y = 0;
|
||||
|
||||
if (mc->x != xsave || mc->y != ysave)
|
||||
xu_ptr_setpos(sc->rootwin, mc->x, mc->y);
|
||||
@ -391,7 +349,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
n++;
|
||||
}
|
||||
|
||||
if (mc->hasprompt && n > 1 && (mc->searchstr[0] != '\0'))
|
||||
if (mc->hasprompt && n > 1)
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc,
|
||||
0, font_height(sc), mc->width, font_height(sc));
|
||||
|
||||
@ -410,11 +368,11 @@ menu_handle_move(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc)
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
|
||||
font_height(sc) * mc->prev, mc->width, font_height(sc));
|
||||
if (mc->entry != -1) {
|
||||
(void)xu_ptr_regrab(MENUGRABMASK, Cursor_normal);
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_select);
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
|
||||
font_height(sc) * mc->entry, mc->width, font_height(sc));
|
||||
} else
|
||||
(void)xu_ptr_regrab(MENUGRABMASK, Cursor_default);
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_default);
|
||||
}
|
||||
|
||||
static struct menu *
|
||||
@ -425,6 +383,7 @@ menu_handle_release(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc,
|
||||
int entry, i = 0;
|
||||
|
||||
entry = menu_calc_entry(sc, mc, e->xbutton.x, e->xbutton.y);
|
||||
xu_ptr_ungrab();
|
||||
|
||||
if (mc->hasprompt)
|
||||
i = 1;
|
||||
@ -457,89 +416,3 @@ menu_calc_entry(struct screen_ctx *sc, struct menu_ctx *mc, int x, int y)
|
||||
|
||||
return (entry);
|
||||
}
|
||||
|
||||
static int
|
||||
menu_keycode(KeyCode kc, u_int state, enum ctltype *ctl, char *chr)
|
||||
{
|
||||
int ks;
|
||||
|
||||
*ctl = CTL_NONE;
|
||||
*chr = '\0';
|
||||
|
||||
ks = XkbKeycodeToKeysym(X_Dpy, kc, 0, (state & ShiftMask) ? 1 : 0);
|
||||
|
||||
/* Look for control characters. */
|
||||
switch (ks) {
|
||||
case XK_BackSpace:
|
||||
*ctl = CTL_ERASEONE;
|
||||
break;
|
||||
case XK_Return:
|
||||
*ctl = CTL_RETURN;
|
||||
break;
|
||||
case XK_Up:
|
||||
*ctl = CTL_UP;
|
||||
break;
|
||||
case XK_Down:
|
||||
*ctl = CTL_DOWN;
|
||||
break;
|
||||
case XK_Escape:
|
||||
*ctl = CTL_ABORT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*ctl == CTL_NONE && (state & ControlMask)) {
|
||||
switch (ks) {
|
||||
case XK_s:
|
||||
case XK_S:
|
||||
/* Emacs "next" */
|
||||
*ctl = CTL_DOWN;
|
||||
break;
|
||||
case XK_r:
|
||||
case XK_R:
|
||||
/* Emacs "previous" */
|
||||
*ctl = CTL_UP;
|
||||
break;
|
||||
case XK_u:
|
||||
case XK_U:
|
||||
*ctl = CTL_WIPE;
|
||||
break;
|
||||
case XK_h:
|
||||
case XK_H:
|
||||
*ctl = CTL_ERASEONE;
|
||||
break;
|
||||
case XK_a:
|
||||
case XK_A:
|
||||
*ctl = CTL_ALL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*ctl == CTL_NONE && (state & Mod1Mask)) {
|
||||
switch (ks) {
|
||||
case XK_j:
|
||||
case XK_J:
|
||||
/* Vi "down" */
|
||||
*ctl = CTL_DOWN;
|
||||
break;
|
||||
case XK_k:
|
||||
case XK_K:
|
||||
/* Vi "up" */
|
||||
*ctl = CTL_UP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*ctl != CTL_NONE)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* For regular characters, only (part of, actually) Latin 1
|
||||
* for now.
|
||||
*/
|
||||
if (ks < 0x20 || ks > 0x07e)
|
||||
return (-1);
|
||||
|
||||
*chr = (char)ks;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
110
mousefunc.c
110
mousefunc.c
@ -16,7 +16,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -37,17 +37,17 @@ static void mousefunc_sweep_draw(struct client_ctx *);
|
||||
static int
|
||||
mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
|
||||
{
|
||||
int width = cc->geom.w, height = cc->geom.h;
|
||||
int width = cc->geom.width, height = cc->geom.height;
|
||||
|
||||
cc->geom.w = abs(x - mx) - cc->bwidth;
|
||||
cc->geom.h = abs(y - my) - cc->bwidth;
|
||||
cc->geom.width = abs(x - mx) - cc->bwidth;
|
||||
cc->geom.height = abs(y - my) - cc->bwidth;
|
||||
|
||||
client_applysizehints(cc);
|
||||
|
||||
cc->geom.x = x <= mx ? x : x - cc->geom.w;
|
||||
cc->geom.y = y <= my ? y : y - cc->geom.h;
|
||||
cc->geom.x = x <= mx ? x : x - cc->geom.width;
|
||||
cc->geom.y = y <= my ? y : y - cc->geom.height;
|
||||
|
||||
return (width != cc->geom.w || height != cc->geom.h);
|
||||
return (width != cc->geom.width || height != cc->geom.height);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -55,47 +55,46 @@ mousefunc_sweep_draw(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
char asize[10]; /* fits "nnnnxnnnn\0" */
|
||||
int width, width_size, width_name;
|
||||
int width, height, width_size, width_name;
|
||||
|
||||
(void)snprintf(asize, sizeof(asize), "%dx%d",
|
||||
(cc->geom.w - cc->hint.basew) / cc->hint.incw,
|
||||
(cc->geom.h - cc->hint.baseh) / cc->hint.inch);
|
||||
snprintf(asize, sizeof(asize), "%dx%d",
|
||||
(cc->geom.width - cc->geom.basew) / cc->geom.incw,
|
||||
(cc->geom.height - cc->geom.baseh) / cc->geom.inch);
|
||||
width_size = font_width(sc, asize, strlen(asize)) + 4;
|
||||
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
|
||||
width = MAX(width_size, width_name);
|
||||
height = font_ascent(sc) + font_descent(sc) + 1;
|
||||
|
||||
XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
|
||||
XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, width, font_height(sc) * 2);
|
||||
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);
|
||||
XClearWindow(X_Dpy, sc->menuwin);
|
||||
font_draw(sc, cc->name, strlen(cc->name), sc->menuwin,
|
||||
2, font_ascent(sc) + 1);
|
||||
font_draw(sc, asize, strlen(asize), sc->menuwin,
|
||||
width / 2 - width_size / 2, font_height(sc) + font_ascent(sc) + 1);
|
||||
width / 2 - width_size / 2, height + font_ascent(sc) + 1);
|
||||
}
|
||||
|
||||
void
|
||||
mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
XEvent ev;
|
||||
Time ltime = 0;
|
||||
Time time = 0;
|
||||
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);
|
||||
|
||||
if (xu_ptr_grab(cc->win, MOUSEMASK, Cursor_resize) < 0)
|
||||
if (xu_ptr_grab(cc->win, MouseMask, Cursor_resize) < 0)
|
||||
return;
|
||||
|
||||
xu_ptr_setpos(cc->win, cc->geom.w, cc->geom.h);
|
||||
xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
|
||||
mousefunc_sweep_draw(cc);
|
||||
|
||||
for (;;) {
|
||||
XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev);
|
||||
XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
|
||||
|
||||
switch (ev.type) {
|
||||
case Expose:
|
||||
@ -107,25 +106,29 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
||||
/* Recompute window output */
|
||||
mousefunc_sweep_draw(cc);
|
||||
|
||||
/* don't resize more than 60 times / second */
|
||||
if ((ev.xmotion.time - ltime) > (1000 / 60)) {
|
||||
ltime = ev.xmotion.time;
|
||||
/* don't sync more than 60 times / second */
|
||||
if ((ev.xmotion.time - time) > (1000 / 60)) {
|
||||
time = ev.xmotion.time;
|
||||
XSync(X_Dpy, False);
|
||||
client_resize(cc);
|
||||
}
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (ltime)
|
||||
if (time) {
|
||||
XSync(X_Dpy, False);
|
||||
client_resize(cc);
|
||||
}
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
|
||||
xu_ptr_ungrab();
|
||||
|
||||
/* Make sure the pointer stays within the window. */
|
||||
if (cc->ptr.x > cc->geom.w)
|
||||
cc->ptr.x = cc->geom.w - cc->bwidth;
|
||||
if (cc->ptr.y > cc->geom.h)
|
||||
cc->ptr.y = cc->geom.h - cc->bwidth;
|
||||
if (cc->ptr.x > cc->geom.width)
|
||||
cc->ptr.x = cc->geom.width - cc->bwidth;
|
||||
if (cc->ptr.y > cc->geom.height)
|
||||
cc->ptr.y = cc->geom.height - cc->bwidth;
|
||||
client_ptrwarp(cc);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -136,47 +139,39 @@ void
|
||||
mousefunc_window_move(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
XEvent ev;
|
||||
Time ltime = 0;
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
Time time = 0;
|
||||
int px, py;
|
||||
|
||||
client_raise(cc);
|
||||
|
||||
if (cc->flags & CLIENT_FREEZE)
|
||||
return;
|
||||
|
||||
if (xu_ptr_grab(cc->win, MOUSEMASK, Cursor_move) < 0)
|
||||
if (xu_ptr_grab(cc->win, MouseMask, Cursor_move) < 0)
|
||||
return;
|
||||
|
||||
xu_ptr_getpos(cc->win, &px, &py);
|
||||
|
||||
for (;;) {
|
||||
XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev);
|
||||
XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
|
||||
|
||||
switch (ev.type) {
|
||||
case Expose:
|
||||
client_draw_border(cc);
|
||||
break;
|
||||
case MotionNotify:
|
||||
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
|
||||
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
|
||||
cc->geom.x = ev.xmotion.x_root - px;
|
||||
cc->geom.y = ev.xmotion.y_root - py;
|
||||
|
||||
cc->geom.x += client_snapcalc(cc->geom.x,
|
||||
cc->geom.w, sc->view.w,
|
||||
cc->bwidth, Conf.snapdist);
|
||||
cc->geom.y += client_snapcalc(cc->geom.y,
|
||||
cc->geom.h, sc->view.h,
|
||||
cc->bwidth, Conf.snapdist);
|
||||
|
||||
/* don't move more than 60 times / second */
|
||||
if ((ev.xmotion.time - ltime) > (1000 / 60)) {
|
||||
ltime = ev.xmotion.time;
|
||||
/* don't sync more than 60 times / second */
|
||||
if ((ev.xmotion.time - time) > (1000 / 60)) {
|
||||
time = ev.xmotion.time;
|
||||
XSync(X_Dpy, False);
|
||||
client_move(cc);
|
||||
}
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (ltime)
|
||||
if (time) {
|
||||
XSync(X_Dpy, False);
|
||||
client_move(cc);
|
||||
}
|
||||
xu_ptr_ungrab();
|
||||
return;
|
||||
}
|
||||
@ -197,12 +192,6 @@ mousefunc_window_lower(struct client_ctx *cc, void *arg)
|
||||
client_lower(cc);
|
||||
}
|
||||
|
||||
void
|
||||
mousefunc_window_raise(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
client_raise(cc);
|
||||
}
|
||||
|
||||
void
|
||||
mousefunc_window_hide(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
@ -218,12 +207,13 @@ mousefunc_menu_group(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct screen_ctx *sc;
|
||||
struct client_ctx *old_cc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
char *wname;
|
||||
|
||||
sc = cc->sc;
|
||||
old_cc = client_current();
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
@ -234,7 +224,7 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
|
||||
continue;
|
||||
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text, wname, sizeof(mi->text));
|
||||
strlcpy(mi->text, wname, sizeof(mi->text));
|
||||
mi->ctx = cc;
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
@ -261,15 +251,17 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct screen_ctx *sc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
struct cmd *cmd;
|
||||
|
||||
sc = cc->sc;
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
(void)strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||
mi->ctx = cmd;
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
|
43
parse.y
43
parse.y
@ -70,10 +70,9 @@ typedef struct {
|
||||
%token FONTNAME STICKY GAP MOUSEBIND
|
||||
%token AUTOGROUP BIND COMMAND IGNORE
|
||||
%token YES NO BORDERWIDTH MOVEAMOUNT
|
||||
%token COLOR SNAPDIST
|
||||
%token COLOR
|
||||
%token ACTIVEBORDER INACTIVEBORDER
|
||||
%token GROUPBORDER UNGROUPBORDER
|
||||
%token MENUBG MENUFG FONTCOLOR
|
||||
%token ERROR
|
||||
%token <v.string> STRING
|
||||
%token <v.number> NUMBER
|
||||
@ -106,8 +105,8 @@ yesno : YES { $$ = 1; }
|
||||
;
|
||||
|
||||
main : FONTNAME STRING {
|
||||
free(conf->font);
|
||||
conf->font = $2;
|
||||
free(conf->DefaultFontName);
|
||||
conf->DefaultFontName = $2;
|
||||
}
|
||||
| STICKY yesno {
|
||||
if ($2 == 0)
|
||||
@ -121,9 +120,6 @@ main : FONTNAME STRING {
|
||||
| MOVEAMOUNT NUMBER {
|
||||
conf->mamount = $2;
|
||||
}
|
||||
| SNAPDIST NUMBER {
|
||||
conf->snapdist = $2;
|
||||
}
|
||||
| COMMAND STRING string {
|
||||
conf_cmd_add(conf, $3, $2, 0);
|
||||
free($2);
|
||||
@ -143,7 +139,7 @@ main : FONTNAME STRING {
|
||||
struct winmatch *wm;
|
||||
|
||||
wm = xcalloc(1, sizeof(*wm));
|
||||
(void)strlcpy(wm->title, $2, sizeof(wm->title));
|
||||
strlcpy(wm->title, $2, sizeof(wm->title));
|
||||
TAILQ_INSERT_TAIL(&conf->ignoreq, wm, entry);
|
||||
|
||||
free($2);
|
||||
@ -170,8 +166,8 @@ color : COLOR colors
|
||||
;
|
||||
|
||||
colors : ACTIVEBORDER STRING {
|
||||
free(conf->color[CWM_COLOR_BORDER_ACTIVE].name);
|
||||
conf->color[CWM_COLOR_BORDER_ACTIVE].name = $2;
|
||||
free(conf->color[CWM_COLOR_BORDOR_ACTIVE].name);
|
||||
conf->color[CWM_COLOR_BORDOR_ACTIVE].name = $2;
|
||||
}
|
||||
| INACTIVEBORDER STRING {
|
||||
free(conf->color[CWM_COLOR_BORDER_INACTIVE].name);
|
||||
@ -185,18 +181,6 @@ colors : ACTIVEBORDER STRING {
|
||||
free(conf->color[CWM_COLOR_BORDER_UNGROUP].name);
|
||||
conf->color[CWM_COLOR_BORDER_UNGROUP].name = $2;
|
||||
}
|
||||
| MENUBG STRING {
|
||||
free(conf->color[CWM_COLOR_BG_MENU].name);
|
||||
conf->color[CWM_COLOR_BG_MENU].name = $2;
|
||||
}
|
||||
| MENUFG STRING {
|
||||
free(conf->color[CWM_COLOR_FG_MENU].name);
|
||||
conf->color[CWM_COLOR_FG_MENU].name = $2;
|
||||
}
|
||||
| FONTCOLOR STRING {
|
||||
free(conf->color[CWM_COLOR_FONT].name);
|
||||
conf->color[CWM_COLOR_FONT].name = $2;
|
||||
}
|
||||
;
|
||||
%%
|
||||
|
||||
@ -236,18 +220,14 @@ lookup(char *s)
|
||||
{ "borderwidth", BORDERWIDTH},
|
||||
{ "color", COLOR},
|
||||
{ "command", COMMAND},
|
||||
{ "font", FONTCOLOR},
|
||||
{ "fontname", FONTNAME},
|
||||
{ "gap", GAP},
|
||||
{ "groupborder", GROUPBORDER},
|
||||
{ "ignore", IGNORE},
|
||||
{ "inactiveborder", INACTIVEBORDER},
|
||||
{ "menubg", MENUBG},
|
||||
{ "menufg", MENUFG},
|
||||
{ "mousebind", MOUSEBIND},
|
||||
{ "moveamount", MOVEAMOUNT},
|
||||
{ "no", NO},
|
||||
{ "snapdist", SNAPDIST},
|
||||
{ "sticky", STICKY},
|
||||
{ "ungroupborder", UNGROUPBORDER},
|
||||
{ "yes", YES}
|
||||
@ -478,6 +458,8 @@ pushfile(const char *name)
|
||||
nfile->name = xstrdup(name);
|
||||
|
||||
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
|
||||
if (errno != ENOENT)
|
||||
warn("%s", nfile->name);
|
||||
free(nfile->name);
|
||||
free(nfile);
|
||||
return (NULL);
|
||||
@ -516,7 +498,7 @@ parse_config(const char *filename, struct conf *xconf)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
(void)strlcpy(conf->conf_path, filename, sizeof(conf->conf_path));
|
||||
strlcpy(conf->conf_path, filename, sizeof(conf->conf_path));
|
||||
|
||||
conf_init(conf);
|
||||
|
||||
@ -541,7 +523,6 @@ parse_config(const char *filename, struct conf *xconf)
|
||||
xconf->flags = conf->flags;
|
||||
xconf->bwidth = conf->bwidth;
|
||||
xconf->mamount = conf->mamount;
|
||||
xconf->snapdist = conf->snapdist;
|
||||
xconf->gap = conf->gap;
|
||||
|
||||
while ((cmd = TAILQ_FIRST(&conf->cmdq)) != NULL) {
|
||||
@ -569,15 +550,15 @@ parse_config(const char *filename, struct conf *xconf)
|
||||
TAILQ_INSERT_TAIL(&xconf->mousebindingq, mb, entry);
|
||||
}
|
||||
|
||||
(void)strlcpy(xconf->termpath, conf->termpath,
|
||||
strlcpy(xconf->termpath, conf->termpath,
|
||||
sizeof(xconf->termpath));
|
||||
(void)strlcpy(xconf->lockpath, conf->lockpath,
|
||||
strlcpy(xconf->lockpath, conf->lockpath,
|
||||
sizeof(xconf->lockpath));
|
||||
|
||||
for (i = 0; i < CWM_COLOR_MAX; i++)
|
||||
xconf->color[i].name = conf->color[i].name;
|
||||
|
||||
xconf->font = conf->font;
|
||||
xconf->DefaultFontName = conf->DefaultFontName;
|
||||
}
|
||||
|
||||
free(conf);
|
||||
|
62
screen.c
62
screen.c
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -30,8 +30,6 @@
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
static void screen_init_xinerama(struct screen_ctx *);
|
||||
|
||||
struct screen_ctx *
|
||||
screen_fromroot(Window rootwin)
|
||||
{
|
||||
@ -67,18 +65,24 @@ screen_updatestackingorder(struct screen_ctx *sc)
|
||||
XFree(wins);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're using RandR then we'll redo this whenever the screen
|
||||
* changes since a CTRC may have been added or removed
|
||||
*/
|
||||
void
|
||||
screen_init_xinerama(struct screen_ctx *sc)
|
||||
{
|
||||
XineramaScreenInfo *info = NULL;
|
||||
int no = 0;
|
||||
XineramaScreenInfo *info;
|
||||
int no;
|
||||
|
||||
if (HasXinerama == 0 || XineramaIsActive(X_Dpy) == 0) {
|
||||
HasXinerama = 0;
|
||||
sc->xinerama_no = 0;
|
||||
}
|
||||
|
||||
if (XineramaIsActive(X_Dpy))
|
||||
info = XineramaQueryScreens(X_Dpy, &no);
|
||||
if (info == NULL) {
|
||||
/* Is xinerama actually off, instead of a malloc failure? */
|
||||
if (sc->xinerama == NULL)
|
||||
HasXinerama = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sc->xinerama != NULL)
|
||||
XFree(sc->xinerama);
|
||||
@ -95,33 +99,35 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y)
|
||||
XineramaScreenInfo *info;
|
||||
int i;
|
||||
|
||||
if (sc->xinerama == NULL)
|
||||
return (NULL);
|
||||
|
||||
for (i = 0; i < sc->xinerama_no; i++) {
|
||||
info = &sc->xinerama[i];
|
||||
if (x >= info->x_org && x < info->x_org + info->width &&
|
||||
y >= info->y_org && y < info->y_org + info->height)
|
||||
if (x > info->x_org && x < info->x_org + info->width &&
|
||||
y > info->y_org && y < info->y_org + info->height)
|
||||
return (info);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
screen_update_geometry(struct screen_ctx *sc)
|
||||
screen_update_geometry(struct screen_ctx *sc, int width, int height)
|
||||
{
|
||||
sc->view.x = 0;
|
||||
sc->view.y = 0;
|
||||
sc->view.w = DisplayWidth(X_Dpy, sc->which);
|
||||
sc->view.h = DisplayHeight(X_Dpy, sc->which);
|
||||
long geom[2], workareas[CALMWM_NGROUPS][4];
|
||||
int i;
|
||||
|
||||
sc->work.x = sc->view.x + sc->gap.left;
|
||||
sc->work.y = sc->view.y + sc->gap.top;
|
||||
sc->work.w = sc->view.w - (sc->gap.left + sc->gap.right);
|
||||
sc->work.h = sc->view.h - (sc->gap.top + sc->gap.bottom);
|
||||
sc->xmax = geom[0] = width;
|
||||
sc->ymax = geom[1] = height;
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_GEOMETRY,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)geom , 2);
|
||||
|
||||
screen_init_xinerama(sc);
|
||||
|
||||
xu_ewmh_net_desktop_geometry(sc);
|
||||
xu_ewmh_net_workarea(sc);
|
||||
/* x, y, width, height. */
|
||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||
workareas[i][0] = sc->gap.left;
|
||||
workareas[i][1] = sc->gap.top;
|
||||
workareas[i][2] = width - (sc->gap.left + sc->gap.right);
|
||||
workareas[i][3] = height - (sc->gap.top + sc->gap.bottom);
|
||||
}
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_WORKAREA,
|
||||
XA_CARDINAL, 32, PropModeReplace,
|
||||
(unsigned char *)workareas, CALMWM_NGROUPS * 4);
|
||||
}
|
||||
|
19
search.c
19
search.c
@ -2,7 +2,6 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
@ -15,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.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -43,10 +42,13 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
{
|
||||
struct winname *wn;
|
||||
struct menu *mi, *tierp[4], *before = NULL;
|
||||
int ntiers;
|
||||
|
||||
ntiers = sizeof(tierp) / sizeof(tierp[0]);
|
||||
|
||||
TAILQ_INIT(resultq);
|
||||
|
||||
(void)memset(tierp, 0, sizeof(tierp));
|
||||
memset(tierp, 0, sizeof(tierp));
|
||||
|
||||
/*
|
||||
* In order of rank:
|
||||
@ -90,14 +92,14 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
* window. Furthermore, this is denoted by a "!" when
|
||||
* printing the window name in the search menu.
|
||||
*/
|
||||
if (cc == client_current() && tier < nitems(tierp) - 1)
|
||||
if (cc == client_current() && tier < ntiers - 1)
|
||||
tier++;
|
||||
|
||||
/* Clients that are hidden get ranked one up. */
|
||||
if (cc->flags & CLIENT_HIDDEN && tier > 0)
|
||||
tier--;
|
||||
|
||||
assert(tier < nitems(tierp));
|
||||
assert(tier < ntiers);
|
||||
|
||||
/*
|
||||
* If you have a tierp, insert after it, and make it
|
||||
@ -134,8 +136,7 @@ search_print_client(struct menu *mi, int list)
|
||||
if (list)
|
||||
cc->matchname = cc->name;
|
||||
|
||||
(void)snprintf(mi->print, sizeof(mi->print), "%c%s", flag,
|
||||
cc->matchname);
|
||||
snprintf(mi->print, sizeof(mi->print), "%c%s", flag, cc->matchname);
|
||||
|
||||
if (!list && cc->matchname != cc->name &&
|
||||
strlen(mi->print) < sizeof(mi->print) - 1) {
|
||||
@ -155,8 +156,8 @@ search_print_client(struct menu *mi, int list)
|
||||
diff = strlen(cc->name);
|
||||
}
|
||||
|
||||
(void)strlcpy(buf, mi->print, sizeof(buf));
|
||||
(void)snprintf(mi->print, sizeof(mi->print),
|
||||
strlcpy(buf, mi->print, sizeof(buf));
|
||||
snprintf(mi->print, sizeof(mi->print),
|
||||
"%s:%.*s%s", buf, diff, cc->name, marker);
|
||||
}
|
||||
}
|
||||
|
61
strlcat.c
Normal file
61
strlcat.c
Normal file
@ -0,0 +1,61 @@
|
||||
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/string/strlcat.c */
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
||||
* full size of dst, not space left). At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
||||
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
|
||||
* If retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcat(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = siz;
|
||||
size_t dlen;
|
||||
|
||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||
while (n-- != 0 && *d != '\0')
|
||||
d++;
|
||||
dlen = d - dst;
|
||||
n = siz - dlen;
|
||||
|
||||
if (n == 0)
|
||||
return(dlen + strlen(s));
|
||||
while (*s != '\0') {
|
||||
if (n != 1) {
|
||||
*d++ = *s;
|
||||
n--;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return(dlen + (s - src)); /* count does not include NUL */
|
||||
}
|
||||
|
||||
#endif /* !HAVE_STRLCAT */
|
57
strlcpy.c
Normal file
57
strlcpy.c
Normal file
@ -0,0 +1,57 @@
|
||||
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size siz. At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcpy(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = siz;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
if (n == 0) {
|
||||
if (siz != 0)
|
||||
*d = '\0'; /* NUL-terminate dst */
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return(s - src - 1); /* count does not include NUL */
|
||||
}
|
||||
|
||||
#endif /* !HAVE_STRLCPY */
|
70
strtonum.c
Normal file
70
strtonum.c
Normal file
@ -0,0 +1,70 @@
|
||||
/* $OpenBSD: strtonum.c,v 1.6 2004/08/03 19:38:01 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Ted Unangst and Todd Miller
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/stdlib/strtonum.c */
|
||||
|
||||
#ifndef HAVE_STRTONUM
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define INVALID 1
|
||||
#define TOOSMALL 2
|
||||
#define TOOLARGE 3
|
||||
|
||||
long long
|
||||
strtonum(const char *numstr, long long minval, long long maxval,
|
||||
const char **errstrp)
|
||||
{
|
||||
long long ll = 0;
|
||||
char *ep;
|
||||
int error = 0;
|
||||
struct errval {
|
||||
const char *errstr;
|
||||
int err;
|
||||
} ev[4] = {
|
||||
{ NULL, 0 },
|
||||
{ "invalid", EINVAL },
|
||||
{ "too small", ERANGE },
|
||||
{ "too large", ERANGE },
|
||||
};
|
||||
|
||||
ev[0].err = errno;
|
||||
errno = 0;
|
||||
if (minval > maxval)
|
||||
error = INVALID;
|
||||
else {
|
||||
ll = strtoll(numstr, &ep, 10);
|
||||
if (numstr == ep || *ep != '\0')
|
||||
error = INVALID;
|
||||
else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
|
||||
error = TOOSMALL;
|
||||
else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)
|
||||
error = TOOLARGE;
|
||||
}
|
||||
if (errstrp != NULL)
|
||||
*errstrp = ev[error].errstr;
|
||||
errno = ev[error].err;
|
||||
if (error)
|
||||
ll = 0;
|
||||
|
||||
return (ll);
|
||||
}
|
||||
|
||||
#endif /* HAVE_STRTONUM */
|
11
util.c
11
util.c
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#define MAXARGLEN 20
|
||||
|
||||
void
|
||||
int
|
||||
u_spawn(char *argstr)
|
||||
{
|
||||
switch (fork()) {
|
||||
@ -42,9 +42,12 @@ u_spawn(char *argstr)
|
||||
break;
|
||||
case -1:
|
||||
warn("fork");
|
||||
return (-1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -76,6 +79,6 @@ u_exec(char *argstr)
|
||||
}
|
||||
|
||||
*ap = NULL;
|
||||
(void)setsid();
|
||||
(void)execvp(args[0], args);
|
||||
setsid();
|
||||
execvp(args[0], args);
|
||||
}
|
||||
|
90
xevents.c
90
xevents.c
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -70,15 +71,13 @@ void (*xev_handlers[LASTEvent])(XEvent *) = {
|
||||
[MappingNotify] = xev_handle_mappingnotify,
|
||||
};
|
||||
|
||||
static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R,
|
||||
XK_Control_L, XK_Control_R };
|
||||
|
||||
static void
|
||||
xev_handle_maprequest(XEvent *ee)
|
||||
{
|
||||
XMapRequestEvent *e = &ee->xmaprequest;
|
||||
struct client_ctx *cc = NULL, *old_cc;
|
||||
XWindowAttributes xattr;
|
||||
struct winmatch *wm;
|
||||
|
||||
if ((old_cc = client_current()) != NULL)
|
||||
client_ptrsave(old_cc);
|
||||
@ -88,7 +87,11 @@ xev_handle_maprequest(XEvent *ee)
|
||||
cc = client_new(e->window, screen_fromroot(xattr.root), 1);
|
||||
}
|
||||
|
||||
if ((cc->flags & CLIENT_IGNORE) == 0)
|
||||
TAILQ_FOREACH(wm, &Conf.ignoreq, entry) {
|
||||
if (strncasecmp(wm->title, cc->name, strlen(wm->title)) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
||||
@ -141,9 +144,9 @@ xev_handle_configurerequest(XEvent *ee)
|
||||
sc = cc->sc;
|
||||
|
||||
if (e->value_mask & CWWidth)
|
||||
cc->geom.w = e->width;
|
||||
cc->geom.width = e->width;
|
||||
if (e->value_mask & CWHeight)
|
||||
cc->geom.h = e->height;
|
||||
cc->geom.height = e->height;
|
||||
if (e->value_mask & CWX)
|
||||
cc->geom.x = e->x;
|
||||
if (e->value_mask & CWY)
|
||||
@ -151,20 +154,20 @@ xev_handle_configurerequest(XEvent *ee)
|
||||
if (e->value_mask & CWBorderWidth)
|
||||
wc.border_width = e->border_width;
|
||||
|
||||
if (cc->geom.x == 0 && cc->geom.w >= sc->view.w)
|
||||
if (cc->geom.x == 0 && cc->geom.width >= sc->xmax)
|
||||
cc->geom.x -= cc->bwidth;
|
||||
|
||||
if (cc->geom.y == 0 && cc->geom.h >= sc->view.h)
|
||||
if (cc->geom.y == 0 && cc->geom.height >= sc->ymax)
|
||||
cc->geom.y -= cc->bwidth;
|
||||
|
||||
wc.x = cc->geom.x;
|
||||
wc.y = cc->geom.y;
|
||||
wc.width = cc->geom.w;
|
||||
wc.height = cc->geom.h;
|
||||
wc.width = cc->geom.width;
|
||||
wc.height = cc->geom.height;
|
||||
wc.border_width = cc->bwidth;
|
||||
|
||||
XConfigureWindow(X_Dpy, cc->win, e->value_mask, &wc);
|
||||
xu_configure(cc);
|
||||
xev_reconfig(cc);
|
||||
} else {
|
||||
/* let it do what it wants, it'll be ours when we map it. */
|
||||
wc.x = e->x;
|
||||
@ -194,9 +197,6 @@ xev_handle_propertynotify(XEvent *ee)
|
||||
case XA_WM_NAME:
|
||||
client_setname(cc);
|
||||
break;
|
||||
case XA_WM_TRANSIENT_FOR:
|
||||
client_transient(cc);
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
@ -206,10 +206,31 @@ xev_handle_propertynotify(XEvent *ee)
|
||||
if (sc->rootwin == e->window)
|
||||
goto test;
|
||||
return;
|
||||
|
||||
test:
|
||||
if (e->atom == ewmh[_NET_DESKTOP_NAMES].atom)
|
||||
if (e->atom == _NET_DESKTOP_NAMES)
|
||||
group_update_names(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
xev_reconfig(struct client_ctx *cc)
|
||||
{
|
||||
XConfigureEvent ce;
|
||||
|
||||
ce.type = ConfigureNotify;
|
||||
ce.event = cc->win;
|
||||
ce.window = cc->win;
|
||||
ce.x = cc->geom.x;
|
||||
ce.y = cc->geom.y;
|
||||
ce.width = cc->geom.width;
|
||||
ce.height = cc->geom.height;
|
||||
ce.border_width = cc->bwidth;
|
||||
ce.above = None;
|
||||
ce.override_redirect = 0;
|
||||
|
||||
XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -279,8 +300,8 @@ xev_handle_keypress(XEvent *ee)
|
||||
KeySym keysym, skeysym;
|
||||
int modshift;
|
||||
|
||||
keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
|
||||
skeysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 1);
|
||||
keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
|
||||
skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1);
|
||||
|
||||
/* we don't care about caps lock and numlock here */
|
||||
e->state &= ~(LockMask | Mod2Mask);
|
||||
@ -315,7 +336,7 @@ xev_handle_keypress(XEvent *ee)
|
||||
}
|
||||
|
||||
/*
|
||||
* This is only used for the modifier suppression detection.
|
||||
* This is only used for the alt suppression detection.
|
||||
*/
|
||||
static void
|
||||
xev_handle_keyrelease(XEvent *ee)
|
||||
@ -323,17 +344,26 @@ xev_handle_keyrelease(XEvent *ee)
|
||||
XKeyEvent *e = &ee->xkey;
|
||||
struct screen_ctx *sc;
|
||||
struct client_ctx *cc;
|
||||
int i, keysym;
|
||||
int keysym;
|
||||
|
||||
sc = screen_fromroot(e->root);
|
||||
cc = client_current();
|
||||
|
||||
keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
|
||||
for (i = 0; i < nitems(modkeys); i++) {
|
||||
if (keysym == modkeys[i]) {
|
||||
client_cycle_leave(sc, cc);
|
||||
break;
|
||||
}
|
||||
keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
|
||||
if (keysym != XK_Alt_L && keysym != XK_Alt_R)
|
||||
return;
|
||||
|
||||
sc->altpersist = 0;
|
||||
|
||||
/*
|
||||
* XXX - better interface... xevents should not know about
|
||||
* how/when to mtf.
|
||||
*/
|
||||
client_mtf(NULL);
|
||||
|
||||
if (cc != NULL) {
|
||||
group_sticky_toggle_exit(cc);
|
||||
XUngrabKeyboard(X_Dpy, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +395,8 @@ xev_handle_randr(XEvent *ee)
|
||||
TAILQ_FOREACH(sc, &Screenq, entry) {
|
||||
if (sc->which == (u_int)i) {
|
||||
XRRUpdateConfiguration(ee);
|
||||
screen_update_geometry(sc);
|
||||
screen_update_geometry(sc, rev->width, rev->height);
|
||||
screen_init_xinerama(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -399,14 +430,15 @@ xev_handle_expose(XEvent *ee)
|
||||
client_draw_border(cc);
|
||||
}
|
||||
|
||||
volatile sig_atomic_t xev_quit = 0;
|
||||
|
||||
volatile sig_atomic_t _xev_quit = 0;
|
||||
|
||||
void
|
||||
xev_loop(void)
|
||||
{
|
||||
XEvent e;
|
||||
|
||||
while (xev_quit == 0) {
|
||||
while (_xev_quit == 0) {
|
||||
XNextEvent(X_Dpy, &e);
|
||||
if (e.type - Randr_ev == RRScreenChangeNotify)
|
||||
xev_handle_randr(&e);
|
||||
|
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
267
xutil.c
267
xutil.c
@ -15,7 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $OpenBSD$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -57,9 +57,9 @@ void
|
||||
xu_btn_grab(Window win, int mask, u_int btn)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nitems(ign_mods); i++)
|
||||
for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++)
|
||||
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
|
||||
False, BUTTONMASK, GrabModeAsync,
|
||||
False, ButtonMask, GrabModeAsync,
|
||||
GrabModeSync, None, None);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ void
|
||||
xu_btn_ungrab(Window win, int mask, u_int btn)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nitems(ign_mods); i++)
|
||||
for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++)
|
||||
XUngrabButton(X_Dpy, btn, (mask | ign_mods[i]), win);
|
||||
}
|
||||
|
||||
@ -94,11 +94,11 @@ xu_key_grab(Window win, int mask, int keysym)
|
||||
int i;
|
||||
|
||||
code = XKeysymToKeycode(X_Dpy, keysym);
|
||||
if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
|
||||
(XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
|
||||
if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) &&
|
||||
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym))
|
||||
mask |= ShiftMask;
|
||||
|
||||
for (i = 0; i < nitems(ign_mods); i++)
|
||||
for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++)
|
||||
XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
|
||||
True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
@ -110,39 +110,20 @@ xu_key_ungrab(Window win, int mask, int keysym)
|
||||
int i;
|
||||
|
||||
code = XKeysymToKeycode(X_Dpy, keysym);
|
||||
if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
|
||||
(XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
|
||||
if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) &&
|
||||
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym))
|
||||
mask |= ShiftMask;
|
||||
|
||||
for (i = 0; i < nitems(ign_mods); i++)
|
||||
for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++)
|
||||
XUngrabKey(X_Dpy, code, (mask | ign_mods[i]), win);
|
||||
}
|
||||
|
||||
void
|
||||
xu_configure(struct client_ctx *cc)
|
||||
{
|
||||
XConfigureEvent ce;
|
||||
|
||||
ce.type = ConfigureNotify;
|
||||
ce.event = cc->win;
|
||||
ce.window = cc->win;
|
||||
ce.x = cc->geom.x;
|
||||
ce.y = cc->geom.y;
|
||||
ce.width = cc->geom.w;
|
||||
ce.height = cc->geom.h;
|
||||
ce.border_width = cc->bwidth;
|
||||
ce.above = None;
|
||||
ce.override_redirect = 0;
|
||||
|
||||
XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce);
|
||||
}
|
||||
|
||||
void
|
||||
xu_sendmsg(Window win, Atom atm, long val)
|
||||
{
|
||||
XEvent e;
|
||||
|
||||
(void)memset(&e, 0, sizeof(e));
|
||||
memset(&e, 0, sizeof(e));
|
||||
e.xclient.type = ClientMessage;
|
||||
e.xclient.window = win;
|
||||
e.xclient.message_type = atm;
|
||||
@ -207,8 +188,7 @@ xu_getstate(struct client_ctx *cc, int *state)
|
||||
{
|
||||
long *p = NULL;
|
||||
|
||||
if (xu_getprop(cc->win, cwmh[WM_STATE].atom, cwmh[WM_STATE].atom, 2L,
|
||||
(u_char **)&p) <= 0)
|
||||
if (xu_getprop(cc->win, WM_STATE, WM_STATE, 2L, (u_char **)&p) <= 0)
|
||||
return (-1);
|
||||
|
||||
*state = (int)*p;
|
||||
@ -226,194 +206,63 @@ xu_setstate(struct client_ctx *cc, int state)
|
||||
dat[1] = None;
|
||||
|
||||
cc->state = state;
|
||||
XChangeProperty(X_Dpy, cc->win,
|
||||
cwmh[WM_STATE].atom, cwmh[WM_STATE].atom, 32,
|
||||
XChangeProperty(X_Dpy, cc->win, WM_STATE, WM_STATE, 32,
|
||||
PropModeReplace, (unsigned char *)dat, 2);
|
||||
}
|
||||
|
||||
struct atom_ctx cwmh[CWMH_NITEMS] = {
|
||||
{"WM_STATE", None},
|
||||
{"WM_DELETE_WINDOW", None},
|
||||
{"WM_TAKE_FOCUS", None},
|
||||
{"WM_PROTOCOLS", None},
|
||||
{"_MOTIF_WM_HINTS", None},
|
||||
{"UTF8_STRING", None},
|
||||
};
|
||||
struct atom_ctx ewmh[EWMH_NITEMS] = {
|
||||
{"_NET_SUPPORTED", None},
|
||||
{"_NET_SUPPORTING_WM_CHECK", None},
|
||||
{"_NET_ACTIVE_WINDOW", None},
|
||||
{"_NET_CLIENT_LIST", None},
|
||||
{"_NET_NUMBER_OF_DESKTOPS", None},
|
||||
{"_NET_CURRENT_DESKTOP", None},
|
||||
{"_NET_DESKTOP_VIEWPORT", None},
|
||||
{"_NET_DESKTOP_GEOMETRY", None},
|
||||
{"_NET_VIRTUAL_ROOTS", None},
|
||||
{"_NET_SHOWING_DESKTOP", None},
|
||||
{"_NET_DESKTOP_NAMES", None},
|
||||
{"_NET_WORKAREA", None},
|
||||
{"_NET_WM_NAME", None},
|
||||
{"_NET_WM_DESKTOP", None},
|
||||
Atom cwm_atoms[CWM_NO_ATOMS];
|
||||
char *atoms[CWM_NO_ATOMS] = {
|
||||
"WM_STATE",
|
||||
"WM_DELETE_WINDOW",
|
||||
"WM_TAKE_FOCUS",
|
||||
"WM_PROTOCOLS",
|
||||
"_MOTIF_WM_HINTS",
|
||||
"UTF8_STRING",
|
||||
"_NET_SUPPORTED",
|
||||
"_NET_SUPPORTING_WM_CHECK",
|
||||
"_NET_WM_NAME",
|
||||
"_NET_ACTIVE_WINDOW",
|
||||
"_NET_CLIENT_LIST",
|
||||
"_NET_NUMBER_OF_DESKTOPS",
|
||||
"_NET_CURRENT_DESKTOP",
|
||||
"_NET_DESKTOP_VIEWPORT",
|
||||
"_NET_DESKTOP_GEOMETRY",
|
||||
"_NET_VIRTUAL_ROOTS",
|
||||
"_NET_SHOWING_DESKTOP",
|
||||
"_NET_DESKTOP_NAMES",
|
||||
"_NET_WM_DESKTOP",
|
||||
"_NET_WORKAREA",
|
||||
};
|
||||
|
||||
void
|
||||
xu_getatoms(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nitems(cwmh); i++)
|
||||
cwmh[i].atom = XInternAtom(X_Dpy, cwmh[i].name, False);
|
||||
for (i = 0; i < nitems(ewmh); i++)
|
||||
ewmh[i].atom = XInternAtom(X_Dpy, ewmh[i].name, False);
|
||||
}
|
||||
|
||||
/* Root Window Properties */
|
||||
void
|
||||
xu_ewmh_net_supported(struct screen_ctx *sc)
|
||||
{
|
||||
Atom atom[EWMH_NITEMS];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nitems(ewmh); i++)
|
||||
atom[i] = ewmh[i].atom;
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SUPPORTED].atom,
|
||||
XA_ATOM, 32, PropModeReplace, (unsigned char *)atom, EWMH_NITEMS);
|
||||
XInternAtoms(X_Dpy, atoms, CWM_NO_ATOMS, False, cwm_atoms);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_supported_wm_check(struct screen_ctx *sc)
|
||||
xu_setwmname(struct screen_ctx *sc)
|
||||
{
|
||||
Window w;
|
||||
|
||||
w = XCreateSimpleWindow(X_Dpy, sc->rootwin, -1, -1, 1, 1, 0, 0, 0);
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SUPPORTING_WM_CHECK].atom,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
||||
XChangeProperty(X_Dpy, w, ewmh[_NET_SUPPORTING_WM_CHECK].atom,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
||||
XChangeProperty(X_Dpy, w, ewmh[_NET_WM_NAME].atom,
|
||||
XA_WM_NAME, 8, PropModeReplace, WMNAME, strlen(WMNAME));
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_desktop_geometry(struct screen_ctx *sc)
|
||||
{
|
||||
long geom[2] = { sc->view.w, sc->view.h };
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_GEOMETRY].atom,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)geom , 2);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_workarea(struct screen_ctx *sc)
|
||||
{
|
||||
long workareas[CALMWM_NGROUPS][4];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||
workareas[i][0] = sc->work.x;
|
||||
workareas[i][1] = sc->work.y;
|
||||
workareas[i][2] = sc->work.w;
|
||||
workareas[i][3] = sc->work.h;
|
||||
}
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_WORKAREA].atom,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)workareas,
|
||||
CALMWM_NGROUPS * 4);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_client_list(struct screen_ctx *sc)
|
||||
{
|
||||
struct client_ctx *cc;
|
||||
Window *winlist;
|
||||
int i = 0, j = 0;
|
||||
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
i++;
|
||||
if (i == 0)
|
||||
return;
|
||||
|
||||
winlist = xmalloc(i * sizeof(*winlist));
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
winlist[j++] = cc->win;
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST].atom,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)winlist, i);
|
||||
xfree(winlist);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_active_window(struct screen_ctx *sc, Window w)
|
||||
{
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_ACTIVE_WINDOW].atom,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_wm_desktop_viewport(struct screen_ctx *sc)
|
||||
{
|
||||
long viewports[2] = {0, 0};
|
||||
|
||||
/* We don't support large desktops, so this is (0, 0). */
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_VIEWPORT].atom,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)viewports, 2);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_wm_number_of_desktops(struct screen_ctx *sc)
|
||||
{
|
||||
long ndesks = CALMWM_NGROUPS;
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_NUMBER_OF_DESKTOPS].atom,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&ndesks, 1);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_showing_desktop(struct screen_ctx *sc)
|
||||
{
|
||||
long zero = 0;
|
||||
|
||||
/* We don't support `showing desktop' mode, so this is zero.
|
||||
* Note that when we hide all groups, or when all groups are
|
||||
* hidden we could technically set this later on.
|
||||
/*
|
||||
* set up the _NET_SUPPORTED hint with all netwm atoms that we
|
||||
* know about.
|
||||
*/
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_SHOWING_DESKTOP].atom,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&zero, 1);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_virtual_roots(struct screen_ctx *sc)
|
||||
{
|
||||
/* We don't support virtual roots, so delete if set by previous wm. */
|
||||
XDeleteProperty(X_Dpy, sc->rootwin, ewmh[_NET_VIRTUAL_ROOTS].atom);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_current_desktop(struct screen_ctx *sc, long idx)
|
||||
{
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CURRENT_DESKTOP].atom,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&idx, 1);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ewmh_net_desktop_names(struct screen_ctx *sc, unsigned char *data, int n)
|
||||
{
|
||||
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_NAMES].atom,
|
||||
cwmh[UTF8_STRING].atom, 8, PropModeReplace, data, n);
|
||||
}
|
||||
|
||||
/* Application Window Properties */
|
||||
void
|
||||
xu_ewmh_net_wm_desktop(struct client_ctx *cc)
|
||||
{
|
||||
struct group_ctx *gc = cc->group;
|
||||
long no = 0xffffffff;
|
||||
|
||||
if (gc)
|
||||
no = gc->shortcut - 1;
|
||||
|
||||
XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP].atom,
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&no, 1);
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_SUPPORTED, XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *)&_NET_SUPPORTED,
|
||||
CWM_NO_ATOMS - CWM_NETWM_START);
|
||||
/*
|
||||
* netwm spec says that to prove that the hint is not stale you must
|
||||
* provide _NET_SUPPORTING_WM_CHECK containing a window (we use the
|
||||
* menu window). The property must be set on the root window and the
|
||||
* window itself, the window also must have _NET_WM_NAME set with the
|
||||
* window manager name.
|
||||
*/
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_SUPPORTING_WM_CHECK,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&sc->menuwin, 1);
|
||||
XChangeProperty(X_Dpy, sc->menuwin, _NET_SUPPORTING_WM_CHECK,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&sc->menuwin, 1);
|
||||
XChangeProperty(X_Dpy, sc->menuwin, _NET_WM_NAME, UTF8_STRING,
|
||||
8, PropModeReplace, WMNAME, strlen(WMNAME));
|
||||
}
|
||||
|
||||
unsigned long
|
||||
@ -424,10 +273,10 @@ xu_getcolor(struct screen_ctx *sc, char *name)
|
||||
if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which),
|
||||
name, &color, &tmp)) {
|
||||
warnx("XAllocNamedColor error: '%s'", name);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (color.pixel);
|
||||
return color.pixel;
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user