Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Related: Issue describing difficulty in specializing MinimalWindowManager

What's new?

Added three new protected helper methods to MinimalWindowManager that allow subclasses to interact with the internal application_selector state. This enables subclasses to customize window management behavior (such as implementing "sloppy focus") while maintaining proper application selector state.

  • New Protected Methods: Added application_selector_advise_focus_gained(), application_selector_advise_focus_lost(), and application_selector_advise_delete_window() as protected non-virtual methods
  • Refactored Existing Methods: Updated advise_focus_gained(), advise_focus_lost(), and advise_delete_window() to call the new helper methods
  • Version Bump: Incremented MIRAL_VERSION_MINOR from 6 to 7 (now at 5.7.0)
  • Symbol Export: Added new public symbols to src/miral/symbols.map under MIRAL_5.7 section and to debian/libmiral7.symbols with version 5.7.0
  • Documentation: Added Doxygen comments for each new method marked as "Since MirAL 5.7"
  • Tests: Added comprehensive tests verifying subclasses can use the helper methods and demonstrating the sloppy focus use case, using modern C++ (std::make_unique)

Example Usage

Subclasses can now override advise_focus_gained() without calling tools.raise_tree() (for sloppy focus behavior) while still maintaining the application selector state:

class SloppyFocusWindowManager : public miral::MinimalWindowManager
{
public:
    using MinimalWindowManager::MinimalWindowManager;

    void advise_focus_gained(miral::WindowInfo const& window_info) override
    {
        // Don't raise the tree for sloppy focus
        application_selector_advise_focus_gained(window_info);
    }
};

How to test

  1. Run the new tests: CustomMinimalWindowManagerTest.application_selector_helpers_are_accessible_to_subclasses and CustomMinimalWindowManagerTest.sloppy_focus_does_not_raise_tree
  2. Verify the code compiles successfully with the updated MIRAL version
  3. Create a subclass of MinimalWindowManager that overrides advise_focus_gained() and uses the new application_selector_advise_focus_gained() helper method
  4. Confirm that the application selector state is properly maintained when using the helper methods
  5. Verify that the new symbols are properly exported in both src/miral/symbols.map and debian/libmiral7.symbols

Checklist

  • Tests added and pass
  • Adequate documentation added
  • (optional) Added Screenshots or videos
Original prompt

This section details on the original issue you should resolve

<issue_title>MinimalWindowManager is hard to specialise</issue_title>
<issue_description>### Summary

MinimalWindowManager overrides a number of methods to update or use the application_selector but it is not possible to customise the methods as subclasses do not have access to this object. In particular:

void miral::MinimalWindowManager::advise_focus_gained(WindowInfo const& window_info)
{
    tools.raise_tree(window_info.window());
    self->application_selector.advise_focus_gained(window_info);
}

Should a specialization of MinimalWindowManager want to drop the raise_tree to allow "sloppy focus" it has no way to update the application_selector.

One plausible solution is to "extract method" these updates:

void miral::MinimalWindowManager::advise_focus_gained(WindowInfo const& window_info)
{
    tools.raise_tree(window_info.window());
    application_selector_advise_focus_gained(window_info);
}

void miral::MinimalWindowManager::application_selector_advise_focus_gained(WindowInfo const& window_info)
{
    self->application_selector.advise_focus_gained(window_info);
}

Making application_selector_advise_focus_gained() et alias a protected method.

Details

No response

Prior Art

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
…version to 5.7

Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
@AlanGriffiths
Copy link
Contributor

These new symbols also need adding to symbols.map and libmiral.symbols

@AlanGriffiths
Copy link
Contributor

These new symbols also need adding to symbols.map and libmiral.symbols

@copilot

Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor MinimalWindowManager for better specialization Refactor MinimalWindowManager for better specialization Feb 5, 2026
Copilot AI requested a review from AlanGriffiths February 5, 2026 15:42
Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

These new symbols also need adding to symbols.map and libmiral.symbols

@copilot

Added new symbols in commit ffe4226. The three new methods are now exported in both:

  • src/miral/symbols.map (MIRAL_5.7 section)
  • debian/libmiral7.symbols (versioned as 5.7.0)

@AlanGriffiths
Copy link
Contributor

@copilot please add some tests for this change

Copy link
Contributor

Copilot AI left a comment

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 MinimalWindowManager to enable better specialization by subclasses. The changes add three new protected helper methods that expose the internal application_selector state management, allowing subclasses to customize window management behaviors (like implementing "sloppy focus") while maintaining proper application selector state.

Changes:

  • Added three new protected helper methods for application selector state management
  • Refactored existing advise_* methods to delegate to the new helpers
  • Bumped MIRAL version from 5.6.0 to 5.7.0
  • Updated symbol export files with new public symbols

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
include/miral/miral/minimal_window_manager.h Declares three new protected helper methods with Doxygen documentation
src/miral/minimal_window_manager.cpp Implements the new helper methods and refactors existing methods to use them
src/CMakeLists.txt Increments MIRAL_VERSION_MINOR from 6 to 7
debian/libmiral7.symbols Adds new symbols under MIRAL_5.7 version

Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 6, 2026

@copilot please add some tests for this change

Added tests in commit b93dd14. The tests verify:

  1. Subclasses can access and use the protected helper methods to interact with application_selector
  2. The sloppy focus use case from the issue - overriding advise_focus_gained without calling raise_tree while still maintaining application_selector state

Comment on lines 1497 to 1498
custom_wm = new CustomMinimalWindowManager(tools, focus_stealing());
return std::unique_ptr<miral::WindowManagementPolicy>(custom_wm);
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot please don't use raw new - we have had make_unique since C++14

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 973b218. Changed to use std::make_unique and capture the raw pointer with .get().

Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
Copilot AI requested a review from AlanGriffiths February 6, 2026 10:52
@AlanGriffiths AlanGriffiths marked this pull request as ready for review February 6, 2026 10:55
@AlanGriffiths AlanGriffiths requested a review from a team as a code owner February 6, 2026 10:55
@tarek-y-ismail tarek-y-ismail added this pull request to the merge queue Feb 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 9, 2026
@AlanGriffiths AlanGriffiths added this pull request to the merge queue Feb 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 9, 2026
@AlanGriffiths AlanGriffiths added this pull request to the merge queue Feb 9, 2026
Merged via the queue into main with commit 5bb586d Feb 9, 2026
49 of 52 checks passed
@AlanGriffiths AlanGriffiths deleted the copilot/refactor-minimal-window-manager branch February 9, 2026 18:41
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.

MinimalWindowManager is hard to specialise

3 participants