cvsimport

This commit is contained in:
Christian Neukirchen 2012-05-20 15:27:16 +02:00
commit 8f587e6c80
9 changed files with 97 additions and 78 deletions

View File

@ -159,9 +159,13 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
XSetWindowAttributes rootattr; XSetWindowAttributes rootattr;
int fake; int fake;
u_int nwins, i; u_int nwins, i;
sc->which = which; sc->which = which;
sc->rootwin = RootWindow(X_Dpy, sc->which); sc->rootwin = RootWindow(X_Dpy, sc->which);
xu_ewmh_net_supported(sc);
xu_ewmh_net_supported_wm_check(sc);
conf_gap(&Conf, sc); conf_gap(&Conf, sc);
screen_update_geometry(sc, DisplayWidth(X_Dpy, sc->which), screen_update_geometry(sc, DisplayWidth(X_Dpy, sc->which),
DisplayHeight(X_Dpy, sc->which)); DisplayHeight(X_Dpy, sc->which));
@ -176,8 +180,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
/* Initialize menu window. */ /* Initialize menu window. */
menu_init(sc); menu_init(sc);
xu_setwmname(sc);
rootattr.cursor = Cursor_normal; rootattr.cursor = Cursor_normal;
rootattr.event_mask = CHILDMASK|PropertyChangeMask|EnterWindowMask| rootattr.event_mask = CHILDMASK|PropertyChangeMask|EnterWindowMask|
LeaveWindowMask|ColormapChangeMask|BUTTONMASK; LeaveWindowMask|ColormapChangeMask|BUTTONMASK;
@ -221,6 +223,7 @@ x_wmerrorhandler(Display *dpy, XErrorEvent *e)
return (0); return (0);
} }
static int static int
x_errorhandler(Display *dpy, XErrorEvent *e) x_errorhandler(Display *dpy, XErrorEvent *e)
{ {

View File

@ -33,6 +33,7 @@ long long strtonum(const char *, long long, long long, const char **);
size_t strlcpy(char *, const char *, size_t); size_t strlcpy(char *, const char *, size_t);
size_t strlcat(char *, const char *, size_t); size_t strlcat(char *, const char *, size_t);
#include <X11/XKBlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -214,7 +215,7 @@ struct screen_ctx {
Window menuwin; Window menuwin;
struct color color[CWM_COLOR_MAX]; struct color color[CWM_COLOR_MAX];
GC gc; GC gc;
int altpersist; int cycling;
int xmax; int xmax;
int ymax; int ymax;
struct gap gap; struct gap gap;
@ -318,6 +319,7 @@ __dead void usage(void);
void client_applysizehints(struct client_ctx *); void client_applysizehints(struct client_ctx *);
struct client_ctx *client_current(void); struct client_ctx *client_current(void);
void client_cycle(struct screen_ctx *, int); void client_cycle(struct screen_ctx *, int);
void client_cycle_leave(struct screen_ctx *, struct client_ctx *);
void client_delete(struct client_ctx *); void client_delete(struct client_ctx *);
void client_draw_border(struct client_ctx *); void client_draw_border(struct client_ctx *);
struct client_ctx *client_find(Window); struct client_ctx *client_find(Window);
@ -473,7 +475,9 @@ void xu_ptr_setpos(Window, int, int);
void xu_ptr_ungrab(void); void xu_ptr_ungrab(void);
void xu_sendmsg(Window, Atom, long); void xu_sendmsg(Window, Atom, long);
void xu_setstate(struct client_ctx *, int); void xu_setstate(struct client_ctx *, int);
void xu_setwmname(struct screen_ctx *);
void xu_ewmh_net_supported(struct screen_ctx *);
void xu_ewmh_net_supported_wm_check(struct screen_ctx *);
void u_exec(char *); void u_exec(char *);
void u_spawn(char *); void u_spawn(char *);

View File

@ -228,7 +228,7 @@ client_setactive(struct client_ctx *cc, int fg)
* If we're in the middle of alt-tabbing, don't change * If we're in the middle of alt-tabbing, don't change
* the order please. * the order please.
*/ */
if (!sc->altpersist) if (!sc->cycling)
client_mtf(cc); client_mtf(cc);
} else } else
client_leave(cc); client_leave(cc);
@ -613,7 +613,8 @@ client_cycle(struct screen_ctx *sc, int flags)
return; return;
if (oldcc == NULL) if (oldcc == NULL)
oldcc = (flags & CWM_RCYCLE ? TAILQ_LAST(&sc->mruq, cycle_entry_q) : oldcc = (flags & CWM_RCYCLE ?
TAILQ_LAST(&sc->mruq, cycle_entry_q) :
TAILQ_FIRST(&sc->mruq)); TAILQ_FIRST(&sc->mruq));
newcc = oldcc; newcc = oldcc;
@ -637,12 +638,24 @@ client_cycle(struct screen_ctx *sc, int flags)
} }
} }
/* reset when alt is released. XXX I hate this hack */ /* reset when cycling mod is released. XXX I hate this hack */
sc->altpersist = 1; sc->cycling = 1;
client_ptrsave(oldcc); client_ptrsave(oldcc);
client_ptrwarp(newcc); client_ptrwarp(newcc);
} }
void
client_cycle_leave(struct screen_ctx *sc, struct client_ctx *cc)
{
sc->cycling = 0;
client_mtf(NULL);
if (cc) {
group_sticky_toggle_exit(cc);
XUngrabKeyboard(X_Dpy, CurrentTime);
}
}
static struct client_ctx * static struct client_ctx *
client_mrunext(struct client_ctx *cc) client_mrunext(struct client_ctx *cc)
{ {
@ -792,6 +805,7 @@ client_getsizehints(struct client_ctx *cc)
cc->size->max_aspect.y; cc->size->max_aspect.y;
} }
} }
void void
client_applysizehints(struct client_ctx *cc) client_applysizehints(struct client_ctx *cc)
{ {
@ -911,13 +925,13 @@ client_snapcalc(int n, int dn, int nmax, int bwidth, int snapdist)
/* possible to snap in both directions */ /* possible to snap in both directions */
if (s0 != 0 && s1 != 0) if (s0 != 0 && s1 != 0)
if (abs(s0) < abs(s1)) if (abs(s0) < abs(s1))
return s0; return (s0);
else else
return s1; return (s1);
else if (s0 != 0) else if (s0 != 0)
return s0; return (s0);
else if (s1 != 0) else if (s1 != 0)
return s1; return (s1);
else else
return 0; return (0);
} }

6
conf.c
View File

@ -361,8 +361,10 @@ static struct {
{ "nogroup", kbfunc_client_nogroup, 0, {0} }, { "nogroup", kbfunc_client_nogroup, 0, {0} },
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} }, { "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} }, { "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
{ "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_CYCLE|CWM_INGROUP} }, { "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_RCYCLE|CWM_INGROUP} }, {.i = CWM_CYCLE|CWM_INGROUP} },
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
{.i = CWM_RCYCLE|CWM_INGROUP} },
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}}, { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} }, { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} }, { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },

25
cwm.1
View File

@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: September 25 2010 $ .Dd $Mdocdate: May 7 2012 $
.Dt CWM 1 .Dt CWM 1
.Os .Os
.Sh NAME .Sh NAME
@ -258,18 +258,6 @@ option is given.
.El .El
.Sh SEE ALSO .Sh SEE ALSO
.Xr cwmrc 5 .Xr cwmrc 5
.Sh AUTHORS
.An -nosplit
.Pp
.Nm
was developed by
.An Marius Aamodt Eriksen Aq marius@monkey.org
with contributions from
.An Andy Adamson Aq dros@monkey.org ,
.An Niels Provos Aq provos@monkey.org ,
and
.An Antti Nyk\(:anen Aq aon@iki.fi .
Ideas, discussion with many others.
.Sh HISTORY .Sh HISTORY
.Nm .Nm
was originally inspired by evilwm, but was rewritten from scratch was originally inspired by evilwm, but was rewritten from scratch
@ -280,3 +268,14 @@ has since been removed or rewritten.
.Nm .Nm
first appeared in first appeared in
.Ox 4.2 . .Ox 4.2 .
.Sh AUTHORS
.An -nosplit
.Nm
was developed by
.An Marius Aamodt Eriksen Aq marius@monkey.org
with contributions from
.An Andy Adamson Aq dros@monkey.org ,
.An Niels Provos Aq provos@monkey.org ,
and
.An Antti Nyk\(:anen Aq aon@iki.fi .
Ideas, discussion with many others.

View File

@ -151,8 +151,9 @@ group_init(struct screen_ctx *sc)
TAILQ_INIT(&sc->groupq); TAILQ_INIT(&sc->groupq);
sc->group_hideall = 0; sc->group_hideall = 0;
/* see if any group names have already been set and update the property /*
* with ours if they'll have changed. * See if any group names have already been set and update the
* property with ours if they'll have changed.
*/ */
group_update_names(sc); group_update_names(sc);

2
menu.c
View File

@ -466,7 +466,7 @@ menu_keycode(KeyCode kc, u_int state, enum ctltype *ctl, char *chr)
*ctl = CTL_NONE; *ctl = CTL_NONE;
*chr = '\0'; *chr = '\0';
ks = XKeycodeToKeysym(X_Dpy, kc, (state & ShiftMask) ? 1 : 0); ks = XkbKeycodeToKeysym(X_Dpy, kc, 0, (state & ShiftMask) ? 1 : 0);
/* Look for control characters. */ /* Look for control characters. */
switch (ks) { switch (ks) {

View File

@ -71,6 +71,9 @@ void (*xev_handlers[LASTEvent])(XEvent *) = {
[MappingNotify] = xev_handle_mappingnotify, [MappingNotify] = xev_handle_mappingnotify,
}; };
static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R,
XK_Control_L, XK_Control_R };
static void static void
xev_handle_maprequest(XEvent *ee) xev_handle_maprequest(XEvent *ee)
{ {
@ -204,12 +207,10 @@ xev_handle_propertynotify(XEvent *ee)
if (sc->rootwin == e->window) if (sc->rootwin == e->window)
goto test; goto test;
return; return;
test: test:
if (e->atom == _NET_DESKTOP_NAMES) if (e->atom == _NET_DESKTOP_NAMES)
group_update_names(sc); group_update_names(sc);
} }
} }
static void static void
@ -279,8 +280,8 @@ xev_handle_keypress(XEvent *ee)
KeySym keysym, skeysym; KeySym keysym, skeysym;
int modshift; int modshift;
keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1); skeysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 1);
/* we don't care about caps lock and numlock here */ /* we don't care about caps lock and numlock here */
e->state &= ~(LockMask | Mod2Mask); e->state &= ~(LockMask | Mod2Mask);
@ -315,7 +316,7 @@ xev_handle_keypress(XEvent *ee)
} }
/* /*
* This is only used for the alt suppression detection. * This is only used for the modifier suppression detection.
*/ */
static void static void
xev_handle_keyrelease(XEvent *ee) xev_handle_keyrelease(XEvent *ee)
@ -323,26 +324,17 @@ xev_handle_keyrelease(XEvent *ee)
XKeyEvent *e = &ee->xkey; XKeyEvent *e = &ee->xkey;
struct screen_ctx *sc; struct screen_ctx *sc;
struct client_ctx *cc; struct client_ctx *cc;
int keysym; int i, keysym;
sc = screen_fromroot(e->root); sc = screen_fromroot(e->root);
cc = client_current(); cc = client_current();
keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
if (keysym != XK_Alt_L && keysym != XK_Alt_R) for (i = 0; i < nitems(modkeys); i++) {
return; if (keysym == modkeys[i]) {
client_cycle_leave(sc, cc);
sc->altpersist = 0; break;
}
/*
* XXX - better interface... xevents should not know about
* how/when to mtf.
*/
client_mtf(NULL);
if (cc != NULL) {
group_sticky_toggle_exit(cc);
XUngrabKeyboard(X_Dpy, CurrentTime);
} }
} }

46
xutil.c
View File

@ -94,8 +94,8 @@ xu_key_grab(Window win, int mask, int keysym)
int i; int i;
code = XKeysymToKeycode(X_Dpy, keysym); code = XKeysymToKeycode(X_Dpy, keysym);
if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) && if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym)) (XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
mask |= ShiftMask; mask |= ShiftMask;
for (i = 0; i < nitems(ign_mods); i++) for (i = 0; i < nitems(ign_mods); i++)
@ -110,8 +110,8 @@ xu_key_ungrab(Window win, int mask, int keysym)
int i; int i;
code = XKeysymToKeycode(X_Dpy, keysym); code = XKeysymToKeycode(X_Dpy, keysym);
if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) && if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) &&
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym)) (XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym))
mask |= ShiftMask; mask |= ShiftMask;
for (i = 0; i < nitems(ign_mods); i++) for (i = 0; i < nitems(ign_mods); i++)
@ -260,27 +260,31 @@ xu_getatoms(void)
} }
void void
xu_setwmname(struct screen_ctx *sc) xu_ewmh_net_supported(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, XChangeProperty(X_Dpy, sc->rootwin, _NET_SUPPORTED, XA_ATOM, 32,
PropModeReplace, (unsigned char *)&_NET_SUPPORTED, PropModeReplace, (unsigned char *)&_NET_SUPPORTED,
CWM_NO_ATOMS - CWM_NETWM_START); 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 * The netwm spec says that to prove that the hint is not stale, one
* window itself, the window also must have _NET_WM_NAME set with the * must provide _NET_SUPPORTING_WM_CHECK containing a window created by
* window manager name. * the root window. The property must be set on the root window and the
* window itself. This child window also must have _NET_WM_NAME set with
* the window manager name.
*/ */
void
xu_ewmh_net_supported_wm_check(struct screen_ctx *sc)
{
Window w;
w = XCreateSimpleWindow(X_Dpy, sc->rootwin, -1, -1, 1, 1, 0, 0, 0);
XChangeProperty(X_Dpy, sc->rootwin, _NET_SUPPORTING_WM_CHECK, XChangeProperty(X_Dpy, sc->rootwin, _NET_SUPPORTING_WM_CHECK,
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&sc->menuwin, 1); XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
XChangeProperty(X_Dpy, sc->menuwin, _NET_SUPPORTING_WM_CHECK, XChangeProperty(X_Dpy, w, _NET_SUPPORTING_WM_CHECK,
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&sc->menuwin, 1); XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
XChangeProperty(X_Dpy, sc->menuwin, _NET_WM_NAME, UTF8_STRING, XChangeProperty(X_Dpy, w, _NET_WM_NAME, UTF8_STRING,
8, PropModeReplace, WMNAME, strlen(WMNAME)); 8, PropModeReplace, WMNAME, strlen(WMNAME));
} }
@ -292,10 +296,10 @@ xu_getcolor(struct screen_ctx *sc, char *name)
if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which), if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which),
name, &color, &tmp)) { name, &color, &tmp)) {
warnx("XAllocNamedColor error: '%s'", name); warnx("XAllocNamedColor error: '%s'", name);
return 0; return (0);
} }
return color.pixel; return (color.pixel);
} }
void void