Class Window

Class Documentation

class Window

A class providing access to a Wayland or X11 surface.

Users are not expected to instantiate instances of this class themselves. Instead, they may implement miral::WindowManagementPolicy::advise_new_window to be notified when the server has received a new window. Similarly, they may implement miral::WindowManagementPolicy::advise_delete_window to be notified when a window has been destroyed.

If the window is default constructed, it will not have any surface backing it.

See also

miral::WindowManagementPolicy::advise_new_window - gets called when a new window has been created by the server

See also

miral::WindowInfo - provides additional information for a miral::Window instance

Public Functions

Window()

Construct an empty window instance.

This window is not backed by anything, meaning that all methods on it will return stub values.

Window(Application const &application, std::shared_ptr<mir::scene::Surface> const &surface)

Construct a window backed by surface for application.

Parameters:
  • application – the application to which this window belongs

  • surface – the raw surface backing this window

~Window()
auto top_left() const -> mir::geometry::Point

Retrieve the position of the top-left corner of the window frame.

Returns:

the top-left point of the frame of the window

auto size() const -> mir::geometry::Size

Retrieve the size of the window frame.

Units are logical screen coordinates (not necessarily device pixels). Any decorations are included in the size.

Returns:

the size of the window, including decorations

auto application() const -> Application

Retrieve the application that created this window.

Returns:

the application

operator bool() const

Checks whether the backing surface is valid or not.

This will return true if the window was default constructed, or if the surface backing it is now invalid.

void resize(mir::geometry::Size const &size)

Resize the window to the given size.

Parameters:

size – the new size

Note

Not for external use, use WindowManagerTools::modify_window instead.

void move_to(mir::geometry::Point top_left)

Move the window to the point given by top_left.

Parameters:

top_left – point to move to

Note

Not for external use, use WindowManagerTools::modify_window instead.