summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/cwm/calmwm.c9
-rw-r--r--app/cwm/calmwm.h19
-rw-r--r--app/cwm/cwm.110
-rw-r--r--app/cwm/util.c10
-rw-r--r--app/cwm/xevents.c30
5 files changed, 44 insertions, 34 deletions
diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c
index a69bf8654..6804030a8 100644
--- a/app/cwm/calmwm.c
+++ b/app/cwm/calmwm.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.
*
- * $OpenBSD: calmwm.c,v 1.107 2018/01/02 14:04:58 okan Exp $
+ * $OpenBSD: calmwm.c,v 1.108 2018/02/04 22:56:26 okan Exp $
*/
#include <sys/types.h>
@@ -67,7 +67,7 @@ main(int argc, char **argv)
fallback = u_argv(argv);
Conf.wm_argv = u_argv(argv);
- while ((ch = getopt(argc, argv, "c:d:")) != -1) {
+ while ((ch = getopt(argc, argv, "c:d:v")) != -1) {
switch (ch) {
case 'c':
conf_file = optarg;
@@ -75,6 +75,9 @@ main(int argc, char **argv)
case 'd':
display_name = optarg;
break;
+ case 'v':
+ Conf.debug++;
+ break;
default:
usage();
}
@@ -241,7 +244,7 @@ usage(void)
{
extern char *__progname;
- (void)fprintf(stderr, "usage: %s [-c file] [-d display]\n",
+ (void)fprintf(stderr, "usage: %s [-v] [-c file] [-d display]\n",
__progname);
exit(1);
}
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index ccb0736fc..a4933471b 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/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.
*
- * $OpenBSD: calmwm.h,v 1.355 2018/02/02 13:40:55 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.356 2018/02/04 22:56:26 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -31,12 +31,10 @@
#include <X11/extensions/Xrandr.h>
#include <X11/keysym.h>
-/* #define DEBUG */
-#ifdef DEBUG
-#define DPRINTF(...) log_debug(__func__, __VA_ARGS__)
-#else
-#define DPRINTF(...) do {} while (0)
-#endif /* DEBUG */
+#define LOG_DEBUG0(...) log_debug(0, __func__, __VA_ARGS__)
+#define LOG_DEBUG1(...) log_debug(1, __func__, __VA_ARGS__)
+#define LOG_DEBUG2(...) log_debug(2, __func__, __VA_ARGS__)
+#define LOG_DEBUG3(...) log_debug(3, __func__, __VA_ARGS__)
#undef MIN
#undef MAX
@@ -313,6 +311,7 @@ struct conf {
char *homedir;
char *known_hosts;
char *wm_argv;
+ u_int32_t debug;
};
/* MWM hints */
@@ -591,9 +590,9 @@ void xu_ewmh_restore_net_wm_state(struct client_ctx *);
char *u_argv(char * const *);
void u_exec(char *);
void u_spawn(char *);
-void log_debug(const char *, const char *, ...)
- __attribute__((__format__ (printf, 2, 3)))
- __attribute__((__nonnull__ (2)));
+void log_debug(int, const char *, const char *, ...)
+ __attribute__((__format__ (printf, 3, 4)))
+ __attribute__((__nonnull__ (3)));
void *xcalloc(size_t, size_t);
void *xmalloc(size_t);
diff --git a/app/cwm/cwm.1 b/app/cwm/cwm.1
index 63986ee69..3b4e76e83 100644
--- a/app/cwm/cwm.1
+++ b/app/cwm/cwm.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cwm.1,v 1.61 2017/12/30 22:25:09 okan Exp $
+.\" $OpenBSD: cwm.1,v 1.62 2018/02/04 22:56:26 okan Exp $
.\"
.\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
.\"
@@ -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: December 30 2017 $
+.Dd $Mdocdate: February 4 2018 $
.Dt CWM 1
.Os
.Sh NAME
@@ -23,6 +23,7 @@
.Sh SYNOPSIS
.\" For a program: program [-abc] file ...
.Nm cwm
+.Op Fl v
.Op Fl c Ar file
.Op Fl d Ar display
.Sh DESCRIPTION
@@ -47,6 +48,11 @@ however,
will continue to process the rest of the configuration file.
.It Fl d Ar display
Specify the display to use.
+.It Fl v
+Verbose mode.
+Multiple
+.Fl v
+options increase the verbosity.
.El
.Pp
.Nm
diff --git a/app/cwm/util.c b/app/cwm/util.c
index 6898a267a..5eb059fc0 100644
--- a/app/cwm/util.c
+++ b/app/cwm/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.
*
- * $OpenBSD: util.c,v 1.21 2018/02/02 13:40:55 okan Exp $
+ * $OpenBSD: util.c,v 1.22 2018/02/04 22:56:26 okan Exp $
*/
#include <sys/types.h>
@@ -123,14 +123,16 @@ log_msg(const char *msg, va_list ap)
}
void
-log_debug(const char *func, const char *msg, ...)
+log_debug(int level, const char *func, const char *msg, ...)
{
char *fmt;
va_list ap;
+ if (Conf.debug < level)
+ return;
+
va_start(ap, msg);
- if (asprintf(&fmt, "%s: %s", func, msg) == -1)
- exit(1);
+ xasprintf(&fmt, "debug%d: %s: %s", level, func, msg);
log_msg(fmt, ap);
va_end(ap);
}
diff --git a/app/cwm/xevents.c b/app/cwm/xevents.c
index 5bf8f3b04..9fc659b0a 100644
--- a/app/cwm/xevents.c
+++ b/app/cwm/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.
*
- * $OpenBSD: xevents.c,v 1.133 2018/02/02 13:50:22 okan Exp $
+ * $OpenBSD: xevents.c,v 1.134 2018/02/04 22:56:26 okan Exp $
*/
/*
@@ -77,7 +77,7 @@ xev_handle_maprequest(XEvent *ee)
XMapRequestEvent *e = &ee->xmaprequest;
struct client_ctx *cc = NULL, *old_cc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
if ((old_cc = client_current()) != NULL)
client_ptrsave(old_cc);
@@ -95,7 +95,7 @@ xev_handle_unmapnotify(XEvent *ee)
XUnmapEvent *e = &ee->xunmap;
struct client_ctx *cc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
if ((cc = client_find(e->window)) != NULL) {
if (e->send_event) {
@@ -113,7 +113,7 @@ xev_handle_destroynotify(XEvent *ee)
XDestroyWindowEvent *e = &ee->xdestroywindow;
struct client_ctx *cc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
if ((cc = client_find(e->window)) != NULL)
client_delete(cc);
@@ -127,7 +127,7 @@ xev_handle_configurerequest(XEvent *ee)
struct screen_ctx *sc;
XWindowChanges wc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
if ((cc = client_find(e->window)) != NULL) {
sc = cc->sc;
@@ -182,7 +182,7 @@ xev_handle_propertynotify(XEvent *ee)
struct screen_ctx *sc;
struct client_ctx *cc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
if ((cc = client_find(e->window)) != NULL) {
switch (e->atom) {
@@ -219,7 +219,7 @@ xev_handle_enternotify(XEvent *ee)
XCrossingEvent *e = &ee->xcrossing;
struct client_ctx *cc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
Last_Event_Time = e->time;
@@ -235,7 +235,7 @@ xev_handle_buttonpress(XEvent *ee)
struct screen_ctx *sc;
struct bind_ctx *mb;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
e->state &= ~IGNOREMODMASK;
@@ -273,7 +273,7 @@ xev_handle_buttonrelease(XEvent *ee)
XButtonEvent *e = &ee->xbutton;
struct client_ctx *cc;
- DPRINTF("window: 0x%lx", ee->xbutton.window);
+ LOG_DEBUG3("window: 0x%lx", ee->xbutton.window);
if ((cc = client_find(e->window)) != NULL) {
if (cc->flags & (CLIENT_ACTIVE | CLIENT_HIGHLIGHT)) {
@@ -293,7 +293,7 @@ xev_handle_keypress(XEvent *ee)
KeySym keysym, skeysym;
unsigned int modshift;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0);
skeysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 1);
@@ -346,7 +346,7 @@ xev_handle_keyrelease(XEvent *ee)
KeySym keysym;
unsigned int i;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
if ((sc = screen_find(e->root)) == NULL)
return;
@@ -377,7 +377,7 @@ xev_handle_clientmessage(XEvent *ee)
struct client_ctx *cc, *old_cc;
struct screen_ctx *sc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
if (e->message_type == cwmh[WM_CHANGE_STATE]) {
if ((cc = client_find(e->window)) != NULL) {
@@ -426,7 +426,7 @@ xev_handle_randr(XEvent *ee)
struct screen_ctx *sc;
int i;
- DPRINTF("new size: %d/%d", rev->width, rev->height);
+ LOG_DEBUG3("new size: %d/%d", rev->width, rev->height);
i = XRRRootToScreen(X_Dpy, rev->root);
TAILQ_FOREACH(sc, &Screenq, entry) {
@@ -448,7 +448,7 @@ xev_handle_mappingnotify(XEvent *ee)
XMappingEvent *e = &ee->xmapping;
struct screen_ctx *sc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
XRefreshKeyboardMapping(e);
if (e->request == MappingKeyboard) {
@@ -463,7 +463,7 @@ xev_handle_expose(XEvent *ee)
XExposeEvent *e = &ee->xexpose;
struct client_ctx *cc;
- DPRINTF("window: 0x%lx", e->window);
+ LOG_DEBUG3("window: 0x%lx", e->window);
if ((cc = client_find(e->window)) != NULL && e->count == 0)
client_draw_border(cc);