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

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
Window &window() const

The miral::Window that backs this instance.

Returns:

the backing window

std::string name() const

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

MirWindowType type() const

The type of the window.

See also

MirWindowType - describes the type of window

Returns:

type of the window

MirWindowState state() const

Returns the state of the window.

See also

MirWindowState - describes the state that a window can be in

Returns:

state of the window

mir::geometry::Rectangle restore_rect() const

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

Window parent() const

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

std::span<Window const> children() const &

The children of this window, if any.

Returns:

the children of this window

mir::geometry::Width min_width() const

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

mir::geometry::Height min_height() const

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

mir::geometry::Width max_width() const

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

mir::geometry::Height max_height() const

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

mir::geometry::DeltaX width_inc() const

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

mir::geometry::DeltaY height_inc() const

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 height increment

AspectRatio min_aspect() const

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

AspectRatio max_aspect() const

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

int output_id() const

The output id that this window is associated with.

If miral::WindowInfo::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

MirOrientationMode preferred_orientation() const

The preferred orientation of the window.

Defaults to mir_orientation_mode_portrait.

See also

MirOrientationMode - the orientations options

Returns:

the orienation of the window

MirPointerConfinementState confine_pointer() const

The confinement of the pointer.

Defaults to mir_pointer_unconfined.

See also

MirPointerConfinementState - the pointer confinement options

Returns:

the confinement of the pointer

MirShellChrome shell_chrome() const

The shell chrome type.

Defaults to mir_shell_chrome_normal.

See also

MirShellChrome - the shell chrome options

Returns:

the shell chrome type

std::shared_ptr<void> userdata() const

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.

MirDepthLayer depth_layer() const

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

MirPlacementGravity attached_edges() const

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

std::optional<mir::geometry::Rectangle> exclusive_rect() const

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

bool ignore_exclusion_zones() const

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

std::optional<mir::geometry::Rectangle> clip_area() const

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(std::optional<mir::geometry::Rectangle>).

This rectangle is in world coordinates.

Returns:

the clip area set for the window

void clip_area(std::optional<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

std::string application_id() const

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

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

Returns:

the application id

MirFocusMode focus_mode() const

Describes how the window should gain and lose focus.

See also

MirFocusMode - the focus mode options

Returns:

the focus mode

bool visible_on_lock_screen() const

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

Returns:

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

mir::Flags<MirTiledEdge> tiled_edges() const

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

float alpha() const

The alpha of the window.

This value is between [0, 1].

Remark

Since MirAL 5.7

Returns:

the window alpha