Enable another application's window to be dragged and dropped onto my widget ?
-
I would like to build a widget wherein I can drag another application's window onto my widget and drop it. My widget will then do things with the other window such as minimize, move it, etc.
How do I sense when the other application is dropped on my widget ? I have drag and drop working for text file, etc. but it doesn't work for another window, probably because the other window receives the mouse events of the drop, not my widget.
Is there a way to capture a drag and drop event for the desktop from my widget ?
Once the other application's window is dropped on my widget, I need to get the handle of the other window. How do I do that ?
Thanks
-
Hi and welcome to devnet,
In the scenario you describe, there is no drag and drop happening at the application level.
You have a different application which has the focus and which window is moved around on the desktop. Your own application will not receive any specific events related to that beside repainting itself because something has changed in its visibility and that will also depend on the window manager you use.
If there's anything that can be done, you should check that at the WM level to see if there's a protocol that allows this kind of communication.
-
@SGaist I figured that. Thanks for the reply.
What if one sensed the position of the mouse outside the application, figure out if it stops over the application's area and if a window is then overlapping the application ? Could that be done ?
If dragging and dropping a window like that does happen at the WM level, how do I pass that into my PyQt application ?
-
@LinuxGuy
I think it is not easy to see the mouse outside of your application windows. Might have to "grab" the mouse, which is not pretty and can leave window system unstable, might be able to "poll" on a timer (https://stackoverflow.com/a/29400627/489865). Google forqt mouse outside application
. Then there is the complication that the windowing system is in the middle of a window-drag operation, which can only make it harder, and you want to detect drop as well. And if you are using Wayland wouldn't surprise me if it stops you doing this (I have no evidence for this, just that it sounds like what it would want to prevent).Can you name an application, other than something in the window manager itself, which does what you are wanting to do?