aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroga2008-01-16 11:39:20 +0000
committeroga2008-01-16 11:39:20 +0000
commit475e835196e065d2010dc146b3ca01598b554893 (patch)
treef2ef0da87afd85a3a3bd26c4cf3e13647a69a05c
parent923c9f8936be6a656e3f9b6607c69a820b411330 (diff)
downloadcwm-475e835196e065d2010dc146b3ca01598b554893.tar.gz
huge amount of cleanup and dead code removal.
full description of changes: -remove fontlist, and all associated structures/calls, it's not needed. this also removes any doubt about leftover 9wm code (the list was borrowed from it). Since cwm now uses Xft for everything, the legacy font handling is just not needed. -add /* FALLTHROUGH */ comments into grab_{label,menu}. I actually didn't intend grab_menu to be a fallthrough, but it actually works quite well there, so remove the extra rectangle drawing. I love it when that happens. -remove a couple of unused prototypes that were obviously missed before. -remove a bunch of commented out or if 0ed out code. It doesn't look to be coming back anytime soon. -several functions returned an int, but this was never checked. most of them only failed if they failed to grab the pointer (thus the internal state didn't change), so just make them void and return early if this is the case. -remove several unused functions and some useless variables. knocks something like 200bytes off the stripped binary size for me. ok marc@, tested by several others.
Diffstat (limited to '')
-rw-r--r--calmwm.c47
-rw-r--r--calmwm.h13
-rw-r--r--client.c38
-rw-r--r--conf.c32
-rw-r--r--grab.c20
-rw-r--r--group.c33
-rw-r--r--kbfunc.c3
-rw-r--r--search.c8
-rw-r--r--util.c9
-rw-r--r--xevents.c4
-rw-r--r--xutil.c23
11 files changed, 33 insertions, 197 deletions
diff --git a/calmwm.c b/calmwm.c
index bbc2cd7..b81d650 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -15,14 +15,13 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: calmwm.c,v 1.6 2008/01/14 15:21:10 oga Exp $
+ * $Id: calmwm.c,v 1.7 2008/01/16 11:39:20 oga Exp $
*/
#include "headers.h"
#include "calmwm.h"
Display *X_Dpy;
-XFontStruct *X_Font;
Cursor Cursor_move;
Cursor Cursor_resize;
@@ -47,15 +46,6 @@ char *DefaultFontName;
#define gray_height 2
static char gray_bits[] = {0x02, 0x01};
-/* List borrowed from 9wm/rio */
-char *tryfonts[] = {
- "9x15bold",
- "*-lucidatypewriter-bold-*-14-*-75-*",
- "*-lucidatypewriter-medium-*-12-*-75-*",
- "fixed",
- "*",
- NULL,
-};
static void _sigchld_cb(int);
@@ -140,15 +130,6 @@ x_setup(char *display_name)
Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i);
- i = 0;
- while ((fontname = tryfonts[i++]) != NULL) {
- if ((X_Font = XLoadQueryFont(X_Dpy, fontname)) != NULL)
- break;
- }
-
- if (fontname == NULL)
- errx(1, "Couldn't load any fonts.");
-
Nscreens = ScreenCount(X_Dpy);
for (i = 0; i < (int)Nscreens; i++) {
XMALLOC(sc, struct screen_ctx);
@@ -158,13 +139,12 @@ x_setup(char *display_name)
Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur);
Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner);
- /* (used to be) XCreateFontCursor(X_Dpy, XC_hand1); */
Cursor_select = XCreateFontCursor(X_Dpy, XC_hand1);
Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor);
Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow);
}
-int
+void
x_setupscreen(struct screen_ctx *sc, u_int which)
{
XColor tmp;
@@ -196,10 +176,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
xu_key_grab(sc->rootwin, kb->modmask, kb->keysym);
- /* Special -- for alt state. */
-/* xu_key_grab(sc->rootwin, 0, XK_Alt_L); */
-/* xu_key_grab(sc->rootwin, 0, XK_Alt_R); */
-
sc->blackpixl = BlackPixel(X_Dpy, sc->which);
sc->whitepixl = WhitePixel(X_Dpy, sc->which);
sc->bluepixl = sc->fccolor.pixel;
@@ -223,32 +199,21 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
gv.function = GXxor;
gv.line_width = 1;
gv.subwindow_mode = IncludeInferiors;
- gv.font = X_Font->fid;
sc->gc = XCreateGC(X_Dpy, sc->rootwin,
GCForeground|GCBackground|GCFunction|
- GCLineWidth|GCSubwindowMode|GCFont, &gv);
-
-#ifdef notyet
- gv2.foreground = sc->blackpixl^sc->cyanpixl;
- gv2.background = sc->cyanpixl;
- gv2.function = GXxor;
- gv2.line_width = 1;
- gv2.subwindow_mode = IncludeInferiors;
- gv2.font = X_Font->fid;
-#endif
+ GCLineWidth|GCSubwindowMode, &gv);
sc->hlgc = XCreateGC(X_Dpy, sc->rootwin,
GCForeground|GCBackground|GCFunction|
- GCLineWidth|GCSubwindowMode|GCFont, &gv);
+ GCLineWidth|GCSubwindowMode, &gv);
gv1.function = GXinvert;
gv1.subwindow_mode = IncludeInferiors;
gv1.line_width = 1;
- gv1.font = X_Font->fid;
sc->invgc = XCreateGC(X_Dpy, sc->rootwin,
- GCFunction|GCSubwindowMode|GCLineWidth|GCFont, &gv1);
+ GCFunction|GCSubwindowMode|GCLineWidth, &gv1);
font_init(sc);
DefaultFont = font_getx(sc, DefaultFontName);
@@ -290,7 +255,7 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
XSync(X_Dpy, False);
- return (0);
+ return;
}
char *
diff --git a/calmwm.h b/calmwm.h
index a212218..50e7c33 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: calmwm.h,v 1.18 2008/01/14 15:21:10 oga Exp $
+ * $Id: calmwm.h,v 1.19 2008/01/16 11:39:20 oga Exp $
*/
#ifndef _CALMWM_H_
@@ -311,8 +311,7 @@ int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int);
int x_errorhandler(Display *, XErrorEvent *);
void x_setup(char *display_name);
char *x_screenname(int);
-void x_loop(void);
-int x_setupscreen(struct screen_ctx *, u_int);
+void x_setupscreen(struct screen_ctx *, u_int);
struct client_ctx *client_find(Window);
void client_setup(void);
@@ -397,8 +396,8 @@ int dirent_isdir(char *);
int dirent_islink(char *);
int u_spawn(char *);
-int grab_sweep(struct client_ctx *);
-int grab_drag(struct client_ctx *);
+void grab_sweep(struct client_ctx *);
+void grab_drag(struct client_ctx *);
void grab_menuinit(struct screen_ctx *);
void *grab_menu(XButtonEvent *, struct menu_q *);
void grab_label(struct client_ctx *);
@@ -472,8 +471,7 @@ void search_match_exec(struct menu_q *, struct menu_q *, char *);
void search_rank_text(struct menu_q *, char *);
void group_init(void);
-int group_new(void);
-int group_select(int);
+void group_select(int);
void group_enter(void);
void group_exit(int);
void group_click(struct client_ctx *);
@@ -509,7 +507,6 @@ struct fontdesc *font_getx(struct screen_ctx *sc, const char *name);
/* Externs */
extern Display *X_Dpy;
-extern XFontStruct *X_Font;
extern Cursor Cursor_move;
extern Cursor Cursor_resize;
diff --git a/client.c b/client.c
index c22dd4e..c01f11b 100644
--- a/client.c
+++ b/client.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: client.c,v 1.10 2008/01/11 16:06:44 oga Exp $
+ * $Id: client.c,v 1.11 2008/01/16 11:39:20 oga Exp $
*/
#include "headers.h"
@@ -267,15 +267,6 @@ client_leave(struct client_ctx *cc)
}
void
-client_nocurrent(void)
-{
- if (_curcc != NULL)
- client_setactive(_curcc, 0);
-
- _curcc = NULL;
-}
-
-void
client_setactive(struct client_ctx *cc, int fg)
{
struct screen_ctx* sc;
@@ -362,19 +353,6 @@ client_maximize(struct client_ctx *cc)
}
void
-client_push_geometry(struct client_ctx *cc)
-{
- cc->savegeom = cc->geom;
-}
-
-void
-client_restore_geometry(struct client_ctx *cc)
-{
- cc->geom = cc->savegeom;
- client_resize(cc);
-}
-
-void
client_resize(struct client_ctx *cc)
{
XMoveResizeWindow(X_Dpy, cc->pwin, cc->geom.x - cc->bwidth,
@@ -408,13 +386,6 @@ client_raise(struct client_ctx *cc)
}
void
-client_warp(struct client_ctx *cc)
-{
- client_raise(cc);
- xu_ptr_setpos(cc->pwin, 0, 0);
-}
-
-void
client_ptrwarp(struct client_ctx *cc)
{
int x = cc->ptr.x, y = cc->ptr.y;
@@ -880,13 +851,6 @@ client_vertmaximize(struct client_ctx *cc)
}
void
-client_map(struct client_ctx *cc)
-{
- /* mtf? */
- client_ptrwarp(cc);
-}
-
-void
client_mtf(struct client_ctx *cc)
{
struct screen_ctx *sc;
diff --git a/conf.c b/conf.c
index 736daea..6fb9f3b 100644
--- a/conf.c
+++ b/conf.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: conf.c,v 1.19 2008/01/11 16:06:44 oga Exp $
+ * $Id: conf.c,v 1.20 2008/01/16 11:39:20 oga Exp $
*/
#include "headers.h"
@@ -327,19 +327,6 @@ conf_get_int(struct client_ctx *cc, enum conftype ctype)
return (val);
}
-char *
-conf_get_str(struct client_ctx *cc, enum conftype ctype)
-{
- switch (ctype) {
- case CONF_NOTIFIER:
- return xstrdup("./notifier.py"); /* XXX */
- break;
- default:
- break;
- }
- return NULL;
-}
-
void
conf_client(struct client_ctx *cc)
{
@@ -410,23 +397,6 @@ struct {
};
void
-conf_bindkey(struct conf *c, void (*arg_callback)(struct client_ctx *, void *),
- int arg_keysym, int arg_modmask, int arg_flags, void * arg_arg)
-{
- struct keybinding *kb;
-
- XMALLOC(kb, struct keybinding);
-
- kb->modmask = arg_modmask;
- kb->keysym = arg_keysym;
- kb->keycode = 0;
- kb->flags = arg_flags;
- kb->callback = arg_callback;
- kb->argument = arg_arg;
- TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
-}
-
-void
conf_parsekeys(struct conf *c, char *filename)
{
DIR *dir;
diff --git a/grab.c b/grab.c
index ac8e2a9..6a79e76 100644
--- a/grab.c
+++ b/grab.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: grab.c,v 1.7 2008/01/14 15:21:10 oga Exp $
+ * $Id: grab.c,v 1.8 2008/01/16 11:39:20 oga Exp $
*/
#include "headers.h"
@@ -53,7 +53,7 @@ grab_sweep_draw(struct client_ctx *cc, int dx, int dy)
wide/2 - wide_size/2, height + font_ascent(font) + 1);
}
-int
+void
grab_sweep(struct client_ctx *cc)
{
XEvent ev;
@@ -68,7 +68,7 @@ grab_sweep(struct client_ctx *cc)
client_ptrsave(cc);
if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_resize) < 0)
- return (-1);
+ return;
xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
grab_sweep_draw(cc, dx, dy);
@@ -101,13 +101,13 @@ grab_sweep(struct client_ctx *cc)
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
xu_ptr_ungrab();
client_ptrwarp(cc);
- return (0);
+ return;
}
}
/* NOTREACHED */
}
-int
+void
grab_drag(struct client_ctx *cc)
{
int x0 = cc->geom.x, y0 = cc->geom.y, xm, ym;
@@ -117,7 +117,7 @@ grab_drag(struct client_ctx *cc)
client_raise(cc);
if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_move) < 0)
- return (-1);
+ return;
xu_ptr_getpos(sc->rootwin, &xm, &ym);
@@ -138,7 +138,7 @@ grab_drag(struct client_ctx *cc)
break;
case ButtonRelease:
xu_ptr_ungrab();
- return (0);
+ return;
}
}
/* NOTREACHED */
@@ -219,9 +219,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
sc->menuwin, fx, fy);
i++;
}
- if (entry != -1)
- XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc,
- 0, entry*height, width, height);
+ /* FALLTHROUGH */
case MotionNotify:
prev = entry;
entry = menu_calc_entry(event.xbutton.x,
@@ -320,7 +318,7 @@ grab_label(struct client_ctx *cc)
xfree(cc->label);
cc->label = xstrdup(labelstr);
-
+ /* FALLTHROUGH */
case CTL_ABORT:
goto out;
default:
diff --git a/group.c b/group.c
index 8147fa8..26c0acd 100644
--- a/group.c
+++ b/group.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: group.c,v 1.4 2008/01/14 15:21:10 oga Exp $
+ * $Id: group.c,v 1.5 2008/01/16 11:39:20 oga Exp $
*/
#include "headers.h"
@@ -197,36 +197,15 @@ group_init(void)
* manipulate the 'current group'
*/
-#if 0
-/* set current group to the first empty group
- * returns 0 on success, -1 if there are no empty groups
- */
-int
-group_new(void)
-{
- int i;
-
- for (i=0; i < CALMWM_NGROUPS; i++) {
- if (TAILQ_EMPTY(&Groups[i].clients)) {
- Group_current = &Groups[i];
-
- return (0);
- }
- }
-
- return (-1);
-}
-#endif
-
/* change the current group */
-int
+void
group_select(int idx)
{
struct group_ctx *gc = Group_current;
struct client_ctx *cc;
if (idx < 0 || idx >= CALMWM_NGROUPS)
- return (-1);
+ return;
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
cc->highlight = 0;
@@ -237,7 +216,7 @@ group_select(int idx)
Group_current = &Groups[idx];
group_display_draw(screen_current());
- return (0);
+ return;
}
/* enter group mode */
@@ -353,7 +332,7 @@ void
group_display_draw(struct screen_ctx *sc)
{
struct group_ctx *gc = Group_current;
- int x, y, dx, dy, fontheight, titlelen;
+ int x, y, dx, dy, fontheight;
struct client_ctx *cc;
char titlebuf[1024];
struct fontdesc *font = DefaultFont;
@@ -363,7 +342,7 @@ group_display_draw(struct screen_ctx *sc)
x = y = 0;
fontheight = font_ascent(font) + font_descent(font) + 1;
- dx = titlelen = font_width(font, titlebuf, strlen(titlebuf));
+ dx = font_width(font, titlebuf, strlen(titlebuf));
dy = fontheight;
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
diff --git a/kbfunc.c b/kbfunc.c
index 5ab243e..2eee457 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: kbfunc.c,v 1.12 2008/01/11 16:06:44 oga Exp $
+ * $Id: kbfunc.c,v 1.13 2008/01/16 11:39:20 oga Exp $
*/
#include <paths.h>
@@ -171,7 +171,6 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
TAILQ_INIT(&menuq);
TAILQ_FOREACH(cc, &Clientq, entry) {
- struct menu *mi;
XCALLOC(mi, struct menu);
strlcpy(mi->text, cc->name, sizeof(mi->text));
mi->ctx = cc;
diff --git a/search.c b/search.c
index ffeec07..cc091dd 100644
--- a/search.c
+++ b/search.c
@@ -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.
*
- * $Id: search.c,v 1.5 2008/01/11 16:06:44 oga Exp $
+ * $Id: search.c,v 1.6 2008/01/16 11:39:20 oga Exp $
*/
#include "headers.h"
@@ -457,12 +457,6 @@ search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
}
-void
-search_rank_text(struct menu_q *resultq, char *search)
-{
- return;
-}
-
static int
_strsubmatch(char *sub, char *str, int zeroidx)
{
diff --git a/util.c b/util.c
index 31e6c30..b7002e3 100644
--- a/util.c
+++ b/util.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: util.c,v 1.3 2008/01/11 16:06:44 oga Exp $
+ * $Id: util.c,v 1.4 2008/01/16 11:39:20 oga Exp $
*/
#include "headers.h"
@@ -65,13 +65,6 @@ exec_wm(char *argstr)
err(1, args[0]);
}
-
-int dirent_exists(char *filename) {
- struct stat buffer;
-
- return stat(filename, &buffer);
-}
-
int dirent_isdir(char *filename) {
struct stat buffer;
int return_value;
diff --git a/xevents.c b/xevents.c
index 6f59c20..bf505ce 100644
--- a/xevents.c
+++ b/xevents.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: xevents.c,v 1.3 2008/01/11 16:06:44 oga Exp $
+ * $Id: xevents.c,v 1.4 2008/01/16 11:39:20 oga Exp $
*/
/*
@@ -27,8 +27,6 @@
#include "headers.h"
#include "calmwm.h"
-void _sendxmsg(Window, Atom, long);
-
/*
* NOTE: in reality, many of these should move to client.c now that
* we've got this nice event layer.
diff --git a/xutil.c b/xutil.c
index b74b3f7..59efd81 100644
--- a/xutil.c
+++ b/xutil.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: xutil.c,v 1.3 2008/01/11 16:06:44 oga Exp $
+ * $Id: xutil.c,v 1.4 2008/01/16 11:39:20 oga Exp $
*/
#include "headers.h"
@@ -84,16 +84,6 @@ xu_key_grab(Window win, int mask, int keysym)
XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True,
GrabModeAsync, GrabModeAsync);
-#if 0
- XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), LockMask|mask,
- win, True, GrabModeAsync, GrabModeAsync);
-#endif
-}
-
-void
-xu_key_grab_keycode(Window win, int mask, int keycode)
-{
- XGrabKey(X_Dpy, keycode, mask, win, True, GrabModeAsync, GrabModeAsync);
}
void
@@ -144,17 +134,6 @@ xu_getstate(struct client_ctx *cc, int *state)
return (0);
}
-char *
-xu_getstrprop(struct client_ctx *cc, Atom atm)
-{
- u_char *cp;
-
- if (xu_getprop(cc, atm, XA_STRING, 100L, &cp) <= 0)
- return (NULL);
-
- return ((char *)cp);
-}
-
void
xu_setstate(struct client_ctx *cc, int state)
{