Don't save window size to config if window is maximized#727
Merged
Conversation
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
WindowConfig::LoadFromConfig/SaveToConfigdefinitions inWindowConfig.cppstill usestd::shared_ptr<IptuxConfig>while the declarations inWindowConfig.huseIptuxConfig::Ptr, which will cause a mismatch; update the cpp signatures to match the header typedef. - In
WindowConfig::on_configure_event,user_datais blindly cast toWindowConfig*without a null check; consider adding anullptrcheck (and usingreinterpret_castinstead of a C-style cast) to avoid undefined behavior if the callback is connected incorrectly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `WindowConfig::LoadFromConfig`/`SaveToConfig` definitions in `WindowConfig.cpp` still use `std::shared_ptr<IptuxConfig>` while the declarations in `WindowConfig.h` use `IptuxConfig::Ptr`, which will cause a mismatch; update the cpp signatures to match the header typedef.
- In `WindowConfig::on_configure_event`, `user_data` is blindly cast to `WindowConfig*` without a null check; consider adding a `nullptr` check (and using `reinterpret_cast` instead of a C-style cast) to avoid undefined behavior if the callback is connected incorrectly.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #727 +/- ##
==========================================
+ Coverage 51.59% 51.61% +0.02%
==========================================
Files 64 64
Lines 8866 8866
==========================================
+ Hits 4574 4576 +2
+ Misses 4292 4290 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors window size persistence in the GTK UI by centralizing load/save logic in WindowConfig, and prevents persisting “non-normal” window dimensions (maximized/fullscreen/minimized) so restored window sizes reflect only the normal state.
Changes:
- Refactor main window and transfer window to use a shared
WindowConfighelper that loads from config on construction and saves on configure events. - Skip persisting window dimensions when the window is maximized, fullscreen, or iconified (minimized).
- Introduce
std::shared_ptrtypedef aliases (Ptr,ConstPtr) forIptuxConfigandUiCoreThread.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/iptux/WindowConfig.h | Extends WindowConfig to own a config pointer, auto-load persisted size, and expose a shared configure-event handler. |
| src/iptux/WindowConfig.cpp | Implements Save() and a GTK configure-event callback that avoids saving sizes in maximized/fullscreen/iconified states. |
| src/iptux/UiCoreThread.h | Adds UiCoreThread::Ptr typedef for shared ownership. |
| src/iptux/TransWindow.cpp | Switches transfer window sizing/persistence to WindowConfig and hooks shared configure-event handler. |
| src/iptux/MainWindow.h | Removes now-obsolete configure-event handler declarations. |
| src/iptux/MainWindow.cpp | Uses WindowConfig for persistence and connects the shared configure-event handler. |
| src/iptux/Application.h | Updates config member and accessor to use IptuxConfig::Ptr. |
| src/api/iptux-core/IptuxConfig.h | Adds Ptr / ConstPtr typedef aliases for IptuxConfig. |
Comment on lines
+33
to
+36
| WindowConfig* self = (WindowConfig*)user_data; | ||
| GdkWindow* gdk_win = gtk_widget_get_window(GTK_WIDGET(window)); | ||
|
|
||
| if (gdk_win != NULL) { |
|
❌ The last analysis has failed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Unify window size persistence through WindowConfig and avoid saving dimensions when windows are minimized, maximized, or fullscreened.
Bug Fixes:
Enhancements: