From b99f734407e5a60b7250f4e109e9f03f2de0b7f2 Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Mon, 10 Jan 2022 13:35:44 +0100 Subject: [PATCH 2/2] Adding riodraw patch with no PID matching --- config.def.h | 1 - dwm.c | 55 +++++++--------------------------------------------- 2 files changed, 7 insertions(+), 49 deletions(-) diff --git a/config.def.h b/config.def.h index bbbc6ca..bb3d58f 100644 --- a/config.def.h +++ b/config.def.h @@ -8,7 +8,6 @@ static const int topbar = 1; /* 0 means bottom bar */ static const char slopspawnstyle[] = "-t 0 -c 0.92,0.85,0.69,0.3 -o"; /* do NOT define -f (format) here */ static const char slopresizestyle[] = "-t 0 -c 0.92,0.85,0.69,0.3"; /* do NOT define -f (format) here */ static const int riodraw_borders = 0; /* 0 or 1, indicates whether the area drawn using slop includes the window borders */ -static const int riodraw_matchpid = 1; /* 0 or 1, indicates whether to match the PID of the client that was spawned with riospawn */ static const int riodraw_spawnasync = 0; /* 0 means that the application is only spawned after a successful selection while * 1 means that the application is being initialised in the background while the selection is made */ static const char *fonts[] = { "monospace:size=10" }; diff --git a/dwm.c b/dwm.c index 95cfcb5..0a72d89 100644 --- a/dwm.c +++ b/dwm.c @@ -177,14 +177,12 @@ static void focusin(XEvent *e); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static Atom getatomprop(Client *c, Atom prop); -static pid_t getparentprocess(pid_t p); static int getrootptr(int *x, int *y); static long getstate(Window w); static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static void grabbuttons(Client *c, int focused); static void grabkeys(void); static void incnmaster(const Arg *arg); -static int isdescprocess(pid_t p, pid_t c); static void keypress(XEvent *e); static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); @@ -893,39 +891,6 @@ getatomprop(Client *c, Atom prop) return atom; } -pid_t -getparentprocess(pid_t p) -{ - unsigned int v = 0; - -#ifdef __linux__ - FILE *f; - char buf[256]; - snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p); - - if (!(f = fopen(buf, "r"))) - return 0; - - fscanf(f, "%*u %*s %*c %u", &v); - fclose(f); -#endif /* __linux__*/ - -#ifdef __OpenBSD__ - int n; - kvm_t *kd; - struct kinfo_proc *kp; - - kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL); - if (!kd) - return 0; - - kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n); - v = kp->p_ppid; -#endif /* __OpenBSD__ */ - - return (pid_t)v; -} - int getrootptr(int *x, int *y) { @@ -1025,15 +990,6 @@ incnmaster(const Arg *arg) arrange(selmon); } -int -isdescprocess(pid_t p, pid_t c) -{ - while (p != c && c != 0) - c = getparentprocess(c); - - return (int)c; -} - #ifdef XINERAMA static int isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) @@ -1137,7 +1093,7 @@ manage(Window w, XWindowAttributes *wa) unfocus(selmon->sel, 0); c->mon->sel = c; - if (riopid && (!riodraw_matchpid || isdescprocess(riopid, c->pid))) { + if (riopid) { if (riodimensions[3] != -1) rioposition(c, riodimensions[0], riodimensions[1], riodimensions[2], riodimensions[3]); else { @@ -1535,10 +1491,13 @@ void riospawn(const Arg *arg) { if (riodraw_spawnasync) { - riopid = spawncmd(arg); + spawn(arg); + riopid = 1; riodraw(NULL, slopspawnstyle); - } else if (riodraw(NULL, slopspawnstyle)) - riopid = spawncmd(arg); + } else if (riodraw(NULL, slopspawnstyle)) { + spawn(arg); + riopid = 1; + } } void -- 2.19.1