diff --git a/src/server/frontend_wayland/xdg_shell_stable.cpp b/src/server/frontend_wayland/xdg_shell_stable.cpp index b3b77d2702..532c7beb04 100644 --- a/src/server/frontend_wayland/xdg_shell_stable.cpp +++ b/src/server/frontend_wayland/xdg_shell_stable.cpp @@ -114,6 +114,10 @@ class XdgPositionerStable : public mw::XdgPositioner, public shell::SurfaceSpeci public: XdgPositionerStable(wl_resource* new_resource); + void ensure_complete() const; + + bool reactive{false}; + private: void set_size(int32_t width, int32_t height) override; void set_anchor_rect(int32_t x, int32_t y, int32_t width, int32_t height) override; @@ -121,6 +125,9 @@ class XdgPositionerStable : public mw::XdgPositioner, public shell::SurfaceSpeci void set_gravity(uint32_t gravity) override; void set_constraint_adjustment(uint32_t constraint_adjustment) override; void set_offset(int32_t x, int32_t y) override; + void set_reactive() override; + void set_parent_size(int32_t parent_width, int32_t parent_height) override; + void set_parent_configure(uint32_t serial) override; }; } @@ -148,7 +155,7 @@ mf::XdgShellStable::XdgShellStable( std::shared_ptr shell, WlSeat& seat, OutputManager* output_manager) - : Global(display, Version<1>()), + : Global(display, Version<5>()), wayland_executor{wayland_executor}, shell{shell}, seat{seat}, @@ -162,7 +169,7 @@ void mf::XdgShellStable::bind(wl_resource* new_resource) } mf::XdgShellStable::Instance::Instance(wl_resource* new_resource, mf::XdgShellStable* shell) - : XdgWmBase{new_resource, Version<1>()}, + : XdgWmBase{new_resource, Version<5>()}, shell{shell} { } @@ -192,7 +199,7 @@ mf::XdgSurfaceStable* mf::XdgSurfaceStable::from(wl_resource* surface) } mf::XdgSurfaceStable::XdgSurfaceStable(wl_resource* new_resource, WlSurface* surface, XdgShellStable const& xdg_shell) - : mw::XdgSurface(new_resource, Version<1>()), + : mw::XdgSurface(new_resource, Version<5>()), surface{surface}, xdg_shell{xdg_shell} { @@ -231,6 +238,10 @@ void mf::XdgSurfaceStable::get_popup( } } + auto xdg_positioner = static_cast( + static_cast( + wl_resource_get_user_data(positioner))); + if (!surface) { BOOST_THROW_EXCEPTION(mw::ProtocolError( @@ -238,7 +249,8 @@ void mf::XdgSurfaceStable::get_popup( mw::generic_error_code, "Tried to create popup after destroying surface")); } - auto popup = new XdgPopupStable{new_popup, this, parent_role, positioner, &surface.value()}; + + auto popup = new XdgPopupStable{new_popup, this, parent_role, *xdg_positioner, &surface.value()}; set_window_role(popup); } @@ -292,9 +304,9 @@ mf::XdgPopupStable::XdgPopupStable( wl_resource* new_resource, XdgSurfaceStable* xdg_surface, std::optional parent_role, - struct wl_resource* positioner, + XdgPositionerStable& positioner, WlSurface* surface) - : mw::XdgPopup(new_resource, Version<1>()), + : mw::XdgPopup(new_resource, Version<5>()), WindowWlSurfaceRole( xdg_surface->xdg_shell.wayland_executor, &xdg_surface->xdg_shell.seat, @@ -302,29 +314,22 @@ mf::XdgPopupStable::XdgPopupStable( surface, xdg_surface->xdg_shell.shell, xdg_surface->xdg_shell.output_manager), + reactive{positioner.reactive}, + aux_rect{positioner.aux_rect ? positioner.aux_rect.value() : geom::Rectangle{}}, shell{xdg_surface->xdg_shell.shell}, xdg_surface{xdg_surface} { - auto specification = static_cast( - static_cast( - static_cast( - wl_resource_get_user_data(positioner)))); - - if (specification->aux_rect) - { - aux_rect = specification->aux_rect.value(); - } - - specification->type = mir_window_type_gloss; + positioner.ensure_complete(); + positioner.type = mir_window_type_gloss; if (parent_role) { if (auto scene_surface = parent_role.value()->scene_surface()) { - specification->parent = scene_surface.value(); + positioner.parent = scene_surface.value(); } } - apply_spec(*specification); + apply_spec(positioner); } void mf::XdgPopupStable::set_aux_rect_offset_now(geom::Displacement const& new_aux_rect_offset) @@ -360,30 +365,60 @@ void mf::XdgPopupStable::grab(struct wl_resource* seat, uint32_t serial) set_type(mir_window_type_menu); } +void mf::XdgPopupStable::reposition(wl_resource* positioner_resource, uint32_t token) +{ + auto const& positioner = *static_cast( + static_cast( + wl_resource_get_user_data(positioner_resource))); + positioner.ensure_complete(); + + reactive = positioner.reactive; + aux_rect = positioner.aux_rect ? positioner.aux_rect.value() : geom::Rectangle{}; + reposition_token = token; + + auto const scene_surface_{scene_surface()}; + if (scene_surface_) + { + shell->modify_surface( + scene_surface_.value()->session().lock(), + scene_surface_.value(), + positioner); + } + else + { + apply_spec(positioner); + } +} + void mf::XdgPopupStable::handle_resize( - std::optional const& new_top_left_, + std::optional const& new_top_left, geometry::Size const& new_size) { - auto new_top_left{new_top_left_}; + auto const prev_rect = popup_rect(); if (new_top_left) { - new_top_left.value() -= aux_rect_offset; + cached_top_left = new_top_left.value() - aux_rect_offset; } - - bool const needs_configure = (new_top_left != cached_top_left) || (new_size != cached_size); - - if (new_top_left) - cached_top_left = new_top_left; - cached_size = new_size; + auto const new_rect = popup_rect(); - if (needs_configure && cached_top_left && cached_size) + bool const configure_appropriate = + reposition_token || + initial_configure_pending || + (reactive && new_rect != prev_rect); + if (new_rect && configure_appropriate) { + if (reposition_token) + { + send_repositioned_event(reposition_token.value()); + reposition_token = std::nullopt; + } send_configure_event(cached_top_left.value().x.as_int(), cached_top_left.value().y.as_int(), cached_size.value().width.as_int(), cached_size.value().height.as_int()); if (xdg_surface) xdg_surface.value().send_configure(); + initial_configure_pending = false; } } @@ -400,6 +435,18 @@ auto mf::XdgPopupStable::from(wl_resource* resource) -> XdgPopupStable* return popup; } +auto mf::XdgPopupStable::popup_rect() const -> std::optional +{ + if (cached_top_left && cached_size) + { + return geometry::Rectangle{cached_top_left.value(), cached_size.value()}; + } + else + { + return std::nullopt; + } +} + void mf::XdgPopupStable::destroy_role() const { wl_resource_destroy(resource); @@ -408,7 +455,7 @@ void mf::XdgPopupStable::destroy_role() const // XdgToplevelStable mf::XdgToplevelStable::XdgToplevelStable(wl_resource* new_resource, XdgSurfaceStable* xdg_surface, WlSurface* surface) - : mw::XdgToplevel(new_resource, Version<1>()), + : mw::XdgToplevel(new_resource, Version<5>()), WindowWlSurfaceRole( xdg_surface->xdg_shell.wayland_executor, &xdg_surface->xdg_shell.seat, @@ -418,6 +465,26 @@ mf::XdgToplevelStable::XdgToplevelStable(wl_resource* new_resource, XdgSurfaceSt xdg_surface->xdg_shell.output_manager), xdg_surface{xdg_surface} { + if (version_supports_wm_capabilities()) + { + std::vector capabilities{ + WmCapabilities::maximize, + WmCapabilities::minimize, + WmCapabilities::fullscreen, + }; + wl_array capability_array; + wl_array_init(&capability_array); + for (auto& capability : capabilities) + { + if (uint32_t *item = static_cast(wl_array_add(&capability_array, sizeof *item))) + { + *item = capability; + } + } + send_wm_capabilities_event(&capability_array); + wl_array_release(&capability_array); + } + wl_array states; wl_array_init(&states); send_configure_event(0, 0, &states); @@ -496,7 +563,15 @@ void mf::XdgToplevelStable::resize(struct wl_resource* /*seat*/, uint32_t serial edge = mir_resize_edge_southeast; break; - default:; + case ResizeEdge::none: + edge = mir_resize_edge_none; + break; + + default: + BOOST_THROW_EXCEPTION(mw::ProtocolError( + resource, + Error::invalid_resize_edge, + "Invalid resize edge %d", edges)); } initiate_interactive_resize(edge, serial); @@ -619,7 +694,7 @@ void mf::XdgToplevelStable::destroy_role() const // XdgPositionerStable mf::XdgPositionerStable::XdgPositionerStable(wl_resource* new_resource) - : mw::XdgPositioner(new_resource, Version<1>()) + : mw::XdgPositioner(new_resource, Version<5>()) { // specifying gravity is not required by the xdg shell protocol, but is by Mir window managers surface_placement_gravity = mir_placement_gravity_center; @@ -627,14 +702,39 @@ mf::XdgPositionerStable::XdgPositionerStable(wl_resource* new_resource) placement_hints = static_cast(0); } +void mf::XdgPositionerStable::ensure_complete() const +{ + if (!width || !height || !aux_rect) + { + BOOST_THROW_EXCEPTION(mw::ProtocolError( + resource, + mw::XdgWmBase::Error::invalid_positioner, + "Incomplete positioner")); + } +} + void mf::XdgPositionerStable::set_size(int32_t width, int32_t height) { + if (width <= 0 || height <= 0) + { + BOOST_THROW_EXCEPTION(mw::ProtocolError( + resource, + mw::XdgPositioner::Error::invalid_input, + "Invalid popup positioner size: %dx%d", width, height)); + } this->width = geom::Width{width}; this->height = geom::Height{height}; } void mf::XdgPositionerStable::set_anchor_rect(int32_t x, int32_t y, int32_t width, int32_t height) { + if (width < 0 || height < 0) + { + BOOST_THROW_EXCEPTION(mw::ProtocolError( + resource, + mw::XdgPositioner::Error::invalid_input, + "Invalid popup anchor rect size: %dx%d", width, height)); + } aux_rect = geom::Rectangle{{x, y}, {width, height}}; } @@ -721,8 +821,15 @@ void mf::XdgPositionerStable::set_gravity(uint32_t gravity) placement = mir_placement_gravity_northwest; break; - default: + case Gravity::none: placement = mir_placement_gravity_center; + break; + + default: + BOOST_THROW_EXCEPTION(mw::ProtocolError( + resource, + mw::XdgPositioner::Error::invalid_input, + "Invalid gravity value %d", gravity)); } surface_placement_gravity = placement; @@ -764,6 +871,26 @@ void mf::XdgPositionerStable::set_offset(int32_t x, int32_t y) aux_rect_placement_offset_y = y; } +void mf::XdgPositionerStable::set_reactive() +{ + reactive = true; +} + +void mf::XdgPositionerStable::set_parent_size(int32_t parent_width, int32_t parent_height) +{ + (void)parent_width; + (void)parent_height; + // TODO + log_warning("xdg_positioner.set_parent_size not implemented"); +} + +void mf::XdgPositionerStable::set_parent_configure(uint32_t serial) +{ + (void)serial; + // TODO + log_warning("xdg_positioner.set_parent_configure not implemented"); +} + auto mf::XdgShellStable::get_window(wl_resource* surface) -> std::shared_ptr { namespace mw = mir::wayland; diff --git a/src/server/frontend_wayland/xdg_shell_stable.h b/src/server/frontend_wayland/xdg_shell_stable.h index 4d2306efa7..a2f606d2a2 100644 --- a/src/server/frontend_wayland/xdg_shell_stable.h +++ b/src/server/frontend_wayland/xdg_shell_stable.h @@ -33,6 +33,7 @@ class WlSeat; class OutputManager; class WlSurface; class XdgSurfaceStable; +class XdgPositionerStable; class XdgShellStable : public wayland::XdgWmBase::Global { @@ -63,7 +64,7 @@ class XdgPopupStable : public wayland::XdgPopup, public WindowWlSurfaceRole wl_resource* new_resource, XdgSurfaceStable* xdg_surface, std::optional parent_role, - wl_resource* positioner, + XdgPositionerStable& positioner, WlSurface* surface); /// Used when the aux rect needs to be adjusted due to the parent logical Wayland surface not lining up with the @@ -71,6 +72,7 @@ class XdgPopupStable : public wayland::XdgPopup, public WindowWlSurfaceRole void set_aux_rect_offset_now(geometry::Displacement const& new_aux_rect_offset); void grab(struct wl_resource* seat, uint32_t serial) override; + void reposition(wl_resource* positioner, uint32_t token) override; void handle_commit() override {}; void handle_state_change(MirWindowState /*new_state*/) override {}; @@ -87,11 +89,16 @@ class XdgPopupStable : public wayland::XdgPopup, public WindowWlSurfaceRole std::optional cached_top_left; std::optional cached_size; + bool initial_configure_pending{true}; + std::optional reposition_token; + bool reactive; + geometry::Rectangle aux_rect; + geometry::Displacement aux_rect_offset; std::shared_ptr const shell; wayland::Weak const xdg_surface; - geometry::Rectangle aux_rect; - geometry::Displacement aux_rect_offset; + + auto popup_rect() const -> std::optional; }; } diff --git a/src/wayland/protocol/xdg-shell.xml b/src/wayland/protocol/xdg-shell.xml index d524ea9e27..6eb0a67c5d 100644 --- a/src/wayland/protocol/xdg-shell.xml +++ b/src/wayland/protocol/xdg-shell.xml @@ -29,7 +29,7 @@ DEALINGS IN THE SOFTWARE. - + The xdg_wm_base interface is exposed as a global object enabling clients to turn their wl_surfaces into windows in a desktop environment. It @@ -50,6 +50,8 @@ summary="the client provided an invalid surface state"/> + @@ -58,7 +60,7 @@ Destroying a bound xdg_wm_base object while there are surfaces still alive created by this xdg_wm_base object instance is illegal - and will result in a protocol error. + and will result in a defunct_surfaces error. @@ -75,7 +77,9 @@ This creates an xdg_surface for the given surface. While xdg_surface itself is not a role, the corresponding surface may only be assigned - a role extending xdg_surface, such as xdg_toplevel or xdg_popup. + a role extending xdg_surface, such as xdg_toplevel or xdg_popup. It is + illegal to create an xdg_surface for a wl_surface which already has an + assigned role and this will result in a role error. This creates an xdg_surface for the given surface. An xdg_surface is used as basis to define a role to a given surface, such as xdg_toplevel @@ -92,7 +96,8 @@ A client must respond to a ping event with a pong request or - the client may be deemed unresponsive. See xdg_wm_base.ping. + the client may be deemed unresponsive. See xdg_wm_base.ping + and xdg_wm_base.error.unresponsive. @@ -101,12 +106,14 @@ The ping event asks the client if it's still alive. Pass the serial specified in the event back to the compositor by sending - a "pong" request back with the specified serial. See xdg_wm_base.ping. + a "pong" request back with the specified serial. See xdg_wm_base.pong. Compositors can use this to determine if the client is still alive. It's unspecified what will happen if the client doesn't respond to the ping request, or in what timeframe. Clients should - try to respond in a reasonable amount of time. + try to respond in a reasonable amount of time. The “unresponsive” + error is provided for compositors that wish to disconnect unresponsive + clients. A compositor is free to ping in any way it wants, but a client must always respond to any xdg_wm_base object it created. @@ -115,7 +122,7 @@ - + The xdg_positioner provides a collection of rules for the placement of a child surface relative to a parent surface. Rules can be defined to ensure @@ -135,7 +142,7 @@ For an xdg_positioner object to be considered complete, it must have a non-zero size set by set_size, and a non-zero anchor rectangle set by set_anchor_rect. Passing an incomplete xdg_positioner object when - positioning a surface raises an error. + positioning a surface raises an invalid_positioner error. @@ -223,7 +230,8 @@ specified (e.g. 'bottom_right' or 'top_left'), then the child surface will be placed towards the specified gravity; otherwise, the child surface will be centered over the anchor point on any axis that had no - gravity specified. + gravity specified. If the gravity is not in the ‘gravity’ enum, an + invalid_input error is raised. @@ -357,9 +365,49 @@ + + + + + + When set reactive, the surface is reconstrained if the conditions used + for constraining changed, e.g. the parent window moved. + + If the conditions changed and the popup was reconstrained, an + xdg_popup.configure event is sent with updated geometry, followed by an + xdg_surface.configure event. + + + + + + Set the parent window geometry the compositor should use when + positioning the popup. The compositor may use this information to + determine the future state the popup should be constrained using. If + this doesn't match the dimension of the parent the popup is eventually + positioned against, the behavior is undefined. + + The arguments are given in the surface-local coordinate space. + + + + + + + + Set the serial of an xdg_surface.configure event this positioner will be + used in response to. The compositor may use this information together + with set_parent_size to determine what future state the popup should be + constrained using. + + + - + An interface that may be implemented by a wl_surface, for implementations that provide a desktop-style user interface. @@ -386,6 +434,11 @@ manipulate a buffer prior to the first xdg_surface.configure call must also be treated as errors. + After creating a role-specific object and setting it up, the client must + perform an initial commit without any buffer attached. The compositor + will reply with an xdg_surface.configure event. The client must + acknowledge it and is then allowed to attach a buffer to map the surface. + Mapping an xdg_surface-based role surface is defined as making it possible for the surface to be shown by the compositor. Note that a mapped surface is not guaranteed to be visible once it is mapped. @@ -399,19 +452,30 @@ A newly-unmapped surface is considered to have met condition (1) out of the 3 required conditions for mapping a surface if its role surface - has not been destroyed. + has not been destroyed, i.e. the client must perform the initial commit + again before attaching a buffer. - - - + + + + + + Destroy the xdg_surface object. An xdg_surface must only be destroyed - after its role object has been destroyed. + after its role object has been destroyed, otherwise + a defunct_role_object error is raised. @@ -469,10 +533,10 @@ the wl_surface associated with this xdg_surface. The width and height must be greater than zero. Setting an invalid size - will raise an error. When applied, the effective window geometry will be - the set window geometry clamped to the bounding rectangle of the - combined geometry of the surface of the xdg_surface and the associated - subsurfaces. + will raise an invalid_size error. When applied, the effective window + geometry will be the set window geometry clamped to the bounding + rectangle of the combined geometry of the surface of the xdg_surface and + the associated subsurfaces. @@ -493,6 +557,8 @@ If the client receives multiple configure events before it can respond to one, it only has to ack the last configure event. + Acking a configure event that was never sent raises an invalid_serial + error. A client is not required to commit immediately after sending an ack_configure request - it may even ack_configure several times @@ -501,6 +567,17 @@ A client may send multiple ack_configure requests before committing, but only the last request sent before a commit indicates which configure event the client really is responding to. + + Sending an ack_configure request consumes the serial number sent with + the request, as well as serial numbers sent by all configure events + sent on this xdg_surface prior to the configure event referenced by + the committed serial. + + It is an error to issue multiple ack_configure requests referencing a + serial from the same configure event, or to issue an ack_configure + request referencing a serial from a configure event issued before the + event identified by the last ack_configure request for the same + xdg_surface. Doing so will raise an invalid_serial error. @@ -526,9 +603,10 @@ + - + This interface defines an xdg_surface role which allows a surface to, among other things, set window-like properties such as maximize, @@ -540,7 +618,11 @@ by the compositor until it is explicitly mapped again. All active operations (e.g., move, resize) are canceled and all attributes (e.g. title, state, stacking, ...) are discarded for - an xdg_toplevel surface when it is unmapped. + an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to + the state it had right after xdg_surface.get_toplevel. The client + can re-map the toplevel by perfoming a commit without any buffer + attached, waiting for a configure event and handling it as usual (see + xdg_surface description). Attaching a null buffer to a toplevel unmaps the surface. @@ -552,24 +634,37 @@ + + + + + + Set the "parent" of this surface. This surface should be stacked above the parent surface and all other ancestor surfaces. - Parent windows should be set on dialogs, toolboxes, or other + Parent surfaces should be set on dialogs, toolboxes, or other "auxiliary" surfaces, so that the parent is raised when the dialog is raised. - Setting a null parent for a child window removes any parent-child - relationship for the child. Setting a null parent for a window which - currently has no parent is a no-op. + Setting a null parent for a child surface unsets its parent. Setting + a null parent for a surface which currently has no parent is a no-op. - If the parent is unmapped then its children are managed as - though the parent of the now-unmapped parent has become the - parent of this surface. If no parent exists for the now-unmapped - parent then the children are managed as though they have no - parent surface. + Only mapped surfaces can have child surfaces. Setting a parent which + is not mapped is equivalent to setting a null parent. If a surface + becomes unmapped, its children's parent is set to the parent of + the now-unmapped surface. If the now-unmapped surface has no parent, + its children's parent is unset. If the now-unmapped surface becomes + mapped again, its parent-child relationship is not restored. + + The parent toplevel must not be one of the child toplevel's + descendants, and the parent must be different from the child toplevel, + otherwise the invalid_parent protocol error is raised. @@ -604,11 +699,14 @@ For example, "org.freedesktop.FooViewer" where the .desktop file is "org.freedesktop.FooViewer.desktop". + Like other properties, a set_app_id request can be sent after the + xdg_toplevel has been mapped to update the property. + See the desktop-entry specification [0] for more details on application identifiers and how they relate to well-known D-Bus names and .desktop files. - [0] http://standards.freedesktop.org/desktop-entry-spec/ + [0] https://standards.freedesktop.org/desktop-entry-spec/ @@ -622,7 +720,8 @@ This request asks the compositor to pop up such a window menu at the given position, relative to the local surface coordinates of the parent surface. There are no guarantees as to what menu items - the window menu contains. + the window menu contains, or even if a window menu will be drawn + at all. This request must be used in response to some sort of user action like a button press, key press, or touch down event. @@ -698,16 +797,17 @@ guarantee that the device focus will return when the resize is completed. - The edges parameter specifies how the surface should be resized, - and is one of the values of the resize_edge enum. The compositor - may use this information to update the surface position for - example when dragging the top left corner. The compositor may also - use this information to adapt its behavior, e.g. choose an - appropriate cursor image. + The edges parameter specifies how the surface should be resized, and + is one of the values of the resize_edge enum. Values not matching + a variant of the enum will cause a protocol error. The compositor + may use this information to update the surface position for example + when dragging the top left corner. The compositor may also use + this information to adapt its behavior, e.g. choose an appropriate + cursor image. - + @@ -724,6 +824,9 @@ The surface is maximized. The window geometry specified in the configure event must be obeyed by the client. + + The client should draw without shadow or other + decoration outside of the window geometry. @@ -750,6 +853,30 @@ keyboard or pointer focus. + + + The window is currently in a tiled layout and the left edge is + considered to be adjacent to another part of the tiling grid. + + + + + The window is currently in a tiled layout and the right edge is + considered to be adjacent to another part of the tiling grid. + + + + + The window is currently in a tiled layout and the top edge is + considered to be adjacent to another part of the tiling grid. + + + + + The window is currently in a tiled layout and the bottom edge is + considered to be adjacent to another part of the tiling grid. + + @@ -783,11 +910,11 @@ request. Requesting a maximum size to be smaller than the minimum size of - a surface is illegal and will result in a protocol error. + a surface is illegal and will result in an invalid_size error. The width and height must be greater than or equal to zero. Using - strictly negative values for width and height will result in a - protocol error. + strictly negative values for width or height will result in a + invalid_size error. @@ -824,11 +951,11 @@ request. Requesting a minimum size to be larger than the maximum size of - a surface is illegal and will result in a protocol error. + a surface is illegal and will result in an invalid_size error. The width and height must be greater than or equal to zero. Using strictly negative values for width and height will result in a - protocol error. + invalid_size error. @@ -839,12 +966,11 @@ Maximize the surface. After requesting that the surface should be maximized, the compositor - will respond by emitting a configure event with the "maximized" state - and the required window geometry. The client should then update its - content, drawing it in a maximized state, i.e. without shadow or other - decoration outside of the window geometry. The client must also - acknowledge the configure when committing the new content (see - ack_configure). + will respond by emitting a configure event. Whether this configure + actually sets the window maximized is subject to compositor policies. + The client must then update its content, drawing in the configured + state. The client must also acknowledge the configure when committing + the new content (see ack_configure). It is up to the compositor to decide how and where to maximize the surface, for example which output and what region of the screen should @@ -854,8 +980,8 @@ a configure event with the "maximized" state. If the surface is in a fullscreen state, this request has no direct - effect. It will alter the state the surface is returned to when - unmaximized if not overridden by the compositor. + effect. It may alter the state the surface is returned to when + unmaximized unless overridden by the compositor. @@ -864,13 +990,13 @@ Unmaximize the surface. After requesting that the surface should be unmaximized, the compositor - will respond by emitting a configure event without the "maximized" - state. If available, the compositor will include the window geometry - dimensions the window had prior to being maximized in the configure - event. The client must then update its content, drawing it in a - regular state, i.e. potentially with shadow, etc. The client must also - acknowledge the configure when committing the new content (see - ack_configure). + will respond by emitting a configure event. Whether this actually + un-maximizes the window is subject to compositor policies. + If available and applicable, the compositor will include the window + geometry dimensions the window had prior to being maximized in the + configure event. The client must then update its content, drawing it in + the configured state. The client must also acknowledge the configure + when committing the new content (see ack_configure). It is up to the compositor to position the surface after it was unmaximized; usually the position the surface had before maximizing, if @@ -880,8 +1006,8 @@ emit a configure event without the "maximized" state. If the surface is in a fullscreen state, this request has no direct - effect. It will alter the state the surface is returned to when - unmaximized if not overridden by the compositor. + effect. It may alter the state the surface is returned to when + unmaximized unless overridden by the compositor. @@ -890,10 +1016,10 @@ Make the surface fullscreen. After requesting that the surface should be fullscreened, the - compositor will respond by emitting a configure event with the - "fullscreen" state and the fullscreen window geometry. The client must - also acknowledge the configure when committing the new content (see - ack_configure). + compositor will respond by emitting a configure event. Whether the + client is actually put into a fullscreen state is subject to compositor + policies. The client must also acknowledge the configure when + committing the new content (see ack_configure). The output passed by the request indicates the client's preference as to which display it should be set fullscreen on. If this value is NULL, @@ -919,8 +1045,9 @@ Make the surface no longer fullscreen. After requesting that the surface should be unfullscreened, the - compositor will respond by emitting a configure event without the - "fullscreen" state. + compositor will respond by emitting a configure event. + Whether this actually removes the fullscreen state of the client is + subject to compositor policies. Making a surface unfullscreen sets states for the surface based on the following: * the state(s) it may have had before becoming fullscreen @@ -987,9 +1114,68 @@ a dialog to ask the user to save their data, etc. + + + + + + The configure_bounds event may be sent prior to a xdg_toplevel.configure + event to communicate the bounds a window geometry size is recommended + to constrain to. + + The passed width and height are in surface coordinate space. If width + and height are 0, it means bounds is unknown and equivalent to as if no + configure_bounds event was ever sent for this surface. + + The bounds can for example correspond to the size of a monitor excluding + any panels or other shell components, so that a surface isn't created in + a way that it cannot fit. + + The bounds may change at any point, and in such a case, a new + xdg_toplevel.configure_bounds will be sent, followed by + xdg_toplevel.configure and xdg_surface.configure. + + + + + + + + + + + + + + + + + This event advertises the capabilities supported by the compositor. If + a capability isn't supported, clients should hide or disable the UI + elements that expose this functionality. For instance, if the + compositor doesn't advertise support for minimized toplevels, a button + triggering the set_minimized request should not be displayed. + + The compositor will ignore requests it doesn't support. For instance, + a compositor which doesn't advertise support for minimized will ignore + set_minimized requests. + + Compositors must send this event once before the first + xdg_surface.configure event. When the capabilities change, compositors + must send this event again and then send an xdg_surface.configure + event. + + The configured state should not be applied immediately. See + xdg_surface.configure for details. + + The capabilities are sent as an array of 32-bit unsigned integers in + native endianness. + + + - + A popup surface is a short-lived, temporary surface. It can be used to implement for example menus, popovers, tooltips and other similar user @@ -1007,21 +1193,12 @@ surface of their own is clicked should dismiss the popup using the destroy request. - The parent surface must have either the xdg_toplevel or xdg_popup surface - role. - A newly created xdg_popup will be stacked on top of all previously created xdg_popup surfaces associated with the same xdg_toplevel. The parent of an xdg_popup must be mapped (see the xdg_surface description) before the xdg_popup itself. - The x and y arguments passed when creating the popup object specify - where the top left of the popup should be placed, relative to the - local surface coordinates of the parent surface. See - xdg_surface.get_popup. An xdg_popup must intersect with or be at least - partially adjacent to its parent surface. - The client must call wl_surface.commit on the corresponding wl_surface for the xdg_popup state to take effect. @@ -1069,10 +1246,6 @@ nested grabbing popup as well. When a compositor dismisses popups, it will follow the same dismissing order as required from the client. - The parent of a grabbing popup must either be another xdg_popup with an - active explicit grab, or an xdg_popup or xdg_toplevel, if there are no - explicit grabs already taken. - If the topmost grabbing popup is destroyed, the grab will be returned to the parent of the popup, if that parent previously had an explicit grab. @@ -1099,6 +1272,11 @@ The x and y arguments represent the position the popup was placed at given the xdg_positioner rule, relative to the upper left corner of the window geometry of the parent surface. + + For version 2 or older, the configure event for an xdg_popup is only + ever sent once for the initial configuration. Starting with version 3, + it may be sent again if the popup is setup with an xdg_positioner with + set_reactive requested, or in response to xdg_popup.reposition requests. @@ -1116,5 +1294,58 @@ + + + + + Reposition an already-mapped popup. The popup will be placed given the + details in the passed xdg_positioner object, and a + xdg_popup.repositioned followed by xdg_popup.configure and + xdg_surface.configure will be emitted in response. Any parameters set + by the previous positioner will be discarded. + + The passed token will be sent in the corresponding + xdg_popup.repositioned event. The new popup position will not take + effect until the corresponding configure event is acknowledged by the + client. See xdg_popup.repositioned for details. The token itself is + opaque, and has no other special meaning. + + If multiple reposition requests are sent, the compositor may skip all + but the last one. + + If the popup is repositioned in response to a configure event for its + parent, the client should send an xdg_positioner.set_parent_configure + and possibly an xdg_positioner.set_parent_size request to allow the + compositor to properly constrain the popup. + + If the popup is repositioned together with a parent that is being + resized, but not in response to a configure event, the client should + send an xdg_positioner.set_parent_size request. + + + + + + + + The repositioned event is sent as part of a popup configuration + sequence, together with xdg_popup.configure and lastly + xdg_surface.configure to notify the completion of a reposition request. + + The repositioned event is to notify about the completion of a + xdg_popup.reposition request. The token argument is the token passed + in the xdg_popup.reposition request. + + Immediately after this event is emitted, xdg_popup.configure and + xdg_surface.configure will be sent with the updated size and position, + as well as a new configure serial. + + The client should optionally update the content of the popup, but must + acknowledge the new popup configuration for the new position to take + effect. See xdg_surface.ack_configure for details. + + + + diff --git a/tests/acceptance-tests/wayland/CMakeLists.txt b/tests/acceptance-tests/wayland/CMakeLists.txt index b28a0a0147..593dcf586d 100644 --- a/tests/acceptance-tests/wayland/CMakeLists.txt +++ b/tests/acceptance-tests/wayland/CMakeLists.txt @@ -103,6 +103,9 @@ set(EXPECTED_FAILURES XdgPopupUnstableV6/XdgPopupTest.grabbed_popup_gets_keyboard_focus/0 XdgPopupStable/XdgPopupTest.grabbed_popup_gets_keyboard_focus/0 LayerShellPopup/XdgPopupTest.grabbed_popup_gets_keyboard_focus/0 + + # Not yet implemented, see https://github.com/MirServer/mir/issues/2861 + XdgPopupTest.when_parent_surface_is_moved_a_reactive_popup_is_moved ) if (MIR_SIGBUS_HANDLER_ENVIRONMENT_BROKEN)