Commit 023228cd authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Introduce SurfaceRole name property

This can be useful for protocol error messages.
parent 69d23935
......@@ -279,7 +279,7 @@ class InputPanelSurfaceV1InterfacePrivate : public QtWaylandServer::zwp_input_pa
public:
InputPanelSurfaceV1InterfacePrivate(SurfaceInterface *surface, quint32 id, InputPanelSurfaceV1Interface *q)
: zwp_input_panel_surface_v1()
, SurfaceRole(surface)
, SurfaceRole(surface, QByteArrayLiteral("input_panel_surface_v1"))
, q(q)
{
Q_UNUSED(id)
......@@ -329,7 +329,9 @@ public:
SurfaceRole *surfaceRole = SurfaceRole::get(surface);
if (surfaceRole) {
wl_resource_post_error(resource->handle, 0, "the surface already has a role assigned");
wl_resource_post_error(resource->handle, 0,
"the surface already has a role assigned %s",
surfaceRole->name().constData());
return;
}
......
......@@ -110,7 +110,8 @@ void LayerShellV1InterfacePrivate::zwlr_layer_shell_v1_get_layer_surface(Resourc
SurfaceRole *surfaceRole = SurfaceRole::get(surface);
if (surfaceRole) {
wl_resource_post_error(resource->handle, error_role,
"the wl_surface already has a role assigned");
"the wl_surface already has a role assigned %s",
surfaceRole->name().constData());
return;
}
......@@ -150,7 +151,7 @@ Display *LayerShellV1Interface::display() const
LayerSurfaceV1InterfacePrivate::LayerSurfaceV1InterfacePrivate(LayerSurfaceV1Interface *q,
SurfaceInterface *surface)
: SurfaceRole(surface)
: SurfaceRole(surface, QByteArrayLiteral("layer_surface_v1"))
, q(q)
, surface(surface)
{
......
......@@ -11,8 +11,9 @@
namespace KWaylandServer
{
SurfaceRole::SurfaceRole(SurfaceInterface *surface)
SurfaceRole::SurfaceRole(SurfaceInterface *surface, const QByteArray &name)
: m_surface(surface)
, m_name(name)
{
SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(surface);
surfacePrivate->role = this;
......@@ -27,6 +28,11 @@ SurfaceRole::~SurfaceRole()
}
}
QByteArray SurfaceRole::name() const
{
return m_name;
}
SurfaceRole *SurfaceRole::get(SurfaceInterface *surface)
{
if (surface) {
......
......@@ -7,6 +7,7 @@
#ifndef KWAYLAND_SERVER_SURFACEROLE_P_H
#define KWAYLAND_SERVER_SURFACEROLE_P_H
#include <QByteArray>
#include <QPointer>
namespace KWaylandServer
......@@ -17,9 +18,10 @@ class SurfaceInterface;
class SurfaceRole
{
public:
explicit SurfaceRole(SurfaceInterface *surface);
SurfaceRole(SurfaceInterface *surface, const QByteArray &name);
virtual ~SurfaceRole();
QByteArray name() const;
const QPointer<SurfaceInterface> &surface() const
{
return m_surface;
......@@ -31,6 +33,7 @@ public:
private:
QPointer<SurfaceInterface> m_surface;
QByteArray m_name;
Q_DISABLE_COPY(SurfaceRole)
};
......
......@@ -186,9 +186,11 @@ void XdgSurfaceInterfacePrivate::xdg_surface_destroy(Resource *resource)
void XdgSurfaceInterfacePrivate::xdg_surface_get_toplevel(Resource *resource, uint32_t id)
{
if (SurfaceRole::get(surface)) {
const SurfaceRole *surfaceRole = SurfaceRole::get(surface);
if (surfaceRole) {
wl_resource_post_error(resource->handle, error_already_constructed,
"xdg_surface has already been constructured");
"the surface already has a role assigned %s",
surfaceRole->name().constData());
return;
}
......@@ -203,9 +205,11 @@ void XdgSurfaceInterfacePrivate::xdg_surface_get_popup(Resource *resource, uint3
::wl_resource *parentResource,
::wl_resource *positionerResource)
{
if (SurfaceRole::get(surface)) {
const SurfaceRole *surfaceRole = SurfaceRole::get(surface);
if (surfaceRole) {
wl_resource_post_error(resource->handle, error_already_constructed,
"xdg_surface has already been constructured");
"the surface already has a role assigned %s",
surfaceRole->name().constData());
return;
}
......@@ -305,7 +309,7 @@ XdgSurfaceInterface *XdgSurfaceInterface::get(::wl_resource *resource)
XdgToplevelInterfacePrivate::XdgToplevelInterfacePrivate(XdgToplevelInterface *toplevel,
XdgSurfaceInterface *surface)
: SurfaceRole(surface->surface())
: SurfaceRole(surface->surface(), QByteArrayLiteral("xdg_toplevel"))
, q(toplevel)
, xdgSurface(surface)
{
......@@ -637,7 +641,7 @@ XdgPopupInterfacePrivate *XdgPopupInterfacePrivate::get(XdgPopupInterface *popup
XdgPopupInterfacePrivate::XdgPopupInterfacePrivate(XdgPopupInterface *popup,
XdgSurfaceInterface *surface)
: SurfaceRole(surface->surface())
: SurfaceRole(surface->surface(), QByteArrayLiteral("xdg_popup"))
, q(popup)
, xdgSurface(surface)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment