fix(wm,tray,replace): fix fullscreen focus, systray XEmbed race, and display-scoped cleanup

This commit is contained in:
Luxferre committed 2026-11-26 19:28:26 +02:00
1 parent be7e3a3155
commit 8da5c5d1cb
4 files changed
+989 -69

No files matched your search

+46 -3
View File
@@ -160,6 +160,43 @@ get_win_pid() {
MY_UID="$(id -u)"
SELF_PID="$$"
norm_display() {
case "${1:-}" in
*.0) printf '%s\n' "${1%.0}" ;;
*) printf '%s\n' "${1:-}" ;;
esac
}
pid_matches_display() {
_p="$1"
[ -n "${DISPLAY:-}" ] || return 0
if [ -d "/proc/$SELF_PID" ]; then
[ -r "/proc/$_p/environ" ] || return 1
_pdisp="$(tr '\0' '\n' < "/proc/$_p/environ" 2>/dev/null | awk 'substr($0, 1, 8) == "DISPLAY=" { print substr($0, 9); exit }' || true)"
[ -n "${_pdisp:-}" ] || return 1
[ "$(norm_display "$_pdisp")" = "$(norm_display "$DISPLAY")" ] && return 0
return 1
fi
_pe="$(ps eww -p "$_p" 2>/dev/null || true)"
if [ -n "${_pe:-}" ]; then
_pdisp="$(printf '%s\n' "$_pe" | awk '
{
for (i = 1; i <= NF; i++) {
if (substr($i, 1, 8) == "DISPLAY=") {
print substr($i, 9)
exit
}
}
}
' || true)"
if [ -n "${_pdisp:-}" ]; then
[ "$(norm_display "$_pdisp")" = "$(norm_display "$DISPLAY")" ] && return 0
return 1
fi
fi
return 0
}
find_wm_pid_by_name() {
_wmname="$1"
[ -n "$_wmname" ] || return 0
@@ -177,10 +214,14 @@ find_wm_pid_by_name() {
sub(/^.*\//, "", c)
if (tolower(c) == t) {
print $2
exit
}
}
'
' | while read -r _wpid; do
if pid_matches_display "$_wpid"; then
printf '%s\n' "$_wpid"
break
fi
done
}
get_ppid() {
@@ -236,7 +277,9 @@ kill_my_procs() {
if (c in want) print $2
}
' | while read -r _kpid; do
kill -TERM "$_kpid" 2>/dev/null || true
if pid_matches_display "$_kpid"; then
kill -TERM "$_kpid" 2>/dev/null || true
fi
done
}