Why Does Minimization Immediately after Show and Activation Cause Non-Minimization?
-
Subject. See reproducer below in PySide6, but the window is not minimized when the code runs. Any way to work around this issue besides adding a short delay, or am I simply crazy for coming up with mashing together random window state commands to find random bugs in Qt?
import sys from PySide6.QtWidgets import QApplication, QMainWindow app = QApplication(sys.argv) window = QMainWindow() window.setWindowTitle("Test Window") window.resize(400, 300) window.show() window.activateWindow() window.showMinimized() sys.exit(app.exec())
Thank you!
-
Hi,
Which version of PySide6
On which OS ?
If Linux:- Which distribution ?
- Which window manager ?
-
Subject. See reproducer below in PySide6, but the window is not minimized when the code runs. Any way to work around this issue besides adding a short delay, or am I simply crazy for coming up with mashing together random window state commands to find random bugs in Qt?
import sys from PySide6.QtWidgets import QApplication, QMainWindow app = QApplication(sys.argv) window = QMainWindow() window.setWindowTitle("Test Window") window.resize(400, 300) window.show() window.activateWindow() window.showMinimized() sys.exit(app.exec())
Thank you!
@johnzhou721
I have tried your code under Ubuntu 24.04, GNOME, Xorg, Qt ~6.4.I agree that something about the combination of
window.show() window.activateWindow()
(seems to require both) preceding makes
window.showMinimized()
not minimize. I am not sure what/how it works exactly.Putting the
showMinimized
into asingleShot()
makes the minimization work. This is not an uncommon technique in Qt UI code, so if it were ne I would probably accept and live with it, unless there is a pressing reason you do not want to do this.I know you are asking about that and window state elsewhere. It is hard to keep tabs on your various separate threads which are really all to do with the same issue.
-
@johnzhou721 said in Why Does Minimization Immediately after Show and Activation Cause Non-Minimization?:
Hi @SGaist! Sorry, latest PySide6, Linux, Fedora KDE Spin, X11.
@JonB Ok... turns out still not minimizing after singleShot... somehow delaying by 100ms works...
I'm interested in knowing why this happesn.
because you are dealing with asyncronous events being handled by a window manager and the state information between app and X11 isn't consistent until you put in a delay to allow the interface to be "realized".
For S&G tryi running your app as the sole X11 client (no window manager) to verify my suspicions.
-
@Kent-Dorfman Alright, just learnt that X11 keeps its separate state. Is there a signal that signifies "finishes activating"? By the way this is purely theoretical as no reasonable userspace app would do that.
-
@Kent-Dorfman Alright, just learnt that X11 keeps its separate state. Is there a signal that signifies "finishes activating"? By the way this is purely theoretical as no reasonable userspace app would do that.
@johnzhou721 said in Why Does Minimization Immediately after Show and Activation Cause Non-Minimization?:
@Kent-Dorfman Alright, just learnt that X11 keeps its separate state. Is there a signal that signifies "finishes activating"?
Not that I'm aware of, at least in any reliable way. There are introspection programs that can display information about a window, provided you know the windows handle id, but original X11 wasn't really designed with the feaure you seek in mind.
However, certain desktop environment projects have invented complicated mousetraps to address some of these issues...ie dbus comms between apps. I won't mention the project itself by name because I'm an outspoken critic of it. LOL