Literally hand applied patch for window swallowing in tmux
Taken from https://web.archive.org/web/20221118135147/https://gist.github.com/ghesy/0ac35d048672c63d7fc3afb1fde4c5f2
This commit is contained in:
parent
8664d1db43
commit
b7c298e10b
2
config.h
2
config.h
|
@ -5,7 +5,7 @@
|
|||
/* appearance */
|
||||
static const unsigned int borderpx = 3; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const int swallowfloating = 1; /* 1 means swallow floating windows by default */
|
||||
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "IosevkaTerm Nerd Font:size=12", "Noto Color Emoji" };
|
||||
|
|
43
dwm.c
43
dwm.c
|
@ -251,6 +251,8 @@ static void zoom(const Arg *arg);
|
|||
|
||||
static pid_t getparentprocess(pid_t p);
|
||||
static int isdescprocess(pid_t p, pid_t c);
|
||||
static int istmuxserver(pid_t p);
|
||||
static long gettmuxclientpid(long shellpid);
|
||||
static Client *swallowingclient(Window w);
|
||||
static Client *termforwin(const Client *c);
|
||||
static pid_t winpid(Window w);
|
||||
|
@ -2441,7 +2443,7 @@ getparentprocess(pid_t p)
|
|||
if (!(f = fopen(buf, "r")))
|
||||
return 0;
|
||||
|
||||
fscanf(f, "%*u %*s %*c %u", &v);
|
||||
fscanf(f, "%*u (%*[^)]) %*c %u", &v);
|
||||
fclose(f);
|
||||
#endif /* __linux__*/
|
||||
|
||||
|
@ -2464,12 +2466,45 @@ getparentprocess(pid_t p)
|
|||
int
|
||||
isdescprocess(pid_t p, pid_t c)
|
||||
{
|
||||
while (p != c && c != 0)
|
||||
c = getparentprocess(c);
|
||||
|
||||
pid_t p_tmp;
|
||||
while (p != c && c != 0) {
|
||||
p_tmp = getparentprocess(c);
|
||||
if (istmuxserver(p_tmp))
|
||||
c = gettmuxclientpid(c);
|
||||
else
|
||||
c = p_tmp;
|
||||
}
|
||||
return (int)c;
|
||||
}
|
||||
|
||||
int
|
||||
istmuxserver(pid_t p)
|
||||
{
|
||||
char path[256];
|
||||
char name[15];
|
||||
FILE* stat;
|
||||
|
||||
snprintf(path, sizeof(path) - 1, "/proc/%u/stat", (unsigned)p);
|
||||
if (!(stat = fopen(path, "r")))
|
||||
return 0;
|
||||
fscanf(stat, "%*u (%12[^)])", name);
|
||||
fclose(stat);
|
||||
return (strcmp(name, "tmux: server") == 0);
|
||||
}
|
||||
|
||||
long
|
||||
gettmuxclientpid(long shellpid)
|
||||
{
|
||||
long volatile panepid, clientpid;
|
||||
FILE* list = popen("tmux list-clients -F '#{pane_pid} #{client_pid}'", "r");
|
||||
if (!list)
|
||||
return 0;
|
||||
while (!feof(list) && panepid != shellpid)
|
||||
fscanf(list, "%ld %ld\n", &panepid, &clientpid);
|
||||
pclose(list);
|
||||
return clientpid;
|
||||
}
|
||||
|
||||
Client *
|
||||
termforwin(const Client *w)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue