Repository: qtile/qtile

Issue:
Systray breaks when reloading qtile (on multimonitor)
<!--
Please do not ask general questions here! There are [community
contact](https://github.com/qtile/qtile#community) options for that.
-->

# Issue description

<!--
A brief discussion of what failed and how it failed. A description of
what you tried is helpful, i.e. "When I use lazy.kill() on a window I get
the following stack trace" instead of "Closing windows doesn't work".
-->

When reloading qtile (`qtile cmd-obj -o cmd -f restart`) items on the systray widget before the restart move between screens and become un-iteractable

# Qtile version

<!--
Please include the exact commit hash of the version of Qtile that failed.
-->
0.18.1.dev0+g8e7ecc0a.d20210719 (from arch repos)

# Stack traces

<!--
Please attach any stack traces found in:

* `~/.xsession-errors`
* `~/.local/share/qtile/qtile.log`
-->
<details><summary>~/.xsession-errors</summary><pre>
sh: 0: Can't open .xinitrc

(redshift-gtk:21369): Gdk-CRITICAL **: 20:17:50.499: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
</pre></details>

<details><summary>~/.local/share/qtile/qtile.log</summary><pre>
2021-07-22 20:07:47,917 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-07-22 20:07:47,919 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-07-22 20:07:48,455 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:07:48,455 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:07:48,455 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:15:24,497 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-07-22 20:15:24,499 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-07-22 20:15:24,891 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 298, in _xpoll
    ret = target(event)
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 688, in handle_DestroyNotify
    if self.qtile.current_window is None:
  File "/usr/lib/python3.9/site-packages/libqtile/core/manager.py", line 522, in current_window
    return self.current_screen.group.current_window
AttributeError: 'Qtile' object has no attribute 'current_screen'
2021-07-22 20:15:25,092 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:15:25,093 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:15:25,093 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:15:30,433 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-07-22 20:15:30,436 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-07-22 20:15:30,991 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:15:30,991 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:15:30,992 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:16:47,274 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-07-22 20:16:47,276 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-07-22 20:16:47,833 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:16:47,834 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:16:47,834 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:16:59,723 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-07-22 20:16:59,731 WARNING libqtile lifecycle.py:_atexit():L38 Qtile will now terminate
2021-07-22 20:17:06,070 ERROR libqtile hook.py:fire():L381 Error in hook startup_once
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/hook.py", line 379, in fire
    i(*args, **kwargs)
  File "/home/tom/.config/qtile/config.py", line 369, in autostart
    subprocess.Popen(p)
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ydotoold'
2021-07-22 20:17:22,364 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-07-22 20:17:22,366 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-07-22 20:17:22,812 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:17:22,813 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:17:43,217 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-07-22 20:17:43,222 WARNING libqtile lifecycle.py:_atexit():L38 Qtile will now terminate
2021-07-22 20:17:50,277 ERROR libqtile hook.py:fire():L381 Error in hook startup_once
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/hook.py", line 379, in fire
    i(*args, **kwargs)
  File "/home/tom/.config/qtile/config.py", line 369, in autostart
    subprocess.Popen(p)
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ydotoold'
2021-07-22 20:21:20,770 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-07-22 20:21:20,772 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-07-22 20:21:21,312 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:21:21,313 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:21:21,313 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:21:21,313 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
</pre></details>

# Configuration

<!--
Please include a link or attach your configuration to the issue.
-->
https://github.com/Douile/dotfiles/blob/94696777f3f5c6a35e410a6aafdaa5fe40b78a37/.config/qtile/config.py


Discussion:
After reloading twice the systray icons became windows that were being tiled by qtile
<details><summary>Extra logs</summary><pre>
2021-07-22 20:46:37,075 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-07-22 20:46:37,630 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:46:37,631 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:46:37,631 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
2021-07-22 20:46:37,631 ERROR libqtile core.py:_xpoll():L330 Got an exception in poll loop
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/backend/x11/core.py", line 283, in _xpoll
    event = self.conn.conn.poll_for_event()
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 571, in wrapper
    return f(*args)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 612, in poll_for_event
    return self.hoist_event(e)
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 686, in hoist_event
    return self._process_error(ffi.cast("xcb_generic_error_t *", e))
  File "/usr/lib/python3.9/site-packages/xcffib/__init__.py", line 649, in _process_error
    raise error(buf)
xcffib.xproto.MatchError
</pre></details>
Are you getting those MatchError's without reloading qtile?
Yes
OK. I only get the MatchError's when I restart, not when I start an app which puts an icon in the System Tray.

However, I do get odd behaviour when restarting (icon is drawn over other widgets) so there is something that needs to be fixed.
Feels like this may be related: https://github.com/qtile/qtile/pull/2372
> Yes

* I am actually the same, MatchError s only occur after reload (hadn't cleared my logs in a while :) )
So, I think this is an issue with how the widget cleans itself up while restarting. Will need a bit of effort to sort this one I think. 

Will add to my list...
Thanks. Maybe not directly related as the issue wasn't occurring on 0.17 and it seems like that PR was merged before that.

Resolving patch:
diff --git a/libqtile/widget/systray.py b/libqtile/widget/systray.py
--- a/libqtile/widget/systray.py
+++ b/libqtile/widget/systray.py
@@ -142,6 +142,19 @@ def _configure(self, qtile, bar):
         self.bar = bar
         atoms = conn.atoms
 
+        # We need tray to tell icons which visual to use.
+        # This needs to be the same as the bar/widget.
+        # This mainly benefits transparent bars.
+        conn.conn.core.ChangeProperty(
+            xcffib.xproto.PropMode.Replace,
+            win.wid,
+            atoms["_NET_SYSTEM_TRAY_VISUAL"],
+            xcffib.xproto.Atom.VISUALID,
+            32,
+            1,
+            [self.drawer._visual.visual_id]
+        )
+
         conn.conn.core.SetSelectionOwner(
             win.wid,
             atoms['_NET_SYSTEM_TRAY_S{:d}'.format(self.screen)],
@@ -161,19 +174,6 @@ def _configure(self, qtile, bar):
         )
         qtile.core._root.send_event(event, mask=EventMask.StructureNotify)
 
-        # We need tray to tell icons which visual to use.
-        # This needs to be the same as the bar/widget.
-        # This mainly benefits transparent bars.
-        conn.conn.core.ChangeProperty(
-            xcffib.xproto.PropMode.Replace,
-            win.wid,
-            atoms["_NET_SYSTEM_TRAY_VISUAL"],
-            xcffib.xproto.Atom.VISUALID,
-            32,
-            1,
-            [self.drawer._visual.visual_id]
-        )
-
     def handle_ClientMessage(self, event):  # noqa: N802
         atoms = self.conn.atoms
 


Test patch: