1 From 160481b9922acb5f183bc5cb2af675cdc508db0c Mon Sep 17 00:00:00 2001
2 From: Jan Palus <atler@pld-linux.org>
3 Date: Wed, 13 Jan 2021 01:57:44 +0100
4 Subject: [PATCH] add support for single process terminals
6 some terminals (urxvt in daemon mode, mate-terminal) consist of single
7 process having multiple X windows. This in turn breaks ueberzug which
8 requires 1:1 mapping between PID and window id. If present use WINDOWID
9 environment variable set by those terminals as a direct pointer to
10 window which should be target for displayed image.
12 ueberzug/xutil.py | 24 +++++++++++++++++++-----
13 1 file changed, 19 insertions(+), 5 deletions(-)
15 diff --git a/ueberzug/xutil.py b/ueberzug/xutil.py
16 index 2c6c871..6864aa4 100644
17 --- a/ueberzug/xutil.py
18 +++ b/ueberzug/xutil.py
20 """This module contains x11 utils"""
26 import Xlib.display as Xdisplay
27 @@ -84,6 +85,16 @@ def get_pid_by_window_id(display: Xdisplay.Display, window_id: int):
31 +def get_visible_window_ids(display: Xdisplay.Display = None):
32 + d = display or get_display()
34 + return d.screen().root.get_full_property(
35 + d.intern_atom('_NET_CLIENT_LIST'),
36 + Xlib.X.AnyPropertyType).value
41 def get_pid_window_id_map():
42 """Determines the pid of each mapped window.
44 @@ -92,11 +103,7 @@ def get_pid_window_id_map():
46 with get_display() as display:
47 root = display.screen().root
48 - visible_window_ids = \
49 - (root.get_full_property(
50 - display.intern_atom('_NET_CLIENT_LIST'),
51 - Xlib.X.AnyPropertyType)
53 + visible_window_ids = get_visible_window_ids(display)
55 get_pid_by_window_id(display, window.id): window.id
56 for window in root.query_tree().children
57 @@ -159,6 +166,13 @@ def get_parent_window_infos():
59 list of TerminalWindowInfo
62 + window_id = os.getenv('WINDOWID')
64 + if window_id and window_id.isnumeric() and int(window_id) in get_visible_window_ids():
65 + pty = get_first_pty(get_parent_pids(process.get_own_pid()))
66 + return [TerminalWindowInfo(int(window_id), pty)]