Closed Fom123 closed 1 year ago
@Fom123
Sorry you're having this issue.
Do you have the ability to print out what this returns so we can see why it's saying it's giving an int
to get_full_text_property()
? I can't replicate this on an empty workspace on my system (Fedora/GNOME). I've never run into anything like this in testing.
print(f'### Bad result of _NET_WM_NAME: {_display.get_atom("_NET_WM_NAME")}')
The proposed try/except should make it work, but it would also be good to get a better understanding of exactly what's happening.
I'd do it myself but I have no experience with qtile
.
@RedBearAK it doesn't give int
to get_full_text_property
. The window object is an integer(1
in my case) and that's why the error occurs.
From the xlib source code
def get_input_focus(self):
"""Return an object with the following attributes:
focus
The window which currently holds the input
focus, X.NONE or X.PointerRoot.
X.NONE
is 0
X.PointerRoot
is 1
.
So we have to handle the case when focus
is a non-window object. Something like this would work.
from Xlib.xobject.drawable import Window
def get_actual_window(window):
# use _NET_WM_NAME string instead of WM_NAME to bypass (COMPOUND_TEXT) encoding problems
if not isinstance(window, Window):
return None
wmname = window.get_full_text_property(_display.get_atom("_NET_WM_NAME"))
wmclass = window.get_wm_class()
# workaround for Java app
# https://github.com/JetBrains/jdk8u_jdk/blob/master/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java#L35
if (wmclass is None and wmname is None) or "FocusProxy" in (wmclass or ""):
parent_window = window.query_tree().parent
if parent_window:
return get_actual_window(parent_window)
return None
return window
I see. In that case it looks like it could just as easily be:
if isinstance(window, int):
return None
Without needing to import anything. If I'm reading the description right, it's either going to be a valid window object, or an int
(0 or 1).
But either way should work.
if not isinstance(window, Window):
return None
Looks good to me. PR?
@joshgoebel
Submitted #144 to fix this.
Seems to work OK for me, and I don't know why it wouldn't, but I have no way of testing the int
condition that this user ran into.
Thanks! I guess it can be closed now.
Describe the bug or unexpected behavior
When I switch to empty workspace in my window manager (
qtile
), I get the following error.Instructions to Reproduce
keyszer
hangs with attribute error.Your setup
3.10
(+K)
we're handling input from:Expected behavior It shouldn't give an error.
Additional context
xprop
of the desktopPossible workaround Ignore all exceptions, as it was before f8e5014 commit.