2020-03-15 15:19:28 +00:00
|
|
|
/*
|
2020-05-04 13:32:23 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2020-05-04 13:32:23 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-04-21 10:56:02 +00:00
|
|
|
#include "xdgshell_interface.h"
|
2020-05-04 13:32:23 +00:00
|
|
|
#include "qwayland-server-xdg-shell.h"
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
#include "surface_interface.h"
|
|
|
|
#include "surfacerole_p.h"
|
Support XDG v6
Summary:
The main clever part that's not just boring boiler plate is how we
handle the structure change
A surface now has an XDGSurface which then has a an Xdg TopLevel or a
Xdg Popup
We need to fit this into the public API which assumes a surface has a
Surface or a Popup.
The old Surface is similar to the new TopLevel.
The shoehorning works by relying on the fact that a surface without a
role is pretty useless.
Clients create the surface implicitly with the toplevel or implicitly
with the popup.
The server only announced it has a new "XdgSurface" when it gets a new
zxdg_surface_get_toplevel.
----
Popup decisions:
- On popup creation the server should copy the current info from the
positioner and then it gets deleted. Given kwaylands job is to keep
state, we expose all these parameter via popup.
- Due to this positioner is not exposed as a resource anywhere.
- Server API is 100% backwards compatiable.
i.e new code will work identically with v5 clients.
- Client API is not. Grabs are called separately from the constructor,
and the parent surface changed to an xdgsurface, not a raw surface.
V5 code still works as-is, just not with the new constructors.
It seemed better to match the v6 (and what will be the stable v7) than
to try and do hacks and lose functionality.
Given the client needs to change the code to opt into V6 anyway. I don't
think this is a huge problem.
Test Plan: Current test still passes.
Reviewers: #plasma, graesslin
Reviewed By: #plasma, graesslin
Subscribers: graesslin, mart, plasma-devel, #frameworks
Tags: #frameworks, #plasma_on_wayland
Differential Revision: https://phabricator.kde.org/D6047
2017-09-04 15:38:35 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2016-04-21 10:56:02 +00:00
|
|
|
{
|
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
class XdgToplevelDecorationV1Interface;
|
|
|
|
|
|
|
|
class XdgShellInterfacePrivate : public QtWaylandServer::xdg_wm_base
|
2016-04-21 10:56:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-05-04 13:32:23 +00:00
|
|
|
XdgShellInterfacePrivate(XdgShellInterface *shell);
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-08-07 18:41:52 +00:00
|
|
|
Resource *resourceForXdgSurface(XdgSurfaceInterface *surface) const;
|
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
void registerXdgSurface(XdgSurfaceInterface *surface);
|
|
|
|
void unregisterXdgSurface(XdgSurfaceInterface *surface);
|
|
|
|
|
|
|
|
void registerPing(quint32 serial);
|
|
|
|
|
|
|
|
static XdgShellInterfacePrivate *get(XdgShellInterface *shell);
|
Support XDG v6
Summary:
The main clever part that's not just boring boiler plate is how we
handle the structure change
A surface now has an XDGSurface which then has a an Xdg TopLevel or a
Xdg Popup
We need to fit this into the public API which assumes a surface has a
Surface or a Popup.
The old Surface is similar to the new TopLevel.
The shoehorning works by relying on the fact that a surface without a
role is pretty useless.
Clients create the surface implicitly with the toplevel or implicitly
with the popup.
The server only announced it has a new "XdgSurface" when it gets a new
zxdg_surface_get_toplevel.
----
Popup decisions:
- On popup creation the server should copy the current info from the
positioner and then it gets deleted. Given kwaylands job is to keep
state, we expose all these parameter via popup.
- Due to this positioner is not exposed as a resource anywhere.
- Server API is 100% backwards compatiable.
i.e new code will work identically with v5 clients.
- Client API is not. Grabs are called separately from the constructor,
and the parent surface changed to an xdgsurface, not a raw surface.
V5 code still works as-is, just not with the new constructors.
It seemed better to match the v6 (and what will be the stable v7) than
to try and do hacks and lose functionality.
Given the client needs to change the code to opt into V6 anyway. I don't
think this is a huge problem.
Test Plan: Current test still passes.
Reviewers: #plasma, graesslin
Reviewed By: #plasma, graesslin
Subscribers: graesslin, mart, plasma-devel, #frameworks
Tags: #frameworks, #plasma_on_wayland
Differential Revision: https://phabricator.kde.org/D6047
2017-09-04 15:38:35 +00:00
|
|
|
|
2016-04-21 10:56:02 +00:00
|
|
|
XdgShellInterface *q;
|
2020-05-04 13:32:23 +00:00
|
|
|
Display *display;
|
|
|
|
QMap<quint32, QTimer *> pings;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void xdg_wm_base_destroy(Resource *resource) override;
|
|
|
|
void xdg_wm_base_create_positioner(Resource *resource, uint32_t id) override;
|
|
|
|
void xdg_wm_base_get_xdg_surface(Resource *resource, uint32_t id, ::wl_resource *surface) override;
|
|
|
|
void xdg_wm_base_pong(Resource *resource, uint32_t serial) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QMultiMap<wl_client *, XdgSurfaceInterface *> xdgSurfaces;
|
2016-04-21 10:56:02 +00:00
|
|
|
};
|
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
class XdgPositionerData : public QSharedData
|
2016-04-21 10:56:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-05-04 13:32:23 +00:00
|
|
|
Qt::Orientations slideConstraintAdjustments;
|
|
|
|
Qt::Orientations flipConstraintAdjustments;
|
|
|
|
Qt::Orientations resizeConstraintAdjustments;
|
|
|
|
Qt::Edges anchorEdges;
|
|
|
|
Qt::Edges gravityEdges;
|
|
|
|
QPoint offset;
|
|
|
|
QSize size;
|
|
|
|
QRect anchorRect;
|
|
|
|
};
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
class XdgPositionerPrivate : public QtWaylandServer::xdg_positioner
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
XdgPositionerPrivate(::wl_resource *resource);
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
QSharedDataPointer<XdgPositionerData> data;
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
static XdgPositionerPrivate *get(::wl_resource *resource);
|
2016-04-21 10:56:02 +00:00
|
|
|
|
|
|
|
protected:
|
2020-05-04 13:32:23 +00:00
|
|
|
void xdg_positioner_destroy_resource(Resource *resource) override;
|
|
|
|
void xdg_positioner_destroy(Resource *resource) override;
|
|
|
|
void xdg_positioner_set_size(Resource *resource, int32_t width, int32_t height) override;
|
|
|
|
void xdg_positioner_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
|
|
|
|
void xdg_positioner_set_anchor(Resource *resource, uint32_t anchor) override;
|
|
|
|
void xdg_positioner_set_gravity(Resource *resource, uint32_t gravity) override;
|
|
|
|
void xdg_positioner_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment) override;
|
|
|
|
void xdg_positioner_set_offset(Resource *resource, int32_t x, int32_t y) override;
|
2016-04-21 10:56:02 +00:00
|
|
|
};
|
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
class XdgSurfaceInterfacePrivate : public QtWaylandServer::xdg_surface
|
2016-04-21 10:56:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-05-04 13:32:23 +00:00
|
|
|
XdgSurfaceInterfacePrivate(XdgSurfaceInterface *xdgSurface);
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
void commit();
|
2020-05-08 10:22:21 +00:00
|
|
|
void reset();
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
XdgSurfaceInterface *q;
|
|
|
|
XdgShellInterface *shell;
|
|
|
|
QPointer<XdgToplevelInterface> toplevel;
|
|
|
|
QPointer<XdgPopupInterface> popup;
|
|
|
|
QPointer<SurfaceInterface> surface;
|
2020-05-08 10:22:21 +00:00
|
|
|
bool isMapped = false;
|
2020-05-04 13:32:23 +00:00
|
|
|
bool isConfigured = false;
|
Support XDG v6
Summary:
The main clever part that's not just boring boiler plate is how we
handle the structure change
A surface now has an XDGSurface which then has a an Xdg TopLevel or a
Xdg Popup
We need to fit this into the public API which assumes a surface has a
Surface or a Popup.
The old Surface is similar to the new TopLevel.
The shoehorning works by relying on the fact that a surface without a
role is pretty useless.
Clients create the surface implicitly with the toplevel or implicitly
with the popup.
The server only announced it has a new "XdgSurface" when it gets a new
zxdg_surface_get_toplevel.
----
Popup decisions:
- On popup creation the server should copy the current info from the
positioner and then it gets deleted. Given kwaylands job is to keep
state, we expose all these parameter via popup.
- Due to this positioner is not exposed as a resource anywhere.
- Server API is 100% backwards compatiable.
i.e new code will work identically with v5 clients.
- Client API is not. Grabs are called separately from the constructor,
and the parent surface changed to an xdgsurface, not a raw surface.
V5 code still works as-is, just not with the new constructors.
It seemed better to match the v6 (and what will be the stable v7) than
to try and do hacks and lose functionality.
Given the client needs to change the code to opt into V6 anyway. I don't
think this is a huge problem.
Test Plan: Current test still passes.
Reviewers: #plasma, graesslin
Reviewed By: #plasma, graesslin
Subscribers: graesslin, mart, plasma-devel, #frameworks
Tags: #frameworks, #plasma_on_wayland
Differential Revision: https://phabricator.kde.org/D6047
2017-09-04 15:38:35 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
struct State
|
|
|
|
{
|
|
|
|
QRect windowGeometry;
|
|
|
|
};
|
Support XDG v6
Summary:
The main clever part that's not just boring boiler plate is how we
handle the structure change
A surface now has an XDGSurface which then has a an Xdg TopLevel or a
Xdg Popup
We need to fit this into the public API which assumes a surface has a
Surface or a Popup.
The old Surface is similar to the new TopLevel.
The shoehorning works by relying on the fact that a surface without a
role is pretty useless.
Clients create the surface implicitly with the toplevel or implicitly
with the popup.
The server only announced it has a new "XdgSurface" when it gets a new
zxdg_surface_get_toplevel.
----
Popup decisions:
- On popup creation the server should copy the current info from the
positioner and then it gets deleted. Given kwaylands job is to keep
state, we expose all these parameter via popup.
- Due to this positioner is not exposed as a resource anywhere.
- Server API is 100% backwards compatiable.
i.e new code will work identically with v5 clients.
- Client API is not. Grabs are called separately from the constructor,
and the parent surface changed to an xdgsurface, not a raw surface.
V5 code still works as-is, just not with the new constructors.
It seemed better to match the v6 (and what will be the stable v7) than
to try and do hacks and lose functionality.
Given the client needs to change the code to opt into V6 anyway. I don't
think this is a huge problem.
Test Plan: Current test still passes.
Reviewers: #plasma, graesslin
Reviewed By: #plasma, graesslin
Subscribers: graesslin, mart, plasma-devel, #frameworks
Tags: #frameworks, #plasma_on_wayland
Differential Revision: https://phabricator.kde.org/D6047
2017-09-04 15:38:35 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
State next;
|
|
|
|
State current;
|
Support XDG v6
Summary:
The main clever part that's not just boring boiler plate is how we
handle the structure change
A surface now has an XDGSurface which then has a an Xdg TopLevel or a
Xdg Popup
We need to fit this into the public API which assumes a surface has a
Surface or a Popup.
The old Surface is similar to the new TopLevel.
The shoehorning works by relying on the fact that a surface without a
role is pretty useless.
Clients create the surface implicitly with the toplevel or implicitly
with the popup.
The server only announced it has a new "XdgSurface" when it gets a new
zxdg_surface_get_toplevel.
----
Popup decisions:
- On popup creation the server should copy the current info from the
positioner and then it gets deleted. Given kwaylands job is to keep
state, we expose all these parameter via popup.
- Due to this positioner is not exposed as a resource anywhere.
- Server API is 100% backwards compatiable.
i.e new code will work identically with v5 clients.
- Client API is not. Grabs are called separately from the constructor,
and the parent surface changed to an xdgsurface, not a raw surface.
V5 code still works as-is, just not with the new constructors.
It seemed better to match the v6 (and what will be the stable v7) than
to try and do hacks and lose functionality.
Given the client needs to change the code to opt into V6 anyway. I don't
think this is a huge problem.
Test Plan: Current test still passes.
Reviewers: #plasma, graesslin
Reviewed By: #plasma, graesslin
Subscribers: graesslin, mart, plasma-devel, #frameworks
Tags: #frameworks, #plasma_on_wayland
Differential Revision: https://phabricator.kde.org/D6047
2017-09-04 15:38:35 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
static XdgSurfaceInterfacePrivate *get(XdgSurfaceInterface *surface);
|
2016-04-21 10:56:02 +00:00
|
|
|
|
|
|
|
protected:
|
2020-05-04 13:32:23 +00:00
|
|
|
void xdg_surface_destroy_resource(Resource *resource) override;
|
|
|
|
void xdg_surface_destroy(Resource *resource) override;
|
|
|
|
void xdg_surface_get_toplevel(Resource *resource, uint32_t id) override;
|
|
|
|
void xdg_surface_get_popup(Resource *resource, uint32_t id, ::wl_resource *parent, ::wl_resource *positioner) override;
|
|
|
|
void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
|
|
|
|
void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override;
|
|
|
|
};
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
class XdgToplevelInterfacePrivate : public SurfaceRole, public QtWaylandServer::xdg_toplevel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
XdgToplevelInterfacePrivate(XdgToplevelInterface *toplevel, XdgSurfaceInterface *surface);
|
|
|
|
|
|
|
|
void commit() override;
|
2020-05-08 10:22:21 +00:00
|
|
|
void reset();
|
2020-05-04 13:32:23 +00:00
|
|
|
|
|
|
|
static XdgToplevelInterfacePrivate *get(XdgToplevelInterface *toplevel);
|
|
|
|
static XdgToplevelInterfacePrivate *get(::wl_resource *resource);
|
|
|
|
|
|
|
|
XdgToplevelInterface *q;
|
|
|
|
QPointer<XdgToplevelInterface> parentXdgToplevel;
|
|
|
|
QPointer<XdgToplevelDecorationV1Interface> decoration;
|
|
|
|
XdgSurfaceInterface *xdgSurface;
|
|
|
|
|
|
|
|
QString windowTitle;
|
|
|
|
QString windowClass;
|
|
|
|
|
|
|
|
struct State
|
|
|
|
{
|
|
|
|
QSize minimumSize;
|
|
|
|
QSize maximumSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
State next;
|
|
|
|
State current;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void xdg_toplevel_destroy_resource(Resource *resource) override;
|
|
|
|
void xdg_toplevel_destroy(Resource *resource) override;
|
|
|
|
void xdg_toplevel_set_parent(Resource *resource, ::wl_resource *parent) override;
|
|
|
|
void xdg_toplevel_set_title(Resource *resource, const QString &title) override;
|
|
|
|
void xdg_toplevel_set_app_id(Resource *resource, const QString &app_id) override;
|
|
|
|
void xdg_toplevel_show_window_menu(Resource *resource, ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y) override;
|
|
|
|
void xdg_toplevel_move(Resource *resource, ::wl_resource *seat, uint32_t serial) override;
|
|
|
|
void xdg_toplevel_resize(Resource *resource, ::wl_resource *seat, uint32_t serial, uint32_t edges) override;
|
|
|
|
void xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height) override;
|
|
|
|
void xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height) override;
|
|
|
|
void xdg_toplevel_set_maximized(Resource *resource) override;
|
|
|
|
void xdg_toplevel_unset_maximized(Resource *resource) override;
|
|
|
|
void xdg_toplevel_set_fullscreen(Resource *resource, ::wl_resource *output) override;
|
|
|
|
void xdg_toplevel_unset_fullscreen(Resource *resource) override;
|
|
|
|
void xdg_toplevel_set_minimized(Resource *resource) override;
|
2016-04-21 10:56:02 +00:00
|
|
|
};
|
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
class XdgPopupInterfacePrivate : public SurfaceRole, public QtWaylandServer::xdg_popup
|
|
|
|
{
|
|
|
|
public:
|
2020-08-07 18:41:52 +00:00
|
|
|
static XdgPopupInterfacePrivate *get(XdgPopupInterface *popup);
|
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
XdgPopupInterfacePrivate(XdgPopupInterface *popup, XdgSurfaceInterface *surface);
|
|
|
|
|
|
|
|
void commit() override;
|
2020-05-08 10:22:21 +00:00
|
|
|
void reset();
|
2020-05-04 13:32:23 +00:00
|
|
|
|
|
|
|
XdgPopupInterface *q;
|
2020-08-07 18:41:52 +00:00
|
|
|
SurfaceInterface *parentSurface;
|
2020-05-04 13:32:23 +00:00
|
|
|
XdgSurfaceInterface *xdgSurface;
|
|
|
|
XdgPositioner positioner;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void xdg_popup_destroy_resource(Resource *resource) override;
|
|
|
|
void xdg_popup_destroy(Resource *resource) override;
|
|
|
|
void xdg_popup_grab(Resource *resource, ::wl_resource *seat, uint32_t serial) override;
|
|
|
|
};
|
2016-04-21 10:56:02 +00:00
|
|
|
|
2020-05-04 13:32:23 +00:00
|
|
|
} // namespace KWaylandServer
|