#include "DSWaylandZxdgShellV6.h"
#include "DSWaylandZxdgShellV6Private.h"
+#define ZXDG_SHELL_V6_VERSION 1
+#define ZXDG_POSITIONER_V6_VERSION 1
+#define ZXDG_SURFACE_V6_VERSION 1
+#define ZXDG_TOPLEVEL_V6_VERSION 1
+#define ZXDG_POPUP_V6_VERSION 1
namespace display_server
{
{
}
+DSWaylandZxdgShellV6::DSWaylandZxdgShellV6(struct ::wl_display *display, int version)
+ : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgShellV6)
+{
+ this->init(display, version);
+}
+
DSWaylandZxdgShellV6::~DSWaylandZxdgShellV6()
{
}
+void DSWaylandZxdgShellV6::init(struct ::wl_display *display, int version)
+{
+ DS_GET_PRIV(DSWaylandZxdgShellV6);
+
+ priv->init(display, version);
+}
+
+void DSWaylandZxdgShellV6::addSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf)
+{
+ DS_GET_PRIV(DSWaylandZxdgShellV6);
+
+ priv->addSurface(zxdgSurf);
+}
+
+void DSWaylandZxdgShellV6::delSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf)
+{
+ DS_GET_PRIV(DSWaylandZxdgShellV6);
+
+ priv->delSurface(zxdgSurf);
+}
+
+std::list<DSWaylandZxdgSurfaceV6 *> DSWaylandZxdgShellV6::getSurfaceList()
+{
+ DS_GET_PRIV(DSWaylandZxdgShellV6);
+
+ return priv->getSurfaceList();
+}
+
DSWaylandZxdgShellV6Private::DSWaylandZxdgShellV6Private(DSWaylandZxdgShellV6 *p_ptr)
: DSObjectPrivate(p_ptr), __p_ptr(p_ptr)
}
void DSWaylandZxdgShellV6Private::zxdg_shell_v6_get_xdg_surface(zxdg_shell_v6::Resource *resource, uint32_t id, struct ::wl_resource *surface)
{
+ DS_GET_PUB(DSWaylandZxdgShellV6);
+
+ DSWaylandZxdgSurfaceV6 *zxdgSurf = new DSWaylandZxdgSurfaceV6(resource->client(), id, ZXDG_SURFACE_V6_VERSION);
+ pub->addSurface(zxdgSurf);
}
void DSWaylandZxdgShellV6Private::zxdg_shell_v6_pong(zxdg_shell_v6::Resource *resource, uint32_t serial)
{
}
+void DSWaylandZxdgShellV6Private::addSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf)
+{
+ for (DSWaylandZxdgSurfaceV6 *surf : __surfList)
+ if (surf == zxdgSurf) return;
+
+ __surfList.push_back(zxdgSurf);
+}
+
+void DSWaylandZxdgShellV6Private::delSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf)
+{
+ __surfList.remove(zxdgSurf);
+}
+
+std::list<DSWaylandZxdgSurfaceV6 *> DSWaylandZxdgShellV6Private::getSurfaceList()
+{
+ return __surfList;
+}
+
/******************************************
DSWaylandZxdgPositionerV6
{
}
+DSWaylandZxdgPositionerV6::DSWaylandZxdgPositionerV6(struct ::wl_client *client, int id, int ver)
+ : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgPositionerV6)
+{
+ this->init(client, id, ver);
+}
+
DSWaylandZxdgPositionerV6::~DSWaylandZxdgPositionerV6()
{
}
+void DSWaylandZxdgPositionerV6::init(struct ::wl_client *client, int id, int ver)
+{
+ DS_GET_PRIV(DSWaylandZxdgPositionerV6);
+
+ priv->init(client, id, ver);
+}
+
DSWaylandZxdgPositionerV6Private::DSWaylandZxdgPositionerV6Private(DSWaylandZxdgPositionerV6 *p_ptr)
: DSObjectPrivate(p_ptr), __p_ptr(p_ptr)
{
}
+DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver)
+ : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6)
+{
+ this->init(client, id, ver);
+}
+
DSWaylandZxdgSurfaceV6::~DSWaylandZxdgSurfaceV6()
{
}
+void DSWaylandZxdgSurfaceV6::init(struct ::wl_client *client, int id, int ver)
+{
+ DS_GET_PRIV(DSWaylandZxdgSurfaceV6);
+
+ priv->init(client, id, ver);
+}
+
+void DSWaylandZxdgSurfaceV6::setWindowTitle(const std::string &title)
+{
+ DS_GET_PRIV(DSWaylandZxdgSurfaceV6);
+
+ priv->setWindowTitle(title);
+}
+
+void DSWaylandZxdgSurfaceV6::setAppID(const std::string &appId)
+{
+ DS_GET_PRIV(DSWaylandZxdgSurfaceV6);
+
+ priv->setAppID(appId);
+}
+
+void DSWaylandZxdgSurfaceV6::getGeometry(int *x, int *y, int *w, int *h)
+{
+ DS_GET_PRIV(DSWaylandZxdgSurfaceV6);
+ int __x = 0, __y = 0, __w = 0, __h = 0;
+
+ priv->getGeometry(&__x, &__y, &__w, &__h);
+
+ if (x) *x = __x;
+ if (y) *y = __y;
+ if (w) *w = __w;
+ if (h) *h = __h;
+}
+
+std::string DSWaylandZxdgSurfaceV6::getWindowTitle()
+{
+ DS_GET_PRIV(DSWaylandZxdgSurfaceV6);
+
+ return priv->getWindowTitle();
+}
+
+std::string DSWaylandZxdgSurfaceV6::getAppID()
+{
+ DS_GET_PRIV(DSWaylandZxdgSurfaceV6);
+
+ return priv->getAppID();
+}
+
DSWaylandZxdgSurfaceV6Private::DSWaylandZxdgSurfaceV6Private(DSWaylandZxdgSurfaceV6 *p_ptr)
- : DSObjectPrivate(p_ptr), __p_ptr(p_ptr)
+ : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), __x(0), __y(0), __w(0), __h(0)
{
}
}
void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_get_toplevel(zxdg_surface_v6::Resource *resource, uint32_t id)
{
+ DS_GET_PUB(DSWaylandZxdgSurfaceV6);
+ DSWaylandZxdgToplevelV6 *zxdgToplevel = new DSWaylandZxdgToplevelV6(pub, resource->client(), id, ZXDG_TOPLEVEL_V6_VERSION);
+ __toplevel = zxdgToplevel;
+ __role = DSWaylandZxdgSurfaceV6::DS_XDG_SURFACE_ROLE_TOPLEVEL;
}
void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_get_popup(zxdg_surface_v6::Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner)
{
+ DS_GET_PUB(DSWaylandZxdgSurfaceV6);
+ DSWaylandZxdgPopupV6 *zxdgPopup = new DSWaylandZxdgPopupV6(pub, resource->client(), id, ZXDG_TOPLEVEL_V6_VERSION);
+ __popup = zxdgPopup;
+ __role = DSWaylandZxdgSurfaceV6::DS_XDG_SURFACE_ROLE_POPUP;
}
void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_set_window_geometry(zxdg_surface_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
{
+ __x = x;
+ __y = y;
+ __w = width;
+ __h = height;
+ // TODO: needs codes for adjust geometry
}
void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_ack_configure(zxdg_surface_v6::Resource *resource, uint32_t serial)
{
}
+void DSWaylandZxdgSurfaceV6Private::setWindowTitle(const std::string &title)
+{
+ // TODO: needs DSWindow title set method
+ //__window->setTitle(title);
+ __title = title;
+}
+
+void DSWaylandZxdgSurfaceV6Private::setAppID(const std::string &appId)
+{
+ // TODO: needs AppID set method
+ __appId = appId;
+}
+
+void DSWaylandZxdgSurfaceV6Private::getGeometry(int *x, int *y, int *w, int *h)
+{
+ if (x) *x = __x;
+ if (y) *y = __y;
+ if (w) *w = __w;
+ if (h) *h = __h;
+}
+
+std::string DSWaylandZxdgSurfaceV6Private::getWindowTitle()
+{
+ // TODO: needs DSWindow title set method
+ //__window->setTitle(title);
+ return __title;
+}
+
+std::string DSWaylandZxdgSurfaceV6Private::getAppID()
+{
+ // TODO: needs AppID set method
+ return __appId;
+}
+
/******************************************
DSWaylandZxdgToplevelV6
{
}
+DSWaylandZxdgToplevelV6::DSWaylandZxdgToplevelV6(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver)
+ : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgToplevelV6)
+{
+ this->init(zxdgSurface, client, id, ver);
+}
+
DSWaylandZxdgToplevelV6::~DSWaylandZxdgToplevelV6()
{
}
+void DSWaylandZxdgToplevelV6::init(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver)
+{
+ DS_GET_PRIV(DSWaylandZxdgToplevelV6);
+
+ priv->init(client, id, ver);
+ priv->__zxdgSurface = zxdgSurface;
+}
+
DSWaylandZxdgToplevelV6Private::DSWaylandZxdgToplevelV6Private(DSWaylandZxdgToplevelV6 *p_ptr)
: DSObjectPrivate(p_ptr), __p_ptr(p_ptr)
}
void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_title(zxdg_toplevel_v6::Resource *resource, const std::string &title)
{
+ __zxdgSurface->setWindowTitle(title);
}
void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_app_id(zxdg_toplevel_v6::Resource *resource, const std::string &app_id)
{
+ __zxdgSurface->setAppID(app_id);
}
void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_show_window_menu(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y)
{
{
}
+DSWaylandZxdgPopupV6::DSWaylandZxdgPopupV6(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver)
+ : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgPopupV6)
+{
+ this->init(zxdgSurface, client, id, ver);
+}
+
DSWaylandZxdgPopupV6::~DSWaylandZxdgPopupV6()
{
}
+void DSWaylandZxdgPopupV6::init(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver)
+{
+ DS_GET_PRIV(DSWaylandZxdgPopupV6);
+
+ priv->init(client, id, ver);
+ priv->__zxdgSurface = zxdgSurface;
+}
+
DSWaylandZxdgPopupV6Private::DSWaylandZxdgPopupV6Private(DSWaylandZxdgPopupV6 *p_ptr)
: DSObjectPrivate(p_ptr), __p_ptr(p_ptr)
#ifndef __DS_WAYLAND_ZXDG_SHELL_V6_H__
#define __DS_WAYLAND_ZXDG_SHELL_V6_H__
-#include "DSCore.h"
+#include <DSCore.h>
#include <DSObject.h>
+#include <wayland-server-core.h>
+
namespace display_server
{
+class DSWaylandZxdgShellV6;
+class DSWaylandZxdgPositionerV6;
+class DSWaylandZxdgSurfaceV6;
+class DSWaylandZxdgToplevelV6;
+class DSWaylandZxdgPopupV6;
class DSWaylandZxdgShellV6Private;
class DSWaylandZxdgPositionerV6Private;
class DSWaylandZxdgSurfaceV6Private;
public:
DSWaylandZxdgShellV6();
+ DSWaylandZxdgShellV6(struct ::wl_display *display, int version);
virtual ~DSWaylandZxdgShellV6();
+ void init(struct ::wl_display *display, int version);
+ void addSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf);
+ void delSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf);
+ std::list<DSWaylandZxdgSurfaceV6 *> getSurfaceList();
+
};
class DSWaylandZxdgPositionerV6 : public DSObject
public:
DSWaylandZxdgPositionerV6();
+ DSWaylandZxdgPositionerV6(struct ::wl_client *client, int id, int ver);
virtual ~DSWaylandZxdgPositionerV6();
+ void init(struct ::wl_client *client, int id, int ver);
+
};
class DSWaylandZxdgSurfaceV6 : public DSObject
DS_PIMPL_USE_PRIVATE(DSWaylandZxdgSurfaceV6);
public:
+ enum Xdg_Surface_Role
+ {
+ DS_XDG_SURFACE_ROLE_NONE,
+ DS_XDG_SURFACE_ROLE_TOPLEVEL,
+ DS_XDG_SURFACE_ROLE_POPUP,
+ };
+
+public:
DSWaylandZxdgSurfaceV6();
+ DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver);
virtual ~DSWaylandZxdgSurfaceV6();
+ void init(struct ::wl_client *client, int id, int ver);
+
+ void setWindowTitle(const std::string &title);
+ void setAppID(const std::string &appId);
+
+ void getGeometry(int *x, int *y, int *w, int *h);
+ std::string getWindowTitle();
+ std::string getAppID();
+
};
class DSWaylandZxdgToplevelV6 : public DSObject
public:
DSWaylandZxdgToplevelV6();
+ DSWaylandZxdgToplevelV6(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver);
virtual ~DSWaylandZxdgToplevelV6();
+
+ void init(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver);
};
class DSWaylandZxdgPopupV6 : public DSObject
public:
DSWaylandZxdgPopupV6();
+ DSWaylandZxdgPopupV6(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver);
virtual ~DSWaylandZxdgPopupV6();
+
+ void init(DSWaylandZxdgSurfaceV6 *zxdgSurface, struct ::wl_client *client, int id, int ver);
};
#ifndef __DS_WAYLAND_ZXDG_SHELL_V6_PRIVATE_H__
#define __DS_WAYLAND_ZXDG_SHELL_V6_PRIVATE_H__
+#include <DSWindow.h>
+
#include "dswayland-server-xdg-shell-unstable-v6.h"
#include "DSWaylandZxdgShellV6.h"
void zxdg_shell_v6_get_xdg_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) override;
void zxdg_shell_v6_pong(Resource *resource, uint32_t serial) override;
+ void addSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf);
+ void delSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf);
+ std::list<DSWaylandZxdgSurfaceV6 *> getSurfaceList();
+
private:
+ std::list<DSWaylandZxdgSurfaceV6 *> __surfList;
};
class DSWaylandZxdgPositionerV6Private : public DSObjectPrivate, public DSWaylandServer::zxdg_positioner_v6
void zxdg_surface_v6_set_window_geometry(zxdg_surface_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
void zxdg_surface_v6_ack_configure(zxdg_surface_v6::Resource *resource, uint32_t serial) override;
+ void setWindowTitle(const std::string &title);
+ void setAppID(const std::string &appId);
+
+ void getGeometry(int *x, int *y, int *w, int *h);
+ std::string getWindowTitle();
+ std::string getAppID();
+
private:
+ DSWindow *window;
+ DSWaylandZxdgToplevelV6 *__toplevel;
+ DSWaylandZxdgPopupV6 *__popup;
+ DSWaylandZxdgSurfaceV6::Xdg_Surface_Role __role;
+
+ int __x, __y, __w, __h;
+ std::string __title, __appId;
};
class DSWaylandZxdgToplevelV6Private : public DSObjectPrivate, public DSWaylandServer::zxdg_toplevel_v6
void zxdg_toplevel_v6_set_minimized(zxdg_toplevel_v6::Resource *resource) override;
private:
+ DSWaylandZxdgSurfaceV6 *__zxdgSurface;
};
class DSWaylandZxdgPopupV6Private : public DSObjectPrivate, public DSWaylandServer::zxdg_popup_v6
void zxdg_popup_v6_grab(zxdg_popup_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial) override;
private:
+ DSWaylandZxdgSurfaceV6 *__zxdgSurface;
};
TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgShellV6)
{
DSWaylandZxdgShellV6 *zxdgShell = new DSWaylandZxdgShellV6;
- delete zxdgShell;
+ EXPECT_TRUE(zxdgShell != nullptr);
+
+ if (zxdgShell)
+ delete zxdgShell;
+}
+
+TEST_F(DSWaylandZxdgShellV6Test, ShellAddSurface)
+{
+ DSWaylandZxdgShellV6 *zxdgShell = new DSWaylandZxdgShellV6;
+ DSWaylandZxdgSurfaceV6 *zxdgSurf = new DSWaylandZxdgSurfaceV6;
+ EXPECT_TRUE(zxdgShell != nullptr);
+ EXPECT_TRUE(zxdgSurf != nullptr);
+
+ zxdgShell->addSurface(zxdgSurf);
EXPECT_TRUE(true);
}
+TEST_F(DSWaylandZxdgShellV6Test, ShellGetSurfaceList)
+{
+ DSWaylandZxdgShellV6 *zxdgShell = new DSWaylandZxdgShellV6;
+ DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6;
+ EXPECT_TRUE(zxdgShell != nullptr);
+ EXPECT_TRUE(zxdgSurface != nullptr);
+
+ zxdgShell->addSurface(zxdgSurface);
+ auto surfList = zxdgShell->getSurfaceList();
+
+ for (auto iter = surfList.begin() ; iter != surfList.end() ; iter++)
+ {
+ EXPECT_TRUE(*iter == zxdgSurface);
+ }
+
+ if (zxdgShell)
+ delete zxdgShell;
+ if (zxdgSurface)
+ delete zxdgSurface;
+}
+
TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgPositionerV6)
{
DSWaylandZxdgPositionerV6 *zxdgPositioner = new DSWaylandZxdgPositionerV6;
- delete zxdgPositioner;
- EXPECT_TRUE(true);
+ EXPECT_TRUE(zxdgPositioner != nullptr);
+
+ if (zxdgPositioner)
+ delete zxdgPositioner;
}
TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgSurfaceV6)
{
DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6;
- delete zxdgSurface;
- EXPECT_TRUE(true);
+ EXPECT_TRUE(zxdgSurface != nullptr);
+
+ if (zxdgSurface)
+ delete zxdgSurface;
+}
+
+TEST_F(DSWaylandZxdgShellV6Test, SurfaceSetWindowTitle)
+{
+ DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6;
+ std::string inputStr("test");
+ EXPECT_TRUE(zxdgSurface != nullptr);
+
+ zxdgSurface->setWindowTitle(inputStr);
+ EXPECT_TRUE(inputStr.compare(zxdgSurface->getWindowTitle().c_str()) == 0);
+
+ if (zxdgSurface)
+ delete zxdgSurface;
+}
+
+TEST_F(DSWaylandZxdgShellV6Test, SurfaceSetAppID)
+{
+ DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6;
+ std::string inputStr("test");
+ EXPECT_TRUE(zxdgSurface != nullptr);
+
+ zxdgSurface->setAppID(inputStr);
+ EXPECT_TRUE(inputStr.compare(zxdgSurface->getAppID().c_str()) == 0);
+
+ if (zxdgSurface)
+ delete zxdgSurface;
}
TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgToplevelV6)
{
DSWaylandZxdgToplevelV6 *zxdgToplevel = new DSWaylandZxdgToplevelV6;
- delete zxdgToplevel;
- EXPECT_TRUE(true);
+ EXPECT_TRUE(zxdgToplevel != nullptr);
+
+ if (zxdgToplevel)
+ delete zxdgToplevel;
}
TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgPopupV6)
{
DSWaylandZxdgPopupV6 *zxdgPopup = new DSWaylandZxdgPopupV6;
- delete zxdgPopup;
- EXPECT_TRUE(true);
+ EXPECT_TRUE(zxdgPopup != nullptr);
+
+ if (zxdgPopup)
+ delete zxdgPopup;
}