-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getWindowsAt errors randomly on Linux with PyQt6 #18
Comments
I think the issue is that I had a window disappear at the same time. The following fixed the issue and properly only listed existing non-problematic windows: def getAllWindows():
"""
Get the list of Window objects for all visible windows
:return: list of Window objects
"""
windows = EWMH.getClientList()
def remove_bad_windows(windows):
for window in windows:
try:
yield LinuxWindow(window)
except Xlib.error.XResourceError:
pass
return [window for window in remove_bad_windows(windows)] Edit: added the full |
Hi! Thank you so much for your comments and help! Sorry not to properly understand your issue. Is it solved now? Just curious, what does it mean "a window disappear"? Can you explain a little further or, even better, paste an example on how you create that window/widget? I think I could use your piece of code to solve the problem, right? But, since it's Linux specific, I would need to test/develop in other platforms too! Thanks again. |
Hi! Sorry I'll try to be a bit more clear. Especially now that I have a better understanding of what's happening. A bit of context: The issue on the code side: How I think I'm triggering the issue: Possible fixes:
Once again, I don't think |
Thanks a lot for your time and this careful and so well explained issue. This kind of discussion really helps me out to improve the module's approach from a real development perspective (not what I somehow "imagine" it should be, I mean). The general answer is yes, Another fix that I was debating with myself is to wrap some parts within a In this case, I think the best option is to use your piece of code to make a last "filter", returning only "good windows", whilst avoiding to crash. I will apply this solution to all other methods which return Window() objects and all other platforms. Thanks a lot for this. Besides, if you have any Xlib knowledge... do you know if there is any way or anything I can try to send a window above the wallpaper but behind desktop icons in GNOME??? This problem is turning me crazy (I managed to make it work in Thanks a lot again! |
Given my use case, I wouldn't mind either solutions. Unfortunately I'm still very new to developing on Linux (and MacOS). I am learning a lot as I am porting https://github.com/Avasam/Auto-Split/tree/linux , which deals with recording specific windows or screens, window positions and sizes, listening to user inputs, and sending keystrokes. But if I find anything, I'll gladly let you know. I'd like to abstract away the Window system for all 3 platforms in my project and this is exactly what PyWinCtl already does. So any improvements I can bring to fully switch to an existing library instead of re-inventing the wheel, I'll do so. |
Wow! Really interesting module! It seems quite complex too, an impressive point to start learning from! I am out these days, but I hope that in a few days I will upload a new version of PyWinCtl including the improvements you suggested to avoid crashes. I will let you know so you can keep working with it. So happy to hear it's useful! I really appreciate your comments and any issue, comment or suggestion you may have in the future. Keep pushing, mate!!! |
Here's my stack trace. Simply calling
pywinctl.getWindowsAt(x, y)
results in an error most of the time. Seemingly randomly.Ubuntu 22.04
Possibly caused by the fact I generate a PyQt widget for the screen-point selection. I wouldn't be surprised if it tries to create a LinuxWindow with it and fails.
The text was updated successfully, but these errors were encountered: