mirror of
https://github.com/eRgo35/dots.git
synced 2025-12-16 23:46:13 +01:00
minor debug fixes
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <regex.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@@ -149,6 +150,7 @@ static void arrangemon(Monitor *m);
|
||||
static void attach(Client *c);
|
||||
static void attachstack(Client *c);
|
||||
static void buttonpress(XEvent *e);
|
||||
static void compileregexes(void);
|
||||
static void checkotherwm(void);
|
||||
static void cleanup(void);
|
||||
static void cleanupmon(Monitor *mon);
|
||||
@@ -205,6 +207,8 @@ static void setmfact(const Arg *arg);
|
||||
static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void sighup(int unused);
|
||||
static void sigterm(int unused);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
@@ -260,6 +264,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[UnmapNotify] = unmapnotify
|
||||
};
|
||||
static Atom wmatom[WMLast], netatom[NetLast];
|
||||
static int restart = 0;
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme;
|
||||
@@ -274,6 +279,8 @@ static Window root, wmcheckwin;
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||
|
||||
static regex_t regexcache[LENGTH(rules)][3];
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
applyrules(Client *c)
|
||||
@@ -293,10 +300,10 @@ applyrules(Client *c)
|
||||
|
||||
for (i = 0; i < LENGTH(rules); i++) {
|
||||
r = &rules[i];
|
||||
if ((!r->title || strstr(c->name, r->title))
|
||||
&& (!r->class || strstr(class, r->class))
|
||||
&& (!r->instance || strstr(instance, r->instance)))
|
||||
{
|
||||
if((!r->title || !regexec(®excache[i][2], c->name, 0, NULL, 0)) &&
|
||||
(!r->class || !regexec(®excache[i][0], class, 0, NULL, 0)) &&
|
||||
(!r->instance || !regexec(®excache[i][1], instance, 0, NULL, 0))) {
|
||||
|
||||
c->isfloating = r->isfloating;
|
||||
c->tags |= r->tags;
|
||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||
@@ -531,6 +538,36 @@ clientmessage(XEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
compileregexes(void)
|
||||
{
|
||||
char regex_error_buffer[256];
|
||||
int i;
|
||||
int status;
|
||||
const Rule *r;
|
||||
for(i = 0; i < LENGTH(rules); i++) {
|
||||
r = &rules[i];
|
||||
if (r->class) {
|
||||
if ((status = regcomp(®excache[i][0], r->class, REG_EXTENDED | REG_NOSUB))) {
|
||||
regerror(status, ®excache[i][0], regex_error_buffer, sizeof(regex_error_buffer));
|
||||
die("Error compiling /%s/: %s", r->class, regex_error_buffer);
|
||||
}
|
||||
}
|
||||
if (r->instance) {
|
||||
if ((status = regcomp(®excache[i][1], r->instance, REG_EXTENDED | REG_NOSUB))) {
|
||||
regerror(status, ®excache[i][1], regex_error_buffer, sizeof(regex_error_buffer));
|
||||
die("Error compiling /%s/: %s", r->instance, regex_error_buffer);
|
||||
}
|
||||
}
|
||||
if (r->title) {
|
||||
if ((status = regcomp(®excache[i][2], r->title, REG_EXTENDED | REG_NOSUB))) {
|
||||
regerror(status, ®excache[i][2], regex_error_buffer, sizeof(regex_error_buffer));
|
||||
die("Error compiling /%s/: %s", r->title, regex_error_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
configure(Client *c)
|
||||
{
|
||||
@@ -1258,6 +1295,7 @@ propertynotify(XEvent *e)
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
if(arg->i) restart = 1;
|
||||
running = 0;
|
||||
}
|
||||
|
||||
@@ -1553,6 +1591,9 @@ setup(void)
|
||||
/* clean up any zombies (inherited from .xinitrc etc) immediately */
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
|
||||
signal(SIGHUP, sighup);
|
||||
signal(SIGTERM, sigterm);
|
||||
|
||||
/* init screen */
|
||||
screen = DefaultScreen(dpy);
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
@@ -1644,6 +1685,20 @@ showhide(Client *c)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sighup(int unused)
|
||||
{
|
||||
Arg a = {.i = 1};
|
||||
quit(&a);
|
||||
}
|
||||
|
||||
void
|
||||
sigterm(int unused)
|
||||
{
|
||||
Arg a = {.i = 0};
|
||||
quit(&a);
|
||||
}
|
||||
|
||||
void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
@@ -2143,6 +2198,7 @@ main(int argc, char *argv[])
|
||||
fputs("warning: no locale support\n", stderr);
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("dwm: cannot open display");
|
||||
compileregexes();
|
||||
checkotherwm();
|
||||
setup();
|
||||
#ifdef __OpenBSD__
|
||||
@@ -2151,6 +2207,7 @@ main(int argc, char *argv[])
|
||||
#endif /* __OpenBSD__ */
|
||||
scan();
|
||||
run();
|
||||
if(restart) execvp(argv[0], argv);
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user