mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Merge branch 'linux' of git://github.com/chneukirchen/cwm into linux
This commit is contained in:
2
Makefile
2
Makefile
@ -26,7 +26,7 @@ MANPREFIX= ${PREFIX}/share/man
|
|||||||
all: ${PROG}
|
all: ${PROG}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf ${OBJS} ${PROG} y.tab.c
|
rm -f ${OBJS} ${PROG} y.tab.c
|
||||||
|
|
||||||
y.tab.c: parse.y
|
y.tab.c: parse.y
|
||||||
yacc parse.y
|
yacc parse.y
|
||||||
|
10
calmwm.h
10
calmwm.h
@ -152,11 +152,11 @@ struct client_ctx {
|
|||||||
TAILQ_ENTRY(client_ctx) mru_entry;
|
TAILQ_ENTRY(client_ctx) mru_entry;
|
||||||
struct screen_ctx *sc;
|
struct screen_ctx *sc;
|
||||||
Window win;
|
Window win;
|
||||||
XSizeHints *size;
|
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
u_int bwidth; /* border width */
|
u_int bwidth; /* border width */
|
||||||
struct geom geom, savegeom;
|
struct geom geom, savegeom;
|
||||||
struct {
|
struct {
|
||||||
|
long flags; /* defined hints */
|
||||||
int basew; /* desired width */
|
int basew; /* desired width */
|
||||||
int baseh; /* desired height */
|
int baseh; /* desired height */
|
||||||
int minw; /* minimum width */
|
int minw; /* minimum width */
|
||||||
@ -180,6 +180,7 @@ struct client_ctx {
|
|||||||
#define CLIENT_FREEZE 0x0010
|
#define CLIENT_FREEZE 0x0010
|
||||||
#define CLIENT_GROUP 0x0020
|
#define CLIENT_GROUP 0x0020
|
||||||
#define CLIENT_UNGROUP 0x0040
|
#define CLIENT_UNGROUP 0x0040
|
||||||
|
#define CLIENT_INPUT 0x0080
|
||||||
|
|
||||||
#define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP)
|
#define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP)
|
||||||
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
|
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
|
||||||
@ -397,7 +398,7 @@ struct client_ctx *client_current(void);
|
|||||||
void client_cycle(struct screen_ctx *, int);
|
void client_cycle(struct screen_ctx *, int);
|
||||||
void client_cycle_leave(struct screen_ctx *,
|
void client_cycle_leave(struct screen_ctx *,
|
||||||
struct client_ctx *);
|
struct client_ctx *);
|
||||||
void client_delete(struct client_ctx *);
|
void client_delete(struct client_ctx *, int);
|
||||||
void client_draw_border(struct client_ctx *);
|
void client_draw_border(struct client_ctx *);
|
||||||
struct client_ctx *client_find(Window);
|
struct client_ctx *client_find(Window);
|
||||||
void client_freeze(struct client_ctx *);
|
void client_freeze(struct client_ctx *);
|
||||||
@ -536,11 +537,12 @@ void conf_screen(struct screen_ctx *);
|
|||||||
void xev_loop(void);
|
void xev_loop(void);
|
||||||
|
|
||||||
void xu_btn_grab(Window, int, u_int);
|
void xu_btn_grab(Window, int, u_int);
|
||||||
void xu_btn_ungrab(Window, int, u_int);
|
void xu_btn_ungrab(Window);
|
||||||
int xu_getprop(Window, Atom, Atom, long, u_char **);
|
int xu_getprop(Window, Atom, Atom, long, unsigned char **);
|
||||||
int xu_get_wm_state(Window, int *);
|
int xu_get_wm_state(Window, int *);
|
||||||
int xu_getstrprop(Window, Atom, char **);
|
int xu_getstrprop(Window, Atom, char **);
|
||||||
void xu_key_grab(Window, u_int, KeySym);
|
void xu_key_grab(Window, u_int, KeySym);
|
||||||
|
void xu_key_ungrab(Window);
|
||||||
void xu_ptr_getpos(Window, int *, int *);
|
void xu_ptr_getpos(Window, int *, int *);
|
||||||
int xu_ptr_grab(Window, u_int, Cursor);
|
int xu_ptr_grab(Window, u_int, Cursor);
|
||||||
int xu_ptr_regrab(u_int, Cursor);
|
int xu_ptr_regrab(u_int, Cursor);
|
||||||
|
124
client.c
124
client.c
@ -73,7 +73,6 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
|
|||||||
cc->state = mapped ? NormalState : IconicState;
|
cc->state = mapped ? NormalState : IconicState;
|
||||||
cc->sc = sc;
|
cc->sc = sc;
|
||||||
cc->win = win;
|
cc->win = win;
|
||||||
cc->size = XAllocSizeHints();
|
|
||||||
|
|
||||||
client_getsizehints(cc);
|
client_getsizehints(cc);
|
||||||
|
|
||||||
@ -99,17 +98,22 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
|
|||||||
cc->geom.h = wattr.height;
|
cc->geom.h = wattr.height;
|
||||||
cc->colormap = wattr.colormap;
|
cc->colormap = wattr.colormap;
|
||||||
|
|
||||||
|
if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) {
|
||||||
|
if (wmhints->flags & InputHint) {
|
||||||
|
if (wmhints->input == 1)
|
||||||
|
cc->flags |= CLIENT_INPUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (wattr.map_state != IsViewable) {
|
if (wattr.map_state != IsViewable) {
|
||||||
client_placecalc(cc);
|
client_placecalc(cc);
|
||||||
client_move(cc);
|
client_move(cc);
|
||||||
if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) {
|
if ((wmhints) && (wmhints->flags & StateHint)) {
|
||||||
if (wmhints->flags & StateHint) {
|
cc->state = wmhints->initial_state;
|
||||||
cc->state = wmhints->initial_state;
|
xu_set_wm_state(cc->win, cc->state);
|
||||||
xu_set_wm_state(cc->win, cc->state);
|
|
||||||
}
|
|
||||||
XFree(wmhints);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (wmhints)
|
||||||
|
XFree(wmhints);
|
||||||
client_draw_border(cc);
|
client_draw_border(cc);
|
||||||
|
|
||||||
if (xu_get_wm_state(cc->win, &state) < 0)
|
if (xu_get_wm_state(cc->win, &state) < 0)
|
||||||
@ -145,17 +149,19 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
client_delete(struct client_ctx *cc)
|
client_delete(struct client_ctx *cc, int destroy)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct winname *wn;
|
struct winname *wn;
|
||||||
|
|
||||||
XGrabServer(X_Dpy);
|
if (destroy) {
|
||||||
cc->state = WithdrawnState;
|
XGrabServer(X_Dpy);
|
||||||
xu_set_wm_state(cc->win, cc->state);
|
cc->state = WithdrawnState;
|
||||||
XRemoveFromSaveSet(X_Dpy, cc->win);
|
xu_set_wm_state(cc->win, cc->state);
|
||||||
XSync(X_Dpy, False);
|
XRemoveFromSaveSet(X_Dpy, cc->win);
|
||||||
XUngrabServer(X_Dpy);
|
XSync(X_Dpy, False);
|
||||||
|
XUngrabServer(X_Dpy);
|
||||||
|
}
|
||||||
|
|
||||||
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
|
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
|
||||||
TAILQ_REMOVE(&Clientq, cc, entry);
|
TAILQ_REMOVE(&Clientq, cc, entry);
|
||||||
@ -168,7 +174,6 @@ client_delete(struct client_ctx *cc)
|
|||||||
if (cc == client_current())
|
if (cc == client_current())
|
||||||
client_none(sc);
|
client_none(sc);
|
||||||
|
|
||||||
XFree(cc->size);
|
|
||||||
if (cc->app_name != NULL)
|
if (cc->app_name != NULL)
|
||||||
XFree(cc->app_name);
|
XFree(cc->app_name);
|
||||||
if (cc->app_class != NULL)
|
if (cc->app_class != NULL)
|
||||||
@ -186,15 +191,10 @@ client_delete(struct client_ctx *cc)
|
|||||||
void
|
void
|
||||||
client_leave(struct client_ctx *cc)
|
client_leave(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc;
|
|
||||||
|
|
||||||
if (cc == NULL)
|
if (cc == NULL)
|
||||||
cc = client_current();
|
cc = client_current();
|
||||||
if (cc == NULL)
|
if (cc == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sc = cc->sc;
|
|
||||||
xu_btn_ungrab(sc->rootwin, AnyModifier, Button1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -211,8 +211,12 @@ client_setactive(struct client_ctx *cc, int fg)
|
|||||||
|
|
||||||
if (fg) {
|
if (fg) {
|
||||||
XInstallColormap(X_Dpy, cc->colormap);
|
XInstallColormap(X_Dpy, cc->colormap);
|
||||||
XSetInputFocus(X_Dpy, cc->win,
|
if (cc->flags & CLIENT_INPUT) {
|
||||||
RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(X_Dpy, cc->win,
|
||||||
|
RevertToPointerRoot, CurrentTime);
|
||||||
|
}
|
||||||
|
if (cc->xproto & _WM_TAKE_FOCUS)
|
||||||
|
client_msg(cc, cwmh[WM_TAKE_FOCUS]);
|
||||||
conf_grab_mouse(cc->win);
|
conf_grab_mouse(cc->win);
|
||||||
/*
|
/*
|
||||||
* If we're in the middle of alt-tabbing, don't change
|
* If we're in the middle of alt-tabbing, don't change
|
||||||
@ -396,8 +400,6 @@ client_resize(struct client_ctx *cc, int reset)
|
|||||||
xu_ewmh_set_net_wm_state(cc);
|
xu_ewmh_set_net_wm_state(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
client_draw_border(cc);
|
|
||||||
|
|
||||||
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x,
|
||||||
cc->geom.y, cc->geom.w, cc->geom.h);
|
cc->geom.y, cc->geom.w, cc->geom.h);
|
||||||
client_config(cc);
|
client_config(cc);
|
||||||
@ -493,7 +495,6 @@ client_unhide(struct client_ctx *cc)
|
|||||||
cc->flags &= ~CLIENT_HIDDEN;
|
cc->flags &= ~CLIENT_HIDDEN;
|
||||||
cc->state = NormalState;
|
cc->state = NormalState;
|
||||||
xu_set_wm_state(cc->win, cc->state);
|
xu_set_wm_state(cc->win, cc->state);
|
||||||
client_draw_border(cc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -682,7 +683,7 @@ client_placecalc(struct client_ctx *cc)
|
|||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
int xslack, yslack;
|
int xslack, yslack;
|
||||||
|
|
||||||
if (cc->size->flags & (USPosition|PPosition)) {
|
if (cc->hint.flags & (USPosition|PPosition)) {
|
||||||
/*
|
/*
|
||||||
* Ignore XINERAMA screens, just make sure it's somewhere
|
* Ignore XINERAMA screens, just make sure it's somewhere
|
||||||
* in the virtual desktop. else it stops people putting xterms
|
* in the virtual desktop. else it stops people putting xterms
|
||||||
@ -692,10 +693,8 @@ client_placecalc(struct client_ctx *cc)
|
|||||||
*/
|
*/
|
||||||
xslack = sc->view.w - cc->geom.w - cc->bwidth * 2;
|
xslack = sc->view.w - cc->geom.w - cc->bwidth * 2;
|
||||||
yslack = sc->view.h - cc->geom.h - cc->bwidth * 2;
|
yslack = sc->view.h - cc->geom.h - cc->bwidth * 2;
|
||||||
if (cc->size->x > 0)
|
cc->geom.x = MIN(cc->geom.x, xslack);
|
||||||
cc->geom.x = MIN(cc->size->x, xslack);
|
cc->geom.y = MIN(cc->geom.y, yslack);
|
||||||
if (cc->size->y > 0)
|
|
||||||
cc->geom.y = MIN(cc->size->y, yslack);
|
|
||||||
} else {
|
} else {
|
||||||
struct geom xine;
|
struct geom xine;
|
||||||
int xmouse, ymouse;
|
int xmouse, ymouse;
|
||||||
@ -747,43 +746,52 @@ void
|
|||||||
client_getsizehints(struct client_ctx *cc)
|
client_getsizehints(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
long tmp;
|
long tmp;
|
||||||
|
XSizeHints *size;
|
||||||
|
|
||||||
if (!XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp))
|
if ((size = XAllocSizeHints()) == NULL)
|
||||||
cc->size->flags = PSize;
|
warnx("XAllocSizeHints failure");
|
||||||
|
|
||||||
if (cc->size->flags & PBaseSize) {
|
if (!XGetWMNormalHints(X_Dpy, cc->win, size, &tmp))
|
||||||
cc->hint.basew = cc->size->base_width;
|
size->flags = 0;
|
||||||
cc->hint.baseh = cc->size->base_height;
|
|
||||||
} else if (cc->size->flags & PMinSize) {
|
cc->hint.flags = size->flags;
|
||||||
cc->hint.basew = cc->size->min_width;
|
|
||||||
cc->hint.baseh = cc->size->min_height;
|
if (size->flags & PBaseSize) {
|
||||||
|
cc->hint.basew = size->base_width;
|
||||||
|
cc->hint.baseh = size->base_height;
|
||||||
|
} else if (size->flags & PMinSize) {
|
||||||
|
cc->hint.basew = size->min_width;
|
||||||
|
cc->hint.baseh = size->min_height;
|
||||||
}
|
}
|
||||||
if (cc->size->flags & PMinSize) {
|
if (size->flags & PMinSize) {
|
||||||
cc->hint.minw = cc->size->min_width;
|
cc->hint.minw = size->min_width;
|
||||||
cc->hint.minh = cc->size->min_height;
|
cc->hint.minh = size->min_height;
|
||||||
} else if (cc->size->flags & PBaseSize) {
|
} else if (size->flags & PBaseSize) {
|
||||||
cc->hint.minw = cc->size->base_width;
|
cc->hint.minw = size->base_width;
|
||||||
cc->hint.minh = cc->size->base_height;
|
cc->hint.minh = size->base_height;
|
||||||
}
|
}
|
||||||
if (cc->size->flags & PMaxSize) {
|
if (size->flags & PMaxSize) {
|
||||||
cc->hint.maxw = cc->size->max_width;
|
cc->hint.maxw = size->max_width;
|
||||||
cc->hint.maxh = cc->size->max_height;
|
cc->hint.maxh = size->max_height;
|
||||||
}
|
}
|
||||||
if (cc->size->flags & PResizeInc) {
|
if (size->flags & PResizeInc) {
|
||||||
cc->hint.incw = cc->size->width_inc;
|
cc->hint.incw = size->width_inc;
|
||||||
cc->hint.inch = cc->size->height_inc;
|
cc->hint.inch = size->height_inc;
|
||||||
}
|
}
|
||||||
cc->hint.incw = MAX(1, cc->hint.incw);
|
cc->hint.incw = MAX(1, cc->hint.incw);
|
||||||
cc->hint.inch = MAX(1, cc->hint.inch);
|
cc->hint.inch = MAX(1, cc->hint.inch);
|
||||||
|
|
||||||
if (cc->size->flags & PAspect) {
|
if (size->flags & PAspect) {
|
||||||
if (cc->size->min_aspect.x > 0)
|
if (size->min_aspect.x > 0)
|
||||||
cc->hint.mina = (float)cc->size->min_aspect.y /
|
cc->hint.mina = (float)size->min_aspect.y /
|
||||||
cc->size->min_aspect.x;
|
size->min_aspect.x;
|
||||||
if (cc->size->max_aspect.y > 0)
|
if (size->max_aspect.y > 0)
|
||||||
cc->hint.maxa = (float)cc->size->max_aspect.x /
|
cc->hint.maxa = (float)size->max_aspect.x /
|
||||||
cc->size->max_aspect.y;
|
size->max_aspect.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
XFree(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -841,7 +849,7 @@ client_getmwmhints(struct client_ctx *cc)
|
|||||||
struct mwm_hints *mwmh;
|
struct mwm_hints *mwmh;
|
||||||
|
|
||||||
if (xu_getprop(cc->win, cwmh[_MOTIF_WM_HINTS], cwmh[_MOTIF_WM_HINTS],
|
if (xu_getprop(cc->win, cwmh[_MOTIF_WM_HINTS], cwmh[_MOTIF_WM_HINTS],
|
||||||
PROP_MWM_HINTS_ELEMENTS, (u_char **)&mwmh) == MWM_NUMHINTS)
|
PROP_MWM_HINTS_ELEMENTS, (unsigned char **)&mwmh) == MWM_NUMHINTS)
|
||||||
if (mwmh->flags & MWM_HINTS_DECORATIONS &&
|
if (mwmh->flags & MWM_HINTS_DECORATIONS &&
|
||||||
!(mwmh->decorations & MWM_DECOR_ALL) &&
|
!(mwmh->decorations & MWM_DECOR_ALL) &&
|
||||||
!(mwmh->decorations & MWM_DECOR_BORDER))
|
!(mwmh->decorations & MWM_DECOR_BORDER))
|
||||||
|
13
conf.c
13
conf.c
@ -104,9 +104,12 @@ conf_screen(struct screen_ctx *sc)
|
|||||||
|
|
||||||
sc->gap = Conf.gap;
|
sc->gap = Conf.gap;
|
||||||
|
|
||||||
sc->xftfont = XftFontOpenName(X_Dpy, sc->which, Conf.font);
|
sc->xftfont = XftFontOpenXlfd(X_Dpy, sc->which, Conf.font);
|
||||||
if (sc->xftfont == NULL)
|
if (sc->xftfont == NULL) {
|
||||||
errx(1, "XftFontOpenName");
|
sc->xftfont = XftFontOpenName(X_Dpy, sc->which, Conf.font);
|
||||||
|
if (sc->xftfont == NULL)
|
||||||
|
errx(1, "XftFontOpenName");
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < nitems(color_binds); i++) {
|
for (i = 0; i < nitems(color_binds); i++) {
|
||||||
if (i == CWM_COLOR_MENU_FONT_SEL && *Conf.color[i] == '\0') {
|
if (i == CWM_COLOR_MENU_FONT_SEL && *Conf.color[i] == '\0') {
|
||||||
@ -672,6 +675,8 @@ conf_grab_mouse(Window win)
|
|||||||
{
|
{
|
||||||
struct mousebinding *mb;
|
struct mousebinding *mb;
|
||||||
|
|
||||||
|
xu_btn_ungrab(win);
|
||||||
|
|
||||||
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
|
||||||
if (mb->flags != MOUSEBIND_CTX_WIN)
|
if (mb->flags != MOUSEBIND_CTX_WIN)
|
||||||
continue;
|
continue;
|
||||||
@ -684,7 +689,7 @@ conf_grab_kbd(Window win)
|
|||||||
{
|
{
|
||||||
struct keybinding *kb;
|
struct keybinding *kb;
|
||||||
|
|
||||||
XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
|
xu_key_ungrab(win);
|
||||||
|
|
||||||
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
|
||||||
xu_key_grab(win, kb->modmask, kb->keysym);
|
xu_key_grab(win, kb->modmask, kb->keysym);
|
||||||
|
8
group.c
8
group.c
@ -191,7 +191,7 @@ group_movetogroup(struct client_ctx *cc, int idx)
|
|||||||
struct group_ctx *gc;
|
struct group_ctx *gc;
|
||||||
|
|
||||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||||
err(1, "group_movetogroup: index out of range (%d)", idx);
|
errx(1, "group_movetogroup: index out of range (%d)", idx);
|
||||||
|
|
||||||
gc = &sc->groups[idx];
|
gc = &sc->groups[idx];
|
||||||
if (cc->group == gc)
|
if (cc->group == gc)
|
||||||
@ -254,7 +254,7 @@ group_hidetoggle(struct screen_ctx *sc, int idx)
|
|||||||
struct group_ctx *gc;
|
struct group_ctx *gc;
|
||||||
|
|
||||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||||
err(1, "group_hidetoggle: index out of range (%d)", idx);
|
errx(1, "group_hidetoggle: index out of range (%d)", idx);
|
||||||
|
|
||||||
gc = &sc->groups[idx];
|
gc = &sc->groups[idx];
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ group_only(struct screen_ctx *sc, int idx)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||||
err(1, "group_only: index out of range (%d)", idx);
|
errx(1, "group_only: index out of range (%d)", idx);
|
||||||
|
|
||||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||||
if (i == idx)
|
if (i == idx)
|
||||||
@ -478,7 +478,7 @@ group_update_names(struct screen_ctx *sc)
|
|||||||
int i = 0, j = 0, nstrings = 0, n = 0, setnames = 0;
|
int i = 0, j = 0, nstrings = 0, n = 0, setnames = 0;
|
||||||
|
|
||||||
if ((j = xu_getprop(sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
|
if ((j = xu_getprop(sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
|
||||||
cwmh[UTF8_STRING], 0xffffff, (u_char **)&prop_ret)) > 0) {
|
cwmh[UTF8_STRING], 0xffffff, (unsigned char **)&prop_ret)) > 0) {
|
||||||
prop_ret[j - 1] = '\0'; /* paranoia */
|
prop_ret[j - 1] = '\0'; /* paranoia */
|
||||||
while (i < j) {
|
while (i < j) {
|
||||||
if (prop_ret[i++] == '\0')
|
if (prop_ret[i++] == '\0')
|
||||||
|
4
kbfunc.c
4
kbfunc.c
@ -326,7 +326,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
|||||||
label = "wm";
|
label = "wm";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err(1, "kbfunc_exec: invalid cmd %d", cmd);
|
errx(1, "kbfunc_exec: invalid cmd %d", cmd);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
|||||||
warn("%s", mi->text);
|
warn("%s", mi->text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err(1, "kb_func: egad, cmd changed value!");
|
errx(1, "kb_func: egad, cmd changed value!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
mousefunc.c
10
mousefunc.c
@ -88,12 +88,9 @@ mousefunc_client_resize(struct client_ctx *cc, void *arg)
|
|||||||
mousefunc_sweep_draw(cc);
|
mousefunc_sweep_draw(cc);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev);
|
XMaskEvent(X_Dpy, MOUSEMASK, &ev);
|
||||||
|
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case Expose:
|
|
||||||
client_draw_border(cc);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
mousefunc_sweep_calc(cc, x, y,
|
mousefunc_sweep_calc(cc, x, y,
|
||||||
ev.xmotion.x_root, ev.xmotion.y_root);
|
ev.xmotion.x_root, ev.xmotion.y_root);
|
||||||
@ -143,12 +140,9 @@ mousefunc_client_move(struct client_ctx *cc, void *arg)
|
|||||||
xu_ptr_getpos(cc->win, &px, &py);
|
xu_ptr_getpos(cc->win, &px, &py);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
XMaskEvent(X_Dpy, MOUSEMASK|ExposureMask, &ev);
|
XMaskEvent(X_Dpy, MOUSEMASK, &ev);
|
||||||
|
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case Expose:
|
|
||||||
client_draw_border(cc);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
|
cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
|
||||||
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
|
cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
|
||||||
|
@ -113,7 +113,7 @@ xev_handle_unmapnotify(XEvent *ee)
|
|||||||
*/
|
*/
|
||||||
if (XCheckTypedWindowEvent(X_Dpy, cc->win,
|
if (XCheckTypedWindowEvent(X_Dpy, cc->win,
|
||||||
DestroyNotify, &ev) || e->send_event != 0) {
|
DestroyNotify, &ev) || e->send_event != 0) {
|
||||||
client_delete(cc);
|
client_delete(cc, 1);
|
||||||
} else
|
} else
|
||||||
client_hide(cc);
|
client_hide(cc);
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ xev_handle_destroynotify(XEvent *ee)
|
|||||||
struct client_ctx *cc;
|
struct client_ctx *cc;
|
||||||
|
|
||||||
if ((cc = client_find(e->window)) != NULL)
|
if ((cc = client_find(e->window)) != NULL)
|
||||||
client_delete(cc);
|
client_delete(cc, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
81
xutil.c
81
xutil.c
@ -32,6 +32,45 @@
|
|||||||
|
|
||||||
static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
|
static unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask };
|
||||||
|
|
||||||
|
void
|
||||||
|
xu_btn_grab(Window win, int mask, u_int btn)
|
||||||
|
{
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < nitems(ign_mods); i++)
|
||||||
|
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
|
||||||
|
False, BUTTONMASK, GrabModeAsync,
|
||||||
|
GrabModeSync, None, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xu_btn_ungrab(Window win)
|
||||||
|
{
|
||||||
|
XUngrabButton(X_Dpy, AnyButton, AnyModifier, win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xu_key_grab(Window win, u_int mask, KeySym keysym)
|
||||||
|
{
|
||||||
|
KeyCode code;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
code = XKeysymToKeycode(X_Dpy, keysym);
|
||||||
|
if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
|
||||||
|
(XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
|
||||||
|
mask |= ShiftMask;
|
||||||
|
|
||||||
|
for (i = 0; i < nitems(ign_mods); i++)
|
||||||
|
XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
|
||||||
|
True, GrabModeAsync, GrabModeAsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xu_key_ungrab(Window win)
|
||||||
|
{
|
||||||
|
XUngrabKey(X_Dpy, AnyKey, AnyModifier, win);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xu_ptr_grab(Window win, u_int mask, Cursor curs)
|
xu_ptr_grab(Window win, u_int mask, Cursor curs)
|
||||||
{
|
{
|
||||||
@ -53,26 +92,6 @@ xu_ptr_ungrab(void)
|
|||||||
XUngrabPointer(X_Dpy, CurrentTime);
|
XUngrabPointer(X_Dpy, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xu_btn_grab(Window win, int mask, u_int btn)
|
|
||||||
{
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
for (i = 0; i < nitems(ign_mods); i++)
|
|
||||||
XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win,
|
|
||||||
False, BUTTONMASK, GrabModeAsync,
|
|
||||||
GrabModeSync, None, None);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xu_btn_ungrab(Window win, int mask, u_int btn)
|
|
||||||
{
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
for (i = 0; i < nitems(ign_mods); i++)
|
|
||||||
XUngrabButton(X_Dpy, btn, (mask | ign_mods[i]), win);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xu_ptr_getpos(Window win, int *x, int *y)
|
xu_ptr_getpos(Window win, int *x, int *y)
|
||||||
{
|
{
|
||||||
@ -89,24 +108,8 @@ xu_ptr_setpos(Window win, int x, int y)
|
|||||||
XWarpPointer(X_Dpy, None, win, 0, 0, 0, 0, x, y);
|
XWarpPointer(X_Dpy, None, win, 0, 0, 0, 0, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xu_key_grab(Window win, u_int mask, KeySym keysym)
|
|
||||||
{
|
|
||||||
KeyCode code;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
code = XKeysymToKeycode(X_Dpy, keysym);
|
|
||||||
if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
|
|
||||||
(XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
|
|
||||||
mask |= ShiftMask;
|
|
||||||
|
|
||||||
for (i = 0; i < nitems(ign_mods); i++)
|
|
||||||
XGrabKey(X_Dpy, code, (mask | ign_mods[i]), win,
|
|
||||||
True, GrabModeAsync, GrabModeAsync);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
xu_getprop(Window win, Atom atm, Atom type, long len, u_char **p)
|
xu_getprop(Window win, Atom atm, Atom type, long len, unsigned char **p)
|
||||||
{
|
{
|
||||||
Atom realtype;
|
Atom realtype;
|
||||||
u_long n, extra;
|
u_long n, extra;
|
||||||
@ -160,7 +163,7 @@ xu_get_wm_state(Window win, int *state)
|
|||||||
long *p = NULL;
|
long *p = NULL;
|
||||||
|
|
||||||
if (xu_getprop(win, cwmh[WM_STATE], cwmh[WM_STATE], 2L,
|
if (xu_getprop(win, cwmh[WM_STATE], cwmh[WM_STATE], 2L,
|
||||||
(u_char **)&p) <= 0)
|
(unsigned char **)&p) <= 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
*state = (int)*p;
|
*state = (int)*p;
|
||||||
@ -331,7 +334,7 @@ xu_ewmh_get_net_wm_state(struct client_ctx *cc, int *n)
|
|||||||
Atom *state, *p = NULL;
|
Atom *state, *p = NULL;
|
||||||
|
|
||||||
if ((*n = xu_getprop(cc->win, ewmh[_NET_WM_STATE], XA_ATOM, 64L,
|
if ((*n = xu_getprop(cc->win, ewmh[_NET_WM_STATE], XA_ATOM, 64L,
|
||||||
(u_char **)&p)) <= 0)
|
(unsigned char **)&p)) <= 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
state = xcalloc(*n, sizeof(Atom));
|
state = xcalloc(*n, sizeof(Atom));
|
||||||
|
Reference in New Issue
Block a user