Class WindowManagerTools

Class Documentation

class WindowManagerTools

Window management functions for querying and updating MirAL’s model.

Query & Update Model

These functions assume that the BasicWindowManager data structures can be accessed freely.

I.e. they should only be used by a thread that has called the WindowManagementPolicy methods (where any necessary locks are held) or via a invoke_under_lock() callback.

auto count_applications() const -> unsigned int

count the applications

Returns:

number of applications

void for_each_application(std::function<void(ApplicationInfo &info)> const &functor)

execute functor for each application

Parameters:

functor – the functor

auto find_application(std::function<bool(ApplicationInfo const &info)> const &predicate) -> Application

find an application meeting the predicate

Parameters:

predicate – the predicate

Returns:

the application

auto info_for(std::weak_ptr<mir::scene::Session> const &session) const -> ApplicationInfo&

retrieve metadata for an application

Parameters:

session – the application session

Returns:

the metadata

auto info_for(std::weak_ptr<mir::scene::Surface> const &surface) const -> WindowInfo&

retrieve metadata for a window

Parameters:

surface – the window surface

Returns:

the metadata

auto info_for(Window const &window) const -> WindowInfo&

retrieve metadata for a window

Parameters:

window – the window

Returns:

the metadata

auto info_for_window_id(std::string const &id) const -> WindowInfo&

retrieve metadata for a persistent surface id

Parameters:

id – the persistent surface id

Throws:

invalid_argument – or runtime_error if the id is badly formatted/doesn’t identify a current window

Returns:

the metadata

auto id_for_window(Window const &window) const -> std::string

retrieve the persistent surface id for a window

Parameters:

window – the window

Returns:

the persistent surface id

void ask_client_to_close(Window const &window)

Send close request to the window.

auto active_window() const -> Window

retrieve the active window

auto select_active_window(Window const &hint) -> Window

select a new active window based on the hint

Parameters:

hint – the hint

Returns:

the new active window

void drag_active_window(mir::geometry::Displacement movement)

move the active window

void drag_window(Window const &window, mir::geometry::Displacement movement)

move the window

void focus_next_application()

make the next application active

void focus_prev_application()

make the previous application active

Remark

Since MirAL 2.5

void focus_next_within_application()

make the next surface active within the active application

void focus_prev_within_application()

make the prev surface active within the active application

auto window_to_select_application(const Application) const -> std::optional<Window>

If possible, returns the application window to select, otherwise std::nullopt

Remark

Since MirAL 3.10

auto can_select_window(Window const&) const -> bool

Check if the provided window can be selected.

Remark

Since MirAL 5.0

auto window_at(mir::geometry::Point cursor) const -> Window

Find the topmost window at the cursor.

auto active_output() -> mir::geometry::Rectangle const

Find the active output area.

auto active_application_zone() const -> Zone

Find the active zone area.

Remark

Since MirAL 3.0

void raise_tree(Window const &root)

Raise window and all its children.

void swap_tree_order(Window const &first, Window const &second)

Swaps the position of the windows in regards to Z order.

Remark

SinceMirAL 3.10

Parameters:
  • first

  • second

void send_tree_to_back(Window const &root)

Moves the window to the bottom of the Z order remark Since MirAL 3.10.

void modify_window(WindowInfo &window_info, WindowSpecification const &modifications)

Apply modifications to a window.

void modify_window(Window const &window, WindowSpecification const &modifications)

Apply modifications to a window.

void place_and_size_for_state(WindowSpecification &modifications, WindowInfo const &window_info) const

Set a default size and position to reflect state change.

auto create_workspace() -> std::shared_ptr<Workspace>

Create a workspace.

Remark

the tools hold only a weak_ptr<> to the workspace - there is no need for an explicit “destroy”.

Returns:

a shared_ptr owning the workspace

void add_tree_to_workspace(Window const &window, std::shared_ptr<Workspace> const &workspace)

Add the tree containing window to a workspace.

Parameters:
  • window – the window

  • workspace – the workspace;

void remove_tree_from_workspace(Window const &window, std::shared_ptr<Workspace> const &workspace)

Remove the tree containing window from a workspace.

Parameters:
  • window – the window

  • workspace – the workspace;

void move_workspace_content_to_workspace(std::shared_ptr<Workspace> const &to_workspace, std::shared_ptr<Workspace> const &from_workspace)

Moves all the content from one workspace to another.

Parameters:
  • from_workspace – the workspace to move the windows from;

  • to_workspace – the workspace to move the windows to;

void for_each_workspace_containing(Window const &window, std::function<void(std::shared_ptr<Workspace> const &workspace)> const &callback)

invoke callback with each workspace containing window

Parameters:
  • window

  • callback

Warning

it is unsafe to add or remove windows from workspaces from the callback during enumeration

void for_each_window_in_workspace(std::shared_ptr<Workspace> const &workspace, std::function<void(Window const &window)> const &callback)

invoke callback with each window contained in workspace

Parameters:
  • workspace

  • callback

Warning

it is unsafe to add or remove windows from workspaces from the callback during enumeration

Public Functions

explicit WindowManagerTools(WindowManagerToolsImplementation *tools)
WindowManagerTools(WindowManagerTools const&)
WindowManagerTools &operator=(WindowManagerTools const&)
~WindowManagerTools()
void invoke_under_lock(std::function<void()> const &callback)

Multi-thread support Allows threads that don’t hold a lock on the model to acquire one and call the “Update Model” member functions.

This should NOT be used by a thread that has called the WindowManagementPolicy methods (and already holds the lock).

void move_cursor_to(mir::geometry::PointF point)

Move the cursor to the provided point.

If the point is outside of the range of the outputs, the point is clamped.

Parameters:

point