mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
cvsimport
This commit is contained in:
commit
8f587e6c80
7
calmwm.c
7
calmwm.c
@ -159,9 +159,13 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
XSetWindowAttributes rootattr;
|
||||
int fake;
|
||||
u_int nwins, i;
|
||||
|
||||
sc->which = which;
|
||||
sc->rootwin = RootWindow(X_Dpy, sc->which);
|
||||
|
||||
xu_ewmh_net_supported(sc);
|
||||
xu_ewmh_net_supported_wm_check(sc);
|
||||
|
||||
conf_gap(&Conf, sc);
|
||||
screen_update_geometry(sc, DisplayWidth(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. */
|
||||
menu_init(sc);
|
||||
|
||||
xu_setwmname(sc);
|
||||
|
||||
rootattr.cursor = Cursor_normal;
|
||||
rootattr.event_mask = CHILDMASK|PropertyChangeMask|EnterWindowMask|
|
||||
LeaveWindowMask|ColormapChangeMask|BUTTONMASK;
|
||||
@ -221,6 +223,7 @@ x_wmerrorhandler(Display *dpy, XErrorEvent *e)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
x_errorhandler(Display *dpy, XErrorEvent *e)
|
||||
{
|
||||
|
8
calmwm.h
8
calmwm.h
@ -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 strlcat(char *, const char *, size_t);
|
||||
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/Xlib.h>
|
||||
@ -214,7 +215,7 @@ struct screen_ctx {
|
||||
Window menuwin;
|
||||
struct color color[CWM_COLOR_MAX];
|
||||
GC gc;
|
||||
int altpersist;
|
||||
int cycling;
|
||||
int xmax;
|
||||
int ymax;
|
||||
struct gap gap;
|
||||
@ -318,6 +319,7 @@ __dead void usage(void);
|
||||
void client_applysizehints(struct client_ctx *);
|
||||
struct client_ctx *client_current(void);
|
||||
void client_cycle(struct screen_ctx *, int);
|
||||
void client_cycle_leave(struct screen_ctx *, struct client_ctx *);
|
||||
void client_delete(struct client_ctx *);
|
||||
void client_draw_border(struct client_ctx *);
|
||||
struct client_ctx *client_find(Window);
|
||||
@ -473,7 +475,9 @@ void xu_ptr_setpos(Window, int, int);
|
||||
void xu_ptr_ungrab(void);
|
||||
void xu_sendmsg(Window, Atom, long);
|
||||
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_spawn(char *);
|
||||
|
32
client.c
32
client.c
@ -228,7 +228,7 @@ client_setactive(struct client_ctx *cc, int fg)
|
||||
* If we're in the middle of alt-tabbing, don't change
|
||||
* the order please.
|
||||
*/
|
||||
if (!sc->altpersist)
|
||||
if (!sc->cycling)
|
||||
client_mtf(cc);
|
||||
} else
|
||||
client_leave(cc);
|
||||
@ -613,7 +613,8 @@ client_cycle(struct screen_ctx *sc, int flags)
|
||||
return;
|
||||
|
||||
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));
|
||||
|
||||
newcc = oldcc;
|
||||
@ -637,12 +638,24 @@ client_cycle(struct screen_ctx *sc, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
/* reset when alt is released. XXX I hate this hack */
|
||||
sc->altpersist = 1;
|
||||
/* reset when cycling mod is released. XXX I hate this hack */
|
||||
sc->cycling = 1;
|
||||
client_ptrsave(oldcc);
|
||||
client_ptrwarp(newcc);
|
||||
}
|
||||
|
||||
void
|
||||
client_cycle_leave(struct screen_ctx *sc, struct client_ctx *cc)
|
||||
{
|
||||
sc->cycling = 0;
|
||||
|
||||
client_mtf(NULL);
|
||||
if (cc) {
|
||||
group_sticky_toggle_exit(cc);
|
||||
XUngrabKeyboard(X_Dpy, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
static struct client_ctx *
|
||||
client_mrunext(struct client_ctx *cc)
|
||||
{
|
||||
@ -792,6 +805,7 @@ client_getsizehints(struct client_ctx *cc)
|
||||
cc->size->max_aspect.y;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
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 */
|
||||
if (s0 != 0 && s1 != 0)
|
||||
if (abs(s0) < abs(s1))
|
||||
return s0;
|
||||
return (s0);
|
||||
else
|
||||
return s1;
|
||||
return (s1);
|
||||
else if (s0 != 0)
|
||||
return s0;
|
||||
return (s0);
|
||||
else if (s1 != 0)
|
||||
return s1;
|
||||
return (s1);
|
||||
else
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
6
conf.c
6
conf.c
@ -361,8 +361,10 @@ static struct {
|
||||
{ "nogroup", kbfunc_client_nogroup, 0, {0} },
|
||||
{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
|
||||
{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
|
||||
{ "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_CYCLE|CWM_INGROUP} },
|
||||
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_RCYCLE|CWM_INGROUP} },
|
||||
{ "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
|
||||
{.i = CWM_CYCLE|CWM_INGROUP} },
|
||||
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
|
||||
{.i = CWM_RCYCLE|CWM_INGROUP} },
|
||||
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
|
||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
|
||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },
|
||||
|
25
cwm.1
25
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: September 25 2010 $
|
||||
.Dd $Mdocdate: May 7 2012 $
|
||||
.Dt CWM 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -258,18 +258,6 @@ option is given.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr cwmrc 5
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
.Pp
|
||||
.Nm
|
||||
was developed by
|
||||
.An Marius Aamodt Eriksen Aq marius@monkey.org
|
||||
with contributions from
|
||||
.An Andy Adamson Aq dros@monkey.org ,
|
||||
.An Niels Provos Aq provos@monkey.org ,
|
||||
and
|
||||
.An Antti Nyk\(:anen Aq aon@iki.fi .
|
||||
Ideas, discussion with many others.
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
was originally inspired by evilwm, but was rewritten from scratch
|
||||
@ -280,3 +268,14 @@ has since been removed or rewritten.
|
||||
.Nm
|
||||
first appeared in
|
||||
.Ox 4.2 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
.Nm
|
||||
was developed by
|
||||
.An Marius Aamodt Eriksen Aq marius@monkey.org
|
||||
with contributions from
|
||||
.An Andy Adamson Aq dros@monkey.org ,
|
||||
.An Niels Provos Aq provos@monkey.org ,
|
||||
and
|
||||
.An Antti Nyk\(:anen Aq aon@iki.fi .
|
||||
Ideas, discussion with many others.
|
||||
|
5
group.c
5
group.c
@ -151,8 +151,9 @@ group_init(struct screen_ctx *sc)
|
||||
|
||||
TAILQ_INIT(&sc->groupq);
|
||||
sc->group_hideall = 0;
|
||||
/* see if any group names have already been set and update the property
|
||||
* with ours if they'll have changed.
|
||||
/*
|
||||
* See if any group names have already been set and update the
|
||||
* property with ours if they'll have changed.
|
||||
*/
|
||||
group_update_names(sc);
|
||||
|
||||
|
2
menu.c
2
menu.c
@ -466,7 +466,7 @@ menu_keycode(KeyCode kc, u_int state, enum ctltype *ctl, char *chr)
|
||||
*ctl = CTL_NONE;
|
||||
*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. */
|
||||
switch (ks) {
|
||||
|
34
xevents.c
34
xevents.c
@ -71,6 +71,9 @@ void (*xev_handlers[LASTEvent])(XEvent *) = {
|
||||
[MappingNotify] = xev_handle_mappingnotify,
|
||||
};
|
||||
|
||||
static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R,
|
||||
XK_Control_L, XK_Control_R };
|
||||
|
||||
static void
|
||||
xev_handle_maprequest(XEvent *ee)
|
||||
{
|
||||
@ -204,12 +207,10 @@ xev_handle_propertynotify(XEvent *ee)
|
||||
if (sc->rootwin == e->window)
|
||||
goto test;
|
||||
return;
|
||||
|
||||
test:
|
||||
if (e->atom == _NET_DESKTOP_NAMES)
|
||||
group_update_names(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@ -279,8 +280,8 @@ xev_handle_keypress(XEvent *ee)
|
||||
KeySym keysym, skeysym;
|
||||
int modshift;
|
||||
|
||||
keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
|
||||
skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1);
|
||||
keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
|
||||
skeysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 1);
|
||||
|
||||
/* we don't care about caps lock and numlock here */
|
||||
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
|
||||
xev_handle_keyrelease(XEvent *ee)
|
||||
@ -323,26 +324,17 @@ xev_handle_keyrelease(XEvent *ee)
|
||||
XKeyEvent *e = &ee->xkey;
|
||||
struct screen_ctx *sc;
|
||||
struct client_ctx *cc;
|
||||
int keysym;
|
||||
int i, keysym;
|
||||
|
||||
sc = screen_fromroot(e->root);
|
||||
cc = client_current();
|
||||
|
||||
keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
|
||||
if (keysym != XK_Alt_L && keysym != XK_Alt_R)
|
||||
return;
|
||||
|
||||
sc->altpersist = 0;
|
||||
|
||||
/*
|
||||
* XXX - better interface... xevents should not know about
|
||||
* how/when to mtf.
|
||||
*/
|
||||
client_mtf(NULL);
|
||||
|
||||
if (cc != NULL) {
|
||||
group_sticky_toggle_exit(cc);
|
||||
XUngrabKeyboard(X_Dpy, CurrentTime);
|
||||
keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
|
||||
for (i = 0; i < nitems(modkeys); i++) {
|
||||
if (keysym == modkeys[i]) {
|
||||
client_cycle_leave(sc, cc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
46
xutil.c
46
xutil.c
@ -94,8 +94,8 @@ xu_key_grab(Window win, int mask, int keysym)
|
||||
int i;
|
||||
|
||||
code = XKeysymToKeycode(X_Dpy, keysym);
|
||||
if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) &&
|
||||
(XKeycodeToKeysym(X_Dpy, code, 1) == 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++)
|
||||
@ -110,8 +110,8 @@ xu_key_ungrab(Window win, int mask, int keysym)
|
||||
int i;
|
||||
|
||||
code = XKeysymToKeycode(X_Dpy, keysym);
|
||||
if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) &&
|
||||
(XKeycodeToKeysym(X_Dpy, code, 1) == 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++)
|
||||
@ -260,27 +260,31 @@ xu_getatoms(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,
|
||||
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.
|
||||
}
|
||||
|
||||
/*
|
||||
* The netwm spec says that to prove that the hint is not stale, one
|
||||
* must provide _NET_SUPPORTING_WM_CHECK containing a window created by
|
||||
* 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,
|
||||
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,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
||||
XChangeProperty(X_Dpy, w, _NET_SUPPORTING_WM_CHECK,
|
||||
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1);
|
||||
XChangeProperty(X_Dpy, w, _NET_WM_NAME, UTF8_STRING,
|
||||
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),
|
||||
name, &color, &tmp)) {
|
||||
warnx("XAllocNamedColor error: '%s'", name);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
return color.pixel;
|
||||
return (color.pixel);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user