cvsimport

This commit is contained in:
okan 2012-11-01 01:10:47 +00:00
commit e27f649ae7
10 changed files with 25 additions and 66 deletions

View File

@ -34,6 +34,7 @@
#include "calmwm.h"
char **cwm_argv;
Display *X_Dpy;
Cursor Cursor_default;
@ -67,6 +68,7 @@ main(int argc, char **argv)
warnx("no locale support");
mbtowc(NULL, NULL, MB_CUR_MAX);
cwm_argv = argv;
while ((ch = getopt(argc, argv, "c:d:")) != -1) {
switch (ch) {
case 'c':

View File

@ -285,7 +285,6 @@ struct conf {
struct keybinding_q keybindingq;
struct autogroupwin_q autogroupq;
struct winmatch_q ignoreq;
char conf_path[MAXPATHLEN];
struct cmd_q cmdq;
struct mousebinding_q mousebindingq;
#define CONF_STICKY_GROUPS 0x0001
@ -409,7 +408,7 @@ void kbfunc_lock(struct client_ctx *, union arg *);
void kbfunc_menu_search(struct client_ctx *, union arg *);
void kbfunc_moveresize(struct client_ctx *, union arg *);
void kbfunc_quit_wm(struct client_ctx *, union arg *);
void kbfunc_reload(struct client_ctx *, union arg *);
void kbfunc_restart(struct client_ctx *, union arg *);
void kbfunc_ssh(struct client_ctx *, union arg *);
void kbfunc_term(struct client_ctx *, union arg *);
@ -443,7 +442,6 @@ void conf_grab(struct conf *, struct keybinding *);
void conf_grab_mouse(struct client_ctx *);
void conf_init(struct conf *);
void conf_mousebind(struct conf *, char *, char *);
void conf_reload(struct conf *);
void conf_setup(struct conf *, const char *);
void conf_ungrab(struct conf *, struct keybinding *);
@ -461,7 +459,6 @@ void xev_loop(void);
void xu_btn_grab(Window, int, u_int);
void xu_btn_ungrab(Window, int, u_int);
void xu_configure(struct client_ctx *);
void xu_freecolor(struct screen_ctx *, unsigned long);
void xu_getatoms(void);
unsigned long xu_getcolor(struct screen_ctx *, char *);
int xu_getprop(Window, Atom, Atom, long, u_char **);

46
conf.c
View File

@ -81,36 +81,8 @@ 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);
for (i = 0; i < CWM_COLOR_MAX; i++)
sc->color[i].pixel = xu_getcolor(sc, c->color[i].name);
}
}
void
conf_reload(struct conf *c)
{
struct screen_ctx *sc;
struct client_ctx *cc;
if (parse_config(c->conf_path, c) == -1) {
warnx("config file %s has errors, not reloading", c->conf_path);
return;
}
TAILQ_FOREACH(sc, &Screenq, entry) {
conf_gap(c, sc);
conf_color(c, sc);
conf_font(c, sc);
menu_init(sc);
}
TAILQ_FOREACH(cc, &Clientq, entry) {
conf_client(cc);
/* XXX Does not take hmax/vmax into account. */
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED)
cc->bwidth = 0;
client_draw_border(cc);
}
}
static struct {
@ -148,7 +120,7 @@ static struct {
{ "CM-equal", "vmaximize" },
{ "CMS-equal", "hmaximize" },
{ "CMS-f", "freeze" },
{ "CMS-r", "reload" },
{ "CMS-r", "restart" },
{ "CMS-q", "quit" },
{ "M-h", "moveleft" },
{ "M-j", "movedown" },
@ -265,6 +237,7 @@ conf_clear(struct conf *c)
void
conf_setup(struct conf *c, const char *conf_file)
{
char conf_path[MAXPATHLEN];
char *home;
struct stat sb;
int parse = 0;
@ -275,23 +248,22 @@ conf_setup(struct conf *c, const char *conf_file)
if ((home = getenv("HOME")) == NULL)
errx(1, "No HOME directory.");
(void)snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s",
(void)snprintf(conf_path, sizeof(conf_path), "%s/%s",
home, CONFFILE);
if (stat(c->conf_path, &sb) == 0 && (sb.st_mode & S_IFREG))
if (stat(conf_path, &sb) == 0 && (sb.st_mode & S_IFREG))
parse = 1;
} else {
if (stat(conf_file, &sb) == -1 || !(sb.st_mode & S_IFREG))
errx(1, "%s: %s", conf_file, strerror(errno));
else {
(void)strlcpy(c->conf_path, conf_file,
sizeof(c->conf_path));
(void)strlcpy(conf_path, conf_file, sizeof(conf_path));
parse = 1;
}
}
if (parse && (parse_config(c->conf_path, c) == -1))
warnx("config file %s has errors, not loading", c->conf_path);
if (parse && (parse_config(conf_path, c) == -1))
warnx("config file %s has errors, not loading", conf_path);
}
void
@ -375,7 +347,7 @@ static struct {
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },
{ "hmaximize", kbfunc_client_hmaximize, KBFLAG_NEEDCLIENT, {0} },
{ "freeze", kbfunc_client_freeze, KBFLAG_NEEDCLIENT, {0} },
{ "reload", kbfunc_reload, 0, {0} },
{ "restart", kbfunc_restart, 0, {0} },
{ "quit", kbfunc_quit_wm, 0, {0} },
{ "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} },
{ "exec_wm", kbfunc_exec, 0, {.i = CWM_EXEC_WM} },

5
cwm.1
View File

@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: May 7 2012 $
.Dd $Mdocdate: May 9 2012 $
.Dt CWM 1
.Os
.Sh NAME
@ -116,7 +116,8 @@ dialog; allows you to switch from
.Nm
to another window manager without restarting the X server.
.It Ic CMS-r
Reload configuration.
Restart the running
.Xr cwm 1 .
.It Ic CMS-q
Quit
.Nm .

10
cwmrc.5
View File

@ -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: July 6 2012 $
.Dd $Mdocdate: October 31 2012 $
.Dt CWMRC 5
.Os
.Sh NAME
@ -58,7 +58,8 @@ is 0, matching windows will not be added to any group; this may be
used to override
.Dq sticky group mode .
.Pp
The name and class values for existing windows may be obtained using
The name and class values, respectively, for existing windows
may be obtained using
.Xr xprop 1 .
.Pp
.It Ic bind Ar keys command
@ -269,8 +270,9 @@ mousebind M-3 window_resize
.Ed
.Sh BIND COMMAND LIST
.Bl -tag -width 18n -compact
.It reload
Reload configuration.
.It restart
Restart the running
.Xr cwm 1 .
.It quit
Quit
.Xr cwm 1 .

5
font.c
View File

@ -51,16 +51,11 @@ font_height(struct screen_ctx *sc)
void
font_init(struct screen_ctx *sc, const char *color)
{
if (sc->xftdraw)
XftDrawDestroy(sc->xftdraw);
sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which));
if (sc->xftdraw == NULL)
errx(1, "XftDrawCreate");
if (sc->xftcolor.pixel)
XftColorFree(X_Dpy, DefaultVisual(X_Dpy, sc->which),
DefaultColormap(X_Dpy, sc->which), &sc->xftcolor);
if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which),
DefaultColormap(X_Dpy, sc->which), color, &sc->xftcolor))
errx(1, "XftColorAllocName");

View File

@ -36,6 +36,7 @@
#define KNOWN_HOSTS ".ssh/known_hosts"
#define HASH_MARKER "|1|"
extern char **cwm_argv;
extern sig_atomic_t xev_quit;
void
@ -491,7 +492,8 @@ kbfunc_quit_wm(struct client_ctx *cc, union arg *arg)
}
void
kbfunc_reload(struct client_ctx *cc, union arg *arg)
kbfunc_restart(struct client_ctx *cc, union arg *arg)
{
conf_reload(&Conf);
(void)setsid();
(void)execvp(cwm_argv[0], cwm_argv);
}

4
menu.c
View File

@ -77,8 +77,6 @@ menu_init(struct screen_ctx *sc)
{
XGCValues gv;
if (sc->menuwin)
XDestroyWindow(X_Dpy, sc->menuwin);
sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1,
Conf.bwidth,
sc->color[CWM_COLOR_FG_MENU].pixel,
@ -89,8 +87,6 @@ menu_init(struct screen_ctx *sc)
gv.background = sc->color[CWM_COLOR_BG_MENU].pixel;
gv.function = GXxor;
if (sc->gc)
XFreeGC(X_Dpy, sc->gc);
sc->gc = XCreateGC(X_Dpy, sc->menuwin,
GCForeground|GCBackground|GCFunction, &gv);
}

View File

@ -518,8 +518,6 @@ parse_config(const char *filename, struct conf *xconf)
return (-1);
}
(void)strlcpy(conf->conf_path, filename, sizeof(conf->conf_path));
conf_init(conf);
yyparse();

View File

@ -429,9 +429,3 @@ xu_getcolor(struct screen_ctx *sc, char *name)
return (color.pixel);
}
void
xu_freecolor(struct screen_ctx *sc, unsigned long pixel)
{
XFreeColors(X_Dpy, DefaultColormap(X_Dpy, sc->which), &pixel, 1, 0L);
}