Struct WindowInfo

Struct Documentation

struct WindowInfo

Provides additional information about a miral::Window.

An instance of this class may be obtained from miral::WindowManagerTools::info_for.

See also

miral::Window - the class for which this class provides information

See also

miral::WindowManagerTools::info_for - the method to get an instance of this class

Unnamed Group

static bool needs_titlebar(MirWindowType type)

Deprecated:

Obsolete: Window::size() includes decorations

Public Types

using AspectRatio = WindowSpecification::AspectRatio

Public Functions

WindowInfo()

Constructs a new window info instance not backed by a miral::Window.

This will result in all methods on this class returning a stub result.

WindowInfo(Window const &window, WindowSpecification const &params)

Constructs a new window info instanced backed by window with the specified params.

Parameters:
  • window – the backing window

  • params – the initial specification for the window

~WindowInfo()
explicit WindowInfo(WindowInfo const &that)
WindowInfo &operator=(WindowInfo const &that)
bool can_be_active() const

Check if the window can have focus.

Returns:

true if it can be active, otherwise false

bool can_morph_to(MirWindowType new_type) const

Check if the window can change its type to new_type.

Parameters:

new_type – the desired type to change to

Returns:

true if the window can change to the desired type, otherwise false

bool must_have_parent() const

Check if the window must have a parent.

Returns:

true if the window must have a parent, otherwise false

bool must_not_have_parent() const

Check if the window must not have a parent.

Returns:

true if the window must NOT have a parent, otherwise false.

bool is_visible() const

Check if the window is currently visible.

Returns:

true if the window is visible, otherwise false.

void constrain_resize(mir::geometry::Point &requested_pos, mir::geometry::Size &requested_size) const
auto window() const -> Window&

The miral::Window that backs this instance.

Returns:

the backing window

auto name() const -> std::string

The name of the window.

In Wayland, this is most commonly set by the client via xdg_toplevel::set_title, but the exact mechanism may vary depending on the client.

Returns:

the name of the window

auto type() const -> MirWindowType

The type of the window.

See also

MirWindowType - describes the type of window

Returns:

type of the window

auto state() const -> MirWindowState

Returns the state of the window.

See also

MirWindowState - describes the state that a window can be in

Returns:

state of the window

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

The size that the window should return to after entering to the mir_window_state_restored state.

Before becoming hidden, fullscreen, maximized, or minimized, the window stores its previous rectangle so that its original size can easily be restored afterward. This size is returned by this method.

Returns:

the restore rectangle

auto parent() const -> Window

The parent of this window.

The result may be the default constructed window (i.e. the “null” window) in the event that this window lacks a parent.

Returns:

the parent window

auto children() const -> std::vector<Window> const&

The children of this window, if any.

Returns:

the children of this window

auto min_width() const -> mir::geometry::Width

The minimum width of the window.

This can be set either by the client or by the compositor author. If set by the client, it is most likely set by xdg_toplevel::set_min_size.

The compositor author may choose to ignore this value, but please be aware that clients may misbehave in such scenarios. For example, a client may continue sending buffers that adhere to the minimum width

Defaults to 0.

Returns:

the minimum width

auto min_height() const -> mir::geometry::Height

The minimum height of the window.

This can be set either by the client or by the compositor author. If set by the client, it is most likely set by xdg_toplevel::set_min_size.

The compositor author may choose to ignore this value, but please be aware that clients may misbehave in such scenarios. For example, a client may continue sending buffers that adhere to the minimum height.

Defaults to 0.

Returns:

the minimum height

auto max_width() const -> mir::geometry::Width

The maximum width of the window.

This can be set either by the client or by the compositor author. If set by the client, it is most likely set by xdg_toplevel::set_max_size.

The compositor author may choose to ignore this value, but please be aware that clients may misbehave in such scenarios. For example, a client may continue sending buffers that adhere to the minimum width

Defaults to std::numeric_limits<int>::max().

Returns:

the maximum width

auto max_height() const -> mir::geometry::Height

The maximum height of the window.

This can be set either by the client or by the compositor author. If set by the client, it is most likely set by xdg_toplevel::set_max_size.

The compositor author may choose to ignore this value, but please be aware that clients may misbehave in such scenarios. For example, a client may continue sending buffers that adhere to the minimum width

Defaults to std::numeric_limits<int>::max().

Returns:

the maximum height

auto width_inc() const -> mir::geometry::DeltaX

The size increments of the window in the X direction.

This is used in cases such as a terminal that can only be resized character-by-character.

Wayland protocols do not support this property, so it is generally not used by clients.

Defaults to 1.

Returns:

the width increment

auto height_inc() const -> mir::geometry::DeltaY

The size increments of the window in the Y direction.

This is used in cases such as a terminal that can only be resized character-by-character.

Wayland protocols do not support this property, so it generally will not be requested by clients.

Defaults to 1.

Returns:

the width increment

auto min_aspect() const -> AspectRatio

The minimum aspect ratio.

Wayland protocols do not support this property, so it generally will not be requested by clients.

Defaults to {0U, std::numeric_limits<unsigned>::max()}.

Returns:

the minimum aspect ratio

auto max_aspect() const -> AspectRatio

The maximum aspect ratio.

Wayland protocols do not support this property, so it generally will not be requested by clients.

Defaults to {std::numeric_limits<unsigned>::max(), 0U}.

Returns:

the maximum aspect ratio

bool has_output_id() const

Whether the window is associated with a particular output.

If this is false, then miral::WindowInfo::output_id will throw a fatal error when accessed.

Returns:

true if output_id is valid, otherwise false

auto output_id() const -> int

The output id that this window is associated with.

If #miral::WindoInfo::has_output_id is false, then this method will throw a fatal error when accessed.

Callers may match this value with an id from miral::Output::id() in order to find out more details about the output.

Returns:

the output id, or a fatal error if none is set

auto preferred_orientation() const -> MirOrientationMode

The preferred orientation of the window.

Defaults to mir_orientation_mode_portrait.

See also

MirOrientationMode - the orientations options

Returns:

the orienation of the window

auto confine_pointer() const -> MirPointerConfinementState

The confinement of the pointer.

Defaults to mir_pointer_unconfined.

See also

MirPointerConfinementState - the pointer confinement options

Returns:

the confinement of the pointer

auto shell_chrome() const -> MirShellChrome

The shell chrome type.

Defaults to mir_shell_chrome_normal.

See also

MirShellChrome - the shell chrome options

Returns:

the shell chrome type

auto userdata() const -> std::shared_ptr<void>

Custom user data for the window.

This can be set by the compositor author via miral::WindowInfo::userdata(std::shared_ptr<void>). This is an arbitrary payload that can contains compositor-specific information.

Returns:

the userdata, or nullptr if none was set

void userdata(std::shared_ptr<void> userdata)

Set the custom user data for the window.

This can be accessed by miral::WindowInfo::userdata(). This is an arbitrary payload that can contain compositor-specific information.

Parameters:

userdata – the userdata

inline void swap(WindowInfo &rhs)

Swap the backing information of \rhs with the contents held in this object.

auto depth_layer() const -> MirDepthLayer

The depth layer of the window.

This can be requested by the client or set by the compositor author. If set by a client, this often comes from zwlr_layer_surface_v1::set_layer.

See also

MirDepthLayer - the depth layer options

Returns:

the depth layer

auto attached_edges() const -> MirPlacementGravity

Get the edges of the output that the window is attached to.

This value is only meaningful for windows when miral::WindowInfo::state is set to mir_window_state_attached.

Returns:

the placement gravity

auto exclusive_rect() const -> mir::optional_value<mir::geometry::Rectangle>

Describes a rectangular area that Mir will avoid occluding.

This area is relative to the window.

This value is only meaningful for windows when miral::WindowInfo::state is set to mir_window_state_attached.

Returns:

the exclusive rect optional

auto ignore_exclusion_zones() const -> bool

When true, this window will ignore the miral::WindowInfo::exclusive_rect of other windows.

This value is only meaningful for windows when miral::WindowInfo::state is set to mir_window_state_attached.

Returns:

true if exclusion zones are ignored, otherwise false

auto clip_area() const -> mir::optional_value<mir::geometry::Rectangle>

The clip area for the window.

If set, Mir will not render any part of the window that falls outside of this rectangle. Compositor authors can set this via #miral::WindowInfo::clip_area(mir::optional_value<mir::geometry::Rectangle>).

This rectangle is in world coordinates.

Returns:

the clip area set for the window

void clip_area(mir::optional_value<mir::geometry::Rectangle> const &area)

Set the clip area of the window.

If set, Mir will not render any part of the window that falls outside of this rectangle.

This rectangle is in world coordinates.

Parameters:

area – the rectangle for the clip area

auto application_id() const -> std::string

The D-bus service name and basename of the app’s .desktop.

See https://specifications.freedesktop.org/desktop-entry-spec/.

Returns:

the application id

auto focus_mode() const -> MirFocusMode

Describes how the window should gain and lose focus.

See also

MirFocusMode - the focus mode options

Returns:

the focus mode

auto visible_on_lock_screen() const -> bool

If this surface should be shown while the compositor is locked.

Returns:

true if it will be shown on the lock screen, otherwise false

auto tiled_edges() const -> mir::Flags<MirTiledEdge>

Describes which edges the window is tiled against.

Used when the surface is in a tiled layout to describe the edges that are touching another part of the tiling grid.

Remark

Since MirAL 5.3

See also

MirTiledEdges - the tiled edge options

Returns:

a flag containing the tiled edges that are set