Skip to content

Present window on activation - #739

Open
City-busz wants to merge 1 commit into
iptux-src:mainfrom
City-busz:patch-3
Open

Present window on activation#739
City-busz wants to merge 1 commit into
iptux-src:mainfrom
City-busz:patch-3

Conversation

@City-busz

@City-busz City-busz commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

This ensures that the main window brings to the front if the application is already launched.

Summary by Sourcery

New Features:

  • Bring the existing application window to the foreground when the application is activated again.

This ensures that the main window brings to the front if the application is already launched.
@sourcery-ai

sourcery-ai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates post-startup activation handling to bring the active main window to the front, while preserving the existing first-start initialization path.

Sequence diagram for presenting the window on activation

sequenceDiagram
    participant Application
    participant GTK
    participant Window
    Application->>Application: onActivate(self)
    alt self.started
        Application->>GTK: gtk_application_get_active_window(self.app)
        GTK-->>Application: window
        alt window exists
            Application->>Window: gtk_window_present(window)
        end
    else first activation
        Application->>Application: self.started = true
    end
Loading

File-Level Changes

Change Details Files
Present the existing application window when activation occurs after startup.
  • Retrieve the active GTK application window on subsequent activations.
  • Call gtk_window_present when a window is available, leaving activation unchanged when none exists.
src/iptux/Application.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/iptux/Application.cpp" line_range="213-216" />
<code_context>

 void Application::onActivate(Application& self) {
   if (self.started) {
+    auto window = gtk_application_get_active_window(self.app);
+    if (window) {
+      gtk_window_present(window);
+    }
     return;
</code_context>
<issue_to_address>
**issue (bug_risk):** The activation handler presents whichever window GTK currently marks active instead of the application's main window. If a secondary dialog is active, the dialog is raised while the main window remains behind; if the main window is hidden and no window is active, the handler does nothing.

**Triggers:** When an already-running instance is activated while a secondary dialog is focused or the main window is hidden.

**Suggested fix:** Call `self.window->Show()` (or explicitly present and deiconify `self.window->getWindow()`) instead of querying the active window.

```suggestion
    self.window->Show();
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/iptux/Application.cpp:216


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.

Comment thread src/iptux/Application.cpp
Comment on lines +213 to +216
auto window = gtk_application_get_active_window(self.app);
if (window) {
gtk_window_present(window);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The activation handler presents whichever window GTK currently marks active instead of the application's main window. If a secondary dialog is active, the dialog is raised while the main window remains behind; if the main window is hidden and no window is active, the handler does nothing.

Triggers: When an already-running instance is activated while a secondary dialog is focused or the main window is hidden.

Suggested fix: Call self.window->Show() (or explicitly present and deiconify self.window->getWindow()) instead of querying the active window.

Suggested change
auto window = gtk_application_get_active_window(self.app);
if (window) {
gtk_window_present(window);
}
self.window->Show();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@City-busz please confirm

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.48%. Comparing base (f47c73f) to head (71389b9).

Files with missing lines Patch % Lines
src/iptux/Application.cpp 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #739   +/-   ##
=======================================
  Coverage   52.47%   52.48%           
=======================================
  Files          71       71           
  Lines        9004     9007    +3     
=======================================
+ Hits         4725     4727    +2     
- Misses       4279     4280    +1     

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

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