Skip to content

Conversation

@ryan-steed-usa
Copy link
Contributor

This change fixes an issue where the statistics dialog would not properly restore its maximized state when reopening. The previous implementation attempted to manually set the window geometry to simulate a maximized state, but this approach was unreliable and didn't properly handle screen boundaries or multi-monitor setups.

The fix replaces the manual geometry setting with a proper call to showMaximized() when the dialog is visible, ensuring that Qt's window management correctly handles the maximized state restoration. This provides consistent behavior across different platforms and display configurations.

Changes made:

  • Removed the manual geometry calculation that attempted to simulate maximized state
  • Added proper isVisible() check before calling showMaximized() to ensure the window is properly initialized
  • Simplified the maximized state restoration logic to use Qt's built-in functionality

A potential caveat is that showMaximized() may encounter problems with X11 although the benefit may outweigh the risk to enhance multi-monitor capability and better compensate for desktop resolution changes. More testing is warranted. Patched 1.7.2 seems to work as expected with KDE Plasma 6.5.2 with Wayland, Linux Mint 22.2 Cinnamon 6.4.8, Ubuntu 24.04 with Gnome 46 and Ubuntu 25.04 with Gnome 48.

X11 provides no standard or easy way to get the frame geometry once the window is decorated. Qt solves this problem with nifty heuristics and clever code that works on a wide range of window managers that exist today. Don't be surprised if you find one where QWidget::frameGeometry() returns wrong results though.

Nor does X11 provide a way to maximize a window. QWidget::showMaximized() has to emulate the feature. Its result depends on the result of QWidget::frameGeometry() and the capability of the window manager to do proper window placement, neither of which can be guaranteed.

…metry

This change fixes an issue where the statistics dialog would not properly restore its maximized state when reopening. The previous implementation attempted to manually set the window geometry to simulate a maximized state, but this approach was unreliable and didn't properly handle screen boundaries or multi-monitor setups.

The fix replaces the manual geometry setting with a proper call to showMaximized() when the dialog is visible, ensuring that Qt's window management correctly handles the maximized state restoration. This provides consistent behavior across different platforms and display configurations.

Changes made:
- Removed the manual geometry calculation that attempted to simulate maximized state
- Added proper isVisible() check before calling showMaximized() to ensure the window is properly initialized
- Simplified the maximized state restoration logic to use Qt's built-in functionality
@ryan-steed-usa
Copy link
Contributor Author

Closes #1431

@gustavo-iniguez-goya
Copy link
Collaborator

gustavo-iniguez-goya commented Nov 22, 2025

thank you @ryan-steed-usa !

I didn't use showMaximized() because it didn't work well on Xwayland #1374, I don't remember the problem but I think it didn't restore the state correctly on Wayland.
Anyway, I've tested the PR on Xorg and Xwayland. On Xorg seems to work fine, but on Wayland (Arch, updated) sometimes when clicking on the systray icon to restore the GUI to the maximized state it fails with:

dialogs/stats.py, line 867, eventFilter
RecursionError: maximum recursion depth exceeded

The problem is that showMaximized() fires the event showEvent(), in showEvent() we load again the settings, showMaximized() is called again, and we end up in a loop.

One option could be to not override showEvent(), and replace it with show() (I've only tested it on Arch/Wayland and Mint22/Xorg):

def showEvent() -> def show()

def show(self):
  ...
  self.load_settings()
  ...
  super(StatsDialog, self).show()

See please if you can reproduce this bug.

This change modifies the StatsDialog class to use the show() method instead of overriding showEvent(). This resolves a recursion error.

Changes made:
- Replaced the showEvent() method override with a show() method
- Maintained the same functionality including:
  - Emitting the _shown_trigger signal
  - Setting window state to active and unminimized
  - Updating the window title with version information
- Removed the event parameter since show() doesn't receive event arguments
- Preserved all existing logic for address checking and window title formatting

Co-authored-by: Gustavo Iñiguez Goia <[email protected]>
@ryan-steed-usa
Copy link
Contributor Author

@gustavo-iniguez-goya

See please if you can reproduce this bug.

Forgive me. I'd only tested with manually patched 1.7.2 versions, where I cannot reproduce the bug. But I have successfully reproduced the recursion error with master branch builds (1.7.3 candidate) while testing with Archlinux and Ubuntu. I'm guessing that the PyQT6 migration, or Qt6 itself, has manifest the bug?

Per your suggestion, I've added a new commit that does resolve the error everywhere I've tested. Let me know if it's acceptable or not. Thanks!

@gustavo-iniguez-goya gustavo-iniguez-goya merged commit 0260693 into evilsocket:master Nov 23, 2025
@gustavo-iniguez-goya
Copy link
Collaborator

thank you @ryan-steed-usa ! just in time for the next release.

@ryan-steed-usa ryan-steed-usa deleted the minimize-maximize-geometry-fix branch November 23, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants