Skip to content

Don't save window size to config if window is maximized#727

Merged
lidaobing merged 8 commits into
mainfrom
bf_not_save_window_size_in_max
Jul 15, 2026
Merged

Don't save window size to config if window is maximized#727
lidaobing merged 8 commits into
mainfrom
bf_not_save_window_size_in_max

Conversation

@lidaobing

@lidaobing lidaobing commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary by Sourcery

Unify window size persistence through WindowConfig and avoid saving dimensions when windows are minimized, maximized, or fullscreened.

Bug Fixes:

  • Prevent saving window size to configuration when the window is maximized, fullscreen, or minimized, so restored sizes reflect normal state only.

Enhancements:

  • Refactor main and transfer window sizing to use a shared WindowConfig helper with automatic loading and saving.
  • Introduce typedef aliases for IptuxConfig and UiCoreThread shared pointer types for clearer usage.

@sourcery-ai

This comment was marked as spam.

@lidaobing lidaobing changed the title Bf not save window size in max Don't save window size to config if window is maximized Jul 15, 2026
@lidaobing
lidaobing requested a review from Copilot July 15, 2026 04:46

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Test Results

69 tests  ±0   69 ✅ ±0   3s ⏱️ ±0s
32 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f0dc6. ± Comparison against base commit 080485e.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.00000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.61%. Comparing base (080485e) to head (52f0dc6).

Files with missing lines Patch % Lines
src/iptux/WindowConfig.cpp 0.00% 11 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 WindowConfig helper 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_ptr typedef aliases (Ptr, ConstPtr) for IptuxConfig and UiCoreThread.

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 thread src/iptux/TransWindow.cpp Outdated
Comment thread src/iptux/WindowConfig.h Outdated
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) {
@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@lidaobing
lidaobing merged commit bf18cec into main Jul 15, 2026
16 of 22 checks passed
@lidaobing
lidaobing deleted the bf_not_save_window_size_in_max branch July 15, 2026 05:00
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