mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Compare commits
63 Commits
OPENBSD_4_
...
ignorewarp
Author | SHA1 | Date | |
---|---|---|---|
a119fe5240 | |||
f2e8fad75c | |||
1f310d57e2 | |||
ff3df256a1 | |||
dee6ac5b7d | |||
2d66003e4b | |||
917bce4b8d | |||
2440efad06 | |||
aaca5b7e45 | |||
2a5e1791d4 | |||
e0c9657773 | |||
85a53083cb | |||
72e6d2d0a9 | |||
f769df540d | |||
a292c96977 | |||
b12e6fc5cd | |||
46c9b5cbae | |||
d90ab51111 | |||
50aff37f50 | |||
507480a695 | |||
c4a97053cd | |||
e88bda0df5 | |||
ccb207a8a8 | |||
09a2d7fb98 | |||
b27c3c22b5 | |||
2ad2b5f31d | |||
597cb25820 | |||
b6b7d273d4 | |||
49661d405b | |||
3b87bdb047 | |||
28e94b2fbc | |||
a0ec2515e9 | |||
b35cbf81d8 | |||
9b04930f24 | |||
a7c3a7cac3 | |||
134e777cf0 | |||
ee7df6a95f | |||
aa88d5848e | |||
728d2a40dd | |||
3c60d854db | |||
3e309894c1 | |||
46630531f8 | |||
ab4d36531c | |||
892e1e1c0d | |||
4e2014863b | |||
42bf29fb20 | |||
afaf69cefc | |||
85d8697676 | |||
4af6a60d84 | |||
38ad2e1d9c | |||
7295c51155 | |||
b9f8367089 | |||
0a44f2e5c4 | |||
1968561fcc | |||
95f65b8be6 | |||
8fd4ff1c7c | |||
fcb2684db1 | |||
e2b1cb98c1 | |||
028a1778db | |||
09d88f4a18 | |||
e7f0d63413 | |||
82911249e2 | |||
e095e955a8 |
38
Makefile
38
Makefile
@ -1,14 +1,23 @@
|
||||
# $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 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
|
||||
|
||||
@ -20,7 +29,26 @@ MAN= cwm.1 cwmrc.5
|
||||
|
||||
CLEANFILES= cwm.cat1 cwmrc.cat5
|
||||
|
||||
obj: _xenocara_obj
|
||||
|
||||
.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>
|
||||
|
58
README
58
README
@ -1,58 +0,0 @@
|
||||
--------------------------------------------------------------------------------
|
||||
cwm release three
|
||||
--------------------------------------------------------------------------------
|
||||
by Marius Aamodt Eriksen <marius@monkey.org>
|
||||
contributions by Andy Adamson <dros@monkey.org>,
|
||||
Niels Provos <provos@monkey.org>,
|
||||
Martin Murray <mmurray@monkey.org>,
|
||||
Dimitris Economou <dimeco@stanford.edu> &
|
||||
Antti Nyk<79>nen <aon@iki.fi>.
|
||||
|
||||
http://monkey.org/~marius/cwm
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
cwm is a window manager initially inspired by evilwm[1]. It
|
||||
developed out of modifications to evilwm, but eventually the code
|
||||
base of evilwm did not accomodate well for the new features added.
|
||||
So calmwm was written from scratch.
|
||||
|
||||
Its main goal is to be as efficient as possible, while providing
|
||||
a very clean, simple & attractive aesthetic.
|
||||
|
||||
cwm has several novel features, including the ability to search
|
||||
for windows.
|
||||
|
||||
HIGHLIGHTS IN RELEASE TWO
|
||||
|
||||
* Improved alt-tabbing, including the ability to reverse cycle.
|
||||
* Display of a context menu when alt-tabbing, showing the previous,
|
||||
current and next window in the cycle order.
|
||||
* Much improved ranking in search.
|
||||
* In search-menus, the ability to list every item.
|
||||
|
||||
HIGHLIGHTS IN RELEASE THREE
|
||||
|
||||
* More search ranking improvements
|
||||
* Many contributions by Antti Nyk<79>nen: keyboard binding "i18n",
|
||||
show window labels in minimized window menu, automatic window
|
||||
grouping, MWM hints support & some bug fixes.
|
||||
* Xft support & the addition of the -f flag (see manpage).
|
||||
|
||||
INSTALL
|
||||
|
||||
./configure
|
||||
make
|
||||
su
|
||||
make install
|
||||
|
||||
DOCUMENTATION
|
||||
|
||||
See the manpage cwm(1).
|
||||
|
||||
LICENSE
|
||||
|
||||
cwm is distributed under a BSD like license. Please see the LICENSE
|
||||
file or the top of any source file for more information.
|
||||
|
||||
[1] http://evilwm.sourceforge.net/
|
26
TODO
26
TODO
@ -1,26 +0,0 @@
|
||||
- window initial position
|
||||
|
||||
- don't map windows if it's within [some time increment] of active typing,
|
||||
this is part of the "calm" goal. also, it helps if you're mindlessly
|
||||
typing in a password and the keyboard input ends up in some other window,
|
||||
bad...
|
||||
|
||||
- integrate everything into /ONE/ event loop.
|
||||
register handlers, with the ability to select, for example,
|
||||
a window, or an event, etc. (no, maybe not...)
|
||||
|
||||
- ignoreq, always lower them. perhaps implement by lowering the entire
|
||||
queue on each XLower...
|
||||
|
||||
- search window should try to stay inside of the screen boundaries.
|
||||
|
||||
- geographical keyboard navigation (window switching)
|
||||
|
||||
- make kbd shortcuts/events more general. the ability to associate an
|
||||
event with a mode (i.e. prioritize). gets rid of hacky-ness in
|
||||
groups, etc.
|
||||
|
||||
- figure out what's up when alt-tab goes back to the current window
|
||||
once before moving on.
|
||||
|
||||
- cache all the atoms somewhere.
|
54
calmwm.c
54
calmwm.c
@ -18,7 +18,19 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
Display *X_Dpy;
|
||||
@ -29,10 +41,8 @@ Cursor Cursor_select;
|
||||
Cursor Cursor_default;
|
||||
Cursor Cursor_question;
|
||||
|
||||
struct screen_ctx_q Screenq;
|
||||
struct screen_ctx *Curscreen;
|
||||
|
||||
struct client_ctx_q Clientq;
|
||||
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
|
||||
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
|
||||
|
||||
int HasXinerama, HasRandr, Randr_ev;
|
||||
int Starting;
|
||||
@ -73,10 +83,6 @@ main(int argc, char **argv)
|
||||
Starting = 1;
|
||||
dpy_init(display_name);
|
||||
|
||||
screen_init();
|
||||
group_init();
|
||||
client_init();
|
||||
|
||||
bzero(&Conf, sizeof(Conf));
|
||||
conf_setup(&Conf, conf_file);
|
||||
xu_getatoms();
|
||||
@ -150,24 +156,32 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
XSetWindowAttributes rootattr;
|
||||
int fake;
|
||||
u_int nwins, i;
|
||||
|
||||
Curscreen = sc;
|
||||
|
||||
sc->which = which;
|
||||
sc->rootwin = RootWindow(X_Dpy, sc->which);
|
||||
sc->xmax = DisplayWidth(X_Dpy, sc->which);
|
||||
sc->ymax = DisplayHeight(X_Dpy, sc->which);
|
||||
|
||||
conf_color(&Conf);
|
||||
conf_gap(&Conf, 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);
|
||||
conf_font(&Conf, sc);
|
||||
|
||||
TAILQ_INIT(&sc->mruq);
|
||||
|
||||
/* Initialize menu window. */
|
||||
menu_init(sc);
|
||||
|
||||
xu_setwmname(sc);
|
||||
|
||||
rootattr.event_mask = ChildMask|PropertyChangeMask|EnterWindowMask|
|
||||
LeaveWindowMask|ColormapChangeMask|ButtonMask;
|
||||
|
||||
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
||||
CWEventMask, &rootattr);
|
||||
|
||||
/* Deal with existing clients. */
|
||||
XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins);
|
||||
|
||||
@ -180,13 +194,7 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
}
|
||||
XFree(wins);
|
||||
|
||||
screen_updatestackingorder();
|
||||
|
||||
rootattr.event_mask = ChildMask|PropertyChangeMask|EnterWindowMask|
|
||||
LeaveWindowMask|ColormapChangeMask|ButtonMask;
|
||||
|
||||
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
||||
CWEventMask, &rootattr);
|
||||
screen_updatestackingorder(sc);
|
||||
|
||||
if (XineramaQueryExtension(X_Dpy, &fake, &fake) == 1 &&
|
||||
((HasXinerama = XineramaIsActive(X_Dpy)) == 1))
|
||||
|
181
calmwm.h
181
calmwm.h
@ -21,6 +21,20 @@
|
||||
#ifndef _CALMWM_H_
|
||||
#define _CALMWM_H_
|
||||
|
||||
/* ugly stuff */
|
||||
#define TAILQ_END(head) NULL
|
||||
#define __dead
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#define CALMWM_MAXNAMELEN 256
|
||||
|
||||
#undef MIN
|
||||
@ -29,6 +43,7 @@
|
||||
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
|
||||
#define CONFFILE ".cwmrc"
|
||||
#define WMNAME "CWM"
|
||||
|
||||
#define ChildMask (SubstructureRedirectMask|SubstructureNotifyMask)
|
||||
#define ButtonMask (ButtonPressMask|ButtonReleaseMask)
|
||||
@ -54,33 +69,60 @@ struct color {
|
||||
unsigned long pixel;
|
||||
char *name;
|
||||
};
|
||||
struct gap {
|
||||
int top;
|
||||
int bottom;
|
||||
int left;
|
||||
int right;
|
||||
};
|
||||
|
||||
struct client_ctx;
|
||||
|
||||
TAILQ_HEAD(cycle_entry_q, client_ctx);
|
||||
TAILQ_HEAD(group_ctx_q, group_ctx);
|
||||
TAILQ_HEAD(client_ctx_q, client_ctx);
|
||||
|
||||
#define CALMWM_NGROUPS 9
|
||||
struct group_ctx {
|
||||
TAILQ_ENTRY(group_ctx) entry;
|
||||
struct client_ctx_q clients;
|
||||
int shortcut;
|
||||
int hidden;
|
||||
int nhidden;
|
||||
int highstack;
|
||||
};
|
||||
|
||||
struct screen_ctx {
|
||||
TAILQ_ENTRY(screen_ctx) entry;
|
||||
TAILQ_ENTRY(screen_ctx) entry;
|
||||
|
||||
u_int which;
|
||||
Window rootwin;
|
||||
Window menuwin;
|
||||
u_int which;
|
||||
Window rootwin;
|
||||
Window menuwin;
|
||||
|
||||
struct color color[CWM_COLOR_MAX];
|
||||
GC gc;
|
||||
struct color color[CWM_COLOR_MAX];
|
||||
GC gc;
|
||||
|
||||
int altpersist;
|
||||
int altpersist;
|
||||
|
||||
int xmax;
|
||||
int ymax;
|
||||
int xmax;
|
||||
int ymax;
|
||||
|
||||
struct cycle_entry_q mruq;
|
||||
struct gap gap;
|
||||
struct cycle_entry_q mruq;
|
||||
|
||||
XftDraw *xftdraw;
|
||||
XftColor xftcolor;
|
||||
XftDraw *xftdraw;
|
||||
XftColor xftcolor;
|
||||
XftFont *font;
|
||||
u_int fontheight;
|
||||
|
||||
int xinerama_no;
|
||||
XineramaScreenInfo *xinerama;
|
||||
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);
|
||||
@ -96,6 +138,8 @@ TAILQ_HEAD(screen_ctx_q, screen_ctx);
|
||||
#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
|
||||
@ -121,8 +165,9 @@ struct client_ctx {
|
||||
|
||||
u_int bwidth;
|
||||
struct {
|
||||
int x, y, width, height;
|
||||
int min_dx, min_dy;
|
||||
int x, y, width, height, basew, baseh,
|
||||
minw, minh, maxw, maxh, incw, inch;
|
||||
float mina, maxa;
|
||||
} geom, savegeom;
|
||||
|
||||
struct {
|
||||
@ -151,29 +196,14 @@ struct client_ctx {
|
||||
char *app_cliarg;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(client_ctx_q, client_ctx);
|
||||
|
||||
extern const char *shortcut_to_name[];
|
||||
|
||||
struct group_ctx {
|
||||
TAILQ_ENTRY(group_ctx) entry;
|
||||
struct client_ctx_q clients;
|
||||
const char *name;
|
||||
int shortcut;
|
||||
int hidden;
|
||||
int nhidden;
|
||||
int highstack;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(group_ctx_q, group_ctx);
|
||||
|
||||
/* Autogroups */
|
||||
struct autogroupwin {
|
||||
TAILQ_ENTRY(autogroupwin) entry;
|
||||
|
||||
char *class;
|
||||
char *name;
|
||||
char *group;
|
||||
TAILQ_ENTRY(autogroupwin) entry;
|
||||
char *class;
|
||||
char *name;
|
||||
int num;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(autogroupwin_q, autogroupwin);
|
||||
@ -265,6 +295,7 @@ struct conf {
|
||||
int bwidth;
|
||||
#define CONF_MAMOUNT 1
|
||||
int mamount;
|
||||
struct gap gap;
|
||||
|
||||
#define CONF_COLOR_ACTIVEBORDER "#CCCCCC"
|
||||
#define CONF_COLOR_INACTIVEBORDER "#666666"
|
||||
@ -279,9 +310,6 @@ struct conf {
|
||||
|
||||
#define DEFAULTFONTNAME "sans-serif:pixelsize=14:bold"
|
||||
char *DefaultFontName;
|
||||
XftFont *DefaultFont;
|
||||
u_int FontHeight;
|
||||
int gap_top, gap_bottom, gap_left, gap_right;
|
||||
};
|
||||
|
||||
/* Menu stuff */
|
||||
@ -296,6 +324,7 @@ struct menu {
|
||||
char print[MENU_MAXENTRY + 1];
|
||||
void *ctx;
|
||||
short dummy;
|
||||
short abort;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(menu_q, menu);
|
||||
@ -327,7 +356,6 @@ int input_keycodetrans(KeyCode, u_int, enum ctltype *,
|
||||
__dead void usage(void);
|
||||
|
||||
struct client_ctx *client_find(Window);
|
||||
void client_init(void);
|
||||
struct client_ctx *client_new(Window, struct screen_ctx *, int);
|
||||
int client_delete(struct client_ctx *);
|
||||
void client_setactive(struct client_ctx *, int);
|
||||
@ -347,11 +375,15 @@ 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(int);
|
||||
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 menu_q *, char *, char *, int,
|
||||
struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
||||
char *, char *, int,
|
||||
void (*)(struct menu_q *, struct menu_q *, char *),
|
||||
void (*)(struct menu *, int));
|
||||
void menu_init(struct screen_ctx *);
|
||||
@ -371,14 +403,14 @@ 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_sendmsg(struct client_ctx *, Atom, long);
|
||||
int xu_getprop(struct client_ctx *, Atom, Atom, long,
|
||||
u_char **);
|
||||
char *xu_getstrprop(struct client_ctx *, Atom atm);
|
||||
void xu_sendmsg(Window, Atom, long);
|
||||
int xu_getprop(Window, Atom, Atom, long, u_char **);
|
||||
int xu_getstrprop(Window, Atom, char **);
|
||||
void xu_setstate(struct client_ctx *, int);
|
||||
int xu_getstate(struct client_ctx *, int *);
|
||||
unsigned long xu_getcolor(struct screen_ctx *, char *);
|
||||
void xu_freecolor(struct screen_ctx *, unsigned long);
|
||||
void xu_setwmname(struct screen_ctx *);
|
||||
|
||||
int u_spawn(char *);
|
||||
void u_exec(char *);
|
||||
@ -388,10 +420,9 @@ void *xmalloc(size_t);
|
||||
void *xcalloc(size_t, size_t);
|
||||
char *xstrdup(const char *);
|
||||
|
||||
void screen_init(void);
|
||||
struct screen_ctx *screen_fromroot(Window);
|
||||
struct screen_ctx *screen_current(void);
|
||||
void screen_updatestackingorder(void);
|
||||
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);
|
||||
|
||||
@ -403,8 +434,9 @@ 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_font(struct conf *);
|
||||
void conf_color(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);
|
||||
@ -435,6 +467,8 @@ 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 *);
|
||||
@ -462,31 +496,30 @@ void search_match_text(struct menu_q *, struct menu_q *,
|
||||
void search_match_exec(struct menu_q *, struct menu_q *,
|
||||
char *);
|
||||
|
||||
void group_init(void);
|
||||
void group_hidetoggle(int);
|
||||
void group_only(int);
|
||||
void group_cycle(int);
|
||||
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(void);
|
||||
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(const char *, int);
|
||||
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 *);
|
||||
|
||||
#define font_ascent() Conf.DefaultFont->ascent
|
||||
#define font_descent() Conf.DefaultFont->descent
|
||||
#define font_height() Conf.FontHeight
|
||||
|
||||
#define CCTOSC(cc) (cc->sc)
|
||||
|
||||
/* Externs */
|
||||
|
||||
extern Display *X_Dpy;
|
||||
@ -510,8 +543,28 @@ extern struct conf Conf;
|
||||
#define WM_TAKE_FOCUS cwm_atoms[2]
|
||||
#define WM_PROTOCOLS cwm_atoms[3]
|
||||
#define _MOTIF_WM_HINTS cwm_atoms[4]
|
||||
#define _CWM_GRP cwm_atoms[5]
|
||||
#define CWM_NO_ATOMS 6
|
||||
#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];
|
||||
|
||||
|
289
client.c
289
client.c
@ -18,11 +18,22 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
static struct client_ctx *client_mrunext(struct client_ctx *);
|
||||
static struct client_ctx *client_mruprev(struct client_ctx *);
|
||||
static void client_none(struct screen_ctx *);
|
||||
static void client_placecalc(struct client_ctx *);
|
||||
static void client_update(struct client_ctx *);
|
||||
static void client_gethints(struct client_ctx *);
|
||||
@ -32,12 +43,6 @@ static int client_inbound(struct client_ctx *, int, int);
|
||||
static char emptystring[] = "";
|
||||
struct client_ctx *_curcc = NULL;
|
||||
|
||||
void
|
||||
client_init(void)
|
||||
{
|
||||
TAILQ_INIT(&Clientq);
|
||||
}
|
||||
|
||||
struct client_ctx *
|
||||
client_find(Window win)
|
||||
{
|
||||
@ -56,7 +61,6 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
struct client_ctx *cc;
|
||||
XWindowAttributes wattr;
|
||||
XWMHints *wmhints;
|
||||
long tmp;
|
||||
int state;
|
||||
|
||||
if (win == None)
|
||||
@ -71,14 +75,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
cc->win = win;
|
||||
cc->size = XAllocSizeHints();
|
||||
|
||||
XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp);
|
||||
if (cc->size->flags & PBaseSize) {
|
||||
cc->geom.min_dx = cc->size->base_width;
|
||||
cc->geom.min_dy = cc->size->base_height;
|
||||
} else if (cc->size->flags & PMinSize) {
|
||||
cc->geom.min_dx = cc->size->min_width;
|
||||
cc->geom.min_dy = cc->size->min_height;
|
||||
}
|
||||
client_getsizehints(cc);
|
||||
|
||||
TAILQ_INIT(&cc->nameq);
|
||||
client_setname(cc);
|
||||
@ -127,6 +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);
|
||||
/* 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);
|
||||
@ -140,8 +140,11 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
int
|
||||
client_delete(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct client_ctx *tcc;
|
||||
struct winname *wn;
|
||||
Window *winlist;
|
||||
int i, j;
|
||||
|
||||
group_client_delete(cc);
|
||||
|
||||
@ -154,16 +157,33 @@ client_delete(struct client_ctx *cc)
|
||||
|
||||
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
|
||||
TAILQ_REMOVE(&Clientq, cc, entry);
|
||||
/*
|
||||
* 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)
|
||||
_curcc = NULL;
|
||||
client_none(sc);
|
||||
|
||||
XFree(cc->size);
|
||||
|
||||
while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) {
|
||||
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
||||
if (wn->name != emptystring)
|
||||
XFree(wn->name);
|
||||
xfree(wn->name);
|
||||
xfree(wn);
|
||||
}
|
||||
|
||||
@ -183,7 +203,7 @@ client_leave(struct client_ctx *cc)
|
||||
if (cc == NULL)
|
||||
return;
|
||||
|
||||
sc = CCTOSC(cc);
|
||||
sc = cc->sc;
|
||||
xu_btn_ungrab(sc->rootwin, AnyModifier, Button1);
|
||||
}
|
||||
|
||||
@ -197,7 +217,7 @@ client_setactive(struct client_ctx *cc, int fg)
|
||||
if (cc == NULL)
|
||||
return;
|
||||
|
||||
sc = CCTOSC(cc);
|
||||
sc = cc->sc;
|
||||
|
||||
if (fg) {
|
||||
XInstallColormap(X_Dpy, cc->cmap);
|
||||
@ -216,12 +236,28 @@ client_setactive(struct client_ctx *cc, int fg)
|
||||
if (fg && _curcc != cc) {
|
||||
client_setactive(NULL, 0);
|
||||
_curcc = cc;
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_ACTIVE_WINDOW,
|
||||
XA_WINDOW, 32, PropModeReplace,
|
||||
(unsigned char *)&cc->win, 1);
|
||||
}
|
||||
|
||||
cc->active = fg;
|
||||
client_draw_border(cc);
|
||||
}
|
||||
|
||||
/*
|
||||
* set when there is no active client
|
||||
*/
|
||||
static void
|
||||
client_none(struct screen_ctx *sc)
|
||||
{
|
||||
Window none = None;
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_ACTIVE_WINDOW,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&none, 1);
|
||||
_curcc = NULL;
|
||||
}
|
||||
|
||||
struct client_ctx *
|
||||
client_current(void)
|
||||
{
|
||||
@ -231,14 +267,14 @@ client_current(void)
|
||||
void
|
||||
client_maximize(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
int xmax = sc->xmax, ymax = sc->ymax;
|
||||
int x_org = 0, y_org = 0;
|
||||
|
||||
if (cc->flags & CLIENT_MAXIMIZED) {
|
||||
cc->geom = cc->savegeom;
|
||||
} else {
|
||||
if (!(cc->flags & CLIENT_VMAXIMIZED))
|
||||
if (!(cc->flags & (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)))
|
||||
cc->savegeom = cc->geom;
|
||||
if (HasXinerama) {
|
||||
XineramaScreenInfo *xine;
|
||||
@ -247,7 +283,7 @@ client_maximize(struct client_ctx *cc)
|
||||
* that's probably more fair than if just the origin of
|
||||
* a window is poking over a boundary
|
||||
*/
|
||||
xine = screen_find_xinerama(CCTOSC(cc),
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
@ -258,10 +294,10 @@ client_maximize(struct client_ctx *cc)
|
||||
ymax = xine->height;
|
||||
}
|
||||
calc:
|
||||
cc->geom.x = x_org - cc->bwidth + Conf.gap_left;
|
||||
cc->geom.y = y_org - cc->bwidth + Conf.gap_top;
|
||||
cc->geom.height = ymax - (Conf.gap_top + Conf.gap_bottom);
|
||||
cc->geom.width = xmax - (Conf.gap_left + Conf.gap_right);
|
||||
cc->geom.x = x_org + sc->gap.left;
|
||||
cc->geom.y = y_org + sc->gap.top;
|
||||
cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom);
|
||||
cc->geom.width = xmax - (sc->gap.left + sc->gap.right);
|
||||
cc->flags |= CLIENT_DOMAXIMIZE;
|
||||
}
|
||||
|
||||
@ -271,17 +307,17 @@ calc:
|
||||
void
|
||||
client_vertmaximize(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
int y_org = 0, ymax = sc->ymax;
|
||||
|
||||
if (cc->flags & CLIENT_VMAXIMIZED) {
|
||||
cc->geom = cc->savegeom;
|
||||
} else {
|
||||
if (!(cc->flags & CLIENT_MAXIMIZED))
|
||||
if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_HMAXIMIZED)))
|
||||
cc->savegeom = cc->geom;
|
||||
if (HasXinerama) {
|
||||
XineramaScreenInfo *xine;
|
||||
xine = screen_find_xinerama(CCTOSC(cc),
|
||||
xine = screen_find_xinerama(sc,
|
||||
cc->geom.x + cc->geom.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
@ -290,29 +326,68 @@ client_vertmaximize(struct client_ctx *cc)
|
||||
ymax = xine->height;
|
||||
}
|
||||
calc:
|
||||
cc->geom.y = y_org + Conf.gap_top;
|
||||
cc->geom.height = ymax - (cc->bwidth * 2) - (Conf.gap_top +
|
||||
Conf.gap_bottom);
|
||||
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;
|
||||
}
|
||||
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_horizmaximize(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
int x_org = 0, xmax = sc->xmax;
|
||||
|
||||
if (cc->flags & CLIENT_HMAXIMIZED) {
|
||||
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.width / 2,
|
||||
cc->geom.y + cc->geom.height / 2);
|
||||
if (xine == NULL)
|
||||
goto calc;
|
||||
x_org = xine->x_org;
|
||||
xmax = xine->width;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_resize(struct client_ctx *cc)
|
||||
{
|
||||
if (cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED))
|
||||
cc->flags &= ~(CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED);
|
||||
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.width, cc->geom.height);
|
||||
xev_reconfig(cc);
|
||||
@ -374,7 +449,7 @@ client_hide(struct client_ctx *cc)
|
||||
xu_setstate(cc, IconicState);
|
||||
|
||||
if (cc == _curcc)
|
||||
_curcc = NULL;
|
||||
client_none(cc->sc);
|
||||
}
|
||||
|
||||
void
|
||||
@ -391,7 +466,7 @@ client_unhide(struct client_ctx *cc)
|
||||
void
|
||||
client_draw_border(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
unsigned long pixel;
|
||||
|
||||
if (cc->active)
|
||||
@ -416,11 +491,11 @@ client_draw_border(struct client_ctx *cc)
|
||||
static void
|
||||
client_update(struct client_ctx *cc)
|
||||
{
|
||||
Atom *p;
|
||||
Atom *p;
|
||||
int i;
|
||||
long n;
|
||||
|
||||
if ((n = xu_getprop(cc, WM_PROTOCOLS,
|
||||
if ((n = xu_getprop(cc->win, WM_PROTOCOLS,
|
||||
XA_ATOM, 20L, (u_char **)&p)) <= 0)
|
||||
return;
|
||||
|
||||
@ -437,7 +512,7 @@ void
|
||||
client_send_delete(struct client_ctx *cc)
|
||||
{
|
||||
if (cc->xproto & CLIENT_PROTO_DELETE)
|
||||
xu_sendmsg(cc, WM_PROTOCOLS, WM_DELETE_WINDOW);
|
||||
xu_sendmsg(cc->win, WM_PROTOCOLS, WM_DELETE_WINDOW);
|
||||
else
|
||||
XKillClient(X_Dpy, cc->win);
|
||||
}
|
||||
@ -448,7 +523,8 @@ client_setname(struct client_ctx *cc)
|
||||
struct winname *wn;
|
||||
char *newname;
|
||||
|
||||
XFetchName(X_Dpy, cc->win, &newname);
|
||||
if (!xu_getstrprop(cc->win, _NET_WM_NAME, &newname))
|
||||
xu_getstrprop(cc->win, XA_WM_NAME, &newname);
|
||||
if (newname == NULL)
|
||||
newname = emptystring;
|
||||
|
||||
@ -474,7 +550,7 @@ match:
|
||||
assert(wn != NULL);
|
||||
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
||||
if (wn->name != emptystring)
|
||||
XFree(wn->name);
|
||||
xfree(wn->name);
|
||||
xfree(wn);
|
||||
cc->nameqlen--;
|
||||
}
|
||||
@ -483,14 +559,12 @@ match:
|
||||
}
|
||||
|
||||
struct client_ctx *
|
||||
client_cycle(int reverse)
|
||||
client_cycle(struct screen_ctx *sc, int reverse)
|
||||
{
|
||||
struct client_ctx *oldcc, *newcc;
|
||||
struct screen_ctx *sc;
|
||||
int again = 1;
|
||||
|
||||
oldcc = client_current();
|
||||
sc = screen_current();
|
||||
|
||||
/* If no windows then you cant cycle */
|
||||
if (TAILQ_EMPTY(&sc->mruq))
|
||||
@ -531,7 +605,7 @@ client_cycle(int reverse)
|
||||
static struct client_ctx *
|
||||
client_mrunext(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct client_ctx *ccc;
|
||||
|
||||
return ((ccc = TAILQ_NEXT(cc, mru_entry)) != NULL ?
|
||||
@ -541,7 +615,7 @@ client_mrunext(struct client_ctx *cc)
|
||||
static struct client_ctx *
|
||||
client_mruprev(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct client_ctx *ccc;
|
||||
|
||||
return ((ccc = TAILQ_PREV(cc, cycle_entry_q, mru_entry)) != NULL ?
|
||||
@ -551,10 +625,10 @@ client_mruprev(struct client_ctx *cc)
|
||||
static void
|
||||
client_placecalc(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
int xslack, yslack;
|
||||
|
||||
if (cc->size->flags & USPosition) {
|
||||
if (cc->size->flags & (USPosition|PPosition)) {
|
||||
/*
|
||||
* Ignore XINERAMA screens, just make sure it's somewhere
|
||||
* in the virtual desktop. else it stops people putting xterms
|
||||
@ -599,21 +673,21 @@ noxine:
|
||||
|
||||
if (xslack >= xorig) {
|
||||
cc->geom.x = MAX(MIN(xmouse, xslack),
|
||||
xorig + Conf.gap_left);
|
||||
if (cc->geom.x > (xslack - Conf.gap_right))
|
||||
cc->geom.x -= Conf.gap_right;
|
||||
xorig + sc->gap.left);
|
||||
if (cc->geom.x > (xslack - sc->gap.right))
|
||||
cc->geom.x -= sc->gap.right;
|
||||
} else {
|
||||
cc->geom.x = xorig + Conf.gap_left;
|
||||
cc->geom.width = xmax - Conf.gap_left;
|
||||
cc->geom.x = xorig + sc->gap.left;
|
||||
cc->geom.width = xmax - sc->gap.left;
|
||||
}
|
||||
if (yslack >= yorig) {
|
||||
cc->geom.y = MAX(MIN(ymouse, yslack),
|
||||
yorig + Conf.gap_top);
|
||||
if (cc->geom.y > (yslack - Conf.gap_bottom))
|
||||
cc->geom.y -= Conf.gap_bottom;
|
||||
yorig + sc->gap.top);
|
||||
if (cc->geom.y > (yslack - sc->gap.bottom))
|
||||
cc->geom.y -= sc->gap.bottom;
|
||||
} else {
|
||||
cc->geom.y = yorig + Conf.gap_top;
|
||||
cc->geom.height = ymax - Conf.gap_top;
|
||||
cc->geom.y = yorig + sc->gap.top;
|
||||
cc->geom.height = ymax - sc->gap.top;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -628,13 +702,104 @@ client_mtf(struct client_ctx *cc)
|
||||
if (cc == NULL)
|
||||
return;
|
||||
|
||||
sc = CCTOSC(cc);
|
||||
sc = cc->sc;
|
||||
|
||||
/* Move to front. */
|
||||
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
|
||||
TAILQ_INSERT_HEAD(&sc->mruq, cc, mru_entry);
|
||||
}
|
||||
|
||||
void
|
||||
client_getsizehints(struct client_ctx *cc)
|
||||
{
|
||||
long tmp;
|
||||
|
||||
if (!XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp))
|
||||
cc->size->flags = PSize;
|
||||
|
||||
if (cc->size->flags & PBaseSize) {
|
||||
cc->geom.basew = cc->size->base_width;
|
||||
cc->geom.baseh = cc->size->base_height;
|
||||
} else if (cc->size->flags & PMinSize) {
|
||||
cc->geom.basew = cc->size->min_width;
|
||||
cc->geom.baseh = cc->size->min_height;
|
||||
}
|
||||
if (cc->size->flags & PMinSize) {
|
||||
cc->geom.minw = cc->size->min_width;
|
||||
cc->geom.minh = cc->size->min_height;
|
||||
} else if (cc->size->flags & PBaseSize) {
|
||||
cc->geom.minw = cc->size->base_width;
|
||||
cc->geom.minh = cc->size->base_height;
|
||||
}
|
||||
if (cc->size->flags & PMaxSize) {
|
||||
cc->geom.maxw = cc->size->max_width;
|
||||
cc->geom.maxh = cc->size->max_height;
|
||||
}
|
||||
if (cc->size->flags & PResizeInc) {
|
||||
cc->geom.incw = cc->size->width_inc;
|
||||
cc->geom.inch = cc->size->height_inc;
|
||||
}
|
||||
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->geom.mina = (float)cc->size->min_aspect.y /
|
||||
cc->size->min_aspect.x;
|
||||
if (cc->size->max_aspect.y > 0)
|
||||
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->geom.basew == cc->geom.minw) &&
|
||||
(cc->geom.baseh == cc->geom.minh);
|
||||
|
||||
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */
|
||||
if (!baseismin) {
|
||||
cc->geom.width -= cc->geom.basew;
|
||||
cc->geom.height -= cc->geom.baseh;
|
||||
}
|
||||
|
||||
/* adjust for aspect limits */
|
||||
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.width -= cc->geom.basew;
|
||||
cc->geom.height -= cc->geom.baseh;
|
||||
}
|
||||
|
||||
/* adjust for increment value */
|
||||
cc->geom.width -= cc->geom.width % cc->geom.incw;
|
||||
cc->geom.height -= cc->geom.height % cc->geom.inch;
|
||||
|
||||
/* restore base dimensions */
|
||||
cc->geom.width += cc->geom.basew;
|
||||
cc->geom.height += cc->geom.baseh;
|
||||
|
||||
/* adjust for min width/height */
|
||||
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->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)
|
||||
{
|
||||
@ -650,7 +815,7 @@ client_gethints(struct client_ctx *cc)
|
||||
cc->app_class = xch.res_class;
|
||||
}
|
||||
|
||||
if (xu_getprop(cc, _MOTIF_WM_HINTS, _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) &&
|
||||
|
265
conf.c
265
conf.c
@ -18,7 +18,17 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
#ifndef timespeccmp
|
||||
@ -31,8 +41,6 @@
|
||||
static void conf_mouseunbind(struct conf *, struct mousebinding *);
|
||||
static void conf_unbind(struct conf *, struct keybinding *);
|
||||
|
||||
extern struct screen_ctx *Curscreen;
|
||||
|
||||
/* Add an command menu entry to the end of the menu */
|
||||
void
|
||||
conf_cmd_add(struct conf *c, char *image, char *label, int flags)
|
||||
@ -53,23 +61,22 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags)
|
||||
}
|
||||
|
||||
void
|
||||
conf_font(struct conf *c)
|
||||
conf_gap(struct conf *c, struct screen_ctx *sc)
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
|
||||
sc = screen_current();
|
||||
|
||||
c->DefaultFont = font_make(sc, c->DefaultFontName);
|
||||
c->FontHeight = font_ascent() + font_descent() + 1;
|
||||
sc->gap = c->gap;
|
||||
}
|
||||
|
||||
void
|
||||
conf_color(struct conf *c)
|
||||
conf_font(struct conf *c, struct screen_ctx *sc)
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
int i;
|
||||
sc->font = font_make(sc, c->DefaultFontName);
|
||||
sc->fontheight = font_ascent(sc) + font_descent(sc) + 1;
|
||||
}
|
||||
|
||||
sc = screen_current();
|
||||
void
|
||||
conf_color(struct conf *c, struct screen_ctx *sc)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CWM_COLOR_MAX; i++) {
|
||||
xu_freecolor(sc, sc->color[i].pixel);
|
||||
@ -80,6 +87,7 @@ conf_color(struct conf *c)
|
||||
void
|
||||
conf_reload(struct conf *c)
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
struct client_ctx *cc;
|
||||
|
||||
if (parse_config(c->conf_path, c) == -1) {
|
||||
@ -87,15 +95,92 @@ conf_reload(struct conf *c)
|
||||
return;
|
||||
}
|
||||
|
||||
conf_color(c);
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
client_draw_border(cc);
|
||||
conf_font(c);
|
||||
TAILQ_FOREACH(sc, &Screenq, entry) {
|
||||
conf_gap(c, sc);
|
||||
conf_color(c, sc);
|
||||
conf_font(c, sc);
|
||||
}
|
||||
}
|
||||
|
||||
static struct {
|
||||
char *key;
|
||||
char *func;
|
||||
} kb_binds[] = {
|
||||
{ "CM-Return", "terminal" },
|
||||
{ "CM-Delete", "lock" },
|
||||
{ "M-question", "exec" },
|
||||
{ "CM-w", "exec_wm" },
|
||||
{ "M-period", "ssh" },
|
||||
{ "M-Return", "hide" },
|
||||
{ "M-Down", "lower" },
|
||||
{ "M-Up", "raise" },
|
||||
{ "M-slash", "search" },
|
||||
{ "C-slash", "menusearch" },
|
||||
{ "M-Tab", "cycle" },
|
||||
{ "MS-Tab", "rcycle" },
|
||||
{ "CM-n", "label" },
|
||||
{ "CM-x", "delete" },
|
||||
{ "CM-0", "nogroup" },
|
||||
{ "CM-1", "group1" },
|
||||
{ "CM-2", "group2" },
|
||||
{ "CM-3", "group3" },
|
||||
{ "CM-4", "group4" },
|
||||
{ "CM-5", "group5" },
|
||||
{ "CM-6", "group6" },
|
||||
{ "CM-7", "group7" },
|
||||
{ "CM-8", "group8" },
|
||||
{ "CM-9", "group9" },
|
||||
{ "M-Right", "cyclegroup" },
|
||||
{ "M-Left", "rcyclegroup" },
|
||||
{ "CM-g", "grouptoggle" },
|
||||
{ "CM-f", "maximize" },
|
||||
{ "CM-equal", "vmaximize" },
|
||||
{ "CMS-equal", "hmaximize" },
|
||||
{ "CMS-r", "reload" },
|
||||
{ "CMS-q", "quit" },
|
||||
{ "M-h", "moveleft" },
|
||||
{ "M-j", "movedown" },
|
||||
{ "M-k", "moveup" },
|
||||
{ "M-l", "moveright" },
|
||||
{ "M-H", "bigmoveleft" },
|
||||
{ "M-J", "bigmovedown" },
|
||||
{ "M-K", "bigmoveup" },
|
||||
{ "M-L", "bigmoveright" },
|
||||
{ "CM-h", "resizeleft" },
|
||||
{ "CM-j", "resizedown" },
|
||||
{ "CM-k", "resizeup" },
|
||||
{ "CM-l", "resizeright" },
|
||||
{ "CM-H", "bigresizeleft" },
|
||||
{ "CM-J", "bigresizedown" },
|
||||
{ "CM-K", "bigresizeup" },
|
||||
{ "CM-L", "bigresizeright" },
|
||||
{ "C-Left", "ptrmoveleft" },
|
||||
{ "C-Down", "ptrmovedown" },
|
||||
{ "C-Up", "ptrmoveup" },
|
||||
{ "C-Right", "ptrmoveright" },
|
||||
{ "CS-Left", "bigptrmoveleft" },
|
||||
{ "CS-Down", "bigptrmovedown" },
|
||||
{ "CS-Up", "bigptrmoveup" },
|
||||
{ "CS-Right", "bigptrmoveright" },
|
||||
},
|
||||
m_binds[] = {
|
||||
{ "1", "menu_unhide" },
|
||||
{ "2", "menu_group" },
|
||||
{ "3", "menu_cmd" },
|
||||
{ "M-1", "window_move" },
|
||||
{ "CM-1", "window_grouptoggle" },
|
||||
{ "M-2", "window_resize" },
|
||||
{ "M-3", "window_lower" },
|
||||
{ "CMS-3", "window_hide" },
|
||||
};
|
||||
|
||||
void
|
||||
conf_init(struct conf *c)
|
||||
{
|
||||
int i;
|
||||
|
||||
c->flags = 0;
|
||||
c->bwidth = CONF_BWIDTH;
|
||||
c->mamount = CONF_MAMOUNT;
|
||||
@ -106,73 +191,11 @@ conf_init(struct conf *c)
|
||||
TAILQ_INIT(&c->autogroupq);
|
||||
TAILQ_INIT(&c->mousebindingq);
|
||||
|
||||
conf_bindname(c, "CM-Return", "terminal");
|
||||
conf_bindname(c, "CM-Delete", "lock");
|
||||
conf_bindname(c, "M-question", "exec");
|
||||
conf_bindname(c, "CM-w", "exec_wm");
|
||||
conf_bindname(c, "M-period", "ssh");
|
||||
conf_bindname(c, "M-Return", "hide");
|
||||
conf_bindname(c, "M-Down", "lower");
|
||||
conf_bindname(c, "M-Up", "raise");
|
||||
conf_bindname(c, "M-slash", "search");
|
||||
conf_bindname(c, "C-slash", "menusearch");
|
||||
conf_bindname(c, "M-Tab", "cycle");
|
||||
conf_bindname(c, "MS-Tab", "rcycle");
|
||||
conf_bindname(c, "CM-n", "label");
|
||||
conf_bindname(c, "CM-x", "delete");
|
||||
conf_bindname(c, "CM-0", "nogroup");
|
||||
conf_bindname(c, "CM-1", "group1");
|
||||
conf_bindname(c, "CM-2", "group2");
|
||||
conf_bindname(c, "CM-3", "group3");
|
||||
conf_bindname(c, "CM-4", "group4");
|
||||
conf_bindname(c, "CM-5", "group5");
|
||||
conf_bindname(c, "CM-6", "group6");
|
||||
conf_bindname(c, "CM-7", "group7");
|
||||
conf_bindname(c, "CM-8", "group8");
|
||||
conf_bindname(c, "CM-9", "group9");
|
||||
conf_bindname(c, "M-Right", "cyclegroup");
|
||||
conf_bindname(c, "M-Left", "rcyclegroup");
|
||||
conf_bindname(c, "CM-g", "grouptoggle");
|
||||
conf_bindname(c, "CM-f", "maximize");
|
||||
conf_bindname(c, "CM-equal", "vmaximize");
|
||||
conf_bindname(c, "CMS-r", "reload");
|
||||
conf_bindname(c, "CMS-q", "quit");
|
||||
for (i = 0; i < sizeof(kb_binds) / sizeof(kb_binds[0]); i++)
|
||||
conf_bindname(c, kb_binds[i].key, kb_binds[i].func);
|
||||
|
||||
conf_bindname(c, "M-h", "moveleft");
|
||||
conf_bindname(c, "M-j", "movedown");
|
||||
conf_bindname(c, "M-k", "moveup");
|
||||
conf_bindname(c, "M-l", "moveright");
|
||||
conf_bindname(c, "M-H", "bigmoveleft");
|
||||
conf_bindname(c, "M-J", "bigmovedown");
|
||||
conf_bindname(c, "M-K", "bigmoveup");
|
||||
conf_bindname(c, "M-L", "bigmoveright");
|
||||
|
||||
conf_bindname(c, "CM-h", "resizeleft");
|
||||
conf_bindname(c, "CM-j", "resizedown");
|
||||
conf_bindname(c, "CM-k", "resizeup");
|
||||
conf_bindname(c, "CM-l", "resizeright");
|
||||
conf_bindname(c, "CM-H", "bigresizeleft");
|
||||
conf_bindname(c, "CM-J", "bigresizedown");
|
||||
conf_bindname(c, "CM-K", "bigresizeup");
|
||||
conf_bindname(c, "CM-L", "bigresizeright");
|
||||
|
||||
conf_bindname(c, "C-Left", "ptrmoveleft");
|
||||
conf_bindname(c, "C-Down", "ptrmovedown");
|
||||
conf_bindname(c, "C-Up", "ptrmoveup");
|
||||
conf_bindname(c, "C-Right", "ptrmoveright");
|
||||
conf_bindname(c, "CS-Left", "bigptrmoveleft");
|
||||
conf_bindname(c, "CS-Down", "bigptrmovedown");
|
||||
conf_bindname(c, "CS-Up", "bigptrmoveup");
|
||||
conf_bindname(c, "CS-Right", "bigptrmoveright");
|
||||
|
||||
conf_mousebind(c, "1", "menu_unhide");
|
||||
conf_mousebind(c, "2", "menu_group");
|
||||
conf_mousebind(c, "3", "menu_cmd");
|
||||
conf_mousebind(c, "M-1", "window_move");
|
||||
conf_mousebind(c, "CM-1", "window_grouptoggle");
|
||||
conf_mousebind(c, "M-2", "window_resize");
|
||||
conf_mousebind(c, "M-3", "window_lower");
|
||||
conf_mousebind(c, "CMS-3", "window_hide");
|
||||
for (i = 0; i < sizeof(m_binds) / sizeof(m_binds[0]); i++)
|
||||
conf_mousebind(c, m_binds[i].key, m_binds[i].func);
|
||||
|
||||
/* Default term/lock */
|
||||
strlcpy(c->termpath, "xterm", sizeof(c->termpath));
|
||||
@ -219,7 +242,6 @@ conf_clear(struct conf *c)
|
||||
xfree(ag->class);
|
||||
if (ag->name)
|
||||
xfree(ag->name);
|
||||
xfree(ag->group);
|
||||
xfree(ag);
|
||||
}
|
||||
|
||||
@ -338,6 +360,7 @@ static struct {
|
||||
{ "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} },
|
||||
{ "reload", kbfunc_reload, 0, {0} },
|
||||
{ "quit", kbfunc_quit_wm, 0, {0} },
|
||||
{ "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} },
|
||||
@ -424,36 +447,40 @@ conf_ungrab(struct conf *c, struct keybinding *kb)
|
||||
xu_key_ungrab(sc->rootwin, kb->modmask, kb->keysym);
|
||||
}
|
||||
|
||||
static struct {
|
||||
char chr;
|
||||
int mask;
|
||||
} bind_mods[] = {
|
||||
{ 'C', ControlMask },
|
||||
{ 'M', Mod1Mask },
|
||||
{ '4', Mod4Mask },
|
||||
{ 'S', ShiftMask },
|
||||
};
|
||||
|
||||
void
|
||||
conf_bindname(struct conf *c, char *name, char *binding)
|
||||
{
|
||||
struct keybinding *current_binding;
|
||||
char *substring;
|
||||
char *substring, *tmp;
|
||||
int iter;
|
||||
|
||||
current_binding = xcalloc(1, sizeof(*current_binding));
|
||||
|
||||
if (strchr(name, 'C') != NULL &&
|
||||
strchr(name, 'C') < strchr(name, '-'))
|
||||
current_binding->modmask |= ControlMask;
|
||||
if ((substring = strchr(name, '-')) != NULL) {
|
||||
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 |=
|
||||
bind_mods[iter].mask;
|
||||
}
|
||||
}
|
||||
|
||||
if (strchr(name, 'M') != NULL &&
|
||||
strchr(name, 'M') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod1Mask;
|
||||
|
||||
if (strchr(name, '4') != NULL &&
|
||||
strchr(name, '4') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod4Mask;
|
||||
|
||||
if (strchr(name, 'S') != NULL &&
|
||||
strchr(name, 'S') < strchr(name, '-'))
|
||||
current_binding->modmask |= ShiftMask;
|
||||
|
||||
substring = strchr(name, '-') + 1;
|
||||
|
||||
/* If there is no '-' in name, continue as is */
|
||||
if (strchr(name, '-') == NULL)
|
||||
/* skip past the modifiers */
|
||||
substring++;
|
||||
} else {
|
||||
substring = name;
|
||||
}
|
||||
|
||||
if (substring[0] == '[' &&
|
||||
substring[strlen(substring)-1] == ']') {
|
||||
@ -539,31 +566,25 @@ void
|
||||
conf_mousebind(struct conf *c, char *name, char *binding)
|
||||
{
|
||||
struct mousebinding *current_binding;
|
||||
char *substring;
|
||||
char *substring, *tmp;
|
||||
const char *errstr;
|
||||
int iter;
|
||||
|
||||
current_binding = xcalloc(1, sizeof(*current_binding));
|
||||
|
||||
if (strchr(name, 'C') != NULL &&
|
||||
strchr(name, 'C') < strchr(name, '-'))
|
||||
current_binding->modmask |= ControlMask;
|
||||
if ((substring = strchr(name, '-')) != NULL) {
|
||||
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 |=
|
||||
bind_mods[iter].mask;
|
||||
}
|
||||
}
|
||||
|
||||
if (strchr(name, 'M') != NULL &&
|
||||
strchr(name, 'M') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod1Mask;
|
||||
|
||||
if (strchr(name, 'S') != NULL &&
|
||||
strchr(name, 'S') < strchr(name, '-'))
|
||||
current_binding->modmask |= ShiftMask;
|
||||
|
||||
if (strchr(name, '4') != NULL &&
|
||||
strchr(name, '4') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod4Mask;
|
||||
|
||||
substring = strchr(name, '-') + 1;
|
||||
|
||||
if (strchr(name, '-') == NULL)
|
||||
/* skip past the modifiers */
|
||||
substring++;
|
||||
} else
|
||||
substring = name;
|
||||
|
||||
current_binding->button = strtonum(substring, 1, 3, &errstr);
|
||||
|
10
cwm.1
10
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: June 18 2009 $
|
||||
.Dd $Mdocdate: August 24 2009 $
|
||||
.Dt CWM 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -92,6 +92,8 @@ Reverse cycle through active groups.
|
||||
Toggle full-screen size of current window.
|
||||
.It Ic CM-=
|
||||
Toggle vertical maximization of current window.
|
||||
.It Ic CMS-=
|
||||
Toggle horizontal maximization of current window.
|
||||
.It Ic M-?
|
||||
Spawn
|
||||
.Dq exec program
|
||||
@ -186,7 +188,7 @@ keeps a history of the 5 previous titles of a window.
|
||||
When searching, the leftmost character of the result list may show a
|
||||
flag:
|
||||
.Pp
|
||||
.Bl -tag -width 10n -offset -indent -compact
|
||||
.Bl -tag -width 10n -offset indent -compact
|
||||
.It !
|
||||
The window is the currently focused window.
|
||||
.It &
|
||||
@ -228,7 +230,7 @@ and a red border will be shown on those just removed.
|
||||
.Sh MENUS
|
||||
Menus are recalled by clicking the mouse on the root window:
|
||||
.Pp
|
||||
.Bl -tag -width 10n -offset -indent -compact
|
||||
.Bl -tag -width 10n -offset indent -compact
|
||||
.It Ic M1
|
||||
Show list of currently hidden windows.
|
||||
Clicking on an item will unhide that window.
|
||||
@ -264,7 +266,7 @@ with contributions from
|
||||
.An Andy Adamson Aq dros@monkey.org ,
|
||||
.An Niels Provos Aq provos@monkey.org ,
|
||||
and
|
||||
.An Antti Nyk<EFBFBD>nen Aq aon@iki.fi .
|
||||
.An Antti Nyk\(:anen Aq aon@iki.fi .
|
||||
Ideas, discussion with many others.
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
|
25
cwmrc.5
25
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: May 17 2009 $
|
||||
.Dd $Mdocdate: September 25 2010 $
|
||||
.Dt CWMRC 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -27,9 +27,9 @@ configuration file.
|
||||
The following options are accepted in the configuration file:
|
||||
.Pp
|
||||
.Bl -tag -width Ds -compact
|
||||
.It Ic autogroup Ar group Dq windowclass
|
||||
.It Ic autogroup Ar group Dq windowclass,windowname
|
||||
Control automatic window grouping, based on the class and/or name
|
||||
.It Ic autogroup Ar group windowname
|
||||
.It Ic autogroup Ar group windowname,windowclass
|
||||
Control automatic window grouping, based on the name and/or class
|
||||
properties, where
|
||||
.Ar group
|
||||
is a number between 0 and 9.
|
||||
@ -38,10 +38,10 @@ allow for
|
||||
.Dq sticky
|
||||
windows in sticky group mode.
|
||||
.Pp
|
||||
The class and name of a window may be obtained using
|
||||
The name and class of a window may be obtained using
|
||||
.Xr xprop 1 .
|
||||
.Pp
|
||||
.It Ic bind Ar keys Ar command
|
||||
.It Ic bind Ar keys command
|
||||
Cause the creation of a keybinding, or replacement of a default
|
||||
keybinding.
|
||||
The modifier keys come first, followed by a
|
||||
@ -96,7 +96,7 @@ Set the color of the inactive border.
|
||||
.It Ic color ungroupborder Ar color
|
||||
Set the color of the border while ungrouping a window.
|
||||
.Pp
|
||||
.It Ic command Ar name Ar path
|
||||
.It Ic command Ar name path
|
||||
Every
|
||||
.Ar name
|
||||
entry is shown in the application menu.
|
||||
@ -138,16 +138,16 @@ can be used for applications such as
|
||||
where the user may wish to remain visible.
|
||||
.Pp
|
||||
.It Ic ignore Ar windowname
|
||||
Ignore windows with the name
|
||||
Ignore, and do not warp to, windows with the name
|
||||
.Ar windowname
|
||||
when drawing borders and cycling through windows.
|
||||
.Pp
|
||||
.It Ic mousebind Ar buttons Ar command
|
||||
.It Ic mousebind Ar buttons command
|
||||
Cause the creation of a mouse binding, or replacement of a default
|
||||
mouse binding.
|
||||
The modifier keys come first, followed by a
|
||||
.Sq - .
|
||||
.Pb
|
||||
.Pp
|
||||
The following modifiers are recognised:
|
||||
.Pp
|
||||
.Bl -tag -width Ds -offset indent -compact
|
||||
@ -164,9 +164,8 @@ The Mod4 key (normally the windows key).
|
||||
The
|
||||
.Sq -
|
||||
should be followed by number:
|
||||
.Pb
|
||||
.Bl -tag -width Ds -offset indent -compact
|
||||
.Pp
|
||||
.Bl -tag -width Ds -offset indent -compact
|
||||
.It 1
|
||||
Left mouse button.
|
||||
.It 2
|
||||
@ -292,6 +291,8 @@ Label current window.
|
||||
Maximize current window full-screen.
|
||||
.It vmaximize
|
||||
Maximize current window vertically.
|
||||
.It hmaximize
|
||||
Maximize current window horizontally.
|
||||
.It moveup
|
||||
Move window
|
||||
.Ar moveamount
|
||||
|
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
|
35
font.c
35
font.c
@ -16,9 +16,36 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#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
|
||||
font_ascent(struct screen_ctx *sc)
|
||||
{
|
||||
return (sc->font->ascent);
|
||||
}
|
||||
|
||||
int
|
||||
font_descent(struct screen_ctx *sc)
|
||||
{
|
||||
return (sc->font->descent);
|
||||
}
|
||||
|
||||
u_int
|
||||
font_height(struct screen_ctx *sc)
|
||||
{
|
||||
return (sc->fontheight);
|
||||
}
|
||||
|
||||
void
|
||||
font_init(struct screen_ctx *sc)
|
||||
{
|
||||
@ -33,11 +60,11 @@ font_init(struct screen_ctx *sc)
|
||||
}
|
||||
|
||||
int
|
||||
font_width(const char *text, int len)
|
||||
font_width(struct screen_ctx *sc, const char *text, int len)
|
||||
{
|
||||
XGlyphInfo extents;
|
||||
|
||||
XftTextExtents8(X_Dpy, Conf.DefaultFont, (const XftChar8*)text,
|
||||
XftTextExtents8(X_Dpy, sc->font, (const XftChar8*)text,
|
||||
len, &extents);
|
||||
|
||||
return (extents.xOff);
|
||||
@ -49,7 +76,7 @@ font_draw(struct screen_ctx *sc, const char *text, int len,
|
||||
{
|
||||
XftDrawChange(sc->xftdraw, d);
|
||||
/* Really needs to be UTF8'd. */
|
||||
XftDrawString8(sc->xftdraw, &sc->xftcolor, Conf.DefaultFont, x, y,
|
||||
XftDrawString8(sc->xftdraw, &sc->xftcolor, sc->font, x, y,
|
||||
(const FcChar8*)text, len);
|
||||
}
|
||||
|
||||
|
290
group.c
290
group.c
@ -19,21 +19,26 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#define CALMWM_NGROUPS 9
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
static void group_add(struct group_ctx *, struct client_ctx *);
|
||||
static void group_remove(struct client_ctx *);
|
||||
static void group_hide(struct group_ctx *);
|
||||
static void group_show(struct group_ctx *);
|
||||
static void group_hide(struct screen_ctx *, struct group_ctx *);
|
||||
static void group_show(struct screen_ctx *, struct group_ctx *);
|
||||
static void group_fix_hidden_state(struct group_ctx *);
|
||||
|
||||
struct group_ctx *Group_active = NULL;
|
||||
struct group_ctx Groups[CALMWM_NGROUPS];
|
||||
int Grouphideall = 0;
|
||||
struct group_ctx_q Groupq;
|
||||
static void group_setactive(struct screen_ctx *, long);
|
||||
static void group_set_names(struct screen_ctx *);
|
||||
|
||||
const char *shortcut_to_name[] = {
|
||||
"nogroup", "one", "two", "three", "four", "five", "six",
|
||||
@ -43,17 +48,20 @@ 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, _CWM_GRP, XA_STRING,
|
||||
8, PropModeReplace, gc->name, strlen(gc->name));
|
||||
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;
|
||||
@ -62,23 +70,24 @@ group_add(struct group_ctx *gc, struct client_ctx *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, _CWM_GRP, XA_STRING, 8,
|
||||
PropModeReplace, shortcut_to_name[0],
|
||||
strlen(shortcut_to_name[0]));
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
group_hide(struct group_ctx *gc)
|
||||
group_hide(struct screen_ctx *sc, struct group_ctx *gc)
|
||||
{
|
||||
struct client_ctx *cc;
|
||||
|
||||
screen_updatestackingorder();
|
||||
screen_updatestackingorder(sc);
|
||||
|
||||
gc->nhidden = 0;
|
||||
gc->highstack = 0;
|
||||
@ -92,7 +101,7 @@ group_hide(struct group_ctx *gc)
|
||||
}
|
||||
|
||||
static void
|
||||
group_show(struct group_ctx *gc)
|
||||
group_show(struct screen_ctx *sc, struct group_ctx *gc)
|
||||
{
|
||||
struct client_ctx *cc;
|
||||
Window *winlist;
|
||||
@ -125,36 +134,90 @@ group_show(struct group_ctx *gc)
|
||||
xfree(winlist);
|
||||
|
||||
gc->hidden = 0;
|
||||
Group_active = gc;
|
||||
group_setactive(sc, gc->shortcut - 1);
|
||||
}
|
||||
|
||||
void
|
||||
group_init(void)
|
||||
group_init(struct screen_ctx *sc)
|
||||
{
|
||||
int i;
|
||||
long viewports[2] = {0, 0};
|
||||
long ndesks = CALMWM_NGROUPS, zero = 0;
|
||||
|
||||
TAILQ_INIT(&Groupq);
|
||||
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.
|
||||
*/
|
||||
group_update_names(sc);
|
||||
|
||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||
TAILQ_INIT(&Groups[i].clients);
|
||||
Groups[i].hidden = 0;
|
||||
Groups[i].shortcut = i + 1;
|
||||
Groups[i].name = shortcut_to_name[Groups[i].shortcut];
|
||||
TAILQ_INSERT_TAIL(&Groupq, &Groups[i], entry);
|
||||
TAILQ_INIT(&sc->groups[i].clients);
|
||||
sc->groups[i].hidden = 0;
|
||||
sc->groups[i].shortcut = i + 1;
|
||||
TAILQ_INSERT_TAIL(&sc->groupq, &sc->groups[i], entry);
|
||||
}
|
||||
|
||||
Group_active = &Groups[0];
|
||||
/* 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);
|
||||
}
|
||||
|
||||
void
|
||||
group_make_autogroup(struct conf *conf, char *val, int no)
|
||||
{
|
||||
struct autogroupwin *aw;
|
||||
char *p;
|
||||
|
||||
aw = xcalloc(1, sizeof(*aw));
|
||||
|
||||
if ((p = strchr(val, ',')) == NULL) {
|
||||
aw->name = NULL;
|
||||
aw->class = xstrdup(val);
|
||||
} else {
|
||||
*(p++) = '\0';
|
||||
aw->name = xstrdup(val);
|
||||
aw->class = xstrdup(p);
|
||||
}
|
||||
aw->num = no;
|
||||
|
||||
TAILQ_INSERT_TAIL(&conf->autogroupq, aw, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
group_setactive(struct screen_ctx *sc, long idx)
|
||||
{
|
||||
sc->group_active = &sc->groups[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;
|
||||
|
||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||
err(1, "group_movetogroup: index out of range (%d)", idx);
|
||||
|
||||
if(Group_active != &Groups[idx])
|
||||
if(sc->group_active != &sc->groups[idx])
|
||||
client_hide(cc);
|
||||
group_add(&Groups[idx], cc);
|
||||
group_add(&sc->groups[idx], cc);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -163,9 +226,10 @@ group_movetogroup(struct client_ctx *cc, int idx)
|
||||
void
|
||||
group_sticky_toggle_enter(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct group_ctx *gc;
|
||||
|
||||
gc = Group_active;
|
||||
gc = sc->group_active;
|
||||
|
||||
if (gc == cc->group) {
|
||||
group_remove(cc);
|
||||
@ -204,28 +268,28 @@ group_fix_hidden_state(struct group_ctx *gc)
|
||||
}
|
||||
|
||||
void
|
||||
group_hidetoggle(int idx)
|
||||
group_hidetoggle(struct screen_ctx *sc, int idx)
|
||||
{
|
||||
struct group_ctx *gc;
|
||||
|
||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||
err(1, "group_hidetoggle: index out of range (%d)", idx);
|
||||
|
||||
gc = &Groups[idx];
|
||||
|
||||
gc = &sc->groups[idx];
|
||||
group_fix_hidden_state(gc);
|
||||
|
||||
if (gc->hidden)
|
||||
group_show(gc);
|
||||
group_show(sc, gc);
|
||||
else {
|
||||
group_hide(gc);
|
||||
group_hide(sc, gc);
|
||||
/* XXX wtf? */
|
||||
if (TAILQ_EMPTY(&gc->clients))
|
||||
Group_active = gc;
|
||||
group_setactive(sc, idx);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
group_only(int idx)
|
||||
group_only(struct screen_ctx *sc, int idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -234,9 +298,9 @@ group_only(int idx)
|
||||
|
||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||
if (i == idx)
|
||||
group_show(&Groups[i]);
|
||||
group_show(sc, &sc->groups[i]);
|
||||
else
|
||||
group_hide(&Groups[i]);
|
||||
group_hide(sc, &sc->groups[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,37 +308,37 @@ group_only(int idx)
|
||||
* Cycle through active groups. If none exist, then just stay put.
|
||||
*/
|
||||
void
|
||||
group_cycle(int reverse)
|
||||
group_cycle(struct screen_ctx *sc, int reverse)
|
||||
{
|
||||
struct group_ctx *gc, *showgroup = NULL;
|
||||
|
||||
assert(Group_active != NULL);
|
||||
assert(sc->group_active != NULL);
|
||||
|
||||
gc = Group_active;
|
||||
gc = sc->group_active;
|
||||
for (;;) {
|
||||
gc = reverse ? TAILQ_PREV(gc, group_ctx_q, entry) :
|
||||
TAILQ_NEXT(gc, entry);
|
||||
if (gc == NULL)
|
||||
gc = reverse ? TAILQ_LAST(&Groupq, group_ctx_q) :
|
||||
TAILQ_FIRST(&Groupq);
|
||||
if (gc == Group_active)
|
||||
gc = reverse ? TAILQ_LAST(&sc->groupq, group_ctx_q) :
|
||||
TAILQ_FIRST(&sc->groupq);
|
||||
if (gc == sc->group_active)
|
||||
break;
|
||||
|
||||
if (!TAILQ_EMPTY(&gc->clients) && showgroup == NULL)
|
||||
showgroup = gc;
|
||||
else if (!gc->hidden)
|
||||
group_hide(gc);
|
||||
group_hide(sc, gc);
|
||||
}
|
||||
|
||||
if (showgroup == NULL)
|
||||
return;
|
||||
|
||||
group_hide(Group_active);
|
||||
group_hide(sc, sc->group_active);
|
||||
|
||||
if (showgroup->hidden)
|
||||
group_show(showgroup);
|
||||
group_show(sc, showgroup);
|
||||
else
|
||||
Group_active = showgroup;
|
||||
group_setactive(sc, showgroup->shortcut - 1);
|
||||
}
|
||||
|
||||
/* called when a client is deleted */
|
||||
@ -291,15 +355,17 @@ group_client_delete(struct client_ctx *cc)
|
||||
void
|
||||
group_menu(XButtonEvent *e)
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
struct group_ctx *gc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
int i;
|
||||
|
||||
sc = screen_fromroot(e->root);
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||
gc = &Groups[i];
|
||||
gc = &sc->groups[i];
|
||||
|
||||
if (TAILQ_EMPTY(&gc->clients))
|
||||
continue;
|
||||
@ -307,10 +373,10 @@ group_menu(XButtonEvent *e)
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
if (gc->hidden)
|
||||
snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
|
||||
gc->shortcut, shortcut_to_name[gc->shortcut]);
|
||||
gc->shortcut, sc->group_names[i]);
|
||||
else
|
||||
snprintf(mi->text, sizeof(mi->text), "%d: %s",
|
||||
gc->shortcut, shortcut_to_name[gc->shortcut]);
|
||||
gc->shortcut, sc->group_names[i]);
|
||||
mi->ctx = gc;
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
@ -318,14 +384,14 @@ group_menu(XButtonEvent *e)
|
||||
if (TAILQ_EMPTY(&menuq))
|
||||
return;
|
||||
|
||||
mi = menu_filter(&menuq, NULL, NULL, 0, NULL, NULL);
|
||||
mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL);
|
||||
|
||||
if (mi == NULL || mi->ctx == NULL)
|
||||
goto cleanup;
|
||||
|
||||
gc = (struct group_ctx *)mi->ctx;
|
||||
|
||||
(gc->hidden) ? group_show(gc) : group_hide(gc);
|
||||
(gc->hidden) ? group_show(sc, gc) : group_hide(sc, gc);
|
||||
|
||||
cleanup:
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
@ -335,56 +401,138 @@ cleanup:
|
||||
}
|
||||
|
||||
void
|
||||
group_alltoggle(void)
|
||||
group_alltoggle(struct screen_ctx *sc)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||
if (Grouphideall)
|
||||
group_show(&Groups[i]);
|
||||
if (sc->group_hideall)
|
||||
group_show(sc, &sc->groups[i]);
|
||||
else
|
||||
group_hide(&Groups[i]);
|
||||
group_hide(sc, &sc->groups[i]);
|
||||
}
|
||||
|
||||
Grouphideall = (Grouphideall) ? 0 : 1;
|
||||
sc->group_hideall = (!sc->group_hideall);
|
||||
}
|
||||
|
||||
void
|
||||
group_autogroup(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
struct autogroupwin *aw;
|
||||
struct group_ctx *gc;
|
||||
unsigned char *grpstr = NULL;
|
||||
char group[CALMWM_MAXNAMELEN];
|
||||
int no = -1;
|
||||
long *grpno;
|
||||
|
||||
if (cc->app_class == NULL || cc->app_name == NULL)
|
||||
return;
|
||||
if (xu_getprop(cc, _CWM_GRP, XA_STRING,
|
||||
(CALMWM_MAXNAMELEN - 1)/sizeof(long), &grpstr) > 0) {
|
||||
strlcpy(group, grpstr, sizeof(group));
|
||||
XFree(grpstr);
|
||||
|
||||
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)
|
||||
no = CALMWM_NGROUPS - 1;
|
||||
else
|
||||
no = *grpno + 1;
|
||||
XFree(grpno);
|
||||
} else {
|
||||
TAILQ_FOREACH(aw, &Conf.autogroupq, entry) {
|
||||
if (strcmp(aw->class, cc->app_class) == 0 &&
|
||||
(aw->name == NULL ||
|
||||
strcmp(aw->name, cc->app_name) == 0)) {
|
||||
strlcpy(group, aw->group, sizeof(group));
|
||||
no = aw->num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp("nogroup", group, 7) == 0)
|
||||
/* no group please */
|
||||
if (no == 0)
|
||||
return;
|
||||
|
||||
TAILQ_FOREACH(gc, &Groupq, entry) {
|
||||
if (strcmp(shortcut_to_name[gc->shortcut], group) == 0) {
|
||||
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
||||
if (gc->shortcut == no) {
|
||||
group_add(gc, cc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Conf.flags & CONF_STICKY_GROUPS)
|
||||
group_add(Group_active, cc);
|
||||
|
||||
group_add(sc->group_active, cc);
|
||||
}
|
||||
|
||||
void
|
||||
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, setnames = 0;
|
||||
unsigned long bytes_after, num_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 */
|
||||
prop_ret[num_ret - 1] = '\0'; /* paranoia */
|
||||
while (i < num_ret) {
|
||||
if (prop_ret[i++] == '\0')
|
||||
nstrings++;
|
||||
}
|
||||
}
|
||||
|
||||
strings = xmalloc((nstrings < CALMWM_NGROUPS ? CALMWM_NGROUPS :
|
||||
nstrings) * sizeof(*strings));
|
||||
|
||||
i = n = 0;
|
||||
p = prop_ret;
|
||||
while (n < nstrings) {
|
||||
strings[n++] = xstrdup(p);
|
||||
p += strlen(p) + 1;
|
||||
}
|
||||
/*
|
||||
* make sure we always set our defaults if nothing is there to
|
||||
* replace them.
|
||||
*/
|
||||
if (n < CALMWM_NGROUPS) {
|
||||
setnames = 1;
|
||||
i = 1;
|
||||
while (n < CALMWM_NGROUPS)
|
||||
strings[n++] = xstrdup(shortcut_to_name[i++]);
|
||||
}
|
||||
|
||||
if (prop_ret != NULL)
|
||||
XFree(prop_ret);
|
||||
if (sc->group_nonames != 0)
|
||||
free(sc->group_names);
|
||||
|
||||
sc->group_names = strings;
|
||||
sc->group_nonames = n;
|
||||
if (setnames)
|
||||
group_set_names(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
group_set_names(struct screen_ctx *sc)
|
||||
{
|
||||
unsigned char *p, *q;
|
||||
size_t len = 0, tlen, slen;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sc->group_nonames; i++)
|
||||
len += strlen(sc->group_names[i]) + 1;
|
||||
q = p = xcalloc(len, sizeof(*p));
|
||||
|
||||
tlen = len;
|
||||
for (i = 0; i < sc->group_nonames; i++) {
|
||||
slen = strlen(sc->group_names[i]) + 1;
|
||||
strlcpy(q, sc->group_names[i], tlen);
|
||||
tlen -= slen;
|
||||
q += slen;
|
||||
}
|
||||
|
||||
XChangeProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_NAMES,
|
||||
UTF8_STRING, 8, PropModeReplace, p, len);
|
||||
}
|
||||
|
53
headers.h
53
headers.h
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
#ifndef _CALMWM_HEADERS_H_
|
||||
#define _CALMWM_HEADERS_H_
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#endif /* _CALMWM_HEADERS_H_ */
|
11
input.c
11
input.c
@ -18,7 +18,16 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#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
|
||||
|
156
kbfunc.c
156
kbfunc.c
@ -18,9 +18,18 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
#define KNOWN_HOSTS ".ssh/known_hosts"
|
||||
@ -49,7 +58,7 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
int x, y, flags, amt;
|
||||
u_int mx, my;
|
||||
|
||||
sc = screen_current();
|
||||
sc = cc->sc;
|
||||
mx = my = 0;
|
||||
|
||||
flags = arg->i;
|
||||
@ -124,12 +133,14 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_search(struct client_ctx *scratch, union arg *arg)
|
||||
kbfunc_client_search(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct client_ctx *cc, *old_cc;
|
||||
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);
|
||||
@ -141,7 +152,7 @@ kbfunc_client_search(struct client_ctx *scratch, union arg *arg)
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
|
||||
if ((mi = menu_filter(&menuq, "window", NULL, 0,
|
||||
if ((mi = menu_filter(sc, &menuq, "window", NULL, 0,
|
||||
search_match_client, search_print_client)) != NULL) {
|
||||
cc = (struct client_ctx *)mi->ctx;
|
||||
if (cc->flags & CLIENT_HIDDEN)
|
||||
@ -159,12 +170,14 @@ kbfunc_client_search(struct client_ctx *scratch, union arg *arg)
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_menu_search(struct client_ctx *scratch, union arg *arg)
|
||||
kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct cmd *cmd;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
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) {
|
||||
@ -174,7 +187,7 @@ kbfunc_menu_search(struct client_ctx *scratch, union arg *arg)
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
|
||||
if ((mi = menu_filter(&menuq, "application", NULL, 0,
|
||||
if ((mi = menu_filter(sc, &menuq, "application", NULL, 0,
|
||||
search_match_text, NULL)) != NULL)
|
||||
u_spawn(((struct cmd *)mi->ctx)->image);
|
||||
|
||||
@ -185,17 +198,17 @@ kbfunc_menu_search(struct client_ctx *scratch, union arg *arg)
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_cycle(struct client_ctx *scratch, union arg *arg)
|
||||
kbfunc_client_cycle(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
|
||||
sc = screen_current();
|
||||
sc = cc->sc;
|
||||
|
||||
/* XXX for X apps that ignore events */
|
||||
XGrabKeyboard(X_Dpy, sc->rootwin, True,
|
||||
GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||
|
||||
client_cycle(arg->i);
|
||||
client_cycle(sc, arg->i);
|
||||
}
|
||||
|
||||
void
|
||||
@ -223,21 +236,19 @@ kbfunc_lock(struct client_ctx *cc, union arg *arg)
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_exec(struct client_ctx *scratch, union arg *arg)
|
||||
kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
#define NPATHS 256
|
||||
char **ap, *paths[NPATHS], *path, *pathcpy, *label;
|
||||
char tpath[MAXPATHLEN];
|
||||
int l, i, j, ngroups;
|
||||
gid_t mygroups[NGROUPS_MAX];
|
||||
uid_t ruid, euid, suid;
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
struct stat sb;
|
||||
struct screen_ctx *sc;
|
||||
char **ap, *paths[NPATHS], *path, *pathcpy, *label;
|
||||
char tpath[MAXPATHLEN];
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
int l, i, cmd = arg->i;
|
||||
|
||||
int cmd = arg->i;
|
||||
sc = cc->sc;
|
||||
switch (cmd) {
|
||||
case CWM_EXEC_PROGRAM:
|
||||
label = "exec";
|
||||
@ -250,11 +261,6 @@ kbfunc_exec(struct client_ctx *scratch, union arg *arg)
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
if (getgroups(0, mygroups) == -1)
|
||||
err(1, "getgroups failure");
|
||||
if ((ngroups = getresuid(&ruid, &euid, &suid)) == -1)
|
||||
err(1, "getresuid failure");
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
if ((path = getenv("PATH")) == NULL)
|
||||
@ -281,39 +287,20 @@ kbfunc_exec(struct client_ctx *scratch, union arg *arg)
|
||||
/* check for truncation etc */
|
||||
if (l == -1 || l >= (int)sizeof(tpath))
|
||||
continue;
|
||||
/* just ignore on stat failure */
|
||||
if (stat(tpath, &sb) == -1)
|
||||
continue;
|
||||
/* may we execute this file? */
|
||||
if (euid == sb.st_uid) {
|
||||
if (sb.st_mode & S_IXUSR)
|
||||
goto executable;
|
||||
else
|
||||
continue;
|
||||
if (access(tpath, X_OK) == 0) {
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
strlcpy(mi->text, dp->d_name, sizeof(mi->text));
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
for (j = 0; j < ngroups; j++) {
|
||||
if (mygroups[j] == sb.st_gid) {
|
||||
if (sb.st_mode & S_IXGRP)
|
||||
goto executable;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (sb.st_mode & S_IXOTH)
|
||||
goto executable;
|
||||
continue;
|
||||
executable:
|
||||
/* the thing in tpath, we may execute */
|
||||
mi = xcalloc(1, sizeof(*mi));
|
||||
strlcpy(mi->text, dp->d_name, sizeof(mi->text));
|
||||
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||
}
|
||||
(void)closedir(dirp);
|
||||
}
|
||||
xfree(path);
|
||||
|
||||
if ((mi = menu_filter(&menuq, label, NULL, 1,
|
||||
if ((mi = menu_filter(sc, &menuq, label, NULL, 1,
|
||||
search_match_exec, NULL)) != NULL) {
|
||||
if (mi->text[0] == '\0')
|
||||
goto out;
|
||||
switch (cmd) {
|
||||
case CWM_EXEC_PROGRAM:
|
||||
u_spawn(mi->text);
|
||||
@ -327,7 +314,7 @@ kbfunc_exec(struct client_ctx *scratch, union arg *arg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (mi != NULL && mi->dummy)
|
||||
xfree(mi);
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
@ -337,16 +324,19 @@ kbfunc_exec(struct client_ctx *scratch, union arg *arg)
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_ssh(struct client_ctx *scratch, union arg *arg)
|
||||
kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
FILE *fp;
|
||||
char *buf, *lbuf, *p, *home;
|
||||
char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN];
|
||||
char cmd[256];
|
||||
int l;
|
||||
size_t len;
|
||||
struct screen_ctx *sc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
FILE *fp;
|
||||
char *buf, *lbuf, *p, *home;
|
||||
char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN];
|
||||
char cmd[256];
|
||||
int l;
|
||||
size_t len;
|
||||
|
||||
sc = cc->sc;
|
||||
|
||||
if ((home = getenv("HOME")) == NULL)
|
||||
return;
|
||||
@ -387,14 +377,16 @@ kbfunc_ssh(struct client_ctx *scratch, union arg *arg)
|
||||
xfree(lbuf);
|
||||
fclose(fp);
|
||||
|
||||
if ((mi = menu_filter(&menuq, "ssh", NULL, 1,
|
||||
if ((mi = menu_filter(sc, &menuq, "ssh", NULL, 1,
|
||||
search_match_exec, NULL)) != NULL) {
|
||||
if (mi->text[0] == '\0')
|
||||
goto out;
|
||||
l = snprintf(cmd, sizeof(cmd), "%s -e ssh %s", Conf.termpath,
|
||||
mi->text);
|
||||
if (l != -1 && l < sizeof(cmd))
|
||||
u_spawn(cmd);
|
||||
}
|
||||
|
||||
out:
|
||||
if (mi != NULL && mi->dummy)
|
||||
xfree(mi);
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
@ -408,19 +400,19 @@ kbfunc_client_label(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
char *current;
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
current = cc->label;
|
||||
|
||||
if ((mi = menu_filter(&menuq, "label", current, 1,
|
||||
search_match_text, NULL)) != NULL) {
|
||||
/* dummy is set, so this will always return */
|
||||
mi = menu_filter(cc->sc, &menuq, "label", cc->label, 1,
|
||||
search_match_text, NULL);
|
||||
|
||||
if (!mi->abort) {
|
||||
if (cc->label != NULL)
|
||||
xfree(cc->label);
|
||||
cc->label = xstrdup(mi->text);
|
||||
xfree(mi);
|
||||
}
|
||||
xfree(mi);
|
||||
}
|
||||
|
||||
void
|
||||
@ -432,25 +424,25 @@ kbfunc_client_delete(struct client_ctx *cc, union arg *arg)
|
||||
void
|
||||
kbfunc_client_group(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
group_hidetoggle(KBTOGROUP(arg->i));
|
||||
group_hidetoggle(cc->sc, KBTOGROUP(arg->i));
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_grouponly(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
group_only(KBTOGROUP(arg->i));
|
||||
group_only(cc->sc, KBTOGROUP(arg->i));
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_cyclegroup(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
group_cycle(arg->i);
|
||||
group_cycle(cc->sc, arg->i);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_nogroup(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
group_alltoggle();
|
||||
group_alltoggle(cc->sc);
|
||||
}
|
||||
|
||||
void
|
||||
@ -481,6 +473,12 @@ kbfunc_client_vmaximize(struct client_ctx *cc, union arg *arg)
|
||||
client_vertmaximize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_hmaximize(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
client_horizmaximize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_quit_wm(struct client_ctx *cc, union arg *arg)
|
||||
{
|
||||
|
53
menu.c
53
menu.c
@ -15,7 +15,16 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#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"
|
||||
|
||||
#define PROMPT_SCHAR '<27>'
|
||||
@ -69,11 +78,11 @@ menu_init(struct screen_ctx *sc)
|
||||
}
|
||||
|
||||
struct menu *
|
||||
menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy,
|
||||
menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
|
||||
char *initial, int dummy,
|
||||
void (*match)(struct menu_q *, struct menu_q *, char *),
|
||||
void (*print)(struct menu *, int))
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
struct menu_ctx mc;
|
||||
struct menu_q resultq;
|
||||
struct menu *mi = NULL;
|
||||
@ -81,8 +90,6 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy,
|
||||
Window focuswin;
|
||||
int evmask, focusrevert;
|
||||
|
||||
sc = screen_current();
|
||||
|
||||
TAILQ_INIT(&resultq);
|
||||
|
||||
bzero(&mc, sizeof(mc));
|
||||
@ -99,7 +106,7 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy,
|
||||
PROMPT_SCHAR);
|
||||
snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%c", mc.promptstr,
|
||||
mc.searchstr, PROMPT_ECHAR);
|
||||
mc.width = font_width(mc.dispstr, strlen(mc.dispstr));
|
||||
mc.width = font_width(sc, mc.dispstr, strlen(mc.dispstr));
|
||||
mc.hasprompt = 1;
|
||||
}
|
||||
|
||||
@ -113,7 +120,7 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy,
|
||||
mc.entry = mc.prev = -1;
|
||||
|
||||
XMoveResizeWindow(X_Dpy, sc->menuwin, mc.x, mc.y, mc.width,
|
||||
font_height());
|
||||
font_height(sc));
|
||||
XSelectInput(X_Dpy, sc->menuwin, evmask);
|
||||
XMapRaised(X_Dpy, sc->menuwin);
|
||||
|
||||
@ -216,6 +223,7 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
mc->searchstr, sizeof(mi->text));
|
||||
mi->dummy = 1;
|
||||
}
|
||||
mi->abort = 0;
|
||||
return (mi);
|
||||
case CTL_WIPE:
|
||||
mc->searchstr[0] = '\0';
|
||||
@ -228,6 +236,7 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
mi = xmalloc(sizeof *mi);
|
||||
mi->text[0] = '\0';
|
||||
mi->dummy = 1;
|
||||
mi->abort = 1;
|
||||
return (mi);
|
||||
default:
|
||||
break;
|
||||
@ -243,14 +252,14 @@ menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
}
|
||||
|
||||
mc->noresult = 0;
|
||||
if (mc->changed && strlen(mc->searchstr) > 0) {
|
||||
if (mc->changed && mc->searchstr[0] != '\0') {
|
||||
(*mc->match)(menuq, resultq, mc->searchstr);
|
||||
/* If menuq is empty, never show we've failed */
|
||||
mc->noresult = TAILQ_EMPTY(resultq) && !TAILQ_EMPTY(menuq);
|
||||
} else if (mc->changed)
|
||||
TAILQ_INIT(resultq);
|
||||
|
||||
if (!mc->list && mc->listing && !mc->changed) {
|
||||
if (!mc->list && mc->listing && !mc->changed) {
|
||||
TAILQ_INIT(resultq);
|
||||
mc->listing = 0;
|
||||
}
|
||||
@ -283,8 +292,8 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
if (mc->hasprompt) {
|
||||
snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%c",
|
||||
mc->promptstr, mc->searchstr, PROMPT_ECHAR);
|
||||
mc->width = font_width(mc->dispstr, strlen(mc->dispstr));
|
||||
dy = font_height();
|
||||
mc->width = font_width(sc, mc->dispstr, strlen(mc->dispstr));
|
||||
dy = font_height(sc);
|
||||
mc->num = 1;
|
||||
}
|
||||
|
||||
@ -299,9 +308,9 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
text = mi->text;
|
||||
}
|
||||
|
||||
mc->width = MAX(mc->width, font_width(text,
|
||||
mc->width = MAX(mc->width, font_width(sc, text,
|
||||
MIN(strlen(text), MENU_MAXENTRY)));
|
||||
dy += font_height();
|
||||
dy += font_height(sc);
|
||||
mc->num++;
|
||||
}
|
||||
|
||||
@ -326,7 +335,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
|
||||
if (mc->hasprompt) {
|
||||
font_draw(sc, mc->dispstr, strlen(mc->dispstr), sc->menuwin,
|
||||
0, font_ascent() + 1);
|
||||
0, font_ascent(sc) + 1);
|
||||
n = 1;
|
||||
} else
|
||||
n = 0;
|
||||
@ -336,17 +345,17 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
|
||||
mi->print : mi->text;
|
||||
|
||||
font_draw(sc, text, MIN(strlen(text), MENU_MAXENTRY),
|
||||
sc->menuwin, 0, n*font_height() + font_ascent() + 1);
|
||||
sc->menuwin, 0, n * font_height(sc) + font_ascent(sc) + 1);
|
||||
n++;
|
||||
}
|
||||
|
||||
if (mc->hasprompt && n > 1)
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc,
|
||||
0, font_height(), mc->width, font_height());
|
||||
0, font_height(sc), mc->width, font_height(sc));
|
||||
|
||||
if (mc->noresult)
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc,
|
||||
0, 0, mc->width, font_height());
|
||||
0, 0, mc->width, font_height(sc));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -357,11 +366,11 @@ menu_handle_move(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc)
|
||||
|
||||
if (mc->prev != -1)
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
|
||||
font_height() * mc->prev, mc->width, font_height());
|
||||
font_height(sc) * mc->prev, mc->width, font_height(sc));
|
||||
if (mc->entry != -1) {
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_select);
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
|
||||
font_height() * mc->entry, mc->width, font_height());
|
||||
font_height(sc) * mc->entry, mc->width, font_height(sc));
|
||||
} else
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_default);
|
||||
}
|
||||
@ -395,11 +404,11 @@ menu_calc_entry(struct screen_ctx *sc, struct menu_ctx *mc, int x, int y)
|
||||
{
|
||||
int entry;
|
||||
|
||||
entry = y / font_height();
|
||||
entry = y / font_height(sc);
|
||||
|
||||
/* in bounds? */
|
||||
if (x < 0 || x > mc->width || y < 0 || y > font_height() * mc->num ||
|
||||
entry < 0 || entry >= mc->num)
|
||||
if (x <= 0 || x > mc->width || y <= 0 ||
|
||||
y > font_height(sc) * mc->num || entry < 0 || entry >= mc->num)
|
||||
entry = -1;
|
||||
|
||||
if (mc->hasprompt && entry == 0)
|
||||
|
64
mousefunc.c
64
mousefunc.c
@ -19,7 +19,16 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#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"
|
||||
|
||||
static int mousefunc_sweep_calc(struct client_ctx *, int, int, int, int);
|
||||
@ -33,22 +42,7 @@ mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
|
||||
cc->geom.width = abs(x - mx) - cc->bwidth;
|
||||
cc->geom.height = abs(y - my) - cc->bwidth;
|
||||
|
||||
if (cc->size->flags & PResizeInc) {
|
||||
cc->geom.width -=
|
||||
(cc->geom.width - cc->geom.min_dx) % cc->size->width_inc;
|
||||
cc->geom.height -=
|
||||
(cc->geom.height - cc->geom.min_dy) % cc->size->height_inc;
|
||||
}
|
||||
|
||||
if (cc->size->flags & PMinSize) {
|
||||
cc->geom.width = MAX(cc->geom.width, cc->size->min_width);
|
||||
cc->geom.height = MAX(cc->geom.height, cc->size->min_height);
|
||||
}
|
||||
|
||||
if (cc->size->flags & PMaxSize) {
|
||||
cc->geom.width = MIN(cc->geom.width, cc->size->max_width);
|
||||
cc->geom.height = MIN(cc->geom.height, cc->size->max_height);
|
||||
}
|
||||
client_applysizehints(cc);
|
||||
|
||||
cc->geom.x = x <= mx ? x : x - cc->geom.width;
|
||||
cc->geom.y = y <= my ? y : y - cc->geom.height;
|
||||
@ -59,17 +53,17 @@ mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my)
|
||||
static void
|
||||
mousefunc_sweep_draw(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
char asize[10]; /* fits "nnnnxnnnn\0" */
|
||||
int width, height, width_size, width_name;
|
||||
|
||||
snprintf(asize, sizeof(asize), "%dx%d",
|
||||
(cc->geom.width - cc->geom.min_dx) / cc->size->width_inc,
|
||||
(cc->geom.height - cc->geom.min_dy) / cc->size->height_inc);
|
||||
width_size = font_width(asize, strlen(asize)) + 4;
|
||||
width_name = font_width(cc->name, strlen(cc->name)) + 4;
|
||||
(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() + font_descent() + 1;
|
||||
height = font_ascent(sc) + font_descent(sc) + 1;
|
||||
|
||||
XMoveResizeWindow(X_Dpy, sc->menuwin, cc->geom.x, cc->geom.y,
|
||||
width, height * 2);
|
||||
@ -77,9 +71,9 @@ mousefunc_sweep_draw(struct client_ctx *cc)
|
||||
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() + 1);
|
||||
2, font_ascent(sc) + 1);
|
||||
font_draw(sc, asize, strlen(asize), sc->menuwin,
|
||||
width / 2 - width_size / 2, height + font_ascent() + 1);
|
||||
width / 2 - width_size / 2, height + font_ascent(sc) + 1);
|
||||
}
|
||||
|
||||
void
|
||||
@ -87,12 +81,9 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
XEvent ev;
|
||||
Time time = 0;
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
struct screen_ctx *sc = cc->sc;
|
||||
int x = cc->geom.x, y = cc->geom.y;
|
||||
|
||||
cc->size->width_inc = MAX(1, cc->size->width_inc);
|
||||
cc->size->height_inc = MAX(1, cc->size->height_inc);
|
||||
|
||||
client_raise(cc);
|
||||
client_ptrsave(cc);
|
||||
|
||||
@ -216,11 +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;
|
||||
struct client_ctx *old_cc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
char *wname;
|
||||
|
||||
sc = cc->sc;
|
||||
old_cc = client_current();
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
@ -239,7 +232,7 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
|
||||
if (TAILQ_EMPTY(&menuq))
|
||||
return;
|
||||
|
||||
mi = menu_filter(&menuq, NULL, NULL, 0, NULL, NULL);
|
||||
mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL);
|
||||
if (mi != NULL) {
|
||||
cc = (struct client_ctx *)mi->ctx;
|
||||
client_unhide(cc);
|
||||
@ -258,9 +251,12 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
struct cmd *cmd;
|
||||
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) {
|
||||
@ -272,7 +268,7 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
|
||||
if (TAILQ_EMPTY(&menuq))
|
||||
return;
|
||||
|
||||
mi = menu_filter(&menuq, NULL, NULL, 0, NULL, NULL);
|
||||
mi = menu_filter(sc, &menuq, NULL, NULL, 0, NULL, NULL);
|
||||
if (mi != NULL)
|
||||
u_spawn(((struct cmd *)mi->ctx)->image);
|
||||
else
|
||||
|
39
parse.y
39
parse.y
@ -21,7 +21,11 @@
|
||||
|
||||
%{
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
@ -29,7 +33,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
|
||||
@ -123,29 +126,13 @@ main : FONTNAME STRING {
|
||||
free($3);
|
||||
}
|
||||
| AUTOGROUP NUMBER STRING {
|
||||
struct autogroupwin *aw;
|
||||
char *p;
|
||||
|
||||
if ($2 < 0 || $2 > 9) {
|
||||
free($3);
|
||||
yyerror("autogroup number out of range: %d", $2);
|
||||
YYERROR;
|
||||
}
|
||||
|
||||
aw = xcalloc(1, sizeof(*aw));
|
||||
|
||||
if ((p = strchr($3, ',')) == NULL) {
|
||||
aw->name = NULL;
|
||||
aw->class = xstrdup($3);
|
||||
} else {
|
||||
*(p++) = '\0';
|
||||
aw->name = xstrdup($3);
|
||||
aw->class = xstrdup(p);
|
||||
}
|
||||
aw->group = xstrdup(shortcut_to_name[$2]);
|
||||
|
||||
TAILQ_INSERT_TAIL(&conf->autogroupq, aw, entry);
|
||||
|
||||
group_make_autogroup(conf, $3, $2);
|
||||
free($3);
|
||||
}
|
||||
| IGNORE STRING {
|
||||
@ -163,10 +150,10 @@ main : FONTNAME STRING {
|
||||
free($3);
|
||||
}
|
||||
| GAP NUMBER NUMBER NUMBER NUMBER {
|
||||
conf->gap_top = $2;
|
||||
conf->gap_bottom = $3;
|
||||
conf->gap_left = $4;
|
||||
conf->gap_right = $5;
|
||||
conf->gap.top = $2;
|
||||
conf->gap.bottom = $3;
|
||||
conf->gap.left = $4;
|
||||
conf->gap.right = $5;
|
||||
}
|
||||
| MOUSEBIND STRING string {
|
||||
conf_mousebind(conf, $2, $3);
|
||||
@ -379,9 +366,10 @@ yylex(void)
|
||||
return (0);
|
||||
if (next == quotec || c == ' ' || c == '\t')
|
||||
c = next;
|
||||
else if (next == '\n')
|
||||
else if (next == '\n') {
|
||||
file->lineno++;
|
||||
continue;
|
||||
else
|
||||
} else
|
||||
lungetc(next);
|
||||
} else if (c == quotec) {
|
||||
*p = '\0';
|
||||
@ -535,6 +523,7 @@ parse_config(const char *filename, struct conf *xconf)
|
||||
xconf->flags = conf->flags;
|
||||
xconf->bwidth = conf->bwidth;
|
||||
xconf->mamount = conf->mamount;
|
||||
xconf->gap = conf->gap;
|
||||
|
||||
while ((cmd = TAILQ_FIRST(&conf->cmdq)) != NULL) {
|
||||
TAILQ_REMOVE(&conf->cmdq, cmd, entry);
|
||||
@ -570,8 +559,6 @@ parse_config(const char *filename, struct conf *xconf)
|
||||
xconf->color[i].name = conf->color[i].name;
|
||||
|
||||
xconf->DefaultFontName = conf->DefaultFontName;
|
||||
|
||||
bcopy(&(conf->gap_top), &(xconf->gap_top), sizeof(int) * 4);
|
||||
}
|
||||
|
||||
free(conf);
|
||||
|
58
screen.c
58
screen.c
@ -18,17 +18,18 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#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"
|
||||
|
||||
extern struct screen_ctx *Curscreen;
|
||||
|
||||
void
|
||||
screen_init(void)
|
||||
{
|
||||
TAILQ_INIT(&Screenq);
|
||||
}
|
||||
|
||||
struct screen_ctx *
|
||||
screen_fromroot(Window rootwin)
|
||||
{
|
||||
@ -42,22 +43,13 @@ screen_fromroot(Window rootwin)
|
||||
return (TAILQ_FIRST(&Screenq));
|
||||
}
|
||||
|
||||
struct screen_ctx *
|
||||
screen_current(void)
|
||||
{
|
||||
return (Curscreen);
|
||||
}
|
||||
|
||||
void
|
||||
screen_updatestackingorder(void)
|
||||
screen_updatestackingorder(struct screen_ctx *sc)
|
||||
{
|
||||
Window *wins, w0, w1;
|
||||
struct screen_ctx *sc;
|
||||
struct client_ctx *cc;
|
||||
u_int nwins, i, s;
|
||||
|
||||
sc = screen_current();
|
||||
|
||||
if (!XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins))
|
||||
return;
|
||||
|
||||
@ -83,10 +75,10 @@ screen_init_xinerama(struct screen_ctx *sc)
|
||||
HasXinerama = 0;
|
||||
sc->xinerama_no = 0;
|
||||
}
|
||||
|
||||
|
||||
info = XineramaQueryScreens(X_Dpy, &no);
|
||||
if (info == NULL) {
|
||||
/*is xinerama is actually off, instead of a malloc failure? */
|
||||
/* Is xinerama actually off, instead of a malloc failure? */
|
||||
if (sc->xinerama == NULL)
|
||||
HasXinerama = 0;
|
||||
return;
|
||||
@ -115,3 +107,27 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y)
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
screen_update_geometry(struct screen_ctx *sc, int width, int height)
|
||||
{
|
||||
long geom[2], workareas[CALMWM_NGROUPS][4];
|
||||
int i;
|
||||
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
23
search.c
23
search.c
@ -17,8 +17,18 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include "headers.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
static int strsubmatch(char *, char *, int);
|
||||
@ -68,11 +78,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* See if there is a match on the window class
|
||||
* name.
|
||||
*/
|
||||
|
||||
/* Then if there is a match on the window class name. */
|
||||
if (tier < 0 && strsubmatch(search, cc->app_class, 0)) {
|
||||
cc->matchname = cc->app_class;
|
||||
tier = 3;
|
||||
@ -89,9 +95,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
if (cc == client_current() && tier < ntiers - 1)
|
||||
tier++;
|
||||
|
||||
/*
|
||||
* Clients that are hidden get ranked one up.
|
||||
*/
|
||||
/* Clients that are hidden get ranked one up. */
|
||||
if (cc->flags & CLIENT_HIDDEN && tier > 0)
|
||||
tier--;
|
||||
|
||||
@ -104,7 +108,6 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
* Always make your current tierp the newly inserted
|
||||
* entry.
|
||||
*/
|
||||
|
||||
for (t = tier; t >= 0 && ((before = tierp[t]) == NULL); t--)
|
||||
;
|
||||
|
||||
|
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
@ -18,7 +18,16 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#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"
|
||||
|
||||
#define MAXARGLEN 20
|
||||
|
65
xevents.c
65
xevents.c
@ -24,7 +24,17 @@
|
||||
* management of the xevent's.
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "calmwm.h"
|
||||
|
||||
static void xev_handle_maprequest(XEvent *);
|
||||
@ -67,6 +77,7 @@ 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);
|
||||
@ -76,6 +87,11 @@ xev_handle_maprequest(XEvent *ee)
|
||||
cc = client_new(e->window, screen_fromroot(xattr.root), 1);
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(wm, &Conf.ignoreq, entry) {
|
||||
if (strncasecmp(wm->title, cc->name, strlen(wm->title)) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
||||
@ -125,7 +141,7 @@ xev_handle_configurerequest(XEvent *ee)
|
||||
XWindowChanges wc;
|
||||
|
||||
if ((cc = client_find(e->window)) != NULL) {
|
||||
sc = CCTOSC(cc);
|
||||
sc = cc->sc;
|
||||
|
||||
if (e->value_mask & CWWidth)
|
||||
cc->geom.width = e->width;
|
||||
@ -170,13 +186,13 @@ static void
|
||||
xev_handle_propertynotify(XEvent *ee)
|
||||
{
|
||||
XPropertyEvent *e = &ee->xproperty;
|
||||
struct screen_ctx *sc;
|
||||
struct client_ctx *cc;
|
||||
long tmp;
|
||||
|
||||
if ((cc = client_find(e->window)) != NULL) {
|
||||
switch (e->atom) {
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp);
|
||||
client_getsizehints(cc);
|
||||
break;
|
||||
case XA_WM_NAME:
|
||||
client_setname(cc);
|
||||
@ -185,7 +201,17 @@ xev_handle_propertynotify(XEvent *ee)
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
TAILQ_FOREACH(sc, &Screenq, entry)
|
||||
if (sc->rootwin == e->window)
|
||||
goto test;
|
||||
return;
|
||||
|
||||
test:
|
||||
if (e->atom == _NET_DESKTOP_NAMES)
|
||||
group_update_names(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@ -228,7 +254,7 @@ static void
|
||||
xev_handle_buttonpress(XEvent *ee)
|
||||
{
|
||||
XButtonEvent *e = &ee->xbutton;
|
||||
struct client_ctx *cc;
|
||||
struct client_ctx *cc, fakecc;
|
||||
struct screen_ctx *sc;
|
||||
struct mousebinding *mb;
|
||||
|
||||
@ -245,15 +271,13 @@ xev_handle_buttonpress(XEvent *ee)
|
||||
|
||||
if (mb == NULL)
|
||||
return;
|
||||
|
||||
if (mb->context == MOUSEBIND_CTX_ROOT) {
|
||||
if (e->window != sc->rootwin)
|
||||
return;
|
||||
} else if (mb->context == MOUSEBIND_CTX_WIN) {
|
||||
cc = client_find(e->window);
|
||||
if (cc == NULL)
|
||||
return;
|
||||
}
|
||||
cc = &fakecc;
|
||||
cc->sc = screen_fromroot(e->window);
|
||||
} else if (cc == NULL) /* (mb->context == MOUSEBIND_CTX_WIN */
|
||||
return;
|
||||
|
||||
(*mb->callback)(cc, e);
|
||||
}
|
||||
@ -271,7 +295,7 @@ static void
|
||||
xev_handle_keypress(XEvent *ee)
|
||||
{
|
||||
XKeyEvent *e = &ee->xkey;
|
||||
struct client_ctx *cc = NULL;
|
||||
struct client_ctx *cc = NULL, fakecc;
|
||||
struct keybinding *kb;
|
||||
KeySym keysym, skeysym;
|
||||
int modshift;
|
||||
@ -299,12 +323,14 @@ xev_handle_keypress(XEvent *ee)
|
||||
|
||||
if (kb == NULL)
|
||||
return;
|
||||
|
||||
if ((kb->flags & (KBFLAG_NEEDCLIENT)) &&
|
||||
(cc = client_find(e->window)) == NULL &&
|
||||
(cc = client_current()) == NULL)
|
||||
if (kb->flags & KBFLAG_NEEDCLIENT)
|
||||
if (kb->flags & KBFLAG_NEEDCLIENT) {
|
||||
if (((cc = client_find(e->window)) == NULL) &&
|
||||
(cc = client_current()) == NULL)
|
||||
return;
|
||||
} else {
|
||||
cc = &fakecc;
|
||||
cc->sc = screen_fromroot(e->window);
|
||||
}
|
||||
|
||||
(*kb->callback)(cc, &kb->argument);
|
||||
}
|
||||
@ -369,14 +395,13 @@ xev_handle_randr(XEvent *ee)
|
||||
TAILQ_FOREACH(sc, &Screenq, entry) {
|
||||
if (sc->which == (u_int)i) {
|
||||
XRRUpdateConfiguration(ee);
|
||||
sc->xmax = rev->width;
|
||||
sc->ymax = rev->height;
|
||||
screen_update_geometry(sc, rev->width, rev->height);
|
||||
screen_init_xinerama(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Called when the keymap has changed.
|
||||
* Ungrab all keys, reload keymap and then regrab
|
||||
*/
|
||||
|
11
xmalloc.c
11
xmalloc.c
@ -18,7 +18,16 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#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"
|
||||
|
||||
void *
|
||||
|
96
xutil.c
96
xutil.c
@ -18,7 +18,16 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#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"
|
||||
|
||||
static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
|
||||
@ -110,29 +119,29 @@ xu_key_ungrab(Window win, int mask, int keysym)
|
||||
}
|
||||
|
||||
void
|
||||
xu_sendmsg(struct client_ctx *cc, Atom atm, long val)
|
||||
xu_sendmsg(Window win, Atom atm, long val)
|
||||
{
|
||||
XEvent e;
|
||||
|
||||
memset(&e, 0, sizeof(e));
|
||||
e.xclient.type = ClientMessage;
|
||||
e.xclient.window = cc->win;
|
||||
e.xclient.window = win;
|
||||
e.xclient.message_type = atm;
|
||||
e.xclient.format = 32;
|
||||
e.xclient.data.l[0] = val;
|
||||
e.xclient.data.l[1] = CurrentTime;
|
||||
|
||||
XSendEvent(X_Dpy, cc->win, False, 0, &e);
|
||||
XSendEvent(X_Dpy, win, False, 0, &e);
|
||||
}
|
||||
|
||||
int
|
||||
xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
|
||||
xu_getprop(Window win, Atom atm, Atom type, long len, u_char **p)
|
||||
{
|
||||
Atom realtype;
|
||||
u_long n, extra;
|
||||
int format;
|
||||
|
||||
if (XGetWindowProperty(X_Dpy, cc->win, atm, 0L, len, False, type,
|
||||
if (XGetWindowProperty(X_Dpy, win, atm, 0L, len, False, type,
|
||||
&realtype, &format, &n, &extra, p) != Success || *p == NULL)
|
||||
return (-1);
|
||||
|
||||
@ -142,12 +151,44 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
|
||||
return (n);
|
||||
}
|
||||
|
||||
int
|
||||
xu_getstrprop(Window win, Atom atm, char **text) {
|
||||
XTextProperty prop;
|
||||
char **list;
|
||||
int nitems = 0;
|
||||
|
||||
*text = NULL;
|
||||
|
||||
XGetTextProperty(X_Dpy, win, &prop, atm);
|
||||
if (!prop.nitems)
|
||||
return (0);
|
||||
|
||||
if (Xutf8TextPropertyToTextList(X_Dpy, &prop, &list,
|
||||
&nitems) == Success && nitems > 0 && *list) {
|
||||
if (nitems > 1) {
|
||||
XTextProperty prop2;
|
||||
if (Xutf8TextListToTextProperty(X_Dpy, list, nitems,
|
||||
XUTF8StringStyle, &prop2) == Success) {
|
||||
*text = xstrdup(prop2.value);
|
||||
XFree(prop2.value);
|
||||
}
|
||||
} else {
|
||||
*text = xstrdup(*list);
|
||||
}
|
||||
XFreeStringList(list);
|
||||
}
|
||||
|
||||
XFree(prop.value);
|
||||
|
||||
return (nitems);
|
||||
}
|
||||
|
||||
int
|
||||
xu_getstate(struct client_ctx *cc, int *state)
|
||||
{
|
||||
long *p = NULL;
|
||||
|
||||
if (xu_getprop(cc, WM_STATE, WM_STATE, 2L, (u_char **)&p) <= 0)
|
||||
if (xu_getprop(cc->win, WM_STATE, WM_STATE, 2L, (u_char **)&p) <= 0)
|
||||
return (-1);
|
||||
|
||||
*state = (int)*p;
|
||||
@ -176,7 +217,21 @@ char *atoms[CWM_NO_ATOMS] = {
|
||||
"WM_TAKE_FOCUS",
|
||||
"WM_PROTOCOLS",
|
||||
"_MOTIF_WM_HINTS",
|
||||
"_CWM_GRP",
|
||||
"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
|
||||
@ -185,6 +240,31 @@ xu_getatoms(void)
|
||||
XInternAtoms(X_Dpy, atoms, CWM_NO_ATOMS, False, cwm_atoms);
|
||||
}
|
||||
|
||||
void
|
||||
xu_setwmname(struct screen_ctx *sc)
|
||||
{
|
||||
/*
|
||||
* set up the _NET_SUPPORTED hint with all netwm atoms that we
|
||||
* know about.
|
||||
*/
|
||||
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
|
||||
xu_getcolor(struct screen_ctx *sc, char *name)
|
||||
{
|
||||
|
Reference in New Issue
Block a user