From ae37d48b7e219c96750d19aac73eae58c1669d40 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 8 Sep 2020 11:35:21 +0900 Subject: [PATCH 01/16] DSUtil: define LCOV_EXCL blocks for error handling code Change-Id: I4f2eedf8056e040c5698c0ec31984d982640c423 Signed-off-by: Sung-Jin Park --- src/DSUtil/DSUtilSocket.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/DSUtil/DSUtilSocket.cpp b/src/DSUtil/DSUtilSocket.cpp index 9c0e0ff..0e25111 100644 --- a/src/DSUtil/DSUtilSocket.cpp +++ b/src/DSUtil/DSUtilSocket.cpp @@ -112,8 +112,10 @@ void DSUtilSocket::initSocket(std::string socketName) int nameLength = socketName.length(); if ((dirLength + nameLength + 2) > STRERR_BUFSIZE) { + /*LCOV_EXCL_START*/ DSLOG_WRN("DSUtilSocket", "Size of buffer is not enough. dir:%s name:%s", xdgDir, socketName); return; + /*LCOV_EXCL_STOP*/ } //snprintf(socket_path, sizeof(socket_path), "%s/%s", dir, name); @@ -125,17 +127,21 @@ void DSUtilSocket::initSocket(std::string socketName) res = chmod(socketPath.c_str(), 509); if (res < 0) { + /*LCOV_EXCL_START*/ DSLOG_WRN("DSUtilSocket", "Could not change modes of socket file:%s (%s)", socketPath.c_str(), strerror_r(errno, buf, STRERR_BUFSIZE)); //PRCTL("[Winsys] Could not chane modes of socket file: %s", socketPath.c_str()); return; + /*LCOV_EXCL_STOP*/ } res = chown(socketPath.c_str(), uid, gid); if (res < 0) { + /*LCOV_EXCL_START*/ DSLOG_WRN("DSUtilSocket", "Could not change owner of socket file:%s (%s)", socketPath.c_str(), strerror_r(errno, buf, STRERR_BUFSIZE)); //PRCTL("[Winsys] Could not change owner of socket file: %s", socketPath.c_str()); return; + /*LCOV_EXCL_STOP*/ } } @@ -156,26 +162,32 @@ int DSUtilSocket::__getpwnam(std::string name) buf = (char *)malloc(bufLen); if (buf == NULL) { + /*LCOV_EXCL_START*/ DSLOG_WRN("DSUtilSocket", "failed to create buffer"); return 0; + /*LCOV_EXCL_STOP*/ } u = (struct ::passwd *)malloc(sizeof(struct passwd)); if (!u) { + /*LCOV_EXCL_START*/ DSLOG_WRN("DSUtilSocket", "failed to create password struct"); free(buf); return 0; + /*LCOV_EXCL_STOP*/ } ret = getpwnam_r(name.c_str(), u, buf, bufLen, &uRes); if (uRes == nullptr) { + /*LCOV_EXCL_START*/ if (ret == 0) DSLOG_WRN("DSUtilSocket", "password not found"); else DSLOG_WRN("DSUtilSocket", "errno returned by getpwnam_r is %d", ret); free(buf); free(u); return 0; + /*LCOV_EXCL_STOP*/ } ret = u->pw_uid; free(buf); @@ -201,26 +213,32 @@ int DSUtilSocket::__getgrnam(std::string name) buf = (char *)malloc(bufLen); if (buf == nullptr) { + /*LCOV_EXCL_START*/ DSLOG_WRN("DSUtilSocket", "failed to create buffer"); return 0; + /*LCOV_EXCL_STOP*/ } g = (struct ::group *)malloc(sizeof(struct group)); if (!g) { + /*LCOV_EXCL_START*/ DSLOG_WRN("DSUtilSocket", "failed to create group struct"); free(buf); return 0; + /*LCOV_EXCL_STOP*/ } ret = getgrnam_r(name.c_str(), g, buf, bufLen, &grpRes); if (grpRes == NULL) { + /*LCOV_EXCL_START*/ if (ret == 0) DSLOG_WRN("DSUtilSocket", "Group not found"); else DSLOG_WRN("DSUtilSocket", "errno returned by getpwnam_r is %d", ret); free(buf); free(g); return 0; + /*LCOV_EXCL_STOP*/ } ret = g->gr_gid; -- 2.7.4 From 4a656fc5877758632f206d34eb27517cdcbcfce9 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 8 Sep 2020 11:49:05 +0900 Subject: [PATCH 02/16] DSWaylandServer: define LCOV_EXCL blocks for event handling logics from client Change-Id: I9de1b0722e2acdfe3660a7adb68567e5243f5b9b Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandCallback.cpp | 2 ++ src/DSWaylandServer/DSWaylandPointer.cpp | 14 ++------------ src/DSWaylandServer/DSWaylandTextInput.cpp | 2 ++ src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h | 2 ++ src/DSWaylandServer/DSWaylandTizenAppinfo.cpp | 4 ++-- .../DSWaylandTizenInputDeviceManagerPrivate.h | 2 ++ 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandCallback.cpp b/src/DSWaylandServer/DSWaylandCallback.cpp index 3e4ae9a..04a6047 100644 --- a/src/DSWaylandServer/DSWaylandCallback.cpp +++ b/src/DSWaylandServer/DSWaylandCallback.cpp @@ -27,6 +27,7 @@ namespace display_server { +/*LCOV_EXCL_START*/ DSWaylandCallbackPrivate::DSWaylandCallbackPrivate(DSWaylandCallback *p_ptr) : DSObjectPrivate(p_ptr) { @@ -52,5 +53,6 @@ DSWaylandCallback::DSWaylandCallback() DSWaylandCallback::~DSWaylandCallback() { } +/*LCOV_EXCL_STOP*/ } /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandPointer.cpp b/src/DSWaylandServer/DSWaylandPointer.cpp index 3ed7813..e856c64 100644 --- a/src/DSWaylandServer/DSWaylandPointer.cpp +++ b/src/DSWaylandServer/DSWaylandPointer.cpp @@ -51,14 +51,6 @@ void DSWaylandPointerPrivate::setFocus(DSWaylandSurface *waylandSurface) { DSLOG_INF("DSWaylandPointerPrivate", "pointer focus changed (%p -> %p)", __waylandSurface, waylandSurface); -#if 0 - if (__waylandSurface) - { - DSLOG_INF("DSWaylandPointerPrivate", "send leave to %p", __waylandSurface); - send_leave(__wlPointerResource, __waylandSurface->getWlResource()); - } -#endif - __waylandSurface = waylandSurface; if (!waylandSurface || !waylandSurface->hasResource()) @@ -68,6 +60,7 @@ void DSWaylandPointerPrivate::setFocus(DSWaylandSurface *waylandSurface) return; } + /*LCOV_EXCL_START*/ struct ::wl_resource *surface = waylandSurface->getWlResource(); auto client = wl_resource_get_client(surface); @@ -90,10 +83,7 @@ void DSWaylandPointerPrivate::setFocus(DSWaylandSurface *waylandSurface) DSLOG_INF("DSWaylandPointerPrivate", "no wlPointerResource available"); return; } -#if 0 - DSLOG_INF("DSWaylandPointerPrivate", "send enter to %p", __waylandSurface); - sendEnter(__wlPointerResource, __waylandSurface->getWlResource(), surface_x, surface_y); -#endif + /*LCOV_EXCL_STOP*/ } DSWaylandSurface *DSWaylandPointerPrivate::getFocus() diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index 820e8ba..d365121 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -29,6 +29,7 @@ namespace display_server { +/*LCOV_EXCL_START*/ DSWaylandTextInputManagerPrivate::DSWaylandTextInputManagerPrivate(DSWaylandTextInputManager *p_ptr, DSWaylandCompositor *compositor) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), @@ -1120,5 +1121,6 @@ DSWaylandSurface* DSWaylandTextInput::getClientSurface() return priv->__clientSurface; } +/*LCOV_EXCL_STOP*/ } diff --git a/src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h b/src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h index dfa815c..fa5d557 100644 --- a/src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h @@ -33,6 +33,7 @@ namespace display_server { +/*LCOV_EXCL_START*/ class DS_DECL_EXPORT DSWaylandTextInputManagerPrivate : public DSObjectPrivate, public DSWaylandServer::wl_text_input_manager { DS_PIMPL_USE_PUBLIC(DSWaylandTextInputManager); @@ -46,6 +47,7 @@ protected: private: DSWaylandCompositor *__compositor; }; +/*LCOV_EXCL_STOP*/ } diff --git a/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp b/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp index 852db56..8bfbd02 100644 --- a/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp +++ b/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp @@ -59,11 +59,11 @@ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_destroy_resource(Resourc { DSLOG_DBG("TizenAppinfoPriv", ""); } +/*LCOV_EXCL_START*/ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_destroy(Resource *resource) { DSLOG_DBG("TizenAppinfoPriv", ""); } -/*LCOV_EXCL_START*/ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_register_pid(Resource *resource, uint32_t pid) { DSLOG_DBG("TizenAppinfoPriv", ""); @@ -76,7 +76,6 @@ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_set_appid(Resource *reso { DSLOG_DBG("TizenAppinfoPriv", ""); } -/*LCOV_EXCL_STOP*/ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_get_base_output_resolution(Resource *resource, uint32_t pid) { @@ -122,6 +121,7 @@ void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_ready_metadata(Resource { DSLOG_DBG("TizenAppinfoPriv", ""); } +/*LCOV_EXCL_STOP*/ DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor) : DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo), diff --git a/src/DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h b/src/DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h index 3850af7..7c5eeb8 100644 --- a/src/DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h +++ b/src/DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h @@ -31,6 +31,7 @@ namespace display_server { +/*LCOV_EXCL_START*/ class DSWaylandTizenInputDeviceManagerPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_input_device_manager { DS_PIMPL_USE_PUBLIC(DSWaylandTizenInputDeviceManager); @@ -61,6 +62,7 @@ protected: private: struct ::wl_display *__display; }; +/*LCOV_EXCL_STOP*/ } -- 2.7.4 From 53cec53f1ab4b74ce91c1f244c72e73a4ff3f14e Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Thu, 12 Nov 2020 11:17:46 +0900 Subject: [PATCH 03/16] dswayland-server: add new interface of input-method Change-Id: Icbfd28f6b77e54930524a1a467e09b4738525493 Signed-off-by: Junseok, Kim --- .../dswayland-server-input-method.cpp | 186 ++++++++++++++++++++- .../dswayland-server-input-method.h | 87 +++++++++- 2 files changed, 267 insertions(+), 6 deletions(-) diff --git a/src/DSWaylandServer/dswayland-server-input-method.cpp b/src/DSWaylandServer/dswayland-server-input-method.cpp index 34fb3e6..b9c41ac 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.cpp +++ b/src/DSWaylandServer/dswayland-server-input-method.cpp @@ -1330,7 +1330,7 @@ namespace DSWaylandServer { } - void wl_input_method::send_show_input_panel(struct ::wl_resource *context) + void wl_input_method::send_show_input_panel(struct ::wl_resource *context, uint32_t degree) { DS_ASSERT_X(m_resource, "wl_input_method::show_input_panel", "Uninitialised resource"); if (DS_UNLIKELY(!m_resource)) { @@ -1339,14 +1339,16 @@ namespace DSWaylandServer { } send_show_input_panel( m_resource->handle, - context); + context, + degree); } - void wl_input_method::send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context) + void wl_input_method::send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t degree) { wl_input_method_send_show_input_panel( resource, - context); + context, + degree); } @@ -1787,6 +1789,182 @@ namespace DSWaylandServer { r, enabled); } + + wl_input_method_manager::wl_input_method_manager(struct ::wl_client *client, uint32_t id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(client, id, version); + } + + wl_input_method_manager::wl_input_method_manager(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(display, version); + } + + wl_input_method_manager::wl_input_method_manager(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(resource); + } + + wl_input_method_manager::wl_input_method_manager() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + } + + wl_input_method_manager::~wl_input_method_manager() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + wl_input_method_manager::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void wl_input_method_manager::init(struct ::wl_client *client, uint32_t id, int version) + { + m_resource = bind(client, id, version); + } + + void wl_input_method_manager::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + wl_input_method_manager::Resource *wl_input_method_manager::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + wl_input_method_manager::Resource *wl_input_method_manager::add(struct ::wl_client *client, uint32_t id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void wl_input_method_manager::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::wl_input_method_manager_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = wl_input_method_manager::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *wl_input_method_manager::interface() + { + return &::wl_input_method_manager_interface; + } + + wl_input_method_manager::Resource *wl_input_method_manager::input_method_manager_allocate() + { + return new Resource; + } + + void wl_input_method_manager::input_method_manager_bind_resource(Resource *) + { + } + + void wl_input_method_manager::input_method_manager_destroy_resource(Resource *) + { + } + + void wl_input_method_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + wl_input_method_manager *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void wl_input_method_manager::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + wl_input_method_manager *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void wl_input_method_manager::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + wl_input_method_manager *that = resource->input_method_manager_object; + that->m_resource_map.erase(resource->client()); + that->input_method_manager_destroy_resource(resource); + delete resource; + } + + wl_input_method_manager::Resource *wl_input_method_manager::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_method_manager_interface, version, id); + return bind(handle); + } + + wl_input_method_manager::Resource *wl_input_method_manager::bind(struct ::wl_resource *handle) + { + Resource *resource = input_method_manager_allocate(); + resource->input_method_manager_object = this; + + wl_resource_set_implementation(handle, &m_wl_input_method_manager_interface, resource, destroy_func); + resource->handle = handle; + input_method_manager_bind_resource(resource); + return resource; + } + wl_input_method_manager::Resource *wl_input_method_manager::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::wl_input_method_manager_interface, &m_wl_input_method_manager_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::wl_input_method_manager_interface wl_input_method_manager::m_wl_input_method_manager_interface = { + wl_input_method_manager::handle_set_transient_for + }; + + void wl_input_method_manager::input_method_manager_set_transient_for(Resource *, uint32_t , uint32_t ) + { + } + + + void wl_input_method_manager::handle_set_transient_for( + ::wl_client *client, + struct wl_resource *resource, + uint32_t parent_pid, + uint32_t child_pid) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->input_method_manager_object)->input_method_manager_set_transient_for( + r, + parent_pid, + child_pid); + } } /*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-input-method.h b/src/DSWaylandServer/dswayland-server-input-method.h index 56c6844..0f9a071 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.h +++ b/src/DSWaylandServer/dswayland-server-input-method.h @@ -364,8 +364,8 @@ namespace DSWaylandServer { void send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t focus_out_event); void send_destroy(struct ::wl_resource *context); void send_destroy(struct ::wl_resource *resource, struct ::wl_resource *context); - void send_show_input_panel(struct ::wl_resource *context); - void send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context); + void send_show_input_panel(struct ::wl_resource *context, uint32_t degree); + void send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t degree); void send_hide_input_panel(struct ::wl_resource *context); void send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context); @@ -582,6 +582,89 @@ namespace DSWaylandServer { }; DisplayDestroyedListener m_displayDestroyedListener; }; + + class wl_input_method_manager + { + public: + wl_input_method_manager(struct ::wl_client *client, uint32_t id, int version); + wl_input_method_manager(struct ::wl_display *display, int version); + wl_input_method_manager(struct ::wl_resource *resource); + wl_input_method_manager(); + + virtual ~wl_input_method_manager(); + + class Resource + { + public: + Resource() : input_method_manager_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + wl_input_method_manager *input_method_manager_object; + wl_input_method_manager *object() { return input_method_manager_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, uint32_t id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, uint32_t id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + protected: + virtual Resource *input_method_manager_allocate(); + + virtual void input_method_manager_bind_resource(Resource *resource); + virtual void input_method_manager_destroy_resource(Resource *resource); + + virtual void input_method_manager_set_transient_for(Resource *resource, uint32_t parent_pid, uint32_t child_pid); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::wl_input_method_manager_interface m_wl_input_method_manager_interface; + + static void handle_set_transient_for( + ::wl_client *client, + struct wl_resource *resource, + uint32_t parent_pid, + uint32_t child_pid); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + wl_input_method_manager *parent; + DisplayDestroyedListener(): parent(NULL) {} + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; } #endif -- 2.7.4 From 43997178b8f8aa534be43bb73bafe8cd5c20c48f Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Thu, 12 Nov 2020 14:39:05 +0900 Subject: [PATCH 04/16] DSWaylandInputMethod: added temporary rotation degree Change-Id: I755e509a8515f2ab837798521b227af247b6178a Signed-off-by: Junseok, Kim --- src/DSWaylandServer/DSWaylandInputMethod.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp index 4001547..ad50352 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -549,7 +549,8 @@ void DSWaylandInputMethodPrivate::sendDeactivate(void *contextResource, bool foc void DSWaylandInputMethodPrivate::showInputPanel(void *contextResource, int textInputId) { //Resource *resource = getResource(textInputId); - send_show_input_panel(__resource->handle, (struct ::wl_resource *)contextResource); + //FIXME: please, replace with current client's rotation degree + send_show_input_panel(__resource->handle, (struct ::wl_resource *)contextResource, 0); } void DSWaylandInputMethodPrivate::hideInputPanel(void *contextResource, int textInputId) -- 2.7.4 From d12a1eeb8310f802528e93ae57eb19d3382567e9 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Thu, 25 Mar 2021 14:25:29 +0900 Subject: [PATCH 05/16] dswayland-server: update latest wayland protocols update following wayland protocols - wayland - tizen-extension - input-method - tzsh Change-Id: I3f605811dbbe73e2c9122440fb4c9f79e9437c88 Signed-off-by: Junseok, Kim --- .../dswayland-server-input-method.cpp | 72 ++-- .../dswayland-server-input-method.h | 20 +- .../dswayland-server-tizen-extension.cpp | 478 ++++++++++++++++++++- .../dswayland-server-tizen-extension.h | 189 ++++++++ src/DSWaylandServer/dswayland-server-tzsh.cpp | 247 +---------- src/DSWaylandServer/dswayland-server-tzsh.h | 116 +---- src/DSWaylandServer/dswayland-server-wayland.h | 5 + 7 files changed, 744 insertions(+), 383 deletions(-) diff --git a/src/DSWaylandServer/dswayland-server-input-method.cpp b/src/DSWaylandServer/dswayland-server-input-method.cpp index b9c41ac..005ffd1 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.cpp +++ b/src/DSWaylandServer/dswayland-server-input-method.cpp @@ -207,7 +207,9 @@ namespace DSWaylandServer { wl_input_method_context::handle_input_panel_event, wl_input_method_context::handle_commit_content, wl_input_method_context::handle_update_candidate_state, - wl_input_method_context::handle_reshow_input_panel + wl_input_method_context::handle_reshow_input_panel, + wl_input_method_context::handle_set_floating_panel, + wl_input_method_context::handle_set_floating_drag_enabled }; void wl_input_method_context::input_method_context_destroy(Resource *) @@ -318,6 +320,14 @@ namespace DSWaylandServer { { } + void wl_input_method_context::input_method_context_set_floating_panel(Resource *, uint32_t ) + { + } + + void wl_input_method_context::input_method_context_set_floating_drag_enabled(Resource *, uint32_t ) + { + } + void wl_input_method_context::handle_destroy( ::wl_client *client, @@ -723,6 +733,30 @@ namespace DSWaylandServer { r); } + void wl_input_method_context::handle_set_floating_panel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t state) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->input_method_context_object)->input_method_context_set_floating_panel( + r, + state); + } + + void wl_input_method_context::handle_set_floating_drag_enabled( + ::wl_client *client, + struct wl_resource *resource, + uint32_t enabled) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->input_method_context_object)->input_method_context_set_floating_drag_enabled( + r, + enabled); + } + void wl_input_method_context::send_reset() { DS_ASSERT_X(m_resource, "wl_input_method_context::reset", "Uninitialised resource"); @@ -1704,9 +1738,7 @@ namespace DSWaylandServer { const struct ::wl_input_panel_surface_interface wl_input_panel_surface::m_wl_input_panel_surface_interface = { wl_input_panel_surface::handle_set_toplevel, wl_input_panel_surface::handle_set_overlay_panel, - wl_input_panel_surface::handle_set_ready, - wl_input_panel_surface::handle_set_floating_panel, - wl_input_panel_surface::handle_set_floating_drag_enabled + wl_input_panel_surface::handle_set_ready }; void wl_input_panel_surface::input_panel_surface_set_toplevel(Resource *, struct ::wl_resource *, uint32_t ) @@ -1721,14 +1753,6 @@ namespace DSWaylandServer { { } - void wl_input_panel_surface::input_panel_surface_set_floating_panel(Resource *, uint32_t ) - { - } - - void wl_input_panel_surface::input_panel_surface_set_floating_drag_enabled(Resource *, uint32_t ) - { - } - void wl_input_panel_surface::handle_set_toplevel( ::wl_client *client, @@ -1766,30 +1790,6 @@ namespace DSWaylandServer { state); } - void wl_input_panel_surface::handle_set_floating_panel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_panel_surface_object)->input_panel_surface_set_floating_panel( - r, - state); - } - - void wl_input_panel_surface::handle_set_floating_drag_enabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t enabled) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_panel_surface_object)->input_panel_surface_set_floating_drag_enabled( - r, - enabled); - } - wl_input_method_manager::wl_input_method_manager(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) diff --git a/src/DSWaylandServer/dswayland-server-input-method.h b/src/DSWaylandServer/dswayland-server-input-method.h index 0f9a071..03c49a7 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.h +++ b/src/DSWaylandServer/dswayland-server-input-method.h @@ -139,6 +139,8 @@ namespace DSWaylandServer { virtual void input_method_context_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types); virtual void input_method_context_update_candidate_state(Resource *resource, uint32_t state); virtual void input_method_context_reshow_input_panel(Resource *resource); + virtual void input_method_context_set_floating_panel(Resource *resource, uint32_t state); + virtual void input_method_context_set_floating_drag_enabled(Resource *resource, uint32_t enabled); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -298,6 +300,14 @@ namespace DSWaylandServer { static void handle_reshow_input_panel( ::wl_client *client, struct wl_resource *resource); + static void handle_set_floating_panel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t state); + static void handle_set_floating_drag_enabled( + ::wl_client *client, + struct wl_resource *resource, + uint32_t enabled); std::multimap m_resource_map; Resource *m_resource; @@ -538,8 +548,6 @@ namespace DSWaylandServer { virtual void input_panel_surface_set_toplevel(Resource *resource, struct ::wl_resource *output, uint32_t position); virtual void input_panel_surface_set_overlay_panel(Resource *resource); virtual void input_panel_surface_set_ready(Resource *resource, uint32_t state); - virtual void input_panel_surface_set_floating_panel(Resource *resource, uint32_t state); - virtual void input_panel_surface_set_floating_drag_enabled(Resource *resource, uint32_t enabled); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -563,14 +571,6 @@ namespace DSWaylandServer { ::wl_client *client, struct wl_resource *resource, uint32_t state); - static void handle_set_floating_panel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state); - static void handle_set_floating_drag_enabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t enabled); std::multimap m_resource_map; Resource *m_resource; diff --git a/src/DSWaylandServer/dswayland-server-tizen-extension.cpp b/src/DSWaylandServer/dswayland-server-tizen-extension.cpp index 15a014c..3236c91 100644 --- a/src/DSWaylandServer/dswayland-server-tizen-extension.cpp +++ b/src/DSWaylandServer/dswayland-server-tizen-extension.cpp @@ -603,7 +603,9 @@ namespace DSWaylandServer { tizen_policy::handle_ack_conformant_region, tizen_policy::handle_destroy, tizen_policy::handle_has_video, - tizen_policy::handle_set_appid + tizen_policy::handle_set_appid, + tizen_policy::handle_show, + tizen_policy::handle_hide }; void tizen_policy::tizen_policy_get_visibility(Resource *, uint32_t, struct ::wl_resource *) @@ -766,6 +768,14 @@ namespace DSWaylandServer { { } + void tizen_policy::tizen_policy_show(Resource *, struct ::wl_resource *) + { + } + + void tizen_policy::tizen_policy_hide(Resource *, struct ::wl_resource *) + { + } + void tizen_policy::handle_get_visibility( ::wl_client *client, @@ -1293,6 +1303,30 @@ namespace DSWaylandServer { std::string(appid)); } + void tizen_policy::handle_show( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_policy_object)->tizen_policy_show( + r, + surface); + } + + void tizen_policy::handle_hide( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_policy_object)->tizen_policy_hide( + r, + surface); + } + void tizen_policy::send_conformant(struct ::wl_resource *surface, uint32_t is_conformant) { DS_ASSERT_X(m_resource, "tizen_policy::conformant", "Uninitialised resource"); @@ -1971,6 +2005,7 @@ namespace DSWaylandServer { y); } + tizen_move_resize::tizen_move_resize(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -2201,6 +2236,7 @@ namespace DSWaylandServer { error_state); } + tizen_gesture::tizen_gesture(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -2839,6 +2875,7 @@ namespace DSWaylandServer { error); } + tizen_keyrouter::tizen_keyrouter(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -3357,6 +3394,7 @@ namespace DSWaylandServer { mode); } + tizen_screenshooter::tizen_screenshooter(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -3604,6 +3642,7 @@ namespace DSWaylandServer { noti); } + tizen_screenmirror::tizen_screenmirror(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -3914,6 +3953,7 @@ namespace DSWaylandServer { resource); } + tizen_video::tizen_video(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -4143,6 +4183,7 @@ namespace DSWaylandServer { format); } + tizen_video_object::tizen_video_object(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -4443,6 +4484,7 @@ namespace DSWaylandServer { prefer_align); } + tizen_subsurface_watcher::tizen_subsurface_watcher(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -4634,6 +4676,7 @@ namespace DSWaylandServer { value); } + tizen_viewport::tizen_viewport(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -5003,6 +5046,7 @@ namespace DSWaylandServer { height); } + tizen_destination_mode::tizen_destination_mode(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -5508,6 +5552,7 @@ namespace DSWaylandServer { sock_fd); } + tizen_input_device_manager::tizen_input_device_manager(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -5672,7 +5717,8 @@ namespace DSWaylandServer { tizen_input_device_manager::handle_pointer_warp, tizen_input_device_manager::handle_init_generator_with_name, tizen_input_device_manager::handle_destroy, - tizen_input_device_manager::handle_generate_axis + tizen_input_device_manager::handle_generate_axis, + tizen_input_device_manager::handle_set_touch_count }; void tizen_input_device_manager::tizen_input_device_manager_block_events(Resource *, uint32_t , uint32_t , uint32_t ) @@ -5719,6 +5765,11 @@ namespace DSWaylandServer { { } + void tizen_input_device_manager::tizen_input_device_manager_set_touch_count(Resource *, int32_t ) + { + } + + void tizen_input_device_manager::handle_block_events( ::wl_client *client, struct wl_resource *resource, @@ -5875,6 +5926,18 @@ namespace DSWaylandServer { value); } + void tizen_input_device_manager::handle_set_touch_count( + ::wl_client *client, + struct wl_resource *resource, + int32_t max_count) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_set_touch_count( + r, + max_count); + } + void tizen_input_device_manager::send_device_add(uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat) { DS_ASSERT_X(m_resource, "tizen_input_device_manager::device_add", "Uninitialised resource"); @@ -5964,6 +6027,31 @@ namespace DSWaylandServer { resource); } + + void tizen_input_device_manager::send_max_touch_count(uint32_t serial, int32_t max_count, struct ::wl_resource *seat) + { + DS_ASSERT_X(m_resource, "tizen_input_device_manager::max_touch_count", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_input_device_manager::max_touch_count as it's not initialised"); + return; + } + send_max_touch_count( + m_resource->handle, + serial, + max_count, + seat); + } + + void tizen_input_device_manager::send_max_touch_count(struct ::wl_resource *resource, uint32_t serial, int32_t max_count, struct ::wl_resource *seat) + { + tizen_input_device_manager_send_max_touch_count( + resource, + serial, + max_count, + seat); + } + + tizen_input_device::tizen_input_device(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -6224,6 +6312,7 @@ namespace DSWaylandServer { value); } + tizen_launchscreen::tizen_launchscreen(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -6874,6 +6963,7 @@ namespace DSWaylandServer { type); } + tizen_display_policy::tizen_display_policy(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -7088,6 +7178,7 @@ namespace DSWaylandServer { error_state); } + tizen_indicator::tizen_indicator(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -7338,6 +7429,7 @@ namespace DSWaylandServer { type); } + tizen_clipboard::tizen_clipboard(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -7600,6 +7692,7 @@ namespace DSWaylandServer { allowed); } + tizen_screen_rotation::tizen_screen_rotation(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -7810,5 +7903,386 @@ namespace DSWaylandServer { ignore); } + + tizen_renderer::tizen_renderer(struct ::wl_client *client, uint32_t id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(client, id, version); + } + + tizen_renderer::tizen_renderer(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(display, version); + } + + tizen_renderer::tizen_renderer(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(resource); + } + + tizen_renderer::tizen_renderer() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + } + + tizen_renderer::~tizen_renderer() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tizen_renderer::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tizen_renderer::init(struct ::wl_client *client, uint32_t id, int version) + { + m_resource = bind(client, id, version); + } + + void tizen_renderer::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tizen_renderer::Resource *tizen_renderer::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tizen_renderer::Resource *tizen_renderer::add(struct ::wl_client *client, uint32_t id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tizen_renderer::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tizen_renderer_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tizen_renderer::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tizen_renderer::interface() + { + return &::tizen_renderer_interface; + } + + tizen_renderer::Resource *tizen_renderer::tizen_renderer_allocate() + { + return new Resource; + } + + void tizen_renderer::tizen_renderer_bind_resource(Resource *) + { + } + + void tizen_renderer::tizen_renderer_destroy_resource(Resource *) + { + } + + void tizen_renderer::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tizen_renderer *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tizen_renderer::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tizen_renderer *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tizen_renderer::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tizen_renderer *that = resource->tizen_renderer_object; + that->m_resource_map.erase(resource->client()); + that->tizen_renderer_destroy_resource(resource); + delete resource; + } + + tizen_renderer::Resource *tizen_renderer::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tizen_renderer_interface, version, id); + return bind(handle); + } + + tizen_renderer::Resource *tizen_renderer::bind(struct ::wl_resource *handle) + { + Resource *resource = tizen_renderer_allocate(); + resource->tizen_renderer_object = this; + + wl_resource_set_implementation(handle, &m_tizen_renderer_interface, resource, destroy_func); + resource->handle = handle; + tizen_renderer_bind_resource(resource); + return resource; + } + tizen_renderer::Resource *tizen_renderer::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tizen_renderer_interface, &m_tizen_renderer_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tizen_renderer_interface tizen_renderer::m_tizen_renderer_interface = { + tizen_renderer::handle_get_renderer_surface, + tizen_renderer::handle_destroy + }; + + void tizen_renderer::tizen_renderer_get_renderer_surface(Resource *, uint32_t, struct ::wl_resource *) + { + } + + void tizen_renderer::tizen_renderer_destroy(Resource *) + { + } + + + void tizen_renderer::handle_get_renderer_surface( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_renderer_object)->tizen_renderer_get_renderer_surface( + r, + id, + surface); + } + + void tizen_renderer::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_renderer_object)->tizen_renderer_destroy( + r); + } + + tizen_renderer_surface::tizen_renderer_surface(struct ::wl_client *client, uint32_t id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(client, id, version); + } + + tizen_renderer_surface::tizen_renderer_surface(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(display, version); + } + + tizen_renderer_surface::tizen_renderer_surface(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(resource); + } + + tizen_renderer_surface::tizen_renderer_surface() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + } + + tizen_renderer_surface::~tizen_renderer_surface() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + tizen_renderer_surface::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void tizen_renderer_surface::init(struct ::wl_client *client, uint32_t id, int version) + { + m_resource = bind(client, id, version); + } + + void tizen_renderer_surface::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + tizen_renderer_surface::Resource *tizen_renderer_surface::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + tizen_renderer_surface::Resource *tizen_renderer_surface::add(struct ::wl_client *client, uint32_t id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void tizen_renderer_surface::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::tizen_renderer_surface_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = tizen_renderer_surface::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *tizen_renderer_surface::interface() + { + return &::tizen_renderer_surface_interface; + } + + tizen_renderer_surface::Resource *tizen_renderer_surface::tizen_renderer_surface_allocate() + { + return new Resource; + } + + void tizen_renderer_surface::tizen_renderer_surface_bind_resource(Resource *) + { + } + + void tizen_renderer_surface::tizen_renderer_surface_destroy_resource(Resource *) + { + } + + void tizen_renderer_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + tizen_renderer_surface *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void tizen_renderer_surface::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + tizen_renderer_surface *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void tizen_renderer_surface::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + tizen_renderer_surface *that = resource->tizen_renderer_surface_object; + that->m_resource_map.erase(resource->client()); + that->tizen_renderer_surface_destroy_resource(resource); + delete resource; + } + + tizen_renderer_surface::Resource *tizen_renderer_surface::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::tizen_renderer_surface_interface, version, id); + return bind(handle); + } + + tizen_renderer_surface::Resource *tizen_renderer_surface::bind(struct ::wl_resource *handle) + { + Resource *resource = tizen_renderer_surface_allocate(); + resource->tizen_renderer_surface_object = this; + + wl_resource_set_implementation(handle, &m_tizen_renderer_surface_interface, resource, destroy_func); + resource->handle = handle; + tizen_renderer_surface_bind_resource(resource); + return resource; + } + tizen_renderer_surface::Resource *tizen_renderer_surface::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::tizen_renderer_surface_interface, &m_tizen_renderer_surface_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::tizen_renderer_surface_interface tizen_renderer_surface::m_tizen_renderer_surface_interface = { + tizen_renderer_surface::handle_destroy + }; + + void tizen_renderer_surface::tizen_renderer_surface_destroy(Resource *) + { + } + + + void tizen_renderer_surface::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_renderer_surface_object)->tizen_renderer_surface_destroy( + r); + } + + void tizen_renderer_surface::send_redraw_request() + { + DS_ASSERT_X(m_resource, "tizen_renderer_surface::redraw_request", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_renderer_surface::redraw_request as it's not initialised"); + return; + } + send_redraw_request( + m_resource->handle); + } + + void tizen_renderer_surface::send_redraw_request(struct ::wl_resource *resource) + { + tizen_renderer_surface_send_redraw_request( + resource); + } + } /*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-extension.h b/src/DSWaylandServer/dswayland-server-tizen-extension.h index cdc2b1f..26b8301 100644 --- a/src/DSWaylandServer/dswayland-server-tizen-extension.h +++ b/src/DSWaylandServer/dswayland-server-tizen-extension.h @@ -356,6 +356,8 @@ namespace DSWaylandServer { virtual void tizen_policy_destroy(Resource *resource); virtual void tizen_policy_has_video(Resource *resource, struct ::wl_resource *surface, uint32_t has); virtual void tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid); + virtual void tizen_policy_show(Resource *resource, struct ::wl_resource *surface); + virtual void tizen_policy_hide(Resource *resource, struct ::wl_resource *surface); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -550,6 +552,14 @@ namespace DSWaylandServer { struct wl_resource *resource, int32_t pid, const char *appid); + static void handle_show( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *surface); + static void handle_hide( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *surface); std::multimap m_resource_map; Resource *m_resource; @@ -2172,6 +2182,7 @@ namespace DSWaylandServer { error_invalid_parameter = 5, // argument is invalid error_invalid_surface = 6, // the given surface is not visible or pointer is not on the given surface error_no_pointer_available = 7, // there is no pointer available to warp + error_not_allowed = 8, // this request is not allowed in this system }; enum pointer_event_type { @@ -2199,6 +2210,8 @@ namespace DSWaylandServer { void send_error(struct ::wl_resource *resource, uint32_t errorcode); void send_block_expired(); void send_block_expired(struct ::wl_resource *resource); + void send_max_touch_count(uint32_t serial, int32_t max_count, struct ::wl_resource *seat); + void send_max_touch_count(struct ::wl_resource *resource, uint32_t serial, int32_t max_count, struct ::wl_resource *seat); protected: virtual Resource *tizen_input_device_manager_allocate(); @@ -2217,6 +2230,7 @@ namespace DSWaylandServer { virtual void tizen_input_device_manager_init_generator_with_name(Resource *resource, uint32_t clas, const std::string &name); virtual void tizen_input_device_manager_destroy(Resource *resource); virtual void tizen_input_device_manager_generate_axis(Resource *resource, uint32_t type, wl_fixed_t value); + virtual void tizen_input_device_manager_set_touch_count(Resource *resource, int32_t max_count); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -2284,6 +2298,10 @@ namespace DSWaylandServer { struct wl_resource *resource, uint32_t type, wl_fixed_t value); + static void handle_set_touch_count( + ::wl_client *client, + struct wl_resource *resource, + int32_t max_count); std::multimap m_resource_map; Resource *m_resource; @@ -3114,6 +3132,177 @@ namespace DSWaylandServer { }; DisplayDestroyedListener m_displayDestroyedListener; }; + + class tizen_renderer + { + public: + tizen_renderer(struct ::wl_client *client, uint32_t id, int version); + tizen_renderer(struct ::wl_display *display, int version); + tizen_renderer(struct ::wl_resource *resource); + tizen_renderer(); + + virtual ~tizen_renderer(); + + class Resource + { + public: + Resource() : tizen_renderer_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tizen_renderer *tizen_renderer_object; + tizen_renderer *object() { return tizen_renderer_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, uint32_t id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, uint32_t id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + protected: + virtual Resource *tizen_renderer_allocate(); + + virtual void tizen_renderer_bind_resource(Resource *resource); + virtual void tizen_renderer_destroy_resource(Resource *resource); + + virtual void tizen_renderer_get_renderer_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); + virtual void tizen_renderer_destroy(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tizen_renderer_interface m_tizen_renderer_interface; + + static void handle_get_renderer_surface( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface); + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tizen_renderer *parent; + DisplayDestroyedListener(): parent(NULL) {} + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; + + class tizen_renderer_surface + { + public: + tizen_renderer_surface(struct ::wl_client *client, uint32_t id, int version); + tizen_renderer_surface(struct ::wl_display *display, int version); + tizen_renderer_surface(struct ::wl_resource *resource); + tizen_renderer_surface(); + + virtual ~tizen_renderer_surface(); + + class Resource + { + public: + Resource() : tizen_renderer_surface_object(NULL), handle(NULL) {} + virtual ~Resource() {} + + tizen_renderer_surface *tizen_renderer_surface_object; + tizen_renderer_surface *object() { return tizen_renderer_surface_object; } + struct ::wl_resource *handle; + + struct ::wl_client *client() const { return wl_resource_get_client(handle); } + int version() const { return wl_resource_get_version(handle); } + + static Resource *fromResource(struct ::wl_resource *resource); + }; + + void init(struct ::wl_client *client, uint32_t id, int version); + void init(struct ::wl_display *display, int version); + void init(struct ::wl_resource *resource); + + Resource *add(struct ::wl_client *client, int version); + Resource *add(struct ::wl_client *client, uint32_t id, int version); + Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); + + Resource *resource() { return m_resource; } + const Resource *resource() const { return m_resource; } + + std::multimap resourceMap() { return m_resource_map; } + const std::multimap resourceMap() const { return m_resource_map; } + + bool isGlobal() const { return m_global != NULL; } + bool isResource() const { return m_resource != NULL; } + + static const struct ::wl_interface *interface(); + static std::string interfaceName() { return interface()->name; } + static int interfaceVersion() { return interface()->version; } + + + void send_redraw_request(); + void send_redraw_request(struct ::wl_resource *resource); + + protected: + virtual Resource *tizen_renderer_surface_allocate(); + + virtual void tizen_renderer_surface_bind_resource(Resource *resource); + virtual void tizen_renderer_surface_destroy_resource(Resource *resource); + + virtual void tizen_renderer_surface_destroy(Resource *resource); + + private: + static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); + static void destroy_func(struct ::wl_resource *client_resource); + static void display_destroy_func(struct ::wl_listener *listener, void *data); + + Resource *bind(struct ::wl_client *client, uint32_t id, int version); + Resource *bind(struct ::wl_resource *handle); + + static const struct ::tizen_renderer_surface_interface m_tizen_renderer_surface_interface; + + static void handle_destroy( + ::wl_client *client, + struct wl_resource *resource); + + std::multimap m_resource_map; + Resource *m_resource; + struct ::wl_global *m_global; + uint32_t m_globalVersion; + struct DisplayDestroyedListener : ::wl_listener { + tizen_renderer_surface *parent; + DisplayDestroyedListener(): parent(NULL) {} + }; + DisplayDestroyedListener m_displayDestroyedListener; + }; } /*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tzsh.cpp b/src/DSWaylandServer/dswayland-server-tzsh.cpp index ae8c2a1..d6b1d66 100644 --- a/src/DSWaylandServer/dswayland-server-tzsh.cpp +++ b/src/DSWaylandServer/dswayland-server-tzsh.cpp @@ -185,7 +185,6 @@ namespace DSWaylandServer { tizen_ws_shell::handle_service_create, tizen_ws_shell::handle_region_create, tizen_ws_shell::handle_quickpanel_get, - tizen_ws_shell::handle_tvsrv_get, tizen_ws_shell::handle_extension_get, tizen_ws_shell::handle_softkey_get, tizen_ws_shell::handle_shared_widget_launch_get @@ -207,10 +206,6 @@ namespace DSWaylandServer { { } - void tizen_ws_shell::tizen_ws_shell_tvsrv_get(Resource *, uint32_t, uint32_t ) - { - } - void tizen_ws_shell::tizen_ws_shell_extension_get(Resource *, uint32_t, const std::string &) { } @@ -276,20 +271,6 @@ namespace DSWaylandServer { win); } - void tizen_ws_shell::handle_tvsrv_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_tvsrv_get( - r, - id, - win); - } - void tizen_ws_shell::handle_extension_get( ::wl_client *client, struct wl_resource *resource, @@ -719,208 +700,6 @@ namespace DSWaylandServer { } - tws_tvsrv::tws_tvsrv(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_tvsrv::tws_tvsrv(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_tvsrv::tws_tvsrv(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_tvsrv::tws_tvsrv() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_tvsrv::~tws_tvsrv() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_tvsrv::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_tvsrv::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_tvsrv::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_tvsrv::Resource *tws_tvsrv::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_tvsrv::Resource *tws_tvsrv::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_tvsrv::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_tvsrv_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_tvsrv::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_tvsrv::interface() - { - return &::tws_tvsrv_interface; - } - - tws_tvsrv::Resource *tws_tvsrv::tws_tvsrv_allocate() - { - return new Resource; - } - - void tws_tvsrv::tws_tvsrv_bind_resource(Resource *) - { - } - - void tws_tvsrv::tws_tvsrv_destroy_resource(Resource *) - { - } - - void tws_tvsrv::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_tvsrv *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_tvsrv::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_tvsrv *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_tvsrv::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_tvsrv *that = resource->tws_tvsrv_object; - that->m_resource_map.erase(resource->client()); - that->tws_tvsrv_destroy_resource(resource); - delete resource; - } - - tws_tvsrv::Resource *tws_tvsrv::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_tvsrv_interface, version, id); - return bind(handle); - } - - tws_tvsrv::Resource *tws_tvsrv::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_tvsrv_allocate(); - resource->tws_tvsrv_object = this; - - wl_resource_set_implementation(handle, &m_tws_tvsrv_interface, resource, destroy_func); - resource->handle = handle; - tws_tvsrv_bind_resource(resource); - return resource; - } - tws_tvsrv::Resource *tws_tvsrv::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_tvsrv_interface, &m_tws_tvsrv_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_tvsrv_interface tws_tvsrv::m_tws_tvsrv_interface = { - tws_tvsrv::handle_release, - tws_tvsrv::handle_bind, - tws_tvsrv::handle_unbind - }; - - void tws_tvsrv::tws_tvsrv_release(Resource *) - { - } - - void tws_tvsrv::tws_tvsrv_bind(Resource *) - { - } - - void tws_tvsrv::tws_tvsrv_unbind(Resource *) - { - } - - - void tws_tvsrv::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_tvsrv_object)->tws_tvsrv_release( - r); - } - - void tws_tvsrv::handle_bind( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_tvsrv_object)->tws_tvsrv_bind( - r); - } - - void tws_tvsrv::handle_unbind( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_tvsrv_object)->tws_tvsrv_unbind( - r); - } - tws_region::tws_region(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -2062,7 +1841,7 @@ namespace DSWaylandServer { { } - void tws_service_screensaver_manager::tws_service_screensaver_manager_state_get(Resource *) + void tws_service_screensaver_manager::tws_service_screensaver_manager_state_get(Resource *, uint32_t ) { } @@ -2111,12 +1890,14 @@ namespace DSWaylandServer { void tws_service_screensaver_manager::handle_state_get( ::wl_client *client, - struct wl_resource *resource) + struct wl_resource *resource, + uint32_t state_type) { DS_UNUSED(client); Resource *r = Resource::fromResource(resource); static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_state_get( - r); + r, + state_type); } void tws_service_screensaver_manager::send_idle() @@ -3139,11 +2920,11 @@ namespace DSWaylandServer { { } - void tws_softkey::tws_softkey_state_set(Resource *) + void tws_softkey::tws_softkey_state_set(Resource *, int32_t , int32_t ) { } - void tws_softkey::tws_softkey_state_get(Resource *) + void tws_softkey::tws_softkey_state_get(Resource *, int32_t ) { } @@ -3190,22 +2971,28 @@ namespace DSWaylandServer { void tws_softkey::handle_state_set( ::wl_client *client, - struct wl_resource *resource) + struct wl_resource *resource, + int32_t type, + int32_t val) { DS_UNUSED(client); Resource *r = Resource::fromResource(resource); static_cast(r->tws_softkey_object)->tws_softkey_state_set( - r); + r, + type, + val); } void tws_softkey::handle_state_get( ::wl_client *client, - struct wl_resource *resource) + struct wl_resource *resource, + int32_t type) { DS_UNUSED(client); Resource *r = Resource::fromResource(resource); static_cast(r->tws_softkey_object)->tws_softkey_state_get( - r); + r, + type); } void tws_softkey::send_support_check_done(int32_t support) diff --git a/src/DSWaylandServer/dswayland-server-tzsh.h b/src/DSWaylandServer/dswayland-server-tzsh.h index 3b94e6c..0d347b8 100644 --- a/src/DSWaylandServer/dswayland-server-tzsh.h +++ b/src/DSWaylandServer/dswayland-server-tzsh.h @@ -95,7 +95,6 @@ namespace DSWaylandServer { virtual void tizen_ws_shell_service_create(Resource *resource, uint32_t id, uint32_t win, const std::string &name); virtual void tizen_ws_shell_region_create(Resource *resource, uint32_t id); virtual void tizen_ws_shell_quickpanel_get(Resource *resource, uint32_t id, uint32_t win); - virtual void tizen_ws_shell_tvsrv_get(Resource *resource, uint32_t id, uint32_t win); virtual void tizen_ws_shell_extension_get(Resource *resource, uint32_t id, const std::string &name); virtual void tizen_ws_shell_softkey_get(Resource *resource, uint32_t id, uint32_t win); virtual void tizen_ws_shell_shared_widget_launch_get(Resource *resource, uint32_t id, uint32_t win); @@ -128,11 +127,6 @@ namespace DSWaylandServer { struct wl_resource *resource, uint32_t id, uint32_t win); - static void handle_tvsrv_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win); static void handle_extension_get( ::wl_client *client, struct wl_resource *resource, @@ -236,6 +230,7 @@ namespace DSWaylandServer { type_value_unknown = 0, type_value_system_default = 1, type_value_context_menu = 2, + type_value_apps_menu = 3, }; void send_state_get_done(int32_t type, int32_t value, uint32_t error_state); @@ -307,99 +302,6 @@ namespace DSWaylandServer { DisplayDestroyedListener m_displayDestroyedListener; }; - class tws_tvsrv - { - public: - tws_tvsrv(struct ::wl_client *client, uint32_t id, int version); - tws_tvsrv(struct ::wl_display *display, int version); - tws_tvsrv(struct ::wl_resource *resource); - tws_tvsrv(); - - virtual ~tws_tvsrv(); - - class Resource - { - public: - Resource() : tws_tvsrv_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_tvsrv *tws_tvsrv_object; - tws_tvsrv *object() { return tws_tvsrv_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_request_rejected = 0, // given request is denied - }; - - protected: - virtual Resource *tws_tvsrv_allocate(); - - virtual void tws_tvsrv_bind_resource(Resource *resource); - virtual void tws_tvsrv_destroy_resource(Resource *resource); - - virtual void tws_tvsrv_release(Resource *resource); - virtual void tws_tvsrv_bind(Resource *resource); - virtual void tws_tvsrv_unbind(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_tvsrv_interface m_tws_tvsrv_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - static void handle_bind( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unbind( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_tvsrv *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - class tws_region { public: @@ -893,7 +795,7 @@ namespace DSWaylandServer { virtual void tws_service_screensaver_manager_enable(Resource *resource); virtual void tws_service_screensaver_manager_disable(Resource *resource); virtual void tws_service_screensaver_manager_idle_time_set(Resource *resource, uint32_t id); - virtual void tws_service_screensaver_manager_state_get(Resource *resource); + virtual void tws_service_screensaver_manager_state_get(Resource *resource, uint32_t state_type); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -920,7 +822,8 @@ namespace DSWaylandServer { uint32_t id); static void handle_state_get( ::wl_client *client, - struct wl_resource *resource); + struct wl_resource *resource, + uint32_t state_type); std::multimap m_resource_map; Resource *m_resource; @@ -1382,8 +1285,8 @@ namespace DSWaylandServer { virtual void tws_softkey_support_check(Resource *resource); virtual void tws_softkey_show(Resource *resource); virtual void tws_softkey_hide(Resource *resource); - virtual void tws_softkey_state_set(Resource *resource); - virtual void tws_softkey_state_get(Resource *resource); + virtual void tws_softkey_state_set(Resource *resource, int32_t type, int32_t val); + virtual void tws_softkey_state_get(Resource *resource, int32_t type); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -1409,10 +1312,13 @@ namespace DSWaylandServer { struct wl_resource *resource); static void handle_state_set( ::wl_client *client, - struct wl_resource *resource); + struct wl_resource *resource, + int32_t type, + int32_t val); static void handle_state_get( ::wl_client *client, - struct wl_resource *resource); + struct wl_resource *resource, + int32_t type); std::multimap m_resource_map; Resource *m_resource; diff --git a/src/DSWaylandServer/dswayland-server-wayland.h b/src/DSWaylandServer/dswayland-server-wayland.h index 0cdfa52..4bf6c30 100644 --- a/src/DSWaylandServer/dswayland-server-wayland.h +++ b/src/DSWaylandServer/dswayland-server-wayland.h @@ -1300,6 +1300,7 @@ namespace DSWaylandServer { enum error { error_invalid_scale = 0, // buffer scale value is invalid error_invalid_transform = 1, // buffer transform value is invalid + error_invalid_size = 2, // buffer size is invalid }; void send_enter(struct ::wl_resource *output); @@ -1446,6 +1447,10 @@ namespace DSWaylandServer { capability_touch = 4, // the seat has touch devices }; + enum error { + error_missing_capability = 0, // get_pointer, get_keyboard or get_touch called on seat without the matching capability + }; + void send_capabilities(uint32_t capabilities); void send_capabilities(struct ::wl_resource *resource, uint32_t capabilities); void send_name(const std::string &name); -- 2.7.4 From 7e992e58214100875346fa8ae6f9e6bf84cb882f Mon Sep 17 00:00:00 2001 From: ulgal-park Date: Mon, 10 May 2021 13:49:11 +0900 Subject: [PATCH 06/16] Build: set b_pie option set b_pie option to true for make PIE Change-Id: Ief61c2c76e3b68bfcc316bf4ba37a5fc8431ca3b --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 1c0ab21..7dbefbe 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( ['c', 'cpp'], version : '0.0.1', license : 'MIT', - default_options : ['c_std=c11', 'cpp_std=c++17'] + default_options : ['c_std=c11', 'cpp_std=c++17', 'b_pie=true'] ) libds_version = meson.project_version().split('.') -- 2.7.4 From f9beee40d1a579e3be55e6f9b44f1b5889b28259 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Tue, 25 May 2021 15:43:48 +0900 Subject: [PATCH 07/16] DSWaylandInputPanel: fix not to use invalid iterator Change-Id: Id5ee96de9d5873ad6ce605b1cebc6a3cc4469aa7 Signed-off-by: Sung-Jin Park --- src/DSWaylandServer/DSWaylandInputPanel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index 46e643b..21d5878 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -326,11 +326,10 @@ void DSWaylandInputPanelSurfacePrivate::clearGlobals(void *inputPanelResource) { for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) { - auto tempIt = it; DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; if (surfaceData->getInputPanelResource() == inputPanelResource) { - __dataMap.erase(tempIt); + it = __dataMap.erase(it); /* TODO: clear window's data */ } } -- 2.7.4 From 38a744c50d2737737910c7f2b676cc71286265ef Mon Sep 17 00:00:00 2001 From: Daekwang Ryu Date: Wed, 2 Jun 2021 11:43:55 +0900 Subject: [PATCH 08/16] Change API usage of OffscreenWindow::New Change-Id: I56aaff48b586c79adcd3b3628230d43f564dbcc4 OffscreenWindow::New was changed. --- src/DSRender/DSRenderEngineDaliImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp index bf2ab39..e1d13c2 100644 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ b/src/DSRender/DSRenderEngineDaliImpl.cpp @@ -39,7 +39,7 @@ DSRenderEngineDaliImpl::DSRenderEngineDaliImpl(std::shared_ptr b __needToRender(false) { tbm_surface_queue_h nativeBufferQueue = (tbm_surface_queue_h)bufferQueue->getNativeBufferQueue(); - __offscreenApplication = OffscreenApplication::New(nativeBufferQueue, true, OffscreenApplication::RenderMode::MANUAL); + __offscreenApplication = OffscreenApplication::New(nativeBufferQueue, OffscreenApplication::RenderMode::MANUAL); __offscreenApplication.InitSignal().Connect(this, &DSRenderEngineDaliImpl::onInitialize); -- 2.7.4 From 79b5d5b275b6178277bf6121bd7a4610ba132f5d Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Fri, 7 Jan 2022 14:36:30 +0900 Subject: [PATCH 09/16] update following wayland protocols - wayland - tizen-extension - tizen-hwc - input-method Change-Id: If4af733eeeb6c80103a96379ae3c82bafcbd0f79 --- src/DSWaylandServer/DSWaylandInputMethod.cpp | 56 +- src/DSWaylandServer/DSWaylandInputMethod.h | 3 + .../DSWaylandInputMethodContextPrivate.h | 4 +- src/DSWaylandServer/DSWaylandInputMethodPrivate.h | 11 +- src/DSWaylandServer/DSWaylandInputPanel.cpp | 8 +- src/DSWaylandServer/DSWaylandInputPanelPrivate.h | 4 +- .../DSWaylandInputPanelSurfacePrivate.h | 4 +- .../dswayland-server-input-method-unstable-v1.cpp | 2050 ++++++++++++++++++++ ...=> dswayland-server-input-method-unstable-v1.h} | 232 +-- .../dswayland-server-input-method.cpp | 1970 ------------------- .../dswayland-server-tizen-extension.cpp | 117 +- .../dswayland-server-tizen-extension.h | 23 +- src/DSWaylandServer/dswayland-server-tizen-hwc.cpp | 10 +- src/DSWaylandServer/dswayland-server-tizen-hwc.h | 6 +- src/meson.build | 4 +- 15 files changed, 2385 insertions(+), 2117 deletions(-) create mode 100644 src/DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp rename src/DSWaylandServer/{dswayland-server-input-method.h => dswayland-server-input-method-unstable-v1.h} (69%) delete mode 100644 src/DSWaylandServer/dswayland-server-input-method.cpp diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp index ad50352..93d3aee 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -490,7 +490,7 @@ DSWaylandInputMethodPrivate::DSWaylandInputMethodPrivate(DSWaylandInputMethod *p if (!compositor) return; - wl_input_method::init(__compositor->display(), 1); + zwp_input_method_v1::init(__compositor->display(), 1); } DSWaylandInputMethodPrivate::~DSWaylandInputMethodPrivate() @@ -532,18 +532,18 @@ DSWaylandInputMethodContextPrivate::Resource* DSWaylandInputMethodPrivate::getRe return resource; } -void DSWaylandInputMethodPrivate::sendActivate(void *contextResource, int textInputId, bool focusInEvent) +void DSWaylandInputMethodPrivate::sendActivate(void *contextResource, int textInputId) { DSWaylandInputMethodContextPrivate::Resource *resource = DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)contextResource); __contextMap.insert(std::pair(resource, textInputId)); - send_activate(__resource->handle, (struct ::wl_resource *)contextResource, textInputId, focusInEvent); + send_activate(__resource->handle, (struct ::wl_resource *)contextResource); } -void DSWaylandInputMethodPrivate::sendDeactivate(void *contextResource, bool focusInEvent) +void DSWaylandInputMethodPrivate::sendDeactivate(void *contextResource) { DSWaylandInputMethodContextPrivate::Resource *resource = DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)contextResource); __contextMap.erase(resource); - send_deactivate(__resource->handle, (struct ::wl_resource *)contextResource, focusInEvent); + send_deactivate(__resource->handle, (struct ::wl_resource *)contextResource); } void DSWaylandInputMethodPrivate::showInputPanel(void *contextResource, int textInputId) @@ -559,6 +559,24 @@ void DSWaylandInputMethodPrivate::hideInputPanel(void *contextResource, int text send_hide_input_panel(__resource->handle, (struct ::wl_resource *)contextResource); } +void DSWaylandInputMethodPrivate::openConnection(void *contextResource) +{ + //Resource *resource = getResource(textInputId); + send_open_connection(__resource->handle, (struct ::wl_resource *)contextResource); +} + +void DSWaylandInputMethodPrivate::closeConnection(void *contextResource) +{ + //Resource *resource = getResource(textInputId); + send_close_connection(__resource->handle, (struct ::wl_resource *)contextResource); +} + +void DSWaylandInputMethodPrivate::setTextInputId(void *contextResource, int textInputId) +{ + //Resource *resource = getResource(textInputId); + send_set_text_input_id(__resource->handle, (struct ::wl_resource *)contextResource, textInputId); +} + void DSWaylandInputMethodPrivate::input_method_bind_resource(Resource *resource) { __resource = resource; @@ -618,7 +636,7 @@ void DSWaylandInputMethod::activate(int textInputId) } if (__activateContext) - priv->sendActivate(__activateContext, textInputId, true); + priv->sendActivate(__activateContext, textInputId); } void DSWaylandInputMethod::deactivate() @@ -627,7 +645,7 @@ void DSWaylandInputMethod::deactivate() if (__activateContext) { - priv->sendDeactivate(__activateContext, true); + priv->sendDeactivate(__activateContext); __activateContext = nullptr; } } @@ -653,6 +671,30 @@ void DSWaylandInputMethod::hideInputPanel(int textInputId) priv->hideInputPanel(__activateContext, textInputId); } +void DSWaylandInputMethod::openConnection() +{ + DS_GET_PRIV(DSWaylandInputMethod); + + if (__activateContext) + priv->openConnection(__activateContext); +} + +void DSWaylandInputMethod::closeConnection() +{ + DS_GET_PRIV(DSWaylandInputMethod); + + if (__activateContext) + priv->closeConnection(__activateContext); +} + +void DSWaylandInputMethod::setTextInputId(int textInputId) +{ + DS_GET_PRIV(DSWaylandInputMethod); + + if (__activateContext) + priv->setTextInputId(__activateContext, textInputId); +} + void DSWaylandInputMethod::resetTextInput() { __inputMethodContext->sendReset(__activateContext); diff --git a/src/DSWaylandServer/DSWaylandInputMethod.h b/src/DSWaylandServer/DSWaylandInputMethod.h index 590f81c..3610d84 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.h +++ b/src/DSWaylandServer/DSWaylandInputMethod.h @@ -50,6 +50,9 @@ public: void deactivate(); void showInputPanel(int textInputId); void hideInputPanel(int textInputId); + void openConnection(); + void closeConnection(); + void setTextInputId(int textInputId); void resetTextInput(); void setContentType(unsigned int hint, unsigned int purpose); void setPreferredLanguage(const std::string language); diff --git a/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h index 72bc88d..0df8a92 100644 --- a/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h +++ b/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h @@ -24,7 +24,7 @@ #ifndef __DS_WAYLAND_INPUT_METHOD_CONTEXT_PRIVATE_H__ #define __DS_WAYLAND_INPUT_METHOD_CONTEXT_PRIVATE_H__ -#include "dswayland-server-input-method.h" +#include "dswayland-server-input-method-unstable-v1.h" #include "DSCore.h" #include "DSObjectPrivate.h" @@ -34,7 +34,7 @@ namespace display_server { /*LCOV_EXCL_START*/ -class DS_DECL_EXPORT DSWaylandInputMethodContextPrivate : public DSObjectPrivate, public DSWaylandServer::wl_input_method_context +class DS_DECL_EXPORT DSWaylandInputMethodContextPrivate : public DSObjectPrivate, public DSWaylandServer::zwp_input_method_context_v1 { DS_PIMPL_USE_PUBLIC(DSWaylandInputMethodContext); public: diff --git a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h index 90b98e3..cb4cc5d 100644 --- a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h +++ b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h @@ -24,7 +24,7 @@ #ifndef __DS_WAYLAND_INPUT_METHOD_PRIVATE_H__ #define __DS_WAYLAND_INPUT_METHOD_PRIVATE_H__ -#include "dswayland-server-input-method.h" +#include "dswayland-server-input-method-unstable-v1.h" #include "DSCore.h" #include "DSObjectPrivate.h" @@ -36,17 +36,20 @@ namespace display_server /*LCOV_EXCL_START*/ class DSWaylandInputMethodContextPrivate; -class DS_DECL_EXPORT DSWaylandInputMethodPrivate : public DSObjectPrivate, public DSWaylandServer::wl_input_method +class DS_DECL_EXPORT DSWaylandInputMethodPrivate : public DSObjectPrivate, public DSWaylandServer::zwp_input_method_v1 { DS_PIMPL_USE_PUBLIC(DSWaylandInputMethod); public: DSWaylandInputMethodPrivate(DSWaylandInputMethod *p_ptr, DSWaylandCompositor *compositor); ~DSWaylandInputMethodPrivate() override; - void sendActivate(void *contextResource, int textInputId, bool focusInEvent); - void sendDeactivate(void *contextResource, bool focusInEvent); + void sendActivate(void *contextResource, int textInputId); + void sendDeactivate(void *contextResource); void showInputPanel(void *contextResource, int textInputId); void hideInputPanel(void *contextResource, int textInputId); + void openConnection(void *contextResource); + void closeConnection(void *contextResource); + void setTextInputId(void *contextResource, int textInputId); int getResourceId(DSWaylandInputMethodContextPrivate::Resource *resource); DSWaylandInputMethodContextPrivate::Resource* getResource(int id); diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index 21d5878..2b63992 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -59,11 +59,11 @@ private: class DSWaylandInputPanelSurfaceData { public: - DSWaylandInputPanelSurfaceData(DSWaylandServer::wl_input_panel_surface::Resource *resource, void *inputPanelResource) + DSWaylandInputPanelSurfaceData(DSWaylandServer::zwp_input_panel_surface_v1::Resource *resource, void *inputPanelResource) : panel(false), showing(false), needShow(false), resizing(false), __resource(resource), __inputPanelResource(inputPanelResource), __wlSurface(nullptr) {} - DSWaylandInputPanelSurfaceData(DSWaylandServer::wl_input_panel_surface::Resource *resource, void *inputPanelResource, void *surfaceResource) + DSWaylandInputPanelSurfaceData(DSWaylandServer::zwp_input_panel_surface_v1::Resource *resource, void *inputPanelResource, void *surfaceResource) : panel(false), showing(false), needShow(false), resizing(false), __resource(resource), __inputPanelResource(inputPanelResource) { __wlSurface = DSWaylandSurface::fromWlResource((struct ::wl_resource *)surfaceResource); } @@ -78,7 +78,7 @@ public: bool resizing; private: - DSWaylandServer::wl_input_panel_surface::Resource *__resource; + DSWaylandServer::zwp_input_panel_surface_v1::Resource *__resource; void *__inputPanelResource; DSWaylandSurface *__wlSurface; }; @@ -90,7 +90,7 @@ DSWaylandInputPanelPrivate::DSWaylandInputPanelPrivate(DSWaylandInputPanel *p_pt if (!compositor) return; - wl_input_panel::init(__compositor->display(), 1); + zwp_input_panel_v1::init(__compositor->display(), 1); } DSWaylandInputPanelPrivate::~DSWaylandInputPanelPrivate() diff --git a/src/DSWaylandServer/DSWaylandInputPanelPrivate.h b/src/DSWaylandServer/DSWaylandInputPanelPrivate.h index fe4bd53..b58135a 100644 --- a/src/DSWaylandServer/DSWaylandInputPanelPrivate.h +++ b/src/DSWaylandServer/DSWaylandInputPanelPrivate.h @@ -24,7 +24,7 @@ #ifndef __DS_WAYLAND_INPUT_PANEL_PRIVATE_H__ #define __DS_WAYLAND_INPUT_PANEL_PRIVATE_H__ -#include "dswayland-server-input-method.h" +#include "dswayland-server-input-method-unstable-v1.h" #include "DSCore.h" #include "DSObjectPrivate.h" @@ -34,7 +34,7 @@ namespace display_server { /*LCOV_EXCL_START*/ -class DS_DECL_EXPORT DSWaylandInputPanelPrivate : public DSObjectPrivate, public DSWaylandServer::wl_input_panel +class DS_DECL_EXPORT DSWaylandInputPanelPrivate : public DSObjectPrivate, public DSWaylandServer::zwp_input_panel_v1 { DS_PIMPL_USE_PUBLIC(DSWaylandInputPanel); public: diff --git a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h index 22e10b3..8edd342 100644 --- a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h +++ b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h @@ -24,7 +24,7 @@ #ifndef __DS_WAYLAND_INPUT_PANEL_SURFACE_PRIVATE_H__ #define __DS_WAYLAND_INPUT_PANEL_SURFACE_PRIVATE_H__ -#include "dswayland-server-input-method.h" +#include "dswayland-server-input-method-unstable-v1.h" #include "DSCore.h" #include "DSObjectPrivate.h" @@ -37,7 +37,7 @@ namespace display_server /*LCOV_EXCL_START*/ class DSWaylandInputPanelSurfaceData; -class DS_DECL_EXPORT DSWaylandInputPanelSurfacePrivate : public DSObjectPrivate, public DSWaylandServer::wl_input_panel_surface +class DS_DECL_EXPORT DSWaylandInputPanelSurfacePrivate : public DSObjectPrivate, public DSWaylandServer::zwp_input_panel_surface_v1 { DS_PIMPL_USE_PUBLIC(DSWaylandInputPanelSurface); public: diff --git a/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp b/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp new file mode 100644 index 0000000..dd60486 --- /dev/null +++ b/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp @@ -0,0 +1,2050 @@ +/*LCOV_EXCL_START*/ +/* Protocol XML file : wayland-extension/input-method.xml */ + +#include "dswayland-server-input-method-unstable-v1.h" + +#ifndef DS_UNLIKELY +#define DS_UNLIKELY(X) X +#endif +#ifndef DS_UNUSED +#define DS_UNUSED(X) (void)X +#endif +#ifndef DS_ASSERT +#define DS_ASSERT(COND) assert(COND) +#endif +#ifndef DS_ASSERT_X +#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ + do {\ + if (! (COND))\ + {\ + fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ + assert(COND);\ + }\ + } while(0) +#endif +#ifndef WRN +#define WRN(X...) fprintf(stderr,##X) +#endif + +namespace DSWaylandServer { + zwp_input_method_context_v1::zwp_input_method_context_v1(struct ::wl_client *client, uint32_t id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(client, id, version); + } + + zwp_input_method_context_v1::zwp_input_method_context_v1(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(display, version); + } + + zwp_input_method_context_v1::zwp_input_method_context_v1(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(resource); + } + + zwp_input_method_context_v1::zwp_input_method_context_v1() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + } + + zwp_input_method_context_v1::~zwp_input_method_context_v1() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zwp_input_method_context_v1::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zwp_input_method_context_v1::init(struct ::wl_client *client, uint32_t id, int version) + { + m_resource = bind(client, id, version); + } + + void zwp_input_method_context_v1::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::add(struct ::wl_client *client, uint32_t id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zwp_input_method_context_v1::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zwp_input_method_context_v1_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zwp_input_method_context_v1::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zwp_input_method_context_v1::interface() + { + return &::zwp_input_method_context_v1_interface; + } + + zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::zwp_input_method_context_v1_allocate() + { + return new Resource; + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_bind_resource(Resource *) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_destroy_resource(Resource *) + { + } + + void zwp_input_method_context_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zwp_input_method_context_v1 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zwp_input_method_context_v1::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zwp_input_method_context_v1 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zwp_input_method_context_v1::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zwp_input_method_context_v1 *that = resource->zwp_input_method_context_v1_object; + that->m_resource_map.erase(resource->client()); + that->zwp_input_method_context_v1_destroy_resource(resource); + delete resource; + } + + zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_method_context_v1_interface, version, id); + return bind(handle); + } + + zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::bind(struct ::wl_resource *handle) + { + Resource *resource = zwp_input_method_context_v1_allocate(); + resource->zwp_input_method_context_v1_object = this; + + wl_resource_set_implementation(handle, &m_zwp_input_method_context_v1_interface, resource, destroy_func); + resource->handle = handle; + zwp_input_method_context_v1_bind_resource(resource); + return resource; + } + zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zwp_input_method_context_v1_interface, &m_zwp_input_method_context_v1_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zwp_input_method_context_v1_interface zwp_input_method_context_v1::m_zwp_input_method_context_v1_interface = { + zwp_input_method_context_v1::handle_destroy, + zwp_input_method_context_v1::handle_commit_string, + zwp_input_method_context_v1::handle_preedit_string, + zwp_input_method_context_v1::handle_preedit_styling, + zwp_input_method_context_v1::handle_preedit_cursor, + zwp_input_method_context_v1::handle_delete_surrounding_text, + zwp_input_method_context_v1::handle_cursor_position, + zwp_input_method_context_v1::handle_modifiers_map, + zwp_input_method_context_v1::handle_keysym, + zwp_input_method_context_v1::handle_grab_keyboard, + zwp_input_method_context_v1::handle_key, + zwp_input_method_context_v1::handle_modifiers, + zwp_input_method_context_v1::handle_language, + zwp_input_method_context_v1::handle_text_direction, + zwp_input_method_context_v1::handle_selection_region, + zwp_input_method_context_v1::handle_private_command, + zwp_input_method_context_v1::handle_update_input_panel_data, + zwp_input_method_context_v1::handle_hide_input_panel, + zwp_input_method_context_v1::handle_get_selection_text, + zwp_input_method_context_v1::handle_get_surrounding_text, + zwp_input_method_context_v1::handle_filter_key_event_done, + zwp_input_method_context_v1::handle_update_ise_geometry, + zwp_input_method_context_v1::handle_recapture_string, + zwp_input_method_context_v1::handle_input_panel_event, + zwp_input_method_context_v1::handle_commit_content, + zwp_input_method_context_v1::handle_update_candidate_state, + zwp_input_method_context_v1::handle_reshow_input_panel, + zwp_input_method_context_v1::handle_set_floating_panel, + zwp_input_method_context_v1::handle_set_floating_drag_enabled + }; + + void zwp_input_method_context_v1::zwp_input_method_context_v1_destroy(Resource *) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_commit_string(Resource *, uint32_t , const std::string &) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_string(Resource *, uint32_t , const std::string &, const std::string &) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_styling(Resource *, uint32_t , uint32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_cursor(Resource *, int32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_delete_surrounding_text(Resource *, int32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_cursor_position(Resource *, int32_t , int32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_modifiers_map(Resource *, struct ::wl_array *) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_keysym(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_grab_keyboard(Resource *, uint32_t) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_key(Resource *, uint32_t , uint32_t , uint32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_modifiers(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_language(Resource *, uint32_t , const std::string &) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_text_direction(Resource *, uint32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_selection_region(Resource *, uint32_t , int32_t , int32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_private_command(Resource *, uint32_t , const std::string &) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_update_input_panel_data(Resource *, uint32_t , const std::string &, uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_hide_input_panel(Resource *, uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_get_selection_text(Resource *, int32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_get_surrounding_text(Resource *, uint32_t , uint32_t , int32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_filter_key_event_done(Resource *, uint32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_update_ise_geometry(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_recapture_string(Resource *, uint32_t , int32_t , uint32_t , const std::string &, const std::string &, const std::string &) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_input_panel_event(Resource *, uint32_t , uint32_t , uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_commit_content(Resource *, uint32_t , const std::string &, const std::string &, const std::string &) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_update_candidate_state(Resource *, uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_reshow_input_panel(Resource *) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_set_floating_panel(Resource *, uint32_t ) + { + } + + void zwp_input_method_context_v1::zwp_input_method_context_v1_set_floating_drag_enabled(Resource *, uint32_t ) + { + } + + + void zwp_input_method_context_v1::handle_destroy( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_destroy( + r); + } + + void zwp_input_method_context_v1::handle_commit_string( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + const char *text) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_commit_string( + r, + serial, + std::string(text)); + } + + void zwp_input_method_context_v1::handle_preedit_string( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + const char *text, + const char *commit) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_string( + r, + serial, + std::string(text), + std::string(commit)); + } + + void zwp_input_method_context_v1::handle_preedit_styling( + ::wl_client *client, + struct wl_resource *resource, + uint32_t index, + uint32_t length, + uint32_t style) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_styling( + r, + index, + length, + style); + } + + void zwp_input_method_context_v1::handle_preedit_cursor( + ::wl_client *client, + struct wl_resource *resource, + int32_t index) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_cursor( + r, + index); + } + + void zwp_input_method_context_v1::handle_delete_surrounding_text( + ::wl_client *client, + struct wl_resource *resource, + int32_t index, + uint32_t length) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_delete_surrounding_text( + r, + index, + length); + } + + void zwp_input_method_context_v1::handle_cursor_position( + ::wl_client *client, + struct wl_resource *resource, + int32_t index, + int32_t anchor) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_cursor_position( + r, + index, + anchor); + } + + void zwp_input_method_context_v1::handle_modifiers_map( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_array *map) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_modifiers_map( + r, + map); + } + + void zwp_input_method_context_v1::handle_keysym( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + uint32_t time, + uint32_t sym, + uint32_t state, + uint32_t modifiers) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_keysym( + r, + serial, + time, + sym, + state, + modifiers); + } + + void zwp_input_method_context_v1::handle_grab_keyboard( + ::wl_client *client, + struct wl_resource *resource, + uint32_t keyboard) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_grab_keyboard( + r, + keyboard); + } + + void zwp_input_method_context_v1::handle_key( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + uint32_t time, + uint32_t key, + uint32_t state) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_key( + r, + serial, + time, + key, + state); + } + + void zwp_input_method_context_v1::handle_modifiers( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + uint32_t mods_depressed, + uint32_t mods_latched, + uint32_t mods_locked, + uint32_t group) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_modifiers( + r, + serial, + mods_depressed, + mods_latched, + mods_locked, + group); + } + + void zwp_input_method_context_v1::handle_language( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + const char *language) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_language( + r, + serial, + std::string(language)); + } + + void zwp_input_method_context_v1::handle_text_direction( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + uint32_t direction) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_text_direction( + r, + serial, + direction); + } + + void zwp_input_method_context_v1::handle_selection_region( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + int32_t start, + int32_t end) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_selection_region( + r, + serial, + start, + end); + } + + void zwp_input_method_context_v1::handle_private_command( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + const char *command) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_private_command( + r, + serial, + std::string(command)); + } + + void zwp_input_method_context_v1::handle_update_input_panel_data( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + const char *input_panel_data, + uint32_t input_panel_data_length) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_update_input_panel_data( + r, + serial, + std::string(input_panel_data), + input_panel_data_length); + } + + void zwp_input_method_context_v1::handle_hide_input_panel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_hide_input_panel( + r, + serial); + } + + void zwp_input_method_context_v1::handle_get_selection_text( + ::wl_client *client, + struct wl_resource *resource, + int32_t fd) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_get_selection_text( + r, + fd); + } + + void zwp_input_method_context_v1::handle_get_surrounding_text( + ::wl_client *client, + struct wl_resource *resource, + uint32_t maxlen_before, + uint32_t maxlen_after, + int32_t fd) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_get_surrounding_text( + r, + maxlen_before, + maxlen_after, + fd); + } + + void zwp_input_method_context_v1::handle_filter_key_event_done( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + uint32_t state) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_filter_key_event_done( + r, + serial, + state); + } + + void zwp_input_method_context_v1::handle_update_ise_geometry( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + uint32_t x, + uint32_t y, + uint32_t width, + uint32_t height) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_update_ise_geometry( + r, + serial, + x, + y, + width, + height); + } + + void zwp_input_method_context_v1::handle_recapture_string( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + int32_t index, + uint32_t length, + const char *preedit, + const char *preedit_commit, + const char *commit) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_recapture_string( + r, + serial, + index, + length, + std::string(preedit), + std::string(preedit_commit), + std::string(commit)); + } + + void zwp_input_method_context_v1::handle_input_panel_event( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + uint32_t event_type, + uint32_t value) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_input_panel_event( + r, + serial, + event_type, + value); + } + + void zwp_input_method_context_v1::handle_commit_content( + ::wl_client *client, + struct wl_resource *resource, + uint32_t serial, + const char *content, + const char *description, + const char *mime_types) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_commit_content( + r, + serial, + std::string(content), + std::string(description), + std::string(mime_types)); + } + + void zwp_input_method_context_v1::handle_update_candidate_state( + ::wl_client *client, + struct wl_resource *resource, + uint32_t state) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_update_candidate_state( + r, + state); + } + + void zwp_input_method_context_v1::handle_reshow_input_panel( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_reshow_input_panel( + r); + } + + void zwp_input_method_context_v1::handle_set_floating_panel( + ::wl_client *client, + struct wl_resource *resource, + uint32_t state) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_set_floating_panel( + r, + state); + } + + void zwp_input_method_context_v1::handle_set_floating_drag_enabled( + ::wl_client *client, + struct wl_resource *resource, + uint32_t enabled) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_set_floating_drag_enabled( + r, + enabled); + } + + void zwp_input_method_context_v1::send_surrounding_text(const std::string &text, uint32_t cursor, uint32_t anchor) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::surrounding_text", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::surrounding_text as it's not initialised"); + return; + } + send_surrounding_text( + m_resource->handle, + text, + cursor, + anchor); + } + + void zwp_input_method_context_v1::send_surrounding_text(struct ::wl_resource *resource, const std::string &text, uint32_t cursor, uint32_t anchor) + { + zwp_input_method_context_v1_send_surrounding_text( + resource, + text.c_str(), + cursor, + anchor); + } + + + void zwp_input_method_context_v1::send_reset() + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::reset", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::reset as it's not initialised"); + return; + } + send_reset( + m_resource->handle); + } + + void zwp_input_method_context_v1::send_reset(struct ::wl_resource *resource) + { + zwp_input_method_context_v1_send_reset( + resource); + } + + + void zwp_input_method_context_v1::send_content_type(uint32_t hint, uint32_t purpose) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::content_type", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::content_type as it's not initialised"); + return; + } + send_content_type( + m_resource->handle, + hint, + purpose); + } + + void zwp_input_method_context_v1::send_content_type(struct ::wl_resource *resource, uint32_t hint, uint32_t purpose) + { + zwp_input_method_context_v1_send_content_type( + resource, + hint, + purpose); + } + + + void zwp_input_method_context_v1::send_invoke_action(uint32_t button, uint32_t index) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::invoke_action", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::invoke_action as it's not initialised"); + return; + } + send_invoke_action( + m_resource->handle, + button, + index); + } + + void zwp_input_method_context_v1::send_invoke_action(struct ::wl_resource *resource, uint32_t button, uint32_t index) + { + zwp_input_method_context_v1_send_invoke_action( + resource, + button, + index); + } + + + void zwp_input_method_context_v1::send_commit_state(uint32_t serial) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::commit_state", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::commit_state as it's not initialised"); + return; + } + send_commit_state( + m_resource->handle, + serial); + } + + void zwp_input_method_context_v1::send_commit_state(struct ::wl_resource *resource, uint32_t serial) + { + zwp_input_method_context_v1_send_commit_state( + resource, + serial); + } + + + void zwp_input_method_context_v1::send_preferred_language(const std::string &language) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::preferred_language", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::preferred_language as it's not initialised"); + return; + } + send_preferred_language( + m_resource->handle, + language); + } + + void zwp_input_method_context_v1::send_preferred_language(struct ::wl_resource *resource, const std::string &language) + { + zwp_input_method_context_v1_send_preferred_language( + resource, + language.c_str()); + } + + + void zwp_input_method_context_v1::send_return_key_type(uint32_t return_key_type) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::return_key_type", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::return_key_type as it's not initialised"); + return; + } + send_return_key_type( + m_resource->handle, + return_key_type); + } + + void zwp_input_method_context_v1::send_return_key_type(struct ::wl_resource *resource, uint32_t return_key_type) + { + zwp_input_method_context_v1_send_return_key_type( + resource, + return_key_type); + } + + + void zwp_input_method_context_v1::send_return_key_disabled(uint32_t return_key_disabled) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::return_key_disabled", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::return_key_disabled as it's not initialised"); + return; + } + send_return_key_disabled( + m_resource->handle, + return_key_disabled); + } + + void zwp_input_method_context_v1::send_return_key_disabled(struct ::wl_resource *resource, uint32_t return_key_disabled) + { + zwp_input_method_context_v1_send_return_key_disabled( + resource, + return_key_disabled); + } + + + void zwp_input_method_context_v1::send_input_panel_data(const std::string &input_panel_data, uint32_t input_panel_data_length) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::input_panel_data", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::input_panel_data as it's not initialised"); + return; + } + send_input_panel_data( + m_resource->handle, + input_panel_data, + input_panel_data_length); + } + + void zwp_input_method_context_v1::send_input_panel_data(struct ::wl_resource *resource, const std::string &input_panel_data, uint32_t input_panel_data_length) + { + zwp_input_method_context_v1_send_input_panel_data( + resource, + input_panel_data.c_str(), + input_panel_data_length); + } + + + void zwp_input_method_context_v1::send_bidi_direction(uint32_t direction) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::bidi_direction", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::bidi_direction as it's not initialised"); + return; + } + send_bidi_direction( + m_resource->handle, + direction); + } + + void zwp_input_method_context_v1::send_bidi_direction(struct ::wl_resource *resource, uint32_t direction) + { + zwp_input_method_context_v1_send_bidi_direction( + resource, + direction); + } + + + void zwp_input_method_context_v1::send_cursor_position(uint32_t cursor_position) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::cursor_position", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::cursor_position as it's not initialised"); + return; + } + send_cursor_position( + m_resource->handle, + cursor_position); + } + + void zwp_input_method_context_v1::send_cursor_position(struct ::wl_resource *resource, uint32_t cursor_position) + { + zwp_input_method_context_v1_send_cursor_position( + resource, + cursor_position); + } + + + void zwp_input_method_context_v1::send_process_input_device_event(uint32_t event_type, const std::string &event_data, uint32_t event_length) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::process_input_device_event", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::process_input_device_event as it's not initialised"); + return; + } + send_process_input_device_event( + m_resource->handle, + event_type, + event_data, + event_length); + } + + void zwp_input_method_context_v1::send_process_input_device_event(struct ::wl_resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length) + { + zwp_input_method_context_v1_send_process_input_device_event( + resource, + event_type, + event_data.c_str(), + event_length); + } + + + void zwp_input_method_context_v1::send_filter_key_event(uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::filter_key_event", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::filter_key_event as it's not initialised"); + return; + } + send_filter_key_event( + m_resource->handle, + serial, + time, + keyname, + state, + modifiers, + dev_name, + dev_class, + dev_subclass, + keycode); + } + + void zwp_input_method_context_v1::send_filter_key_event(struct ::wl_resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode) + { + zwp_input_method_context_v1_send_filter_key_event( + resource, + serial, + time, + keyname.c_str(), + state, + modifiers, + dev_name.c_str(), + dev_class, + dev_subclass, + keycode); + } + + + void zwp_input_method_context_v1::send_capital_mode(uint32_t mode) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::capital_mode", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::capital_mode as it's not initialised"); + return; + } + send_capital_mode( + m_resource->handle, + mode); + } + + void zwp_input_method_context_v1::send_capital_mode(struct ::wl_resource *resource, uint32_t mode) + { + zwp_input_method_context_v1_send_capital_mode( + resource, + mode); + } + + + void zwp_input_method_context_v1::send_prediction_hint(const std::string &text) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::prediction_hint", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::prediction_hint as it's not initialised"); + return; + } + send_prediction_hint( + m_resource->handle, + text); + } + + void zwp_input_method_context_v1::send_prediction_hint(struct ::wl_resource *resource, const std::string &text) + { + zwp_input_method_context_v1_send_prediction_hint( + resource, + text.c_str()); + } + + + void zwp_input_method_context_v1::send_mime_type(const std::string &type) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::mime_type", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::mime_type as it's not initialised"); + return; + } + send_mime_type( + m_resource->handle, + type); + } + + void zwp_input_method_context_v1::send_mime_type(struct ::wl_resource *resource, const std::string &type) + { + zwp_input_method_context_v1_send_mime_type( + resource, + type.c_str()); + } + + + void zwp_input_method_context_v1::send_finalized_content(const std::string &text, uint32_t cursor_position) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::finalized_content", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::finalized_content as it's not initialised"); + return; + } + send_finalized_content( + m_resource->handle, + text, + cursor_position); + } + + void zwp_input_method_context_v1::send_finalized_content(struct ::wl_resource *resource, const std::string &text, uint32_t cursor_position) + { + zwp_input_method_context_v1_send_finalized_content( + resource, + text.c_str(), + cursor_position); + } + + + void zwp_input_method_context_v1::send_prediction_hint_data(const std::string &key, const std::string &value) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::prediction_hint_data", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::prediction_hint_data as it's not initialised"); + return; + } + send_prediction_hint_data( + m_resource->handle, + key, + value); + } + + void zwp_input_method_context_v1::send_prediction_hint_data(struct ::wl_resource *resource, const std::string &key, const std::string &value) + { + zwp_input_method_context_v1_send_prediction_hint_data( + resource, + key.c_str(), + value.c_str()); + } + + + void zwp_input_method_context_v1::send_input_panel_enabled(uint32_t enabled) + { + DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::input_panel_enabled", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_context_v1::input_panel_enabled as it's not initialised"); + return; + } + send_input_panel_enabled( + m_resource->handle, + enabled); + } + + void zwp_input_method_context_v1::send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled) + { + zwp_input_method_context_v1_send_input_panel_enabled( + resource, + enabled); + } + + + zwp_input_method_v1::zwp_input_method_v1(struct ::wl_client *client, uint32_t id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(client, id, version); + } + + zwp_input_method_v1::zwp_input_method_v1(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(display, version); + } + + zwp_input_method_v1::zwp_input_method_v1(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(resource); + } + + zwp_input_method_v1::zwp_input_method_v1() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + } + + zwp_input_method_v1::~zwp_input_method_v1() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zwp_input_method_v1::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zwp_input_method_v1::init(struct ::wl_client *client, uint32_t id, int version) + { + m_resource = bind(client, id, version); + } + + void zwp_input_method_v1::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zwp_input_method_v1::Resource *zwp_input_method_v1::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zwp_input_method_v1::Resource *zwp_input_method_v1::add(struct ::wl_client *client, uint32_t id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zwp_input_method_v1::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zwp_input_method_v1_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zwp_input_method_v1::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zwp_input_method_v1::interface() + { + return &::zwp_input_method_v1_interface; + } + + zwp_input_method_v1::Resource *zwp_input_method_v1::zwp_input_method_v1_allocate() + { + return new Resource; + } + + void zwp_input_method_v1::zwp_input_method_v1_bind_resource(Resource *) + { + } + + void zwp_input_method_v1::zwp_input_method_v1_destroy_resource(Resource *) + { + } + + void zwp_input_method_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zwp_input_method_v1 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zwp_input_method_v1::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zwp_input_method_v1 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zwp_input_method_v1::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zwp_input_method_v1 *that = resource->zwp_input_method_v1_object; + that->m_resource_map.erase(resource->client()); + that->zwp_input_method_v1_destroy_resource(resource); + delete resource; + } + + zwp_input_method_v1::Resource *zwp_input_method_v1::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_method_v1_interface, version, id); + return bind(handle); + } + + zwp_input_method_v1::Resource *zwp_input_method_v1::bind(struct ::wl_resource *handle) + { + Resource *resource = zwp_input_method_v1_allocate(); + resource->zwp_input_method_v1_object = this; + + wl_resource_set_implementation(handle, NULL, resource, destroy_func); + resource->handle = handle; + zwp_input_method_v1_bind_resource(resource); + return resource; + } + zwp_input_method_v1::Resource *zwp_input_method_v1::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zwp_input_method_v1_interface, NULL)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + void zwp_input_method_v1::send_activate(struct ::wl_resource *id) + { + DS_ASSERT_X(m_resource, "zwp_input_method_v1::activate", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_v1::activate as it's not initialised"); + return; + } + send_activate( + m_resource->handle, + id); + } + + void zwp_input_method_v1::send_activate(struct ::wl_resource *resource, struct ::wl_resource *id) + { + zwp_input_method_v1_send_activate( + resource, + id); + } + + + void zwp_input_method_v1::send_deactivate(struct ::wl_resource *context) + { + DS_ASSERT_X(m_resource, "zwp_input_method_v1::deactivate", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_v1::deactivate as it's not initialised"); + return; + } + send_deactivate( + m_resource->handle, + context); + } + + void zwp_input_method_v1::send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context) + { + zwp_input_method_v1_send_deactivate( + resource, + context); + } + + + void zwp_input_method_v1::send_destroy(struct ::wl_resource *context) + { + DS_ASSERT_X(m_resource, "zwp_input_method_v1::destroy", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_v1::destroy as it's not initialised"); + return; + } + send_destroy( + m_resource->handle, + context); + } + + void zwp_input_method_v1::send_destroy(struct ::wl_resource *resource, struct ::wl_resource *context) + { + zwp_input_method_v1_send_destroy( + resource, + context); + } + + + void zwp_input_method_v1::send_show_input_panel(struct ::wl_resource *context, uint32_t degree) + { + DS_ASSERT_X(m_resource, "zwp_input_method_v1::show_input_panel", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_v1::show_input_panel as it's not initialised"); + return; + } + send_show_input_panel( + m_resource->handle, + context, + degree); + } + + void zwp_input_method_v1::send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t degree) + { + zwp_input_method_v1_send_show_input_panel( + resource, + context, + degree); + } + + + void zwp_input_method_v1::send_hide_input_panel(struct ::wl_resource *context) + { + DS_ASSERT_X(m_resource, "zwp_input_method_v1::hide_input_panel", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_v1::hide_input_panel as it's not initialised"); + return; + } + send_hide_input_panel( + m_resource->handle, + context); + } + + void zwp_input_method_v1::send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context) + { + zwp_input_method_v1_send_hide_input_panel( + resource, + context); + } + + + void zwp_input_method_v1::send_open_connection(struct ::wl_resource *context) + { + DS_ASSERT_X(m_resource, "zwp_input_method_v1::open_connection", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_v1::open_connection as it's not initialised"); + return; + } + send_open_connection( + m_resource->handle, + context); + } + + void zwp_input_method_v1::send_open_connection(struct ::wl_resource *resource, struct ::wl_resource *context) + { + zwp_input_method_v1_send_open_connection( + resource, + context); + } + + + void zwp_input_method_v1::send_close_connection(struct ::wl_resource *context) + { + DS_ASSERT_X(m_resource, "zwp_input_method_v1::close_connection", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_v1::close_connection as it's not initialised"); + return; + } + send_close_connection( + m_resource->handle, + context); + } + + void zwp_input_method_v1::send_close_connection(struct ::wl_resource *resource, struct ::wl_resource *context) + { + zwp_input_method_v1_send_close_connection( + resource, + context); + } + + + void zwp_input_method_v1::send_set_text_input_id(struct ::wl_resource *context, uint32_t text_input_id) + { + DS_ASSERT_X(m_resource, "zwp_input_method_v1::set_text_input_id", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call zwp_input_method_v1::set_text_input_id as it's not initialised"); + return; + } + send_set_text_input_id( + m_resource->handle, + context, + text_input_id); + } + + void zwp_input_method_v1::send_set_text_input_id(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t text_input_id) + { + zwp_input_method_v1_send_set_text_input_id( + resource, + context, + text_input_id); + } + + + zwp_input_panel_v1::zwp_input_panel_v1(struct ::wl_client *client, uint32_t id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(client, id, version); + } + + zwp_input_panel_v1::zwp_input_panel_v1(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(display, version); + } + + zwp_input_panel_v1::zwp_input_panel_v1(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(resource); + } + + zwp_input_panel_v1::zwp_input_panel_v1() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + } + + zwp_input_panel_v1::~zwp_input_panel_v1() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zwp_input_panel_v1::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zwp_input_panel_v1::init(struct ::wl_client *client, uint32_t id, int version) + { + m_resource = bind(client, id, version); + } + + void zwp_input_panel_v1::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zwp_input_panel_v1::Resource *zwp_input_panel_v1::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zwp_input_panel_v1::Resource *zwp_input_panel_v1::add(struct ::wl_client *client, uint32_t id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zwp_input_panel_v1::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zwp_input_panel_v1_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zwp_input_panel_v1::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zwp_input_panel_v1::interface() + { + return &::zwp_input_panel_v1_interface; + } + + zwp_input_panel_v1::Resource *zwp_input_panel_v1::zwp_input_panel_v1_allocate() + { + return new Resource; + } + + void zwp_input_panel_v1::zwp_input_panel_v1_bind_resource(Resource *) + { + } + + void zwp_input_panel_v1::zwp_input_panel_v1_destroy_resource(Resource *) + { + } + + void zwp_input_panel_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zwp_input_panel_v1 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zwp_input_panel_v1::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zwp_input_panel_v1 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zwp_input_panel_v1::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zwp_input_panel_v1 *that = resource->zwp_input_panel_v1_object; + that->m_resource_map.erase(resource->client()); + that->zwp_input_panel_v1_destroy_resource(resource); + delete resource; + } + + zwp_input_panel_v1::Resource *zwp_input_panel_v1::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_panel_v1_interface, version, id); + return bind(handle); + } + + zwp_input_panel_v1::Resource *zwp_input_panel_v1::bind(struct ::wl_resource *handle) + { + Resource *resource = zwp_input_panel_v1_allocate(); + resource->zwp_input_panel_v1_object = this; + + wl_resource_set_implementation(handle, &m_zwp_input_panel_v1_interface, resource, destroy_func); + resource->handle = handle; + zwp_input_panel_v1_bind_resource(resource); + return resource; + } + zwp_input_panel_v1::Resource *zwp_input_panel_v1::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zwp_input_panel_v1_interface, &m_zwp_input_panel_v1_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zwp_input_panel_v1_interface zwp_input_panel_v1::m_zwp_input_panel_v1_interface = { + zwp_input_panel_v1::handle_get_input_panel_surface + }; + + void zwp_input_panel_v1::zwp_input_panel_v1_get_input_panel_surface(Resource *, uint32_t, struct ::wl_resource *) + { + } + + + void zwp_input_panel_v1::handle_get_input_panel_surface( + ::wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct ::wl_resource *surface) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_panel_v1_object)->zwp_input_panel_v1_get_input_panel_surface( + r, + id, + surface); + } + + zwp_input_panel_surface_v1::zwp_input_panel_surface_v1(struct ::wl_client *client, uint32_t id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(client, id, version); + } + + zwp_input_panel_surface_v1::zwp_input_panel_surface_v1(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(display, version); + } + + zwp_input_panel_surface_v1::zwp_input_panel_surface_v1(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(resource); + } + + zwp_input_panel_surface_v1::zwp_input_panel_surface_v1() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + } + + zwp_input_panel_surface_v1::~zwp_input_panel_surface_v1() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zwp_input_panel_surface_v1::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zwp_input_panel_surface_v1::init(struct ::wl_client *client, uint32_t id, int version) + { + m_resource = bind(client, id, version); + } + + void zwp_input_panel_surface_v1::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::add(struct ::wl_client *client, uint32_t id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zwp_input_panel_surface_v1::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zwp_input_panel_surface_v1_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zwp_input_panel_surface_v1::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zwp_input_panel_surface_v1::interface() + { + return &::zwp_input_panel_surface_v1_interface; + } + + zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_allocate() + { + return new Resource; + } + + void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_bind_resource(Resource *) + { + } + + void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_destroy_resource(Resource *) + { + } + + void zwp_input_panel_surface_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zwp_input_panel_surface_v1 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zwp_input_panel_surface_v1::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zwp_input_panel_surface_v1 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zwp_input_panel_surface_v1::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zwp_input_panel_surface_v1 *that = resource->zwp_input_panel_surface_v1_object; + that->m_resource_map.erase(resource->client()); + that->zwp_input_panel_surface_v1_destroy_resource(resource); + delete resource; + } + + zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_panel_surface_v1_interface, version, id); + return bind(handle); + } + + zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::bind(struct ::wl_resource *handle) + { + Resource *resource = zwp_input_panel_surface_v1_allocate(); + resource->zwp_input_panel_surface_v1_object = this; + + wl_resource_set_implementation(handle, &m_zwp_input_panel_surface_v1_interface, resource, destroy_func); + resource->handle = handle; + zwp_input_panel_surface_v1_bind_resource(resource); + return resource; + } + zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zwp_input_panel_surface_v1_interface, &m_zwp_input_panel_surface_v1_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zwp_input_panel_surface_v1_interface zwp_input_panel_surface_v1::m_zwp_input_panel_surface_v1_interface = { + zwp_input_panel_surface_v1::handle_set_toplevel, + zwp_input_panel_surface_v1::handle_set_overlay_panel, + zwp_input_panel_surface_v1::handle_set_ready + }; + + void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_set_toplevel(Resource *, struct ::wl_resource *, uint32_t ) + { + } + + void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_set_overlay_panel(Resource *) + { + } + + void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_set_ready(Resource *, uint32_t ) + { + } + + + void zwp_input_panel_surface_v1::handle_set_toplevel( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *output, + uint32_t position) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_panel_surface_v1_object)->zwp_input_panel_surface_v1_set_toplevel( + r, + output, + position); + } + + void zwp_input_panel_surface_v1::handle_set_overlay_panel( + ::wl_client *client, + struct wl_resource *resource) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_panel_surface_v1_object)->zwp_input_panel_surface_v1_set_overlay_panel( + r); + } + + void zwp_input_panel_surface_v1::handle_set_ready( + ::wl_client *client, + struct wl_resource *resource, + uint32_t state) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_panel_surface_v1_object)->zwp_input_panel_surface_v1_set_ready( + r, + state); + } + + zwp_input_method_manager_v1::zwp_input_method_manager_v1(struct ::wl_client *client, uint32_t id, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(client, id, version); + } + + zwp_input_method_manager_v1::zwp_input_method_manager_v1(struct ::wl_display *display, int version) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(display, version); + } + + zwp_input_method_manager_v1::zwp_input_method_manager_v1(struct ::wl_resource *resource) + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + init(resource); + } + + zwp_input_method_manager_v1::zwp_input_method_manager_v1() + : m_resource_map() + , m_resource(NULL) + , m_global(NULL) + , m_globalVersion(0) + , m_displayDestroyedListener() + { + } + + zwp_input_method_manager_v1::~zwp_input_method_manager_v1() + { + std::multimap::iterator it; + for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { + zwp_input_method_manager_v1::Resource *resource = (*it).second; + wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); + } + + if (m_global) { + wl_global_destroy(m_global); + wl_list_remove(&m_displayDestroyedListener.link); + } + } + + void zwp_input_method_manager_v1::init(struct ::wl_client *client, uint32_t id, int version) + { + m_resource = bind(client, id, version); + } + + void zwp_input_method_manager_v1::init(struct ::wl_resource *resource) + { + m_resource = bind(resource); + } + + zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::add(struct ::wl_client *client, int version) + { + Resource *resource = bind(client, 0, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::add(struct ::wl_client *client, uint32_t id, int version) + { + Resource *resource = bind(client, id, version); + m_resource_map.insert(std::pair(client, resource)); + return resource; + } + + void zwp_input_method_manager_v1::init(struct ::wl_display *display, int version) + { + m_global = wl_global_create(display, &::zwp_input_method_manager_v1_interface, version, this, bind_func); + m_globalVersion = version; + m_displayDestroyedListener.notify = zwp_input_method_manager_v1::display_destroy_func; + m_displayDestroyedListener.parent = this; + wl_display_add_destroy_listener(display, &m_displayDestroyedListener); + } + + const struct wl_interface *zwp_input_method_manager_v1::interface() + { + return &::zwp_input_method_manager_v1_interface; + } + + zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::zwp_input_method_manager_v1_allocate() + { + return new Resource; + } + + void zwp_input_method_manager_v1::zwp_input_method_manager_v1_bind_resource(Resource *) + { + } + + void zwp_input_method_manager_v1::zwp_input_method_manager_v1_destroy_resource(Resource *) + { + } + + void zwp_input_method_manager_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) + { + zwp_input_method_manager_v1 *that = static_cast(data); + that->add(client, id, std::min(that->m_globalVersion, version)); + } + + void zwp_input_method_manager_v1::display_destroy_func(struct ::wl_listener *listener, void *data) + { + DS_UNUSED(data); + zwp_input_method_manager_v1 *that = static_cast(listener)->parent; + that->m_global = NULL; + } + + void zwp_input_method_manager_v1::destroy_func(struct ::wl_resource *client_resource) + { + Resource *resource = Resource::fromResource(client_resource); + DS_ASSERT(resource); + zwp_input_method_manager_v1 *that = resource->zwp_input_method_manager_v1_object; + that->m_resource_map.erase(resource->client()); + that->zwp_input_method_manager_v1_destroy_resource(resource); + delete resource; + } + + zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::bind(struct ::wl_client *client, uint32_t id, int version) + { + DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); + struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_method_manager_v1_interface, version, id); + return bind(handle); + } + + zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::bind(struct ::wl_resource *handle) + { + Resource *resource = zwp_input_method_manager_v1_allocate(); + resource->zwp_input_method_manager_v1_object = this; + + wl_resource_set_implementation(handle, &m_zwp_input_method_manager_v1_interface, resource, destroy_func); + resource->handle = handle; + zwp_input_method_manager_v1_bind_resource(resource); + return resource; + } + zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::Resource::fromResource(struct ::wl_resource *resource) + { + if (DS_UNLIKELY(!resource)) + return NULL; + if (wl_resource_instance_of(resource, &::zwp_input_method_manager_v1_interface, &m_zwp_input_method_manager_v1_interface)) + return static_cast(wl_resource_get_user_data(resource)); + return NULL; + } + + const struct ::zwp_input_method_manager_v1_interface zwp_input_method_manager_v1::m_zwp_input_method_manager_v1_interface = { + zwp_input_method_manager_v1::handle_set_transient_for + }; + + void zwp_input_method_manager_v1::zwp_input_method_manager_v1_set_transient_for(Resource *, uint32_t , uint32_t ) + { + } + + + void zwp_input_method_manager_v1::handle_set_transient_for( + ::wl_client *client, + struct wl_resource *resource, + uint32_t parent_pid, + uint32_t child_pid) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->zwp_input_method_manager_v1_object)->zwp_input_method_manager_v1_set_transient_for( + r, + parent_pid, + child_pid); + } +} + +/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-input-method.h b/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.h similarity index 69% rename from src/DSWaylandServer/dswayland-server-input-method.h rename to src/DSWaylandServer/dswayland-server-input-method-unstable-v1.h index 03c49a7..42ae0b2 100644 --- a/src/DSWaylandServer/dswayland-server-input-method.h +++ b/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.h @@ -1,8 +1,8 @@ /*LCOV_EXCL_START*/ /* Protocol XML file : wayland-extension/input-method.xml */ -#ifndef __DS_INPUT_METHOD_PROTOCOL_H__ -#define __DS_INPUT_METHOD_PROTOCOL_H__ +#ifndef __DS_INPUT_METHOD_UNSTABLE_V1_PROTOCOL_H__ +#define __DS_INPUT_METHOD_UNSTABLE_V1_PROTOCOL_H__ #include "wayland-server-core.h" #include "input-method-server-protocol.h" @@ -21,24 +21,24 @@ namespace DSWaylandServer { - class wl_input_method_context + class zwp_input_method_context_v1 { public: - wl_input_method_context(struct ::wl_client *client, uint32_t id, int version); - wl_input_method_context(struct ::wl_display *display, int version); - wl_input_method_context(struct ::wl_resource *resource); - wl_input_method_context(); + zwp_input_method_context_v1(struct ::wl_client *client, uint32_t id, int version); + zwp_input_method_context_v1(struct ::wl_display *display, int version); + zwp_input_method_context_v1(struct ::wl_resource *resource); + zwp_input_method_context_v1(); - virtual ~wl_input_method_context(); + virtual ~zwp_input_method_context_v1(); class Resource { public: - Resource() : input_method_context_object(NULL), handle(NULL) {} + Resource() : zwp_input_method_context_v1_object(NULL), handle(NULL) {} virtual ~Resource() {} - wl_input_method_context *input_method_context_object; - wl_input_method_context *object() { return input_method_context_object; } + zwp_input_method_context_v1 *zwp_input_method_context_v1_object; + zwp_input_method_context_v1 *object() { return zwp_input_method_context_v1_object; } struct ::wl_resource *handle; struct ::wl_client *client() const { return wl_resource_get_client(handle); } @@ -69,6 +69,8 @@ namespace DSWaylandServer { static int interfaceVersion() { return interface()->version; } + void send_surrounding_text(const std::string &text, uint32_t cursor, uint32_t anchor); + void send_surrounding_text(struct ::wl_resource *resource, const std::string &text, uint32_t cursor, uint32_t anchor); void send_reset(); void send_reset(struct ::wl_resource *resource); void send_content_type(uint32_t hint, uint32_t purpose); @@ -107,40 +109,40 @@ namespace DSWaylandServer { void send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled); protected: - virtual Resource *input_method_context_allocate(); - - virtual void input_method_context_bind_resource(Resource *resource); - virtual void input_method_context_destroy_resource(Resource *resource); - - virtual void input_method_context_destroy(Resource *resource); - virtual void input_method_context_commit_string(Resource *resource, uint32_t serial, const std::string &text); - virtual void input_method_context_preedit_string(Resource *resource, uint32_t serial, const std::string &text, const std::string &commit); - virtual void input_method_context_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style); - virtual void input_method_context_preedit_cursor(Resource *resource, int32_t index); - virtual void input_method_context_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length); - virtual void input_method_context_cursor_position(Resource *resource, int32_t index, int32_t anchor); - virtual void input_method_context_modifiers_map(Resource *resource, struct ::wl_array *map); - virtual void input_method_context_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers); - virtual void input_method_context_grab_keyboard(Resource *resource, uint32_t keyboard); - virtual void input_method_context_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); - virtual void input_method_context_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); - virtual void input_method_context_language(Resource *resource, uint32_t serial, const std::string &language); - virtual void input_method_context_text_direction(Resource *resource, uint32_t serial, uint32_t direction); - virtual void input_method_context_selection_region(Resource *resource, uint32_t serial, int32_t start, int32_t end); - virtual void input_method_context_private_command(Resource *resource, uint32_t serial, const std::string &command); - virtual void input_method_context_update_input_panel_data(Resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length); - virtual void input_method_context_hide_input_panel(Resource *resource, uint32_t serial); - virtual void input_method_context_get_selection_text(Resource *resource, int32_t fd); - virtual void input_method_context_get_surrounding_text(Resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd); - virtual void input_method_context_filter_key_event_done(Resource *resource, uint32_t serial, uint32_t state); - virtual void input_method_context_update_ise_geometry(Resource *resource, uint32_t serial, uint32_t x, uint32_t y, uint32_t width, uint32_t height); - virtual void input_method_context_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit); - virtual void input_method_context_input_panel_event(Resource *resource, uint32_t serial, uint32_t event_type, uint32_t value); - virtual void input_method_context_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types); - virtual void input_method_context_update_candidate_state(Resource *resource, uint32_t state); - virtual void input_method_context_reshow_input_panel(Resource *resource); - virtual void input_method_context_set_floating_panel(Resource *resource, uint32_t state); - virtual void input_method_context_set_floating_drag_enabled(Resource *resource, uint32_t enabled); + virtual Resource *zwp_input_method_context_v1_allocate(); + + virtual void zwp_input_method_context_v1_bind_resource(Resource *resource); + virtual void zwp_input_method_context_v1_destroy_resource(Resource *resource); + + virtual void zwp_input_method_context_v1_destroy(Resource *resource); + virtual void zwp_input_method_context_v1_commit_string(Resource *resource, uint32_t serial, const std::string &text); + virtual void zwp_input_method_context_v1_preedit_string(Resource *resource, uint32_t serial, const std::string &text, const std::string &commit); + virtual void zwp_input_method_context_v1_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style); + virtual void zwp_input_method_context_v1_preedit_cursor(Resource *resource, int32_t index); + virtual void zwp_input_method_context_v1_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length); + virtual void zwp_input_method_context_v1_cursor_position(Resource *resource, int32_t index, int32_t anchor); + virtual void zwp_input_method_context_v1_modifiers_map(Resource *resource, struct ::wl_array *map); + virtual void zwp_input_method_context_v1_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers); + virtual void zwp_input_method_context_v1_grab_keyboard(Resource *resource, uint32_t keyboard); + virtual void zwp_input_method_context_v1_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); + virtual void zwp_input_method_context_v1_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); + virtual void zwp_input_method_context_v1_language(Resource *resource, uint32_t serial, const std::string &language); + virtual void zwp_input_method_context_v1_text_direction(Resource *resource, uint32_t serial, uint32_t direction); + virtual void zwp_input_method_context_v1_selection_region(Resource *resource, uint32_t serial, int32_t start, int32_t end); + virtual void zwp_input_method_context_v1_private_command(Resource *resource, uint32_t serial, const std::string &command); + virtual void zwp_input_method_context_v1_update_input_panel_data(Resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length); + virtual void zwp_input_method_context_v1_hide_input_panel(Resource *resource, uint32_t serial); + virtual void zwp_input_method_context_v1_get_selection_text(Resource *resource, int32_t fd); + virtual void zwp_input_method_context_v1_get_surrounding_text(Resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd); + virtual void zwp_input_method_context_v1_filter_key_event_done(Resource *resource, uint32_t serial, uint32_t state); + virtual void zwp_input_method_context_v1_update_ise_geometry(Resource *resource, uint32_t serial, uint32_t x, uint32_t y, uint32_t width, uint32_t height); + virtual void zwp_input_method_context_v1_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit); + virtual void zwp_input_method_context_v1_input_panel_event(Resource *resource, uint32_t serial, uint32_t event_type, uint32_t value); + virtual void zwp_input_method_context_v1_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types); + virtual void zwp_input_method_context_v1_update_candidate_state(Resource *resource, uint32_t state); + virtual void zwp_input_method_context_v1_reshow_input_panel(Resource *resource); + virtual void zwp_input_method_context_v1_set_floating_panel(Resource *resource, uint32_t state); + virtual void zwp_input_method_context_v1_set_floating_drag_enabled(Resource *resource, uint32_t enabled); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -150,7 +152,7 @@ namespace DSWaylandServer { Resource *bind(struct ::wl_client *client, uint32_t id, int version); Resource *bind(struct ::wl_resource *handle); - static const struct ::wl_input_method_context_interface m_wl_input_method_context_interface; + static const struct ::zwp_input_method_context_v1_interface m_zwp_input_method_context_v1_interface; static void handle_destroy( ::wl_client *client, @@ -314,30 +316,30 @@ namespace DSWaylandServer { struct ::wl_global *m_global; uint32_t m_globalVersion; struct DisplayDestroyedListener : ::wl_listener { - wl_input_method_context *parent; + zwp_input_method_context_v1 *parent; DisplayDestroyedListener(): parent(NULL) {} }; DisplayDestroyedListener m_displayDestroyedListener; }; - class wl_input_method + class zwp_input_method_v1 { public: - wl_input_method(struct ::wl_client *client, uint32_t id, int version); - wl_input_method(struct ::wl_display *display, int version); - wl_input_method(struct ::wl_resource *resource); - wl_input_method(); + zwp_input_method_v1(struct ::wl_client *client, uint32_t id, int version); + zwp_input_method_v1(struct ::wl_display *display, int version); + zwp_input_method_v1(struct ::wl_resource *resource); + zwp_input_method_v1(); - virtual ~wl_input_method(); + virtual ~zwp_input_method_v1(); class Resource { public: - Resource() : input_method_object(NULL), handle(NULL) {} + Resource() : zwp_input_method_v1_object(NULL), handle(NULL) {} virtual ~Resource() {} - wl_input_method *input_method_object; - wl_input_method *object() { return input_method_object; } + zwp_input_method_v1 *zwp_input_method_v1_object; + zwp_input_method_v1 *object() { return zwp_input_method_v1_object; } struct ::wl_resource *handle; struct ::wl_client *client() const { return wl_resource_get_client(handle); } @@ -368,22 +370,28 @@ namespace DSWaylandServer { static int interfaceVersion() { return interface()->version; } - void send_activate(struct ::wl_resource *id, uint32_t text_input_id, uint32_t focus_in_event); - void send_activate(struct ::wl_resource *resource, struct ::wl_resource *id, uint32_t text_input_id, uint32_t focus_in_event); - void send_deactivate(struct ::wl_resource *context, uint32_t focus_out_event); - void send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t focus_out_event); + void send_activate(struct ::wl_resource *id); + void send_activate(struct ::wl_resource *resource, struct ::wl_resource *id); + void send_deactivate(struct ::wl_resource *context); + void send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context); void send_destroy(struct ::wl_resource *context); void send_destroy(struct ::wl_resource *resource, struct ::wl_resource *context); void send_show_input_panel(struct ::wl_resource *context, uint32_t degree); void send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t degree); void send_hide_input_panel(struct ::wl_resource *context); void send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context); + void send_open_connection(struct ::wl_resource *context); + void send_open_connection(struct ::wl_resource *resource, struct ::wl_resource *context); + void send_close_connection(struct ::wl_resource *context); + void send_close_connection(struct ::wl_resource *resource, struct ::wl_resource *context); + void send_set_text_input_id(struct ::wl_resource *context, uint32_t text_input_id); + void send_set_text_input_id(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t text_input_id); protected: - virtual Resource *input_method_allocate(); + virtual Resource *zwp_input_method_v1_allocate(); - virtual void input_method_bind_resource(Resource *resource); - virtual void input_method_destroy_resource(Resource *resource); + virtual void zwp_input_method_v1_bind_resource(Resource *resource); + virtual void zwp_input_method_v1_destroy_resource(Resource *resource); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -398,30 +406,30 @@ namespace DSWaylandServer { struct ::wl_global *m_global; uint32_t m_globalVersion; struct DisplayDestroyedListener : ::wl_listener { - wl_input_method *parent; + zwp_input_method_v1 *parent; DisplayDestroyedListener(): parent(NULL) {} }; DisplayDestroyedListener m_displayDestroyedListener; }; - class wl_input_panel + class zwp_input_panel_v1 { public: - wl_input_panel(struct ::wl_client *client, uint32_t id, int version); - wl_input_panel(struct ::wl_display *display, int version); - wl_input_panel(struct ::wl_resource *resource); - wl_input_panel(); + zwp_input_panel_v1(struct ::wl_client *client, uint32_t id, int version); + zwp_input_panel_v1(struct ::wl_display *display, int version); + zwp_input_panel_v1(struct ::wl_resource *resource); + zwp_input_panel_v1(); - virtual ~wl_input_panel(); + virtual ~zwp_input_panel_v1(); class Resource { public: - Resource() : input_panel_object(NULL), handle(NULL) {} + Resource() : zwp_input_panel_v1_object(NULL), handle(NULL) {} virtual ~Resource() {} - wl_input_panel *input_panel_object; - wl_input_panel *object() { return input_panel_object; } + zwp_input_panel_v1 *zwp_input_panel_v1_object; + zwp_input_panel_v1 *object() { return zwp_input_panel_v1_object; } struct ::wl_resource *handle; struct ::wl_client *client() const { return wl_resource_get_client(handle); } @@ -453,12 +461,12 @@ namespace DSWaylandServer { protected: - virtual Resource *input_panel_allocate(); + virtual Resource *zwp_input_panel_v1_allocate(); - virtual void input_panel_bind_resource(Resource *resource); - virtual void input_panel_destroy_resource(Resource *resource); + virtual void zwp_input_panel_v1_bind_resource(Resource *resource); + virtual void zwp_input_panel_v1_destroy_resource(Resource *resource); - virtual void input_panel_get_input_panel_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); + virtual void zwp_input_panel_v1_get_input_panel_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -468,7 +476,7 @@ namespace DSWaylandServer { Resource *bind(struct ::wl_client *client, uint32_t id, int version); Resource *bind(struct ::wl_resource *handle); - static const struct ::wl_input_panel_interface m_wl_input_panel_interface; + static const struct ::zwp_input_panel_v1_interface m_zwp_input_panel_v1_interface; static void handle_get_input_panel_surface( ::wl_client *client, @@ -481,30 +489,30 @@ namespace DSWaylandServer { struct ::wl_global *m_global; uint32_t m_globalVersion; struct DisplayDestroyedListener : ::wl_listener { - wl_input_panel *parent; + zwp_input_panel_v1 *parent; DisplayDestroyedListener(): parent(NULL) {} }; DisplayDestroyedListener m_displayDestroyedListener; }; - class wl_input_panel_surface + class zwp_input_panel_surface_v1 { public: - wl_input_panel_surface(struct ::wl_client *client, uint32_t id, int version); - wl_input_panel_surface(struct ::wl_display *display, int version); - wl_input_panel_surface(struct ::wl_resource *resource); - wl_input_panel_surface(); + zwp_input_panel_surface_v1(struct ::wl_client *client, uint32_t id, int version); + zwp_input_panel_surface_v1(struct ::wl_display *display, int version); + zwp_input_panel_surface_v1(struct ::wl_resource *resource); + zwp_input_panel_surface_v1(); - virtual ~wl_input_panel_surface(); + virtual ~zwp_input_panel_surface_v1(); class Resource { public: - Resource() : input_panel_surface_object(NULL), handle(NULL) {} + Resource() : zwp_input_panel_surface_v1_object(NULL), handle(NULL) {} virtual ~Resource() {} - wl_input_panel_surface *input_panel_surface_object; - wl_input_panel_surface *object() { return input_panel_surface_object; } + zwp_input_panel_surface_v1 *zwp_input_panel_surface_v1_object; + zwp_input_panel_surface_v1 *object() { return zwp_input_panel_surface_v1_object; } struct ::wl_resource *handle; struct ::wl_client *client() const { return wl_resource_get_client(handle); } @@ -540,14 +548,14 @@ namespace DSWaylandServer { }; protected: - virtual Resource *input_panel_surface_allocate(); + virtual Resource *zwp_input_panel_surface_v1_allocate(); - virtual void input_panel_surface_bind_resource(Resource *resource); - virtual void input_panel_surface_destroy_resource(Resource *resource); + virtual void zwp_input_panel_surface_v1_bind_resource(Resource *resource); + virtual void zwp_input_panel_surface_v1_destroy_resource(Resource *resource); - virtual void input_panel_surface_set_toplevel(Resource *resource, struct ::wl_resource *output, uint32_t position); - virtual void input_panel_surface_set_overlay_panel(Resource *resource); - virtual void input_panel_surface_set_ready(Resource *resource, uint32_t state); + virtual void zwp_input_panel_surface_v1_set_toplevel(Resource *resource, struct ::wl_resource *output, uint32_t position); + virtual void zwp_input_panel_surface_v1_set_overlay_panel(Resource *resource); + virtual void zwp_input_panel_surface_v1_set_ready(Resource *resource, uint32_t state); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -557,7 +565,7 @@ namespace DSWaylandServer { Resource *bind(struct ::wl_client *client, uint32_t id, int version); Resource *bind(struct ::wl_resource *handle); - static const struct ::wl_input_panel_surface_interface m_wl_input_panel_surface_interface; + static const struct ::zwp_input_panel_surface_v1_interface m_zwp_input_panel_surface_v1_interface; static void handle_set_toplevel( ::wl_client *client, @@ -577,30 +585,30 @@ namespace DSWaylandServer { struct ::wl_global *m_global; uint32_t m_globalVersion; struct DisplayDestroyedListener : ::wl_listener { - wl_input_panel_surface *parent; + zwp_input_panel_surface_v1 *parent; DisplayDestroyedListener(): parent(NULL) {} }; DisplayDestroyedListener m_displayDestroyedListener; }; - class wl_input_method_manager + class zwp_input_method_manager_v1 { public: - wl_input_method_manager(struct ::wl_client *client, uint32_t id, int version); - wl_input_method_manager(struct ::wl_display *display, int version); - wl_input_method_manager(struct ::wl_resource *resource); - wl_input_method_manager(); + zwp_input_method_manager_v1(struct ::wl_client *client, uint32_t id, int version); + zwp_input_method_manager_v1(struct ::wl_display *display, int version); + zwp_input_method_manager_v1(struct ::wl_resource *resource); + zwp_input_method_manager_v1(); - virtual ~wl_input_method_manager(); + virtual ~zwp_input_method_manager_v1(); class Resource { public: - Resource() : input_method_manager_object(NULL), handle(NULL) {} + Resource() : zwp_input_method_manager_v1_object(NULL), handle(NULL) {} virtual ~Resource() {} - wl_input_method_manager *input_method_manager_object; - wl_input_method_manager *object() { return input_method_manager_object; } + zwp_input_method_manager_v1 *zwp_input_method_manager_v1_object; + zwp_input_method_manager_v1 *object() { return zwp_input_method_manager_v1_object; } struct ::wl_resource *handle; struct ::wl_client *client() const { return wl_resource_get_client(handle); } @@ -632,12 +640,12 @@ namespace DSWaylandServer { protected: - virtual Resource *input_method_manager_allocate(); + virtual Resource *zwp_input_method_manager_v1_allocate(); - virtual void input_method_manager_bind_resource(Resource *resource); - virtual void input_method_manager_destroy_resource(Resource *resource); + virtual void zwp_input_method_manager_v1_bind_resource(Resource *resource); + virtual void zwp_input_method_manager_v1_destroy_resource(Resource *resource); - virtual void input_method_manager_set_transient_for(Resource *resource, uint32_t parent_pid, uint32_t child_pid); + virtual void zwp_input_method_manager_v1_set_transient_for(Resource *resource, uint32_t parent_pid, uint32_t child_pid); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -647,7 +655,7 @@ namespace DSWaylandServer { Resource *bind(struct ::wl_client *client, uint32_t id, int version); Resource *bind(struct ::wl_resource *handle); - static const struct ::wl_input_method_manager_interface m_wl_input_method_manager_interface; + static const struct ::zwp_input_method_manager_v1_interface m_zwp_input_method_manager_v1_interface; static void handle_set_transient_for( ::wl_client *client, @@ -660,7 +668,7 @@ namespace DSWaylandServer { struct ::wl_global *m_global; uint32_t m_globalVersion; struct DisplayDestroyedListener : ::wl_listener { - wl_input_method_manager *parent; + zwp_input_method_manager_v1 *parent; DisplayDestroyedListener(): parent(NULL) {} }; DisplayDestroyedListener m_displayDestroyedListener; @@ -668,4 +676,4 @@ namespace DSWaylandServer { } #endif -/*LCOV_EXCL_STOP*/ +/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-input-method.cpp b/src/DSWaylandServer/dswayland-server-input-method.cpp deleted file mode 100644 index 005ffd1..0000000 --- a/src/DSWaylandServer/dswayland-server-input-method.cpp +++ /dev/null @@ -1,1970 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/input-method.xml */ - -#include "dswayland-server-input-method.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - wl_input_method_context::wl_input_method_context(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_input_method_context::wl_input_method_context(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_input_method_context::wl_input_method_context(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_input_method_context::wl_input_method_context() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_input_method_context::~wl_input_method_context() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_input_method_context::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_input_method_context::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_input_method_context::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_input_method_context::Resource *wl_input_method_context::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_input_method_context::Resource *wl_input_method_context::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_input_method_context::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_input_method_context_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_input_method_context::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_input_method_context::interface() - { - return &::wl_input_method_context_interface; - } - - wl_input_method_context::Resource *wl_input_method_context::input_method_context_allocate() - { - return new Resource; - } - - void wl_input_method_context::input_method_context_bind_resource(Resource *) - { - } - - void wl_input_method_context::input_method_context_destroy_resource(Resource *) - { - } - - void wl_input_method_context::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_input_method_context *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_input_method_context::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_input_method_context *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_input_method_context::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_input_method_context *that = resource->input_method_context_object; - that->m_resource_map.erase(resource->client()); - that->input_method_context_destroy_resource(resource); - delete resource; - } - - wl_input_method_context::Resource *wl_input_method_context::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_method_context_interface, version, id); - return bind(handle); - } - - wl_input_method_context::Resource *wl_input_method_context::bind(struct ::wl_resource *handle) - { - Resource *resource = input_method_context_allocate(); - resource->input_method_context_object = this; - - wl_resource_set_implementation(handle, &m_wl_input_method_context_interface, resource, destroy_func); - resource->handle = handle; - input_method_context_bind_resource(resource); - return resource; - } - wl_input_method_context::Resource *wl_input_method_context::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_input_method_context_interface, &m_wl_input_method_context_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_input_method_context_interface wl_input_method_context::m_wl_input_method_context_interface = { - wl_input_method_context::handle_destroy, - wl_input_method_context::handle_commit_string, - wl_input_method_context::handle_preedit_string, - wl_input_method_context::handle_preedit_styling, - wl_input_method_context::handle_preedit_cursor, - wl_input_method_context::handle_delete_surrounding_text, - wl_input_method_context::handle_cursor_position, - wl_input_method_context::handle_modifiers_map, - wl_input_method_context::handle_keysym, - wl_input_method_context::handle_grab_keyboard, - wl_input_method_context::handle_key, - wl_input_method_context::handle_modifiers, - wl_input_method_context::handle_language, - wl_input_method_context::handle_text_direction, - wl_input_method_context::handle_selection_region, - wl_input_method_context::handle_private_command, - wl_input_method_context::handle_update_input_panel_data, - wl_input_method_context::handle_hide_input_panel, - wl_input_method_context::handle_get_selection_text, - wl_input_method_context::handle_get_surrounding_text, - wl_input_method_context::handle_filter_key_event_done, - wl_input_method_context::handle_update_ise_geometry, - wl_input_method_context::handle_recapture_string, - wl_input_method_context::handle_input_panel_event, - wl_input_method_context::handle_commit_content, - wl_input_method_context::handle_update_candidate_state, - wl_input_method_context::handle_reshow_input_panel, - wl_input_method_context::handle_set_floating_panel, - wl_input_method_context::handle_set_floating_drag_enabled - }; - - void wl_input_method_context::input_method_context_destroy(Resource *) - { - } - - void wl_input_method_context::input_method_context_commit_string(Resource *, uint32_t , const std::string &) - { - } - - void wl_input_method_context::input_method_context_preedit_string(Resource *, uint32_t , const std::string &, const std::string &) - { - } - - void wl_input_method_context::input_method_context_preedit_styling(Resource *, uint32_t , uint32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_preedit_cursor(Resource *, int32_t ) - { - } - - void wl_input_method_context::input_method_context_delete_surrounding_text(Resource *, int32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_cursor_position(Resource *, int32_t , int32_t ) - { - } - - void wl_input_method_context::input_method_context_modifiers_map(Resource *, struct ::wl_array *) - { - } - - void wl_input_method_context::input_method_context_keysym(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_grab_keyboard(Resource *, uint32_t) - { - } - - void wl_input_method_context::input_method_context_key(Resource *, uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_modifiers(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_language(Resource *, uint32_t , const std::string &) - { - } - - void wl_input_method_context::input_method_context_text_direction(Resource *, uint32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_selection_region(Resource *, uint32_t , int32_t , int32_t ) - { - } - - void wl_input_method_context::input_method_context_private_command(Resource *, uint32_t , const std::string &) - { - } - - void wl_input_method_context::input_method_context_update_input_panel_data(Resource *, uint32_t , const std::string &, uint32_t ) - { - } - - void wl_input_method_context::input_method_context_hide_input_panel(Resource *, uint32_t ) - { - } - - void wl_input_method_context::input_method_context_get_selection_text(Resource *, int32_t ) - { - } - - void wl_input_method_context::input_method_context_get_surrounding_text(Resource *, uint32_t , uint32_t , int32_t ) - { - } - - void wl_input_method_context::input_method_context_filter_key_event_done(Resource *, uint32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_update_ise_geometry(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_recapture_string(Resource *, uint32_t , int32_t , uint32_t , const std::string &, const std::string &, const std::string &) - { - } - - void wl_input_method_context::input_method_context_input_panel_event(Resource *, uint32_t , uint32_t , uint32_t ) - { - } - - void wl_input_method_context::input_method_context_commit_content(Resource *, uint32_t , const std::string &, const std::string &, const std::string &) - { - } - - void wl_input_method_context::input_method_context_update_candidate_state(Resource *, uint32_t ) - { - } - - void wl_input_method_context::input_method_context_reshow_input_panel(Resource *) - { - } - - void wl_input_method_context::input_method_context_set_floating_panel(Resource *, uint32_t ) - { - } - - void wl_input_method_context::input_method_context_set_floating_drag_enabled(Resource *, uint32_t ) - { - } - - - void wl_input_method_context::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_destroy( - r); - } - - void wl_input_method_context::handle_commit_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *text) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_commit_string( - r, - serial, - std::string(text)); - } - - void wl_input_method_context::handle_preedit_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *text, - const char *commit) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_preedit_string( - r, - serial, - std::string(text), - std::string(commit)); - } - - void wl_input_method_context::handle_preedit_styling( - ::wl_client *client, - struct wl_resource *resource, - uint32_t index, - uint32_t length, - uint32_t style) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_preedit_styling( - r, - index, - length, - style); - } - - void wl_input_method_context::handle_preedit_cursor( - ::wl_client *client, - struct wl_resource *resource, - int32_t index) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_preedit_cursor( - r, - index); - } - - void wl_input_method_context::handle_delete_surrounding_text( - ::wl_client *client, - struct wl_resource *resource, - int32_t index, - uint32_t length) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_delete_surrounding_text( - r, - index, - length); - } - - void wl_input_method_context::handle_cursor_position( - ::wl_client *client, - struct wl_resource *resource, - int32_t index, - int32_t anchor) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_cursor_position( - r, - index, - anchor); - } - - void wl_input_method_context::handle_modifiers_map( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_array *map) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_modifiers_map( - r, - map); - } - - void wl_input_method_context::handle_keysym( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t time, - uint32_t sym, - uint32_t state, - uint32_t modifiers) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_keysym( - r, - serial, - time, - sym, - state, - modifiers); - } - - void wl_input_method_context::handle_grab_keyboard( - ::wl_client *client, - struct wl_resource *resource, - uint32_t keyboard) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_grab_keyboard( - r, - keyboard); - } - - void wl_input_method_context::handle_key( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t time, - uint32_t key, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_key( - r, - serial, - time, - key, - state); - } - - void wl_input_method_context::handle_modifiers( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t mods_depressed, - uint32_t mods_latched, - uint32_t mods_locked, - uint32_t group) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_modifiers( - r, - serial, - mods_depressed, - mods_latched, - mods_locked, - group); - } - - void wl_input_method_context::handle_language( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *language) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_language( - r, - serial, - std::string(language)); - } - - void wl_input_method_context::handle_text_direction( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t direction) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_text_direction( - r, - serial, - direction); - } - - void wl_input_method_context::handle_selection_region( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - int32_t start, - int32_t end) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_selection_region( - r, - serial, - start, - end); - } - - void wl_input_method_context::handle_private_command( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *command) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_private_command( - r, - serial, - std::string(command)); - } - - void wl_input_method_context::handle_update_input_panel_data( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *input_panel_data, - uint32_t input_panel_data_length) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_update_input_panel_data( - r, - serial, - std::string(input_panel_data), - input_panel_data_length); - } - - void wl_input_method_context::handle_hide_input_panel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_hide_input_panel( - r, - serial); - } - - void wl_input_method_context::handle_get_selection_text( - ::wl_client *client, - struct wl_resource *resource, - int32_t fd) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_get_selection_text( - r, - fd); - } - - void wl_input_method_context::handle_get_surrounding_text( - ::wl_client *client, - struct wl_resource *resource, - uint32_t maxlen_before, - uint32_t maxlen_after, - int32_t fd) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_get_surrounding_text( - r, - maxlen_before, - maxlen_after, - fd); - } - - void wl_input_method_context::handle_filter_key_event_done( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_filter_key_event_done( - r, - serial, - state); - } - - void wl_input_method_context::handle_update_ise_geometry( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_update_ise_geometry( - r, - serial, - x, - y, - width, - height); - } - - void wl_input_method_context::handle_recapture_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - int32_t index, - uint32_t length, - const char *preedit, - const char *preedit_commit, - const char *commit) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_recapture_string( - r, - serial, - index, - length, - std::string(preedit), - std::string(preedit_commit), - std::string(commit)); - } - - void wl_input_method_context::handle_input_panel_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t event_type, - uint32_t value) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_input_panel_event( - r, - serial, - event_type, - value); - } - - void wl_input_method_context::handle_commit_content( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *content, - const char *description, - const char *mime_types) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_commit_content( - r, - serial, - std::string(content), - std::string(description), - std::string(mime_types)); - } - - void wl_input_method_context::handle_update_candidate_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_update_candidate_state( - r, - state); - } - - void wl_input_method_context::handle_reshow_input_panel( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_reshow_input_panel( - r); - } - - void wl_input_method_context::handle_set_floating_panel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_set_floating_panel( - r, - state); - } - - void wl_input_method_context::handle_set_floating_drag_enabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t enabled) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_context_object)->input_method_context_set_floating_drag_enabled( - r, - enabled); - } - - void wl_input_method_context::send_reset() - { - DS_ASSERT_X(m_resource, "wl_input_method_context::reset", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::reset as it's not initialised"); - return; - } - send_reset( - m_resource->handle); - } - - void wl_input_method_context::send_reset(struct ::wl_resource *resource) - { - wl_input_method_context_send_reset( - resource); - } - - - void wl_input_method_context::send_content_type(uint32_t hint, uint32_t purpose) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::content_type", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::content_type as it's not initialised"); - return; - } - send_content_type( - m_resource->handle, - hint, - purpose); - } - - void wl_input_method_context::send_content_type(struct ::wl_resource *resource, uint32_t hint, uint32_t purpose) - { - wl_input_method_context_send_content_type( - resource, - hint, - purpose); - } - - - void wl_input_method_context::send_invoke_action(uint32_t button, uint32_t index) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::invoke_action", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::invoke_action as it's not initialised"); - return; - } - send_invoke_action( - m_resource->handle, - button, - index); - } - - void wl_input_method_context::send_invoke_action(struct ::wl_resource *resource, uint32_t button, uint32_t index) - { - wl_input_method_context_send_invoke_action( - resource, - button, - index); - } - - - void wl_input_method_context::send_commit_state(uint32_t serial) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::commit_state", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::commit_state as it's not initialised"); - return; - } - send_commit_state( - m_resource->handle, - serial); - } - - void wl_input_method_context::send_commit_state(struct ::wl_resource *resource, uint32_t serial) - { - wl_input_method_context_send_commit_state( - resource, - serial); - } - - - void wl_input_method_context::send_preferred_language(const std::string &language) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::preferred_language", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::preferred_language as it's not initialised"); - return; - } - send_preferred_language( - m_resource->handle, - language); - } - - void wl_input_method_context::send_preferred_language(struct ::wl_resource *resource, const std::string &language) - { - wl_input_method_context_send_preferred_language( - resource, - language.c_str()); - } - - - void wl_input_method_context::send_return_key_type(uint32_t return_key_type) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::return_key_type", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::return_key_type as it's not initialised"); - return; - } - send_return_key_type( - m_resource->handle, - return_key_type); - } - - void wl_input_method_context::send_return_key_type(struct ::wl_resource *resource, uint32_t return_key_type) - { - wl_input_method_context_send_return_key_type( - resource, - return_key_type); - } - - - void wl_input_method_context::send_return_key_disabled(uint32_t return_key_disabled) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::return_key_disabled", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::return_key_disabled as it's not initialised"); - return; - } - send_return_key_disabled( - m_resource->handle, - return_key_disabled); - } - - void wl_input_method_context::send_return_key_disabled(struct ::wl_resource *resource, uint32_t return_key_disabled) - { - wl_input_method_context_send_return_key_disabled( - resource, - return_key_disabled); - } - - - void wl_input_method_context::send_input_panel_data(const std::string &input_panel_data, uint32_t input_panel_data_length) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::input_panel_data", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::input_panel_data as it's not initialised"); - return; - } - send_input_panel_data( - m_resource->handle, - input_panel_data, - input_panel_data_length); - } - - void wl_input_method_context::send_input_panel_data(struct ::wl_resource *resource, const std::string &input_panel_data, uint32_t input_panel_data_length) - { - wl_input_method_context_send_input_panel_data( - resource, - input_panel_data.c_str(), - input_panel_data_length); - } - - - void wl_input_method_context::send_bidi_direction(uint32_t direction) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::bidi_direction", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::bidi_direction as it's not initialised"); - return; - } - send_bidi_direction( - m_resource->handle, - direction); - } - - void wl_input_method_context::send_bidi_direction(struct ::wl_resource *resource, uint32_t direction) - { - wl_input_method_context_send_bidi_direction( - resource, - direction); - } - - - void wl_input_method_context::send_cursor_position(uint32_t cursor_position) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::cursor_position", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::cursor_position as it's not initialised"); - return; - } - send_cursor_position( - m_resource->handle, - cursor_position); - } - - void wl_input_method_context::send_cursor_position(struct ::wl_resource *resource, uint32_t cursor_position) - { - wl_input_method_context_send_cursor_position( - resource, - cursor_position); - } - - - void wl_input_method_context::send_process_input_device_event(uint32_t event_type, const std::string &event_data, uint32_t event_length) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::process_input_device_event", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::process_input_device_event as it's not initialised"); - return; - } - send_process_input_device_event( - m_resource->handle, - event_type, - event_data, - event_length); - } - - void wl_input_method_context::send_process_input_device_event(struct ::wl_resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length) - { - wl_input_method_context_send_process_input_device_event( - resource, - event_type, - event_data.c_str(), - event_length); - } - - - void wl_input_method_context::send_filter_key_event(uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::filter_key_event", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::filter_key_event as it's not initialised"); - return; - } - send_filter_key_event( - m_resource->handle, - serial, - time, - keyname, - state, - modifiers, - dev_name, - dev_class, - dev_subclass, - keycode); - } - - void wl_input_method_context::send_filter_key_event(struct ::wl_resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode) - { - wl_input_method_context_send_filter_key_event( - resource, - serial, - time, - keyname.c_str(), - state, - modifiers, - dev_name.c_str(), - dev_class, - dev_subclass, - keycode); - } - - - void wl_input_method_context::send_capital_mode(uint32_t mode) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::capital_mode", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::capital_mode as it's not initialised"); - return; - } - send_capital_mode( - m_resource->handle, - mode); - } - - void wl_input_method_context::send_capital_mode(struct ::wl_resource *resource, uint32_t mode) - { - wl_input_method_context_send_capital_mode( - resource, - mode); - } - - - void wl_input_method_context::send_prediction_hint(const std::string &text) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::prediction_hint", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::prediction_hint as it's not initialised"); - return; - } - send_prediction_hint( - m_resource->handle, - text); - } - - void wl_input_method_context::send_prediction_hint(struct ::wl_resource *resource, const std::string &text) - { - wl_input_method_context_send_prediction_hint( - resource, - text.c_str()); - } - - - void wl_input_method_context::send_mime_type(const std::string &type) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::mime_type", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::mime_type as it's not initialised"); - return; - } - send_mime_type( - m_resource->handle, - type); - } - - void wl_input_method_context::send_mime_type(struct ::wl_resource *resource, const std::string &type) - { - wl_input_method_context_send_mime_type( - resource, - type.c_str()); - } - - - void wl_input_method_context::send_finalized_content(const std::string &text, uint32_t cursor_position) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::finalized_content", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::finalized_content as it's not initialised"); - return; - } - send_finalized_content( - m_resource->handle, - text, - cursor_position); - } - - void wl_input_method_context::send_finalized_content(struct ::wl_resource *resource, const std::string &text, uint32_t cursor_position) - { - wl_input_method_context_send_finalized_content( - resource, - text.c_str(), - cursor_position); - } - - - void wl_input_method_context::send_prediction_hint_data(const std::string &key, const std::string &value) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::prediction_hint_data", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::prediction_hint_data as it's not initialised"); - return; - } - send_prediction_hint_data( - m_resource->handle, - key, - value); - } - - void wl_input_method_context::send_prediction_hint_data(struct ::wl_resource *resource, const std::string &key, const std::string &value) - { - wl_input_method_context_send_prediction_hint_data( - resource, - key.c_str(), - value.c_str()); - } - - - void wl_input_method_context::send_input_panel_enabled(uint32_t enabled) - { - DS_ASSERT_X(m_resource, "wl_input_method_context::input_panel_enabled", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method_context::input_panel_enabled as it's not initialised"); - return; - } - send_input_panel_enabled( - m_resource->handle, - enabled); - } - - void wl_input_method_context::send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled) - { - wl_input_method_context_send_input_panel_enabled( - resource, - enabled); - } - - - wl_input_method::wl_input_method(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_input_method::wl_input_method(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_input_method::wl_input_method(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_input_method::wl_input_method() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_input_method::~wl_input_method() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_input_method::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_input_method::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_input_method::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_input_method::Resource *wl_input_method::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_input_method::Resource *wl_input_method::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_input_method::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_input_method_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_input_method::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_input_method::interface() - { - return &::wl_input_method_interface; - } - - wl_input_method::Resource *wl_input_method::input_method_allocate() - { - return new Resource; - } - - void wl_input_method::input_method_bind_resource(Resource *) - { - } - - void wl_input_method::input_method_destroy_resource(Resource *) - { - } - - void wl_input_method::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_input_method *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_input_method::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_input_method *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_input_method::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_input_method *that = resource->input_method_object; - that->m_resource_map.erase(resource->client()); - that->input_method_destroy_resource(resource); - delete resource; - } - - wl_input_method::Resource *wl_input_method::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_method_interface, version, id); - return bind(handle); - } - - wl_input_method::Resource *wl_input_method::bind(struct ::wl_resource *handle) - { - Resource *resource = input_method_allocate(); - resource->input_method_object = this; - - wl_resource_set_implementation(handle, NULL, resource, destroy_func); - resource->handle = handle; - input_method_bind_resource(resource); - return resource; - } - wl_input_method::Resource *wl_input_method::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_input_method_interface, NULL)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - void wl_input_method::send_activate(struct ::wl_resource *id, uint32_t text_input_id, uint32_t focus_in_event) - { - DS_ASSERT_X(m_resource, "wl_input_method::activate", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method::activate as it's not initialised"); - return; - } - send_activate( - m_resource->handle, - id, - text_input_id, - focus_in_event); - } - - void wl_input_method::send_activate(struct ::wl_resource *resource, struct ::wl_resource *id, uint32_t text_input_id, uint32_t focus_in_event) - { - wl_input_method_send_activate( - resource, - id, - text_input_id, - focus_in_event); - } - - - void wl_input_method::send_deactivate(struct ::wl_resource *context, uint32_t focus_out_event) - { - DS_ASSERT_X(m_resource, "wl_input_method::deactivate", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method::deactivate as it's not initialised"); - return; - } - send_deactivate( - m_resource->handle, - context, - focus_out_event); - } - - void wl_input_method::send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t focus_out_event) - { - wl_input_method_send_deactivate( - resource, - context, - focus_out_event); - } - - - void wl_input_method::send_destroy(struct ::wl_resource *context) - { - DS_ASSERT_X(m_resource, "wl_input_method::destroy", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method::destroy as it's not initialised"); - return; - } - send_destroy( - m_resource->handle, - context); - } - - void wl_input_method::send_destroy(struct ::wl_resource *resource, struct ::wl_resource *context) - { - wl_input_method_send_destroy( - resource, - context); - } - - - void wl_input_method::send_show_input_panel(struct ::wl_resource *context, uint32_t degree) - { - DS_ASSERT_X(m_resource, "wl_input_method::show_input_panel", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method::show_input_panel as it's not initialised"); - return; - } - send_show_input_panel( - m_resource->handle, - context, - degree); - } - - void wl_input_method::send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t degree) - { - wl_input_method_send_show_input_panel( - resource, - context, - degree); - } - - - void wl_input_method::send_hide_input_panel(struct ::wl_resource *context) - { - DS_ASSERT_X(m_resource, "wl_input_method::hide_input_panel", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_input_method::hide_input_panel as it's not initialised"); - return; - } - send_hide_input_panel( - m_resource->handle, - context); - } - - void wl_input_method::send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context) - { - wl_input_method_send_hide_input_panel( - resource, - context); - } - - - wl_input_panel::wl_input_panel(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_input_panel::wl_input_panel(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_input_panel::wl_input_panel(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_input_panel::wl_input_panel() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_input_panel::~wl_input_panel() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_input_panel::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_input_panel::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_input_panel::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_input_panel::Resource *wl_input_panel::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_input_panel::Resource *wl_input_panel::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_input_panel::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_input_panel_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_input_panel::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_input_panel::interface() - { - return &::wl_input_panel_interface; - } - - wl_input_panel::Resource *wl_input_panel::input_panel_allocate() - { - return new Resource; - } - - void wl_input_panel::input_panel_bind_resource(Resource *) - { - } - - void wl_input_panel::input_panel_destroy_resource(Resource *) - { - } - - void wl_input_panel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_input_panel *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_input_panel::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_input_panel *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_input_panel::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_input_panel *that = resource->input_panel_object; - that->m_resource_map.erase(resource->client()); - that->input_panel_destroy_resource(resource); - delete resource; - } - - wl_input_panel::Resource *wl_input_panel::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_panel_interface, version, id); - return bind(handle); - } - - wl_input_panel::Resource *wl_input_panel::bind(struct ::wl_resource *handle) - { - Resource *resource = input_panel_allocate(); - resource->input_panel_object = this; - - wl_resource_set_implementation(handle, &m_wl_input_panel_interface, resource, destroy_func); - resource->handle = handle; - input_panel_bind_resource(resource); - return resource; - } - wl_input_panel::Resource *wl_input_panel::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_input_panel_interface, &m_wl_input_panel_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_input_panel_interface wl_input_panel::m_wl_input_panel_interface = { - wl_input_panel::handle_get_input_panel_surface - }; - - void wl_input_panel::input_panel_get_input_panel_surface(Resource *, uint32_t, struct ::wl_resource *) - { - } - - - void wl_input_panel::handle_get_input_panel_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_panel_object)->input_panel_get_input_panel_surface( - r, - id, - surface); - } - - wl_input_panel_surface::wl_input_panel_surface(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_input_panel_surface::wl_input_panel_surface(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_input_panel_surface::wl_input_panel_surface(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_input_panel_surface::wl_input_panel_surface() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_input_panel_surface::~wl_input_panel_surface() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_input_panel_surface::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_input_panel_surface::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_input_panel_surface::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_input_panel_surface::Resource *wl_input_panel_surface::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_input_panel_surface::Resource *wl_input_panel_surface::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_input_panel_surface::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_input_panel_surface_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_input_panel_surface::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_input_panel_surface::interface() - { - return &::wl_input_panel_surface_interface; - } - - wl_input_panel_surface::Resource *wl_input_panel_surface::input_panel_surface_allocate() - { - return new Resource; - } - - void wl_input_panel_surface::input_panel_surface_bind_resource(Resource *) - { - } - - void wl_input_panel_surface::input_panel_surface_destroy_resource(Resource *) - { - } - - void wl_input_panel_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_input_panel_surface *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_input_panel_surface::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_input_panel_surface *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_input_panel_surface::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_input_panel_surface *that = resource->input_panel_surface_object; - that->m_resource_map.erase(resource->client()); - that->input_panel_surface_destroy_resource(resource); - delete resource; - } - - wl_input_panel_surface::Resource *wl_input_panel_surface::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_panel_surface_interface, version, id); - return bind(handle); - } - - wl_input_panel_surface::Resource *wl_input_panel_surface::bind(struct ::wl_resource *handle) - { - Resource *resource = input_panel_surface_allocate(); - resource->input_panel_surface_object = this; - - wl_resource_set_implementation(handle, &m_wl_input_panel_surface_interface, resource, destroy_func); - resource->handle = handle; - input_panel_surface_bind_resource(resource); - return resource; - } - wl_input_panel_surface::Resource *wl_input_panel_surface::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_input_panel_surface_interface, &m_wl_input_panel_surface_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_input_panel_surface_interface wl_input_panel_surface::m_wl_input_panel_surface_interface = { - wl_input_panel_surface::handle_set_toplevel, - wl_input_panel_surface::handle_set_overlay_panel, - wl_input_panel_surface::handle_set_ready - }; - - void wl_input_panel_surface::input_panel_surface_set_toplevel(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void wl_input_panel_surface::input_panel_surface_set_overlay_panel(Resource *) - { - } - - void wl_input_panel_surface::input_panel_surface_set_ready(Resource *, uint32_t ) - { - } - - - void wl_input_panel_surface::handle_set_toplevel( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output, - uint32_t position) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_panel_surface_object)->input_panel_surface_set_toplevel( - r, - output, - position); - } - - void wl_input_panel_surface::handle_set_overlay_panel( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_panel_surface_object)->input_panel_surface_set_overlay_panel( - r); - } - - void wl_input_panel_surface::handle_set_ready( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_panel_surface_object)->input_panel_surface_set_ready( - r, - state); - } - - wl_input_method_manager::wl_input_method_manager(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_input_method_manager::wl_input_method_manager(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_input_method_manager::wl_input_method_manager(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_input_method_manager::wl_input_method_manager() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_input_method_manager::~wl_input_method_manager() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_input_method_manager::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_input_method_manager::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_input_method_manager::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_input_method_manager::Resource *wl_input_method_manager::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_input_method_manager::Resource *wl_input_method_manager::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_input_method_manager::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_input_method_manager_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_input_method_manager::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_input_method_manager::interface() - { - return &::wl_input_method_manager_interface; - } - - wl_input_method_manager::Resource *wl_input_method_manager::input_method_manager_allocate() - { - return new Resource; - } - - void wl_input_method_manager::input_method_manager_bind_resource(Resource *) - { - } - - void wl_input_method_manager::input_method_manager_destroy_resource(Resource *) - { - } - - void wl_input_method_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_input_method_manager *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_input_method_manager::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_input_method_manager *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_input_method_manager::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_input_method_manager *that = resource->input_method_manager_object; - that->m_resource_map.erase(resource->client()); - that->input_method_manager_destroy_resource(resource); - delete resource; - } - - wl_input_method_manager::Resource *wl_input_method_manager::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_input_method_manager_interface, version, id); - return bind(handle); - } - - wl_input_method_manager::Resource *wl_input_method_manager::bind(struct ::wl_resource *handle) - { - Resource *resource = input_method_manager_allocate(); - resource->input_method_manager_object = this; - - wl_resource_set_implementation(handle, &m_wl_input_method_manager_interface, resource, destroy_func); - resource->handle = handle; - input_method_manager_bind_resource(resource); - return resource; - } - wl_input_method_manager::Resource *wl_input_method_manager::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_input_method_manager_interface, &m_wl_input_method_manager_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_input_method_manager_interface wl_input_method_manager::m_wl_input_method_manager_interface = { - wl_input_method_manager::handle_set_transient_for - }; - - void wl_input_method_manager::input_method_manager_set_transient_for(Resource *, uint32_t , uint32_t ) - { - } - - - void wl_input_method_manager::handle_set_transient_for( - ::wl_client *client, - struct wl_resource *resource, - uint32_t parent_pid, - uint32_t child_pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->input_method_manager_object)->input_method_manager_set_transient_for( - r, - parent_pid, - child_pid); - } -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-extension.cpp b/src/DSWaylandServer/dswayland-server-tizen-extension.cpp index 3236c91..499087a 100644 --- a/src/DSWaylandServer/dswayland-server-tizen-extension.cpp +++ b/src/DSWaylandServer/dswayland-server-tizen-extension.cpp @@ -605,7 +605,9 @@ namespace DSWaylandServer { tizen_policy::handle_has_video, tizen_policy::handle_set_appid, tizen_policy::handle_show, - tizen_policy::handle_hide + tizen_policy::handle_hide, + tizen_policy::handle_set_transient_for_below, + tizen_policy::handle_set_parent_with_below }; void tizen_policy::tizen_policy_get_visibility(Resource *, uint32_t, struct ::wl_resource *) @@ -776,6 +778,14 @@ namespace DSWaylandServer { { } + void tizen_policy::tizen_policy_set_transient_for_below(Resource *, uint32_t , uint32_t ) + { + } + + void tizen_policy::tizen_policy_set_parent_with_below(Resource *, struct ::wl_resource *, struct ::wl_resource *) + { + } + void tizen_policy::handle_get_visibility( ::wl_client *client, @@ -1327,6 +1337,34 @@ namespace DSWaylandServer { surface); } + void tizen_policy::handle_set_transient_for_below( + ::wl_client *client, + struct wl_resource *resource, + uint32_t child_id, + uint32_t parent_id) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_policy_object)->tizen_policy_set_transient_for_below( + r, + child_id, + parent_id); + } + + void tizen_policy::handle_set_parent_with_below( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *child, + struct ::wl_resource *parent) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_policy_object)->tizen_policy_set_parent_with_below( + r, + child, + parent); + } + void tizen_policy::send_conformant(struct ::wl_resource *surface, uint32_t is_conformant) { DS_ASSERT_X(m_resource, "tizen_policy::conformant", "Uninitialised resource"); @@ -1579,6 +1617,62 @@ namespace DSWaylandServer { } + void tizen_policy::send_interactive_move_done(struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h) + { + DS_ASSERT_X(m_resource, "tizen_policy::interactive_move_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_policy::interactive_move_done as it's not initialised"); + return; + } + send_interactive_move_done( + m_resource->handle, + surface, + x, + y, + w, + h); + } + + void tizen_policy::send_interactive_move_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h) + { + tizen_policy_send_interactive_move_done( + resource, + surface, + x, + y, + w, + h); + } + + + void tizen_policy::send_interactive_resize_done(struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h) + { + DS_ASSERT_X(m_resource, "tizen_policy::interactive_resize_done", "Uninitialised resource"); + if (DS_UNLIKELY(!m_resource)) { + WRN("could not call tizen_policy::interactive_resize_done as it's not initialised"); + return; + } + send_interactive_resize_done( + m_resource->handle, + surface, + x, + y, + w, + h); + } + + void tizen_policy::send_interactive_resize_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h) + { + tizen_policy_send_interactive_resize_done( + resource, + surface, + x, + y, + w, + h); + } + + tizen_visibility::tizen_visibility(struct ::wl_client *client, uint32_t id, int version) : m_resource_map() , m_resource(NULL) @@ -3802,7 +3896,8 @@ namespace DSWaylandServer { tizen_screenmirror::handle_queue, tizen_screenmirror::handle_dequeue, tizen_screenmirror::handle_start, - tizen_screenmirror::handle_stop + tizen_screenmirror::handle_stop, + tizen_screenmirror::handle_set_auto_rotation }; void tizen_screenmirror::tizen_screenmirror_destroy(Resource *) @@ -3829,6 +3924,10 @@ namespace DSWaylandServer { { } + void tizen_screenmirror::tizen_screenmirror_set_auto_rotation(Resource *, uint32_t ) + { + } + void tizen_screenmirror::handle_destroy( ::wl_client *client, @@ -3896,6 +3995,18 @@ namespace DSWaylandServer { r); } + void tizen_screenmirror::handle_set_auto_rotation( + ::wl_client *client, + struct wl_resource *resource, + uint32_t set) + { + DS_UNUSED(client); + Resource *r = Resource::fromResource(resource); + static_cast(r->tizen_screenmirror_object)->tizen_screenmirror_set_auto_rotation( + r, + set); + } + void tizen_screenmirror::send_dequeued(struct ::wl_resource *buffer) { DS_ASSERT_X(m_resource, "tizen_screenmirror::dequeued", "Uninitialised resource"); @@ -8285,4 +8396,4 @@ namespace DSWaylandServer { } } -/*LCOV_EXCL_STOP*/ +/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-tizen-extension.h b/src/DSWaylandServer/dswayland-server-tizen-extension.h index 26b8301..5dd83e3 100644 --- a/src/DSWaylandServer/dswayland-server-tizen-extension.h +++ b/src/DSWaylandServer/dswayland-server-tizen-extension.h @@ -309,6 +309,10 @@ namespace DSWaylandServer { void send_aux_message(struct ::wl_resource *resource, struct ::wl_resource *surface, const std::string &key, const std::string &value, struct ::wl_array *options); void send_conformant_region(struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial); void send_conformant_region(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial); + void send_interactive_move_done(struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h); + void send_interactive_move_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h); + void send_interactive_resize_done(struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h); + void send_interactive_resize_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h); protected: virtual Resource *tizen_policy_allocate(); @@ -358,6 +362,8 @@ namespace DSWaylandServer { virtual void tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid); virtual void tizen_policy_show(Resource *resource, struct ::wl_resource *surface); virtual void tizen_policy_hide(Resource *resource, struct ::wl_resource *surface); + virtual void tizen_policy_set_transient_for_below(Resource *resource, uint32_t child_id, uint32_t parent_id); + virtual void tizen_policy_set_parent_with_below(Resource *resource, struct ::wl_resource *child, struct ::wl_resource *parent); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -560,6 +566,16 @@ namespace DSWaylandServer { ::wl_client *client, struct wl_resource *resource, struct ::wl_resource *surface); + static void handle_set_transient_for_below( + ::wl_client *client, + struct wl_resource *resource, + uint32_t child_id, + uint32_t parent_id); + static void handle_set_parent_with_below( + ::wl_client *client, + struct wl_resource *resource, + struct ::wl_resource *child, + struct ::wl_resource *parent); std::multimap m_resource_map; Resource *m_resource; @@ -1421,6 +1437,7 @@ namespace DSWaylandServer { virtual void tizen_screenmirror_dequeue(Resource *resource, struct ::wl_resource *buffer); virtual void tizen_screenmirror_start(Resource *resource); virtual void tizen_screenmirror_stop(Resource *resource); + virtual void tizen_screenmirror_set_auto_rotation(Resource *resource, uint32_t set); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -1453,6 +1470,10 @@ namespace DSWaylandServer { static void handle_stop( ::wl_client *client, struct wl_resource *resource); + static void handle_set_auto_rotation( + ::wl_client *client, + struct wl_resource *resource, + uint32_t set); std::multimap m_resource_map; Resource *m_resource; @@ -3306,4 +3327,4 @@ namespace DSWaylandServer { } /*LCOV_EXCL_STOP*/ -#endif +#endif \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-tizen-hwc.cpp b/src/DSWaylandServer/dswayland-server-tizen-hwc.cpp index 67b13b6..f4edebf 100644 --- a/src/DSWaylandServer/dswayland-server-tizen-hwc.cpp +++ b/src/DSWaylandServer/dswayland-server-tizen-hwc.cpp @@ -182,14 +182,14 @@ namespace DSWaylandServer { const struct ::tizen_hwc_interface tizen_hwc::m_tizen_hwc_interface = { tizen_hwc::handle_destroy, - tizen_hwc::handle_commit_feedback + tizen_hwc::handle_create_commit_feedback }; void tizen_hwc::tizen_hwc_destroy(Resource *) { } - void tizen_hwc::tizen_hwc_commit_feedback(Resource *, struct ::wl_resource *, uint32_t, uint32_t ) + void tizen_hwc::tizen_hwc_create_commit_feedback(Resource *, struct ::wl_resource *, uint32_t, uint32_t ) { } @@ -204,7 +204,7 @@ namespace DSWaylandServer { r); } - void tizen_hwc::handle_commit_feedback( + void tizen_hwc::handle_create_commit_feedback( ::wl_client *client, struct wl_resource *resource, struct ::wl_resource *surface, @@ -213,7 +213,7 @@ namespace DSWaylandServer { { DS_UNUSED(client); Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_hwc_object)->tizen_hwc_commit_feedback( + static_cast(r->tizen_hwc_object)->tizen_hwc_create_commit_feedback( r, surface, id, @@ -414,4 +414,4 @@ namespace DSWaylandServer { } -/*LCOV_EXCL_STOP*/ +/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-tizen-hwc.h b/src/DSWaylandServer/dswayland-server-tizen-hwc.h index c763bac..56d196c 100644 --- a/src/DSWaylandServer/dswayland-server-tizen-hwc.h +++ b/src/DSWaylandServer/dswayland-server-tizen-hwc.h @@ -76,7 +76,7 @@ namespace DSWaylandServer { virtual void tizen_hwc_destroy_resource(Resource *resource); virtual void tizen_hwc_destroy(Resource *resource); - virtual void tizen_hwc_commit_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t id, uint32_t serial); + virtual void tizen_hwc_create_commit_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t id, uint32_t serial); private: static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); @@ -91,7 +91,7 @@ namespace DSWaylandServer { static void handle_destroy( ::wl_client *client, struct wl_resource *resource); - static void handle_commit_feedback( + static void handle_create_commit_feedback( ::wl_client *client, struct wl_resource *resource, struct ::wl_resource *surface, @@ -189,4 +189,4 @@ namespace DSWaylandServer { } #endif -/*LCOV_EXCL_STOP*/ +/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index 5b39ed4..06c2d12 100644 --- a/src/meson.build +++ b/src/meson.build @@ -98,8 +98,8 @@ libds_wayland_srcs = [ 'DSWaylandServer/dswayland-server-text.h', 'DSWaylandServer/dswayland-server-tizen-launch.cpp', 'DSWaylandServer/dswayland-server-tizen-launch.h', - 'DSWaylandServer/dswayland-server-input-method.cpp', - 'DSWaylandServer/dswayland-server-input-method.h', + 'DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp', + 'DSWaylandServer/dswayland-server-input-method-unstable-v1.h', 'DSWaylandServer/dswayland-server-tizen-policy-ext.cpp', 'DSWaylandServer/dswayland-server-tizen-policy-ext.h', 'DSWaylandServer/DSWaylandCallback.cpp', -- 2.7.4 From 6d60da1cbbd10c16bab8462b18dd608831786404 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 18 Jul 2022 13:37:26 +0900 Subject: [PATCH 10/16] Remove all legacy files The legacy libds is not used anymore. The new libds source code will be merge. Change-Id: I78ac63c3f064271f6dd4293127cb775189e6b129 --- CODEOWNERS | 9 - COPYING | 26 - README.md | 25 - data/units/display-manager.service | 15 - data/units/libds.env | 12 - meson.build | 16 - meson_options.txt | 0 packaging/libds.manifest | 5 - packaging/libds.spec | 136 - samples/exampleClient.c | 579 -- samples/exampleClientNoShellRendering.cpp | 397 - samples/exampleClientShellRendering.cpp | 430 - samples/exampleCompositor.cpp | 122 - samples/exampleObjectPimpl.cpp | 120 - samples/exampleProperty.cpp | 153 - samples/exampleSignalSlot.cpp | 137 - samples/meson.build | 60 - src/DSBase/DSRefBase.cpp | 0 src/DSBase/DSRefBase.h | 61 - src/DSBuffer/DSBufferManager.cpp | 182 - src/DSBuffer/DSBufferManager.h | 60 - src/DSBuffer/DSBufferManagerPrivate.h | 57 - src/DSBuffer/DSBufferQueueTBMImpl.cpp | 177 - src/DSBuffer/DSBufferQueueTBMImpl.h | 68 - src/DSBuffer/DSBufferRef.cpp | 46 - src/DSBuffer/DSBufferRef.h | 47 - src/DSBuffer/DSBufferTBMImpl.cpp | 140 - src/DSBuffer/DSBufferTBMImpl.h | 68 - src/DSBuffer/IDSBuffer.h | 52 - src/DSBuffer/IDSBufferQueue.h | 52 - src/DSBuffer/README.md | 14 - src/DSBuffer/plantuml/IDSBuffer.plantuml | 25 - src/DSBuffer/plantuml/IDSBufferQueue.plantuml | 47 - src/DSCallback/DSCallback.h | 66 - src/DSCanvas/DSCanvas.cpp | 112 - src/DSCanvas/DSCanvas.h | 50 - src/DSCanvas/DSCanvasPrivate.h | 53 - src/DSClient/DSClient.cpp | 139 - src/DSClient/DSClient.h | 59 - src/DSClient/DSClientPrivate.h | 56 - src/DSCompositor/DSCompositor.cpp | 179 - src/DSCompositor/DSCompositor.h | 58 - src/DSCompositor/DSCompositorPrivate.h | 80 - src/DSCore/DSCore.h | 97 - src/DSCore/DSStruct.h | 68 - src/DSDebug/DSDebugLog.cpp | 112 - src/DSDebug/DSDebugLog.h | 90 - src/DSDisplayArea/DSDisplayArea.cpp | 156 - src/DSDisplayArea/DSDisplayArea.h | 49 - src/DSDisplayArea/DSDisplayAreaPrivate.h | 71 - src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp | 289 - src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h | 64 - .../DSDisplayDeviceHWCWindowTDMImpl.cpp | 58 - .../DSDisplayDeviceHWCWindowTDMImpl.h | 51 - .../DSDisplayDeviceHWCWindowTDMTargetImpl.cpp | 129 - .../DSDisplayDeviceHWCWindowTDMTargetImpl.h | 61 - .../DSDisplayDeviceOutputModeTDMImpl.cpp | 64 - .../DSDisplayDeviceOutputModeTDMImpl.h | 52 - .../DSDisplayDeviceOutputTDMImpl.cpp | 316 - src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h | 98 - src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp | 108 - src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h | 62 - src/DSDisplayDevice/IDSDisplayDevice.h | 44 - src/DSDisplayDevice/IDSDisplayDeviceHWC.h | 51 - src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h | 39 - src/DSDisplayDevice/IDSDisplayDeviceOutput.h | 104 - src/DSDisplayDevice/IDSDisplayDeviceOutputMode.h | 45 - src/DSEventLoop/DSEventLoop.cpp | 137 - src/DSEventLoop/DSEventLoop.h | 72 - src/DSInput/DSInput.cpp | 627 -- src/DSInput/DSInput.h | 139 - src/DSInput/DSInputEvent.h | 142 - src/DSInput/DSInputPrivate.h | 58 - src/DSInput/DSLibinput.cpp | 333 - src/DSInput/DSLibinput.h | 77 - src/DSObject/DSObject.cpp | 73 - src/DSObject/DSObject.h | 66 - src/DSObject/DSObjectPrivate.cpp | 107 - src/DSObject/DSObjectPrivate.h | 74 - src/DSObject/IDSObjectObserver.h | 41 - src/DSOutput/DSOutputImpl.cpp | 90 - src/DSOutput/DSOutputImpl.h | 53 - src/DSOutput/IDSOutput.h | 42 - src/DSOutput/README.md | 14 - src/DSPolicyArea/DSPolicyArea.cpp | 125 - src/DSPolicyArea/DSPolicyArea.h | 50 - src/DSPolicyArea/DSPolicyAreaPrivate.h | 56 - src/DSProperty/DSProperty.cpp | 81 - src/DSProperty/DSProperty.h | 84 - src/DSProperty/DSPropertyPrivate.cpp | 96 - src/DSProperty/DSPropertyPrivate.h | 77 - src/DSRender/DSRenderEngineDaliImpl.cpp | 89 - src/DSRender/DSRenderEngineDaliImpl.h | 60 - src/DSRender/DSRenderEngineEcoreEvasImpl.cpp | 84 - src/DSRender/DSRenderEngineEcoreEvasImpl.h | 52 - src/DSRender/DSRenderView.cpp | 35 - src/DSRender/DSRenderView.h | 52 - src/DSRender/DSRenderViewDaliImpl.cpp | 184 - src/DSRender/DSRenderViewDaliImpl.h | 67 - src/DSRender/DSRenderViewEcoreEvasImpl.cpp | 84 - src/DSRender/DSRenderViewEcoreEvasImpl.h | 56 - src/DSRender/IDSRenderEngine.h | 43 - src/DSRender/README.md | 18 - src/DSRender/plantuml/IDSRenderEngine.plantuml | 33 - src/DSSeat/DSKeyboard.cpp | 170 - src/DSSeat/DSKeyboard.h | 68 - src/DSSeat/DSPointer.cpp | 207 - src/DSSeat/DSPointer.h | 66 - src/DSSeat/DSSeat.cpp | 686 -- src/DSSeat/DSSeat.h | 123 - src/DSSeat/DSTouch.cpp | 168 - src/DSSeat/DSTouch.h | 64 - src/DSSignal/DSSignal.cpp | 38 - src/DSSignal/DSSignal.h | 144 - src/DSSignal/DSSignalBroker.cpp | 75 - src/DSSignal/DSSignalBroker.h | 199 - src/DSTextInput/DSTextInput.cpp | 323 - src/DSTextInput/DSTextInput.h | 48 - src/DSTextInput/DSTextInputPrivate.h | 128 - src/DSTizenAppinfo/DSTizenAppinfo.cpp | 91 - src/DSTizenAppinfo/DSTizenAppinfo.h | 60 - src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp | 214 - src/DSTizenAppinfo/DSTizenAppinfoMgr.h | 65 - src/DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h | 53 - src/DSTraceInfo/DSTraceInfo.cpp | 131 - src/DSTraceInfo/DSTraceInfo.h | 64 - src/DSUtil/DSUtilSocket.cpp | 252 - src/DSUtil/DSUtilSocket.h | 54 - src/DSWaylandExtension/DSWaylandExtension.cpp | 186 - src/DSWaylandExtension/DSWaylandExtension.h | 54 - src/DSWaylandExtension/DSWaylandExtensionPrivate.h | 69 - src/DSWaylandServer/DSWaylandBuffer.cpp | 66 - src/DSWaylandServer/DSWaylandBuffer.h | 49 - src/DSWaylandServer/DSWaylandBufferPrivate.h | 51 - src/DSWaylandServer/DSWaylandCallback.cpp | 58 - src/DSWaylandServer/DSWaylandCallback.h | 57 - src/DSWaylandServer/DSWaylandCallbackPrivate.h | 50 - src/DSWaylandServer/DSWaylandClient.cpp | 191 - src/DSWaylandServer/DSWaylandClient.h | 63 - src/DSWaylandServer/DSWaylandClientPrivate.h | 64 - src/DSWaylandServer/DSWaylandCompositor.cpp | 570 -- src/DSWaylandServer/DSWaylandCompositor.h | 104 - src/DSWaylandServer/DSWaylandCompositorPrivate.h | 117 - src/DSWaylandServer/DSWaylandInputMethod.cpp | 966 --- src/DSWaylandServer/DSWaylandInputMethod.h | 113 - src/DSWaylandServer/DSWaylandInputMethodContext.h | 74 - .../DSWaylandInputMethodContextPrivate.h | 100 - src/DSWaylandServer/DSWaylandInputMethodPrivate.h | 70 - src/DSWaylandServer/DSWaylandInputPanel.cpp | 692 -- src/DSWaylandServer/DSWaylandInputPanel.h | 87 - src/DSWaylandServer/DSWaylandInputPanelPrivate.h | 56 - src/DSWaylandServer/DSWaylandInputPanelSurface.h | 66 - .../DSWaylandInputPanelSurfacePrivate.h | 79 - src/DSWaylandServer/DSWaylandKeyboard.cpp | 342 - src/DSWaylandServer/DSWaylandKeyboard.h | 68 - src/DSWaylandServer/DSWaylandKeyboardPrivate.h | 92 - src/DSWaylandServer/DSWaylandOutput.cpp | 215 - src/DSWaylandServer/DSWaylandOutput.h | 53 - src/DSWaylandServer/DSWaylandOutputPrivate.h | 77 - src/DSWaylandServer/DSWaylandPointer.cpp | 236 - src/DSWaylandServer/DSWaylandPointer.h | 66 - src/DSWaylandServer/DSWaylandPointerPrivate.h | 81 - src/DSWaylandServer/DSWaylandProtocolTrace.cpp | 1494 ---- src/DSWaylandServer/DSWaylandProtocolTrace.h | 58 - .../DSWaylandProtocolTracePrivate.h | 109 - src/DSWaylandServer/DSWaylandProtocolTraceStruct.h | 218 - src/DSWaylandServer/DSWaylandRegion.cpp | 110 - src/DSWaylandServer/DSWaylandRegion.h | 59 - src/DSWaylandServer/DSWaylandRegionPrivate.h | 59 - src/DSWaylandServer/DSWaylandSeat.cpp | 256 - src/DSWaylandServer/DSWaylandSeat.h | 84 - src/DSWaylandServer/DSWaylandSeatPrivate.h | 71 - src/DSWaylandServer/DSWaylandSurface.cpp | 314 - src/DSWaylandServer/DSWaylandSurface.h | 80 - src/DSWaylandServer/DSWaylandSurfacePrivate.h | 127 - src/DSWaylandServer/DSWaylandTextInput.cpp | 1126 --- src/DSWaylandServer/DSWaylandTextInput.h | 86 - src/DSWaylandServer/DSWaylandTextInputManager.h | 88 - .../DSWaylandTextInputManagerPrivate.h | 55 - src/DSWaylandServer/DSWaylandTextInputPrivate.h | 112 - src/DSWaylandServer/DSWaylandTizenAppinfo.cpp | 191 - src/DSWaylandServer/DSWaylandTizenAppinfo.h | 63 - src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h | 66 - src/DSWaylandServer/DSWaylandTizenIndicator.cpp | 105 - src/DSWaylandServer/DSWaylandTizenIndicator.h | 57 - .../DSWaylandTizenIndicatorPrivate.h | 61 - src/DSWaylandServer/DSWaylandTizenInputDevice.h | 56 - .../DSWaylandTizenInputDeviceManager.cpp | 210 - .../DSWaylandTizenInputDeviceManager.h | 61 - .../DSWaylandTizenInputDeviceManagerPrivate.h | 70 - .../DSWaylandTizenInputDevicePrivate.h | 55 - src/DSWaylandServer/DSWaylandTizenLaunchEffect.cpp | 137 - src/DSWaylandServer/DSWaylandTizenLaunchEffect.h | 56 - .../DSWaylandTizenLaunchEffectPrivate.h | 65 - src/DSWaylandServer/DSWaylandTizenLaunchSplash.cpp | 71 - src/DSWaylandServer/DSWaylandTizenLaunchSplash.h | 49 - .../DSWaylandTizenLaunchSplashPrivate.h | 63 - src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 426 - src/DSWaylandServer/DSWaylandTizenPolicy.h | 60 - src/DSWaylandServer/DSWaylandTizenPolicyExt.cpp | 164 - src/DSWaylandServer/DSWaylandTizenPolicyExt.h | 68 - .../DSWaylandTizenPolicyExtPrivate.h | 77 - src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h | 105 - src/DSWaylandServer/DSWaylandTizenPosition.cpp | 94 - src/DSWaylandServer/DSWaylandTizenPosition.h | 56 - .../DSWaylandTizenPositionPrivate.h | 60 - src/DSWaylandServer/DSWaylandTizenSurface.cpp | 225 - src/DSWaylandServer/DSWaylandTizenSurface.h | 68 - src/DSWaylandServer/DSWaylandTizenSurfacePrivate.h | 82 - src/DSWaylandServer/DSWaylandTizenSurfaceShm.cpp | 169 - src/DSWaylandServer/DSWaylandTizenSurfaceShm.h | 66 - .../DSWaylandTizenSurfaceShmPrivate.h | 71 - src/DSWaylandServer/DSWaylandTizenVisibility.cpp | 82 - src/DSWaylandServer/DSWaylandTizenVisibility.h | 52 - .../DSWaylandTizenVisibilityPrivate.h | 58 - src/DSWaylandServer/DSWaylandTouch.cpp | 206 - src/DSWaylandServer/DSWaylandTouch.h | 66 - src/DSWaylandServer/DSWaylandTouchPrivate.h | 80 - src/DSWaylandServer/DSWaylandZxdgShellV6.cpp | 683 -- src/DSWaylandServer/DSWaylandZxdgShellV6.h | 154 - src/DSWaylandServer/DSWaylandZxdgShellV6Private.h | 190 - src/DSWaylandServer/IDSWaylandShell.h | 68 - src/DSWaylandServer/README.md | 2 - src/DSWaylandServer/dswayland-server-eom.cpp | 439 - src/DSWaylandServer/dswayland-server-eom.h | 190 - .../dswayland-server-fullscreen-shell.cpp | 474 -- .../dswayland-server-fullscreen-shell.h | 222 - .../dswayland-server-input-method-unstable-v1.cpp | 2050 ----- .../dswayland-server-input-method-unstable-v1.h | 679 -- .../dswayland-server-presentation-time.cpp | 465 -- .../dswayland-server-presentation-time.h | 208 - src/DSWaylandServer/dswayland-server-scaler.cpp | 463 -- src/DSWaylandServer/dswayland-server-scaler.h | 226 - .../dswayland-server-screenshooter.cpp | 225 - .../dswayland-server-screenshooter.h | 112 - .../dswayland-server-text-cursor-position.cpp | 209 - .../dswayland-server-text-cursor-position.h | 110 - src/DSWaylandServer/dswayland-server-text.cpp | 1380 ---- src/DSWaylandServer/dswayland-server-text.h | 475 -- .../dswayland-server-tizen-dpms.cpp | 283 - src/DSWaylandServer/dswayland-server-tizen-dpms.h | 138 - .../dswayland-server-tizen-extension.cpp | 8399 -------------------- .../dswayland-server-tizen-extension.h | 3330 -------- src/DSWaylandServer/dswayland-server-tizen-hwc.cpp | 417 - src/DSWaylandServer/dswayland-server-tizen-hwc.h | 192 - .../dswayland-server-tizen-launch.cpp | 849 -- .../dswayland-server-tizen-launch.h | 379 - .../dswayland-server-tizen-policy-ext.cpp | 580 -- .../dswayland-server-tizen-policy-ext.h | 239 - .../dswayland-server-tizen-remote-surface.cpp | 1290 --- .../dswayland-server-tizen-remote-surface.h | 579 -- .../dswayland-server-tizen-surface.cpp | 430 - .../dswayland-server-tizen-surface.h | 199 - src/DSWaylandServer/dswayland-server-transform.cpp | 424 - src/DSWaylandServer/dswayland-server-transform.h | 206 - src/DSWaylandServer/dswayland-server-tzsh.cpp | 3852 --------- src/DSWaylandServer/dswayland-server-tzsh.h | 1684 ---- src/DSWaylandServer/dswayland-server-wayland.cpp | 5378 ------------- src/DSWaylandServer/dswayland-server-wayland.h | 2251 ------ .../dswayland-server-xdg-shell-unstable-v6.cpp | 1508 ---- .../dswayland-server-xdg-shell-unstable-v6.h | 666 -- src/DSWaylandServer/dswayland-server-xdg-shell.cpp | 1508 ---- src/DSWaylandServer/dswayland-server-xdg-shell.h | 678 -- src/DSWindow/DSWindow.cpp | 534 -- src/DSWindow/DSWindow.h | 113 - src/DSWindow/DSWindowPrivate.h | 113 - src/DSWindowManager/DSWindowManager.cpp | 599 -- src/DSWindowManager/DSWindowManager.h | 98 - src/DSWindowManager/DSWindowManagerPrivate.h | 99 - src/DSWindowShell/DSWindowShell.cpp | 386 - src/DSWindowShell/DSWindowShell.h | 128 - src/DSWindowShell/DSWindowShellPrivate.cpp | 698 -- src/DSWindowShell/DSWindowShellPrivate.h | 156 - src/DSXkb/DSXkb.cpp | 404 - src/DSXkb/DSXkb.h | 65 - src/DSXkb/DSXkbPrivate.h | 78 - src/DSZone/DSZone.cpp | 570 -- src/DSZone/DSZone.h | 141 - src/meson.build | 285 - tests/DSBufferManager-test.cpp | 52 - tests/DSBufferRef-test.cpp | 52 - tests/DSBufferTBMImpl-test.cpp | 149 - tests/DSCanvas-test.cpp | 149 - tests/DSClient-test.cpp | 151 - tests/DSCompositor-test.cpp | 95 - tests/DSDebugLog-test.cpp | 72 - tests/DSDisplayArea-test.cpp | 75 - tests/DSDisplayDeviceTDMImpl-test.cpp | 303 - tests/DSEventLoop-test.cpp | 101 - tests/DSInput-test.cpp | 433 - tests/DSKeyboard-test.cpp | 120 - tests/DSObject-test.cpp | 254 - tests/DSOutputImpl-test.cpp | 65 - tests/DSPointer-test.cpp | 114 - tests/DSPolicyArea-test.cpp | 59 - tests/DSProperty-test.cpp | 100 - tests/DSRefBase-test.cpp | 58 - tests/DSRenderEngineDaliImpl-test.cpp | 531 -- tests/DSRenderEngineEcoreEvasImpl-test.cpp | 86 - tests/DSSeat-test.cpp | 201 - tests/DSSignal-test.cpp | 102 - tests/DSSignalBroker-test.cpp | 292 - tests/DSTextInput-test.cpp | 51 - tests/DSTizenAppinfo-test.cpp | 118 - tests/DSTouch-test.cpp | 114 - tests/DSTraceInfo-test.cpp | 114 - tests/DSWaylandBuffer-test.cpp | 48 - tests/DSWaylandCallback-test.cpp | 48 - tests/DSWaylandClient-test.cpp | 159 - tests/DSWaylandCompositor-test.cpp | 265 - tests/DSWaylandExtension-test.cpp | 54 - tests/DSWaylandInputMethod-test.cpp | 657 -- tests/DSWaylandInputMethodContext-test.cpp | 294 - tests/DSWaylandInputPanel-test.cpp | 219 - tests/DSWaylandInputPanelSurface-test.cpp | 168 - tests/DSWaylandKeyboard-test.cpp | 142 - tests/DSWaylandOutput-test.cpp | 52 - tests/DSWaylandPointer-test.cpp | 105 - tests/DSWaylandProtocolTrace-test.cpp | 149 - tests/DSWaylandSeat-test.cpp | 189 - tests/DSWaylandSurface-test.cpp | 160 - tests/DSWaylandTextInput-test.cpp | 406 - tests/DSWaylandTextInputManager-test.cpp | 353 - tests/DSWaylandTizenAppinfo-test.cpp | 161 - tests/DSWaylandTizenIndicator-test.cpp | 62 - tests/DSWaylandTizenInputDevice-test.cpp | 65 - tests/DSWaylandTizenInputDeviceManager-test.cpp | 80 - tests/DSWaylandTizenLaunchEffect-test.cpp | 69 - tests/DSWaylandTizenPolicy-test.cpp | 90 - tests/DSWaylandTizenPolicyExt-test.cpp | 52 - tests/DSWaylandTizenSurface-test.cpp | 52 - tests/DSWaylandTizenSurfaceShm-test.cpp | 52 - tests/DSWaylandTouch-test.cpp | 105 - tests/DSWaylandZxdgShellV6-test.cpp | 164 - tests/DSWindow-test.cpp | 210 - tests/DSWindowManager-test.cpp | 444 -- tests/DSWindowShell-test.cpp | 539 -- tests/DSXkb-test.cpp | 161 - tests/DSZone-test.cpp | 396 - tests/libds-mock.h | 111 - tests/libds-tests.cpp | 61 - tests/libds-tests.h | 51 - tests/meson.build | 78 - 343 files changed, 86521 deletions(-) delete mode 100644 CODEOWNERS delete mode 100644 COPYING delete mode 100644 README.md delete mode 100644 data/units/display-manager.service delete mode 100644 data/units/libds.env delete mode 100644 meson.build delete mode 100644 meson_options.txt delete mode 100644 packaging/libds.manifest delete mode 100644 packaging/libds.spec delete mode 100644 samples/exampleClient.c delete mode 100644 samples/exampleClientNoShellRendering.cpp delete mode 100644 samples/exampleClientShellRendering.cpp delete mode 100644 samples/exampleCompositor.cpp delete mode 100644 samples/exampleObjectPimpl.cpp delete mode 100644 samples/exampleProperty.cpp delete mode 100644 samples/exampleSignalSlot.cpp delete mode 100644 samples/meson.build delete mode 100644 src/DSBase/DSRefBase.cpp delete mode 100644 src/DSBase/DSRefBase.h delete mode 100644 src/DSBuffer/DSBufferManager.cpp delete mode 100644 src/DSBuffer/DSBufferManager.h delete mode 100644 src/DSBuffer/DSBufferManagerPrivate.h delete mode 100644 src/DSBuffer/DSBufferQueueTBMImpl.cpp delete mode 100644 src/DSBuffer/DSBufferQueueTBMImpl.h delete mode 100644 src/DSBuffer/DSBufferRef.cpp delete mode 100644 src/DSBuffer/DSBufferRef.h delete mode 100644 src/DSBuffer/DSBufferTBMImpl.cpp delete mode 100644 src/DSBuffer/DSBufferTBMImpl.h delete mode 100644 src/DSBuffer/IDSBuffer.h delete mode 100644 src/DSBuffer/IDSBufferQueue.h delete mode 100644 src/DSBuffer/README.md delete mode 100644 src/DSBuffer/plantuml/IDSBuffer.plantuml delete mode 100755 src/DSBuffer/plantuml/IDSBufferQueue.plantuml delete mode 100644 src/DSCallback/DSCallback.h delete mode 100644 src/DSCanvas/DSCanvas.cpp delete mode 100644 src/DSCanvas/DSCanvas.h delete mode 100644 src/DSCanvas/DSCanvasPrivate.h delete mode 100644 src/DSClient/DSClient.cpp delete mode 100644 src/DSClient/DSClient.h delete mode 100644 src/DSClient/DSClientPrivate.h delete mode 100644 src/DSCompositor/DSCompositor.cpp delete mode 100644 src/DSCompositor/DSCompositor.h delete mode 100644 src/DSCompositor/DSCompositorPrivate.h delete mode 100644 src/DSCore/DSCore.h delete mode 100644 src/DSCore/DSStruct.h delete mode 100644 src/DSDebug/DSDebugLog.cpp delete mode 100644 src/DSDebug/DSDebugLog.h delete mode 100644 src/DSDisplayArea/DSDisplayArea.cpp delete mode 100644 src/DSDisplayArea/DSDisplayArea.h delete mode 100644 src/DSDisplayArea/DSDisplayAreaPrivate.h delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.cpp delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.h delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp delete mode 100644 src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h delete mode 100644 src/DSDisplayDevice/IDSDisplayDevice.h delete mode 100644 src/DSDisplayDevice/IDSDisplayDeviceHWC.h delete mode 100644 src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h delete mode 100644 src/DSDisplayDevice/IDSDisplayDeviceOutput.h delete mode 100644 src/DSDisplayDevice/IDSDisplayDeviceOutputMode.h delete mode 100644 src/DSEventLoop/DSEventLoop.cpp delete mode 100644 src/DSEventLoop/DSEventLoop.h delete mode 100644 src/DSInput/DSInput.cpp delete mode 100644 src/DSInput/DSInput.h delete mode 100644 src/DSInput/DSInputEvent.h delete mode 100644 src/DSInput/DSInputPrivate.h delete mode 100644 src/DSInput/DSLibinput.cpp delete mode 100644 src/DSInput/DSLibinput.h delete mode 100644 src/DSObject/DSObject.cpp delete mode 100644 src/DSObject/DSObject.h delete mode 100644 src/DSObject/DSObjectPrivate.cpp delete mode 100644 src/DSObject/DSObjectPrivate.h delete mode 100644 src/DSObject/IDSObjectObserver.h delete mode 100644 src/DSOutput/DSOutputImpl.cpp delete mode 100644 src/DSOutput/DSOutputImpl.h delete mode 100644 src/DSOutput/IDSOutput.h delete mode 100644 src/DSOutput/README.md delete mode 100644 src/DSPolicyArea/DSPolicyArea.cpp delete mode 100644 src/DSPolicyArea/DSPolicyArea.h delete mode 100644 src/DSPolicyArea/DSPolicyAreaPrivate.h delete mode 100644 src/DSProperty/DSProperty.cpp delete mode 100644 src/DSProperty/DSProperty.h delete mode 100644 src/DSProperty/DSPropertyPrivate.cpp delete mode 100644 src/DSProperty/DSPropertyPrivate.h delete mode 100644 src/DSRender/DSRenderEngineDaliImpl.cpp delete mode 100644 src/DSRender/DSRenderEngineDaliImpl.h delete mode 100644 src/DSRender/DSRenderEngineEcoreEvasImpl.cpp delete mode 100644 src/DSRender/DSRenderEngineEcoreEvasImpl.h delete mode 100644 src/DSRender/DSRenderView.cpp delete mode 100644 src/DSRender/DSRenderView.h delete mode 100644 src/DSRender/DSRenderViewDaliImpl.cpp delete mode 100644 src/DSRender/DSRenderViewDaliImpl.h delete mode 100644 src/DSRender/DSRenderViewEcoreEvasImpl.cpp delete mode 100644 src/DSRender/DSRenderViewEcoreEvasImpl.h delete mode 100644 src/DSRender/IDSRenderEngine.h delete mode 100644 src/DSRender/README.md delete mode 100644 src/DSRender/plantuml/IDSRenderEngine.plantuml delete mode 100644 src/DSSeat/DSKeyboard.cpp delete mode 100644 src/DSSeat/DSKeyboard.h delete mode 100644 src/DSSeat/DSPointer.cpp delete mode 100644 src/DSSeat/DSPointer.h delete mode 100644 src/DSSeat/DSSeat.cpp delete mode 100644 src/DSSeat/DSSeat.h delete mode 100644 src/DSSeat/DSTouch.cpp delete mode 100644 src/DSSeat/DSTouch.h delete mode 100644 src/DSSignal/DSSignal.cpp delete mode 100644 src/DSSignal/DSSignal.h delete mode 100644 src/DSSignal/DSSignalBroker.cpp delete mode 100644 src/DSSignal/DSSignalBroker.h delete mode 100644 src/DSTextInput/DSTextInput.cpp delete mode 100644 src/DSTextInput/DSTextInput.h delete mode 100644 src/DSTextInput/DSTextInputPrivate.h delete mode 100644 src/DSTizenAppinfo/DSTizenAppinfo.cpp delete mode 100644 src/DSTizenAppinfo/DSTizenAppinfo.h delete mode 100644 src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp delete mode 100644 src/DSTizenAppinfo/DSTizenAppinfoMgr.h delete mode 100644 src/DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h delete mode 100644 src/DSTraceInfo/DSTraceInfo.cpp delete mode 100644 src/DSTraceInfo/DSTraceInfo.h delete mode 100644 src/DSUtil/DSUtilSocket.cpp delete mode 100644 src/DSUtil/DSUtilSocket.h delete mode 100644 src/DSWaylandExtension/DSWaylandExtension.cpp delete mode 100644 src/DSWaylandExtension/DSWaylandExtension.h delete mode 100644 src/DSWaylandExtension/DSWaylandExtensionPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandBuffer.cpp delete mode 100644 src/DSWaylandServer/DSWaylandBuffer.h delete mode 100644 src/DSWaylandServer/DSWaylandBufferPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandCallback.cpp delete mode 100644 src/DSWaylandServer/DSWaylandCallback.h delete mode 100644 src/DSWaylandServer/DSWaylandCallbackPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandClient.cpp delete mode 100644 src/DSWaylandServer/DSWaylandClient.h delete mode 100644 src/DSWaylandServer/DSWaylandClientPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandCompositor.cpp delete mode 100644 src/DSWaylandServer/DSWaylandCompositor.h delete mode 100644 src/DSWaylandServer/DSWaylandCompositorPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandInputMethod.cpp delete mode 100644 src/DSWaylandServer/DSWaylandInputMethod.h delete mode 100644 src/DSWaylandServer/DSWaylandInputMethodContext.h delete mode 100644 src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandInputMethodPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandInputPanel.cpp delete mode 100644 src/DSWaylandServer/DSWaylandInputPanel.h delete mode 100644 src/DSWaylandServer/DSWaylandInputPanelPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandInputPanelSurface.h delete mode 100644 src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandKeyboard.cpp delete mode 100644 src/DSWaylandServer/DSWaylandKeyboard.h delete mode 100644 src/DSWaylandServer/DSWaylandKeyboardPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandOutput.cpp delete mode 100644 src/DSWaylandServer/DSWaylandOutput.h delete mode 100644 src/DSWaylandServer/DSWaylandOutputPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandPointer.cpp delete mode 100644 src/DSWaylandServer/DSWaylandPointer.h delete mode 100644 src/DSWaylandServer/DSWaylandPointerPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandProtocolTrace.cpp delete mode 100644 src/DSWaylandServer/DSWaylandProtocolTrace.h delete mode 100644 src/DSWaylandServer/DSWaylandProtocolTracePrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandProtocolTraceStruct.h delete mode 100644 src/DSWaylandServer/DSWaylandRegion.cpp delete mode 100644 src/DSWaylandServer/DSWaylandRegion.h delete mode 100644 src/DSWaylandServer/DSWaylandRegionPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandSeat.cpp delete mode 100644 src/DSWaylandServer/DSWaylandSeat.h delete mode 100644 src/DSWaylandServer/DSWaylandSeatPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandSurface.cpp delete mode 100644 src/DSWaylandServer/DSWaylandSurface.h delete mode 100644 src/DSWaylandServer/DSWaylandSurfacePrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTextInput.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTextInput.h delete mode 100644 src/DSWaylandServer/DSWaylandTextInputManager.h delete mode 100644 src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTextInputPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenAppinfo.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenAppinfo.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenIndicator.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenIndicator.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenIndicatorPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenInputDevice.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenInputDeviceManager.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenInputDevicePrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenLaunchEffect.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenLaunchEffect.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenLaunchEffectPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenLaunchSplash.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenLaunchSplash.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenLaunchSplashPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenPolicy.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenPolicy.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenPolicyExt.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenPolicyExt.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenPolicyExtPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenPosition.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenPosition.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenPositionPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenSurface.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenSurface.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenSurfacePrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenSurfaceShm.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenSurfaceShm.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenSurfaceShmPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenVisibility.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTizenVisibility.h delete mode 100644 src/DSWaylandServer/DSWaylandTizenVisibilityPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandTouch.cpp delete mode 100644 src/DSWaylandServer/DSWaylandTouch.h delete mode 100644 src/DSWaylandServer/DSWaylandTouchPrivate.h delete mode 100644 src/DSWaylandServer/DSWaylandZxdgShellV6.cpp delete mode 100644 src/DSWaylandServer/DSWaylandZxdgShellV6.h delete mode 100644 src/DSWaylandServer/DSWaylandZxdgShellV6Private.h delete mode 100644 src/DSWaylandServer/IDSWaylandShell.h delete mode 100644 src/DSWaylandServer/README.md delete mode 100644 src/DSWaylandServer/dswayland-server-eom.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-eom.h delete mode 100644 src/DSWaylandServer/dswayland-server-fullscreen-shell.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-fullscreen-shell.h delete mode 100644 src/DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-input-method-unstable-v1.h delete mode 100644 src/DSWaylandServer/dswayland-server-presentation-time.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-presentation-time.h delete mode 100644 src/DSWaylandServer/dswayland-server-scaler.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-scaler.h delete mode 100644 src/DSWaylandServer/dswayland-server-screenshooter.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-screenshooter.h delete mode 100644 src/DSWaylandServer/dswayland-server-text-cursor-position.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-text-cursor-position.h delete mode 100644 src/DSWaylandServer/dswayland-server-text.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-text.h delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-dpms.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-dpms.h delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-extension.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-extension.h delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-hwc.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-hwc.h delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-launch.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-launch.h delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-policy-ext.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-policy-ext.h delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-remote-surface.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-remote-surface.h delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-surface.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-tizen-surface.h delete mode 100644 src/DSWaylandServer/dswayland-server-transform.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-transform.h delete mode 100644 src/DSWaylandServer/dswayland-server-tzsh.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-tzsh.h delete mode 100644 src/DSWaylandServer/dswayland-server-wayland.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-wayland.h delete mode 100644 src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h delete mode 100644 src/DSWaylandServer/dswayland-server-xdg-shell.cpp delete mode 100644 src/DSWaylandServer/dswayland-server-xdg-shell.h delete mode 100644 src/DSWindow/DSWindow.cpp delete mode 100644 src/DSWindow/DSWindow.h delete mode 100644 src/DSWindow/DSWindowPrivate.h delete mode 100644 src/DSWindowManager/DSWindowManager.cpp delete mode 100644 src/DSWindowManager/DSWindowManager.h delete mode 100644 src/DSWindowManager/DSWindowManagerPrivate.h delete mode 100644 src/DSWindowShell/DSWindowShell.cpp delete mode 100644 src/DSWindowShell/DSWindowShell.h delete mode 100644 src/DSWindowShell/DSWindowShellPrivate.cpp delete mode 100644 src/DSWindowShell/DSWindowShellPrivate.h delete mode 100644 src/DSXkb/DSXkb.cpp delete mode 100644 src/DSXkb/DSXkb.h delete mode 100644 src/DSXkb/DSXkbPrivate.h delete mode 100644 src/DSZone/DSZone.cpp delete mode 100644 src/DSZone/DSZone.h delete mode 100644 src/meson.build delete mode 100644 tests/DSBufferManager-test.cpp delete mode 100644 tests/DSBufferRef-test.cpp delete mode 100644 tests/DSBufferTBMImpl-test.cpp delete mode 100644 tests/DSCanvas-test.cpp delete mode 100644 tests/DSClient-test.cpp delete mode 100644 tests/DSCompositor-test.cpp delete mode 100644 tests/DSDebugLog-test.cpp delete mode 100644 tests/DSDisplayArea-test.cpp delete mode 100644 tests/DSDisplayDeviceTDMImpl-test.cpp delete mode 100644 tests/DSEventLoop-test.cpp delete mode 100644 tests/DSInput-test.cpp delete mode 100644 tests/DSKeyboard-test.cpp delete mode 100644 tests/DSObject-test.cpp delete mode 100644 tests/DSOutputImpl-test.cpp delete mode 100644 tests/DSPointer-test.cpp delete mode 100644 tests/DSPolicyArea-test.cpp delete mode 100644 tests/DSProperty-test.cpp delete mode 100644 tests/DSRefBase-test.cpp delete mode 100644 tests/DSRenderEngineDaliImpl-test.cpp delete mode 100644 tests/DSRenderEngineEcoreEvasImpl-test.cpp delete mode 100644 tests/DSSeat-test.cpp delete mode 100644 tests/DSSignal-test.cpp delete mode 100644 tests/DSSignalBroker-test.cpp delete mode 100644 tests/DSTextInput-test.cpp delete mode 100644 tests/DSTizenAppinfo-test.cpp delete mode 100644 tests/DSTouch-test.cpp delete mode 100644 tests/DSTraceInfo-test.cpp delete mode 100644 tests/DSWaylandBuffer-test.cpp delete mode 100644 tests/DSWaylandCallback-test.cpp delete mode 100644 tests/DSWaylandClient-test.cpp delete mode 100644 tests/DSWaylandCompositor-test.cpp delete mode 100644 tests/DSWaylandExtension-test.cpp delete mode 100644 tests/DSWaylandInputMethod-test.cpp delete mode 100644 tests/DSWaylandInputMethodContext-test.cpp delete mode 100644 tests/DSWaylandInputPanel-test.cpp delete mode 100644 tests/DSWaylandInputPanelSurface-test.cpp delete mode 100644 tests/DSWaylandKeyboard-test.cpp delete mode 100644 tests/DSWaylandOutput-test.cpp delete mode 100644 tests/DSWaylandPointer-test.cpp delete mode 100644 tests/DSWaylandProtocolTrace-test.cpp delete mode 100644 tests/DSWaylandSeat-test.cpp delete mode 100644 tests/DSWaylandSurface-test.cpp delete mode 100644 tests/DSWaylandTextInput-test.cpp delete mode 100644 tests/DSWaylandTextInputManager-test.cpp delete mode 100644 tests/DSWaylandTizenAppinfo-test.cpp delete mode 100644 tests/DSWaylandTizenIndicator-test.cpp delete mode 100644 tests/DSWaylandTizenInputDevice-test.cpp delete mode 100644 tests/DSWaylandTizenInputDeviceManager-test.cpp delete mode 100644 tests/DSWaylandTizenLaunchEffect-test.cpp delete mode 100644 tests/DSWaylandTizenPolicy-test.cpp delete mode 100644 tests/DSWaylandTizenPolicyExt-test.cpp delete mode 100644 tests/DSWaylandTizenSurface-test.cpp delete mode 100644 tests/DSWaylandTizenSurfaceShm-test.cpp delete mode 100644 tests/DSWaylandTouch-test.cpp delete mode 100644 tests/DSWaylandZxdgShellV6-test.cpp delete mode 100644 tests/DSWindow-test.cpp delete mode 100644 tests/DSWindowManager-test.cpp delete mode 100644 tests/DSWindowShell-test.cpp delete mode 100644 tests/DSXkb-test.cpp delete mode 100644 tests/DSZone-test.cpp delete mode 100644 tests/libds-mock.h delete mode 100644 tests/libds-tests.cpp delete mode 100644 tests/libds-tests.h delete mode 100644 tests/meson.build diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 09062c1..0000000 --- a/CODEOWNERS +++ /dev/null @@ -1,9 +0,0 @@ -# This is a comment. -# Each line is a file pattern followed by one or more owners. - -# These owners will be the default owners for everything in -# the repo. Unless a later match takes precedence, -# @global-owner1 and @global-owner2 will be requested for -# review when someone opens a pull request. -* @cyeon-lee @doyoun-kang @gl77-lee @jhyuni-kang @jk0430-kim @joonbum-ko @juns-kim @dyamy-lee @lsj119 @sc1-lim @shiin-lee @sj76-park @duna-oh - diff --git a/COPYING b/COPYING deleted file mode 100644 index cfa2560..0000000 --- a/COPYING +++ /dev/null @@ -1,26 +0,0 @@ -Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - ---- - -The above is the version of the MIT "Expat" License used by X.org: - - http://cgit.freedesktop.org/xorg/xserver/tree/COPYING diff --git a/README.md b/README.md deleted file mode 100644 index b49212a..0000000 --- a/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# libds -Requires: - c++17 standard feature support - - std::variant(>=gcc-7, >=clang4, >=MSVC19.10x) - -# Ground Rule - ## Committer rule - - Committer는 Commit message와 Description을 영어로 작성한다. - - Committer는 Reviewer가 patch의 목적을 이해할 수 있도록 Commit message와 Description을 충실히 작성한다. - - Committer는 patch를 간단한 단일기능 혹은 단일 주제를 가지도록 만든다. 단일 주제를 가지는 Commit message를 작성할 수 있도록 한다. - - Committer는 코드 수정들을 가장 작은 단위의 patch들도 나누어 Commit한다. - - Committer는 2명 이상의 Reviewer들에게 리뷰 요청을 한다. - - Committer는 빌드 및 동작검증을 한 후에 PR을 요청한다. - - Committer는 PR에 하나 혹은 ê·¸ 이상의 patch들을 포함할 수 있다. - - Committer는 patch를 SE의 C++ coding rule을 준수하여 작성한다. (C++ Coding Rule) - ## Reviewer rule - - Reviewer는 한글/영어로 review comment를 작성한다. - - Reviewer는 Merge가 될 수 있는 PR이면 Approve를 체크한다. - - Reviewer는 reviewer로 등록되면 working day 1일 이내에 리뷰하도록 노력한다. - - Reviewer는 Code에 대한 의견만 제시한다. - - Reviewer는 리뷰 시에는 반드시 Comment를 기록한다. - ## Merge rule - - Rebase and Submit를 원칙으로 한다. - - Approve가 두 개 이상일 경우에만 merge가 가능하다. - diff --git a/data/units/display-manager.service b/data/units/display-manager.service deleted file mode 100644 index d171f75..0000000 --- a/data/units/display-manager.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Display manager (libds) - -[Service] -EnvironmentFile=/etc/sysconfig/libds.env -SmackProcessLabel=System -ExecStartPre=-/usr/bin/keymap_update.sh -ExecStart=/usr/bin/bash -c "/usr/bin/exampleCompositor" -ExecStartPost=/usr/bin/bash -c "/usr/bin/touch $XDG_RUNTIME_DIR/.wm_ready;devicectl display start;devicectl display stop" -Restart=always -RestartSec=10 - -[Install] -WantedBy=graphical.target - diff --git a/data/units/libds.env b/data/units/libds.env deleted file mode 100644 index 3c8c695..0000000 --- a/data/units/libds.env +++ /dev/null @@ -1,12 +0,0 @@ -# env for exampleCompositor (libds) -E_CONF_PROFILE=tizen-mobile -XDG_RUNTIME_DIR=/run -XDG_CACHE_HOME=/run -ECORE_EVAS_FORCE_SYNC_RENDER=1 -ELM_PROFILE=mobile -HOME=/var/lib/enlightenment -EINA_LOG_DLOG_ENABLE=1 -DSLOG_DLOG_ENABLE=1 -LIBINPUT_IGNORE_JOYSTICK=1 -#E_INFO_RULE_FILE=/opt/rule/rule -#E_INFO_TRACE_FILE=/tmp/trace diff --git a/meson.build b/meson.build deleted file mode 100644 index 7dbefbe..0000000 --- a/meson.build +++ /dev/null @@ -1,16 +0,0 @@ -project( - 'libds', - ['c', 'cpp'], - version : '0.0.1', - license : 'MIT', - default_options : ['c_std=c11', 'cpp_std=c++17', 'b_pie=true'] - ) - -libds_version = meson.project_version().split('.') -libds_prefix = get_option('prefix') -libds_prefix_bindir = join_paths(libds_prefix, get_option('bindir')) -libds_prefix_libdir = join_paths(libds_prefix, get_option('libdir')) - -subdir('src') -subdir('tests') -subdir('samples') diff --git a/meson_options.txt b/meson_options.txt deleted file mode 100644 index e69de29..0000000 diff --git a/packaging/libds.manifest b/packaging/libds.manifest deleted file mode 100644 index 75b0fa5..0000000 --- a/packaging/libds.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/libds.spec b/packaging/libds.spec deleted file mode 100644 index 31b2f12..0000000 --- a/packaging/libds.spec +++ /dev/null @@ -1,136 +0,0 @@ -%define USE_GCOV 0 - -Name: libds -Version: 0.0.1 -Release: 0 -Summary: Display Server library -License: MIT -URL: http://www.tizen.org/ -Source: %name-%version.tar.xz -Source1001: %name.manifest - -BuildRequires: meson -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(gmock) -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(libtdm) -BuildRequires: pkgconfig(libtbm) -BuildRequires: pkgconfig(wayland-tbm-server) -BuildRequires: pkgconfig(wayland-server) -BuildRequires: pkgconfig(tizen-extension-server) -BuildRequires: pkgconfig(input-method-server) -BuildRequires: pkgconfig(text-server) -BuildRequires: pkgconfig(tizen-launch-server) -BuildRequires: pkgconfig(tizen-surface-server) -BuildRequires: pkgconfig(xdg-shell-unstable-v6-server) -BuildRequires: pkgconfig(xdg-shell-server) -BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(ecore-evas) -BuildRequires: pkgconfig(libinput) -BuildRequires: pkgconfig(libudev) -BuildRequires: pkgconfig(xkbcommon) -BuildRequires: pkgconfig(dali2-core) -BuildRequires: pkgconfig(dali2-adaptor) -BuildRequires: pkgconfig(dali2-toolkit) -BuildRequires: pkgconfig(dali2-extension) - -# For samples and tests -BuildRequires: pkgconfig(wayland-client) -BuildRequires: pkgconfig(xkbcommon) -BuildRequires: pkgconfig(wayland-tbm-client) -BuildRequires: pkgconfig(xdg-shell-client) -BuildRequires: pkgconfig(xdg-shell-unstable-v6-client) - -%description - -Test DS c++ server - -%package devel -Summary: Test DS c++ server -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} - - -%description devel - -Test DS c++ server and lib - -%package tests -Summary: libds unit tests -Group: System/Libraries - -%description tests -Test module for testing libtbm APIs - -%package boot -Summary: package for boot with libds-based display server -Group: System/Libraries - -%description boot -Package for boot with libds-based display server - -%prep -%setup -q -cp %{SOURCE1001} . - -%build -%if "%{USE_GCOV}" == "1" -CXXFLAGS+=" -fprofile-arcs -ftest-coverage -DTIZEN_TEST_GCOV" -LDFLAGS+=" -lgcov" -%endif -meson setup \ - --prefix /usr \ - --libdir %{_libdir} \ - --bindir %{_bindir} \ - builddir -ninja -C builddir all - -%install -export DESTDIR=%{buildroot} -ninja -C builddir install - -%define daemon_user display -%define daemon_group display - -# install service -#%__mkdir_p %{buildroot}%{_unitdir} -#install -m 644 data/units/display-manager.service %{buildroot}%{_unitdir} - -# install env file for service -#%__mkdir_p %{buildroot}%{_sysconfdir}/sysconfig -#install -m 0644 data/units/libds.env %{buildroot}%{_sysconfdir}/sysconfig - -#%pre -# create groups 'display' -#getent group %{daemon_group} >/dev/null || %{_sbindir}/groupadd -r -o %{daemon_group} -# create user 'display' -#getent passwd %{daemon_user} >/dev/null || %{_sbindir}/useradd -r -g %{daemon_group} -d /run/display -s /bin/false -c "Display daemon" %{daemon_user} - -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig - -%files -%manifest %{name}.manifest -%defattr(-,root,root,-) -%license COPYING -%{_libdir}/*.so.* -%{_bindir}/* - -%files devel -%manifest %{name}.manifest -%defattr(-,root,root,-) -%license COPYING -%{_includedir}/* -%{_libdir}/*.so -%{_libdir}/pkgconfig/* - -%files tests -%defattr(-,root,root,-) -%license COPYING -%{_bindir}/libds-tests - -%files boot -%defattr(-,root,root,-) -%license COPYING -#%{_unitdir}/display-manager.service -#%config %{_sysconfdir}/sysconfig/libds.env diff --git a/samples/exampleClient.c b/samples/exampleClient.c deleted file mode 100644 index 6726029..0000000 --- a/samples/exampleClient.c +++ /dev/null @@ -1,579 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct wl_display *display = NULL; -struct wl_compositor *compositor = NULL; -struct wl_seat *seat = NULL; -struct wl_surface *surface = NULL; -struct wl_pointer *pointer = NULL; -struct wl_keyboard *keyboard = NULL; -struct wl_touch *touch = NULL; -struct wl_output *output = NULL; -struct xkb_context *xkb_context = NULL; -struct xkb_keymap *keymap = NULL; -struct tizen_policy *tz_policy = NULL; -struct tizen_launch_appinfo *tz_appinfo = NULL; -struct tizen_launch_effect *tz_launcheffect = NULL; -struct tizen_launch_splash *tz_launchsplash = NULL; -struct zxdg_shell_v6 *zxdg_shell; -struct zxdg_surface_v6 *zxdg_surface; -struct zxdg_toplevel_v6 *zxdg_toplevel; - -static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) -{ - (void) data; - (void) wl_pointer; - (void) serial; - (void) surface; - (void) surface_x; - (void) surface_y; - - printf("... serial=%d, x=%.f, y=%.f\n", serial, wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y)); -} - -static void pointer_leave(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface) -{ - (void) data; - (void) wl_pointer; - (void) serial; - (void) surface; - - printf("... serial=%d\n", serial); -} - -static void pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) -{ - (void) data; - (void) wl_pointer; - (void) time; - (void) surface_x; - (void) surface_y; - - printf("... time=%d, x=%.f, y=%.f\n", time, wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y)); -} - -static void pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) -{ - (void) data; - (void) wl_pointer; - (void) serial; - (void) time; - (void) button; - (void) state; - - printf("... serial=%d, time=%d, button=%d, state=%d\n", serial, time, button, state); -} - -static void pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis, wl_fixed_t value) -{ - (void) data; - (void) wl_pointer; - (void) time; - (void) axis; - (void) value; - - printf("... time=%d, axis=%d, value=%.f\n", time, axis, wl_fixed_to_double(value)); -} - -static void -keyboard_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size) -{ - (void) data; - (void) keyboard; - (void) format; - (void) fd; - (void) size; - - char *map = NULL; - - printf("...WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1=%d, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP=%d\n", - WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP); - printf("[Keyboard Keymap] ... format=%d, fd=%d, size=%d\n", format, fd, size); - - if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) - { - printf("... Invalid format: %d\n", format); - close(fd); - return; - } - - map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); - - if (map == MAP_FAILED) - { - printf("... Failed to mmap from fd(%d) size(%d)\n", fd, size); - close(fd); - return; - } - - printf("... Succeed to mmap from fd(%d) size(%d)\n", fd, size); - - keymap = xkb_map_new_from_string(xkb_context, map, - XKB_KEYMAP_FORMAT_TEXT_V1, 0); - if (!keymap) - printf("... Failed to get keymap from fd(%d)\n", fd); - else - printf("... Succeed to get keymap from fd(%d)\n", fd); - - munmap(map, size); - close(fd); -} - -static void -keyboard_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys) -{ - (void) data; - (void) keyboard; - (void) serial; - (void) surface; - (void) keys; - - printf("[Keyboard Enter] ... serial=%d\n", serial); -} - -static void -keyboard_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface) -{ - (void) data; - (void) keyboard; - (void) serial; - (void) surface; - - printf("[Keyboard Leave] ... serial=%d\n", serial); -} - -static void -keyboard_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) -{ - (void) data; - (void) keyboard; - (void) serial; - (void) time; - (void) key; - (void) state; - - printf("[Keyboard Key]... serial=%d, time=%d, key=%d, state=%d\n", serial, time, key, state); -} - -static void -keyboard_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) -{ - (void) data; - (void) keyboard; - (void) serial; - (void) mods_depressed; - (void) mods_latched; - (void) mods_locked; - (void) group; - - printf("[Keyboard Modifiers]... serial=%d, mods_depressed=%d, mods_latched=%d, mods_locked=%d, group=%d\n", serial, mods_depressed, mods_latched, mods_locked, group); -} - - static void -keyboard_repeatinfo(void *data, struct wl_keyboard *keyboard, int32_t rate, int32_t delay) -{ - (void) data; - (void) keyboard; - - printf("... repeat rate=%u, repeat delay=%u\n", rate, delay); -} - -static void -touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time, struct wl_surface *surface, int32_t id, wl_fixed_t x_w, wl_fixed_t y_w) -{ - (void) data; - (void) wl_touch; - (void) serial; - (void) time; - (void) surface; - (void) id; - (void) x_w; - (void) y_w; - - printf("... serial=%d, time=%d, id=%d, x_w=%.f, y_w=%.f\n", serial, time, id, wl_fixed_to_double(x_w), wl_fixed_to_double(y_w)); -} - -static void -touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time, int32_t id) -{ - (void) data; - (void) wl_touch; - (void) serial; - (void) time; - (void) id; - - printf("... serial=%d, time=%d, id=%d\n", serial, time, id); -} - -static void -touch_motion(void *data, struct wl_touch *wl_touch, uint32_t time, int32_t id, wl_fixed_t x_w, wl_fixed_t y_w) -{ - (void) data; - (void) wl_touch; - (void) time; - (void) id; - (void) x_w; - (void) y_w; - - printf("... time=%d, id=%d, x_w=%.f, y_w=%.f\n", time, id, wl_fixed_to_double(x_w), wl_fixed_to_double(y_w)); -} - -static void -touch_frame(void *data, struct wl_touch *wl_touch) -{ - (void) data; - (void) wl_touch; - - printf("...\n"); -} - -static void -touch_cancel(void *data, struct wl_touch *wl_touch) -{ - (void) data; - (void) wl_touch; - - printf("...\n"); -} - -static const struct wl_pointer_listener pointer_listener = { - pointer_enter, - pointer_leave, - pointer_motion, - pointer_button, - pointer_axis, -}; - - -static const struct wl_touch_listener touch_listener = { - touch_down, - touch_up, - touch_motion, - touch_frame, - touch_cancel -}; - -static const struct wl_keyboard_listener keyboard_listener = { - keyboard_keymap, - keyboard_enter, - keyboard_leave, - keyboard_key, - keyboard_modifiers, - keyboard_repeatinfo -}; - -static void -seat_handle_capabilities(void *data, struct wl_seat *seat, - enum wl_seat_capability caps) -{ - printf("Capabilities events ! (caps=%d)\n", caps); - - if (caps & WL_SEAT_CAPABILITY_POINTER) - { - if (!pointer) - { - printf("Display has a pointer.\n"); - pointer = wl_seat_get_pointer(seat); - wl_pointer_add_listener(pointer, &pointer_listener, NULL); - } - } - else - { - if (pointer) - { - printf("Pointer has been removed.\n"); - wl_pointer_release(pointer); - pointer = NULL; - } - } - - if (caps & WL_SEAT_CAPABILITY_KEYBOARD) - { - if (!keyboard) - { - printf("Display has a keyboard.\n"); - keyboard = wl_seat_get_keyboard(seat); - wl_keyboard_add_listener(keyboard, &keyboard_listener, NULL); - } - } - else - { - if (keyboard) - { - printf("Keyboard has been removed.\n"); - wl_keyboard_release(keyboard); - keyboard = NULL; - } - } - - if (caps & WL_SEAT_CAPABILITY_TOUCH) - { - if (!touch) - { - printf("Display has a touch screen.\n"); - touch = wl_seat_get_touch(seat); - wl_touch_add_listener(touch, &touch_listener, NULL); - } - } - else - { - if (touch) - { - printf("Touch has been removed.\n"); - wl_touch_release(touch); - touch = NULL; - } - } -} - -static void -seat_handle_name(void *data, struct wl_seat *seat, const char *name) -{ - printf("Seat has a name (%s)\n", name); -} - -static const struct wl_seat_listener seat_listener = { - seat_handle_capabilities, - seat_handle_name, -}; - - -static void -_tizen_policy_cb_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, uint32_t is_conformant) -{ -} - -static void -_tizen_policy_cb_conformant_area(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h) -{ -} - -static void -_tizen_policy_cb_notification_done(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, int32_t level, uint32_t state) -{ -} - -static void -_tizen_policy_cb_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id) -{ -} - -static void -_tizen_policy_cb_window_screen_mode_done(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t mode, uint32_t state) -{ -} - -static void -_tizen_policy_cb_iconify_state_changed(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, uint32_t iconified, uint32_t force) -{ -} - -static void -_tizen_policy_cb_supported_aux_hints(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, struct wl_array *hints, uint32_t num_hints) -{ -} - -static void -_tizen_policy_cb_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy , struct wl_surface *surface_resource, int id) -{ -} - -static void -_tizen_policy_cb_aux_message(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, const char *key, const char *val, struct wl_array *options) -{ -} - -static void -_tizen_policy_cb_conformant_region(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial) -{ -} - -static const struct tizen_policy_listener tz_policy_listener = { - _tizen_policy_cb_conformant, - _tizen_policy_cb_conformant_area, - _tizen_policy_cb_notification_done, - _tizen_policy_cb_transient_for_done, - _tizen_policy_cb_window_screen_mode_done, - _tizen_policy_cb_iconify_state_changed, - _tizen_policy_cb_supported_aux_hints, - _tizen_policy_cb_allowed_aux_hint, - _tizen_policy_cb_aux_message, - _tizen_policy_cb_conformant_region, -}; - -static void -_tizen_launch_appinfo_cb_base_output_resolution_done(void *data, struct tizen_launch_appinfo *tizen_appinfo, uint32_t pid, uint32_t width, uint32_t height) -{ - printf("Tizen Appinfo callback: base_output_resolution_done pid:(%d) w,h:(%d,%d)\n", pid, width, height); -} - -static const struct tizen_launch_appinfo_listener tz_appinfo_listener = { - _tizen_launch_appinfo_cb_base_output_resolution_done, -}; - -static void -global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, - const char *interface, uint32_t version) -{ - printf("Registry event : global added (interface:%s, id:%d, version:%d)\n", interface, id, version); - - if (strcmp(interface, "wl_compositor") == 0) - { - compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); - } - else if(strcmp(interface, "wl_seat") == 0) - { - seat = wl_registry_bind(registry, id, &wl_seat_interface, 4); - wl_seat_add_listener(seat, &seat_listener, NULL); - } - else if(strcmp(interface, "tizen_policy") == 0) - { - tz_policy = wl_registry_bind(registry, id, &tizen_policy_interface, 7); - tizen_policy_add_listener(tz_policy, &tz_policy_listener, NULL); - } - else if(strcmp(interface, "zxdg_shell_v6") == 0) - { - zxdg_shell = wl_registry_bind(registry, id, &zxdg_shell_v6_interface, 1); - } - else if(strcmp(interface, "tizen_launch_appinfo") == 0) - { - tz_appinfo = wl_registry_bind(registry, id, &tizen_launch_appinfo_interface, 1); - - /* TODO: This request should be used by AMD.*/ - tizen_launch_appinfo_add_listener(tz_appinfo, &tz_appinfo_listener, NULL); - tizen_launch_appinfo_register_appid(tz_appinfo, "com.samsung.clocksetting"); - tizen_launch_appinfo_set_pid(tz_appinfo, "com.samsung.clocksetting", 4077); - } - else if(strcmp(interface, "wl_output") == 0) - { - output = wl_registry_bind(registry, id, &wl_output_interface, 2); - } - else if(strcmp(interface, "tizen_launch_effect") == 0) - { - tz_launcheffect = wl_registry_bind(registry, id, &tizen_launch_effect_interface, 1); - - tz_launchsplash = tizen_launch_effect_create_splash_img(tz_launcheffect); - } -} - -static void -global_registry_remover(void *data, struct wl_registry *registry, uint32_t id) -{ - printf("Registry event : global removed (id:%d)\n", id); -} - -static const struct wl_registry_listener registry_listener = { - global_registry_handler, - global_registry_remover -}; - -static void -_zxdg_v6_shell_surface_create(struct wl_surface *surface) -{ - if (zxdg_surface) return; - - printf("Request get xdg_surface. zxdg_shell:%p", zxdg_shell); - - zxdg_surface = zxdg_shell_v6_get_xdg_surface(zxdg_shell, surface); - // zxdg_surface_v6_add_listener(zxdg_surface, &_zxdg_surface_listener, NULL); - - printf("create zxdg_surface:%p", zxdg_surface); - - zxdg_toplevel = zxdg_surface_v6_get_toplevel(zxdg_surface); - //zxdg_toplevel_v6_add_listener(zxdg_toplevel, &_zxdg_toplevel_listener, NULL); - - zxdg_toplevel_v6_set_title(zxdg_toplevel, "zxdg_toplevel"); -} - - -int main(int argc, char **argv) { - - xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); - - display = wl_display_connect(NULL); - - if (display == NULL) - { - fprintf(stderr, "Can't connect to display\n"); - exit(1); - } - - printf("connected to display\n"); - - struct wl_registry *registry = wl_display_get_registry(display); - wl_registry_add_listener(registry, ®istry_listener, NULL); - wl_display_dispatch(display); - wl_display_roundtrip(display); - - if (compositor == NULL) - { - fprintf(stderr, "Can't find compositor\n"); - exit(1); - } - else - { - fprintf(stderr, "Found compositor\n"); - } - - surface = wl_compositor_create_surface(compositor); - - if (surface == NULL) - { - fprintf(stderr, "Can't create surface\n"); - exit(1); - } - else - { - fprintf(stderr, "Surface created.\n"); - - _zxdg_v6_shell_surface_create(surface); - } - - while (wl_display_dispatch(display) != -1) - { - ; - } - - wl_display_disconnect(display); - printf("disconnected from display\n"); - - exit(0); -} - diff --git a/samples/exampleClientNoShellRendering.cpp b/samples/exampleClientNoShellRendering.cpp deleted file mode 100644 index 5922d0d..0000000 --- a/samples/exampleClientNoShellRendering.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define BUF_WIDTH 400 -#define BUF_HEIGHT 200 -#define TEST_COUNT 200 -#define BUF_NUM 3 - -class WlClientSimpleRendering { - int __width; - int __height; - int __stride; - int __size; - int __count; - tbm_format __format; - tbm_surface_h __tbmSurface[BUF_NUM]; - - Ecore_Wl2_Display *__ecoreWl2Dpy; - struct wl_display *__wlDisplay; - struct wl_registry *__wlRegistry; - -public: - WlClientSimpleRendering(int width, int height, tbm_format format) - :__width(width), - __height(height), - __format(format) - { - __stride = width * 4; - __size = height * __stride; - __count = 0; - - for (int i = 0; i < BUF_NUM; i++) - { - __tbmSurface[i] = nullptr; - __wlBuffer[i] = nullptr; - } - - __ecoreWl2Dpy = nullptr; - __wlDisplay = nullptr; - __wlRegistry = nullptr; - __wlCompositor = nullptr; - __wlSurface = nullptr; - __wlTbmClient = nullptr; - } - - ~WlClientSimpleRendering() - { - for (int i = 0; i < BUF_NUM; i++) - { - if (__wlBuffer[i] != nullptr) wl_buffer_destroy(__wlBuffer[i]); - if (__tbmSurface[i] != nullptr) tbm_surface_destroy(__tbmSurface[i]); - } - if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); - if (__wlCompositor != nullptr) wl_compositor_destroy(__wlCompositor); - - if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); - if (__ecoreWl2Dpy != nullptr) ecore_wl2_display_disconnect(__ecoreWl2Dpy); - } - - int ConnectDisplay(); - void DisconnectDisplay(); - int CreateBuffer(int bufferNum); - void DestroyBuffer(int bufferNum); - int RenderingBuffer(int bufferNum, unsigned char color); - void CommitBuffer(int bufferNum); - - struct wl_compositor *__wlCompositor; - struct wl_surface *__wlSurface; - struct wl_buffer *__wlBuffer[BUF_NUM]; - struct wayland_tbm_client *__wlTbmClient; -}; - -static void -handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) -{ - WlClientSimpleRendering *temp = (WlClientSimpleRendering *)data; - - if (strcmp(interface, "wl_compositor") == 0) { - temp->__wlCompositor = (struct wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 3); - if (temp->__wlCompositor == nullptr) - std::cout << __func__ << " Error. fail to bind " << interface << std::endl; - else - std::cout << __func__ << " bind " << interface << std::endl; - } else { - std::cout << __func__ << " Not bind" << interface << std::endl; - } -} - -static void -handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) -{ -} - -static const struct wl_registry_listener registry_listener = { - handle_global, - handle_global_remove -}; - -int WlClientSimpleRendering::ConnectDisplay() -{ - __ecoreWl2Dpy = ecore_wl2_display_connect(NULL); - if (__ecoreWl2Dpy == nullptr) - { - std::cout << __func__ << " Error. fail ecore_wl2_display_connect" << std::endl; - return -1; - } - - __wlDisplay = ecore_wl2_display_get(__ecoreWl2Dpy); - if (__wlDisplay == nullptr) - { - std::cout << __func__ << " Error. fail ecore_wl2_display_get" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - __wlRegistry = wl_display_get_registry(__wlDisplay); - if (__wlRegistry == nullptr) - { - std::cout << __func__ << " Error. fail wl_display_get_registry" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - wl_registry_add_listener(__wlRegistry, ®istry_listener, this); - wl_display_dispatch(__wlDisplay); - wl_display_roundtrip(__wlDisplay); - - if (__wlCompositor == nullptr) - { - std::cout << __func__ << " Error. fail binding" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - __wlTbmClient = wayland_tbm_client_init(__wlDisplay); - if (__wlTbmClient == nullptr) - { - std::cout << __func__ << " Error. fail wayland_tbm_client_init" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - __wlSurface = wl_compositor_create_surface(__wlCompositor); - if (__wlSurface == nullptr) - { - std::cout << __func__ << " Error. fail wl_compositor_create_surface" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - return 0; -} - -void WlClientSimpleRendering::DisconnectDisplay() -{ - int i; - - for (i = 0; i < BUF_NUM; i++) - { - this->DestroyBuffer(i); - } - if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); - __wlTbmClient = nullptr; - - if (__wlCompositor) wl_compositor_destroy(__wlCompositor); - __wlCompositor = nullptr; - - if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); - __wlRegistry = nullptr; - __wlDisplay = nullptr; - if (__ecoreWl2Dpy != nullptr) ecore_wl2_display_disconnect(__ecoreWl2Dpy); - __ecoreWl2Dpy = nullptr; -} - -int WlClientSimpleRendering::CreateBuffer(int bufferNum) -{ - tbm_surface_h tbm_surface; - - if (bufferNum >= BUF_NUM) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return -1; - } - - if (__wlTbmClient == nullptr) - { - std::cout << __func__ << " Error. no __wlTbmClient. execute ConnectDisplay first" << std::endl; - return -1; - } - - tbm_surface = tbm_surface_create(__width, __height, __format); - if (tbm_surface == nullptr) - { - std::cout << __func__ << " Error. fail to create tbm_surface" << std::endl; - return -1; - } - - if (__tbmSurface[bufferNum] != nullptr) - { - std::cout << __func__ << " destroy prev tbm_surface " << bufferNum << ":" << __tbmSurface[bufferNum] << std::endl; - this->DestroyBuffer(bufferNum); - } - __tbmSurface[bufferNum] = tbm_surface; - - __wlBuffer[bufferNum] = wayland_tbm_client_create_buffer(__wlTbmClient, __tbmSurface[bufferNum]); - if (__wlBuffer[bufferNum] == nullptr) - { - std::cout << __func__ << " Error. fail to create wl_buffer" << std::endl; - tbm_surface_destroy(__tbmSurface[bufferNum]); - __tbmSurface[bufferNum] = nullptr; - return -1; - } - - std::cout << __func__ << " create " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; - - return 0; -} - -void WlClientSimpleRendering::DestroyBuffer(int bufferNum) -{ - if (bufferNum >= BUF_NUM) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return; - } - - if (__tbmSurface[bufferNum] == nullptr) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return; - } - - std::cout << __func__ << " destroy " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; - - wl_buffer_destroy(__wlBuffer[bufferNum]); - __wlBuffer[bufferNum] = nullptr; - tbm_surface_destroy(__tbmSurface[bufferNum]); - __tbmSurface[bufferNum] = nullptr; -} - -int WlClientSimpleRendering::RenderingBuffer(int bufferNum, unsigned char color) -{ - tbm_surface_h tbm_surface; - tbm_surface_info_s info; - int ret = 0; - - if (bufferNum >= BUF_NUM) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return -1; - } - - tbm_surface = __tbmSurface[bufferNum]; - if (tbm_surface == nullptr) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return -1; - } - - ret = tbm_surface_map(tbm_surface, TBM_SURF_OPTION_WRITE, &info); - if (ret != 0) - { - std::cout << __func__ << " Error. fail to tbm_surface_map " << ret << std::endl; - return ret; - } - - memset(info.planes[0].ptr, color, info.planes[0].stride * info.height); - - tbm_surface_unmap(tbm_surface); - - return ret; -} - -void WlClientSimpleRendering::CommitBuffer(int bufferNum) -{ - if (__wlSurface == nullptr || __wlDisplay == nullptr) - { - std::cout << __func__ << " Error. execute connect first" << std::endl; - return; - } - - if (bufferNum >= BUF_NUM || __wlBuffer[bufferNum] == nullptr) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return; - } - - wl_surface_attach(__wlSurface, __wlBuffer[bufferNum], 0, 0); - wl_surface_damage(__wlSurface, 0, 0, __width, __height); - wl_surface_commit(__wlSurface); - - std::cout << __func__ << " commit " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; -#if 0 - int ret = 0; - - ret = wl_display_dispatch(__wlDisplay); - if (ret < 0) { - std::cout << __func__ << " Error. wl_display_dispatch error:" << ret << std::endl; - return; - } -#endif - wl_display_roundtrip(__wlDisplay); -} - -int main (void) -{ - WlClientSimpleRendering *simpleRenderSample = nullptr; - int count = 0; - int ret = 0; - int i; - unsigned char color; - - ecore_wl2_init(); - - simpleRenderSample = new WlClientSimpleRendering(BUF_WIDTH, BUF_HEIGHT, TBM_FORMAT_ARGB8888); - if (simpleRenderSample == nullptr) - { - std::cout << __func__ << " Error. fail create WlClientSimpleRendering" << std::endl; - ecore_wl2_shutdown(); - return -1; - } - - ret = simpleRenderSample->ConnectDisplay(); - if (ret) - { - std::cout << __func__ << " Error. fail ConnectDisplay" << std::endl; - ecore_wl2_shutdown(); - return -1; - } - - for (i = 0; i < BUF_NUM; i++) - { - ret = simpleRenderSample->CreateBuffer(i); - if (ret) - { - std::cout << __func__ << " Error. fail CreateBuffer " << i << std::endl; - goto finish; - } - } - - /* main loop */ - i = 0; - color = 0x11; - std::cout << __func__ << " loop start." << std::endl; - while (count < TEST_COUNT) { - simpleRenderSample->RenderingBuffer(i, color); - simpleRenderSample->CommitBuffer(i); - count++; - i++; - if (i == BUF_NUM) i = 0; - if (color == 0xff) - color = 0x11; - else - color += 0x11; - std::cout << __func__ << " loop running " << count << std::endl; - usleep(100000); - } - std::cout << __func__ << " loop end." << std::endl; - -finish: - simpleRenderSample->DisconnectDisplay(); - - delete simpleRenderSample; - - ecore_wl2_shutdown(); - - return 0; -} diff --git a/samples/exampleClientShellRendering.cpp b/samples/exampleClientShellRendering.cpp deleted file mode 100644 index bc98223..0000000 --- a/samples/exampleClientShellRendering.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BUF_WIDTH 400 -#define BUF_HEIGHT 200 -#define TEST_COUNT 200 -#define BUF_NUM 3 - -class WlClientSimpleRendering { - int __width; - int __height; - int __stride; - int __size; - int __count; - tbm_format __format; - tbm_surface_h __tbmSurface[BUF_NUM]; - - Ecore_Wl2_Display *__ecoreWl2Dpy; - struct wl_display *__wlDisplay; - struct wl_registry *__wlRegistry; - -public: - WlClientSimpleRendering(int width, int height, tbm_format format) - :__width(width), - __height(height), - __format(format) - { - __stride = width * 4; - __size = height * __stride; - __count = 0; - - for (int i = 0; i < BUF_NUM; i++) - { - __tbmSurface[i] = nullptr; - __wlBuffer[i] = nullptr; - } - - __ecoreWl2Dpy = nullptr; - __wlDisplay = nullptr; - __wlRegistry = nullptr; - __wlCompositor = nullptr; - __zxdgShell = nullptr; - __wlSurface = nullptr; - __zxdgShellSurface = nullptr; - __wlTbmClient = nullptr; - } - - ~WlClientSimpleRendering() - { - if (__zxdgShellSurface != nullptr) zxdg_surface_v6_destroy(__zxdgShellSurface); - if (__wlSurface != nullptr) wl_surface_destroy(__wlSurface); - for (int i = 0; i < BUF_NUM; i++) - { - if (__wlBuffer[i] != nullptr) wl_buffer_destroy(__wlBuffer[i]); - if (__tbmSurface[i] != nullptr) tbm_surface_destroy(__tbmSurface[i]); - } - if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); - if (__zxdgShell != nullptr) zxdg_shell_v6_destroy(__zxdgShell); - if (__wlCompositor != nullptr) wl_compositor_destroy(__wlCompositor); - - if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); - if (__ecoreWl2Dpy != nullptr) ecore_wl2_display_disconnect(__ecoreWl2Dpy); - } - - int ConnectDisplay(); - void DisconnectDisplay(); - int CreateBuffer(int bufferNum); - void DestroyBuffer(int bufferNum); - int RenderingBuffer(int bufferNum, unsigned char color); - void CommitBuffer(int bufferNum); - - struct wl_compositor *__wlCompositor; - struct zxdg_shell_v6 *__zxdgShell; - struct wl_surface *__wlSurface; - struct zxdg_surface_v6 *__zxdgShellSurface; - struct wl_buffer *__wlBuffer[BUF_NUM]; - struct wayland_tbm_client *__wlTbmClient; -}; - -static void -handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) -{ - WlClientSimpleRendering *temp = (WlClientSimpleRendering *)data; - - if (strcmp(interface, "wl_compositor") == 0) { - temp->__wlCompositor = (struct wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 3); - if (temp->__wlCompositor == nullptr) - std::cout << __func__ << " Error. fail to bind " << interface << std::endl; - else - std::cout << __func__ << " bind " << interface << std::endl; - } else if (strcmp(interface, "zxdg_shell_v6") == 0) { - temp->__zxdgShell = (struct zxdg_shell_v6 *)wl_registry_bind(registry, name, &zxdg_shell_v6_interface, 1); - if (temp->__zxdgShell == nullptr) - std::cout << __func__ << " Error. fail to bind " << interface << std::endl; - else - std::cout << __func__ << " bind " << interface << std::endl; - } else { - std::cout << __func__ << " Not bind" << interface << std::endl; - } -} - -static void -handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) -{ -} - -static const struct wl_registry_listener registry_listener = { - handle_global, - handle_global_remove -}; - -int WlClientSimpleRendering::ConnectDisplay() -{ - __ecoreWl2Dpy = ecore_wl2_display_connect(NULL); - if (__ecoreWl2Dpy == nullptr) - { - std::cout << __func__ << " Error. fail ecore_wl2_display_connect" << std::endl; - return -1; - } - - __wlDisplay = ecore_wl2_display_get(__ecoreWl2Dpy); - if (__wlDisplay == nullptr) - { - std::cout << __func__ << " Error. fail ecore_wl2_display_get" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - __wlRegistry = wl_display_get_registry(__wlDisplay); - if (__wlRegistry == nullptr) - { - std::cout << __func__ << " Error. fail wl_display_get_registry" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - wl_registry_add_listener(__wlRegistry, ®istry_listener, this); - wl_display_dispatch(__wlDisplay); - wl_display_roundtrip(__wlDisplay); - - if (__wlCompositor == nullptr || __zxdgShell == nullptr) - { - std::cout << __func__ << " Error. fail binding" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - __wlTbmClient = wayland_tbm_client_init(__wlDisplay); - if (__wlTbmClient == nullptr) - { - std::cout << __func__ << " Error. fail wayland_tbm_client_init" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - __wlSurface = wl_compositor_create_surface(__wlCompositor); - if (__wlSurface == nullptr) - { - std::cout << __func__ << " Error. fail wl_compositor_create_surface" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - __zxdgShellSurface = zxdg_shell_v6_get_xdg_surface(__zxdgShell, __wlSurface); - if (__zxdgShellSurface == nullptr) - { - std::cout << __func__ << " Error. fail zxdg_shell_v6_get_xdg_surface" << std::endl; - this->DisconnectDisplay(); - return -1; - } - - return 0; -} - -void WlClientSimpleRendering::DisconnectDisplay() -{ - int i; - - if (__zxdgShellSurface != nullptr) zxdg_surface_v6_destroy(__zxdgShellSurface); - __zxdgShellSurface = nullptr; - if (__wlSurface != nullptr) wl_surface_destroy(__wlSurface); - __wlSurface = nullptr; - for (i = 0; i < BUF_NUM; i++) - { - this->DestroyBuffer(i); - } - if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); - __wlTbmClient = nullptr; - - if (__zxdgShell != nullptr) zxdg_shell_v6_destroy(__zxdgShell); - __zxdgShell = nullptr; - if (__wlCompositor) wl_compositor_destroy(__wlCompositor); - __wlCompositor = nullptr; - - if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); - __wlRegistry = nullptr; - __wlDisplay = nullptr; - if (__ecoreWl2Dpy != nullptr) ecore_wl2_display_disconnect(__ecoreWl2Dpy); - __ecoreWl2Dpy = nullptr; -} - -int WlClientSimpleRendering::CreateBuffer(int bufferNum) -{ - tbm_surface_h tbm_surface; - - if (bufferNum >= BUF_NUM) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return -1; - } - - if (__wlTbmClient == nullptr) - { - std::cout << __func__ << " Error. no __wlTbmClient. execute ConnectDisplay first" << std::endl; - return -1; - } - - tbm_surface = tbm_surface_create(__width, __height, __format); - if (tbm_surface == nullptr) - { - std::cout << __func__ << " Error. fail to create tbm_surface" << std::endl; - return -1; - } - - if (__tbmSurface[bufferNum] != nullptr) - { - std::cout << __func__ << " destroy prev tbm_surface " << bufferNum << ":" << __tbmSurface[bufferNum] << std::endl; - this->DestroyBuffer(bufferNum); - } - __tbmSurface[bufferNum] = tbm_surface; - - __wlBuffer[bufferNum] = wayland_tbm_client_create_buffer(__wlTbmClient, __tbmSurface[bufferNum]); - if (__wlBuffer[bufferNum] == nullptr) - { - std::cout << __func__ << " Error. fail to create wl_buffer" << std::endl; - tbm_surface_destroy(__tbmSurface[bufferNum]); - __tbmSurface[bufferNum] = nullptr; - return -1; - } - - std::cout << __func__ << " create " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; - - return 0; -} - -void WlClientSimpleRendering::DestroyBuffer(int bufferNum) -{ - if (bufferNum >= BUF_NUM) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return; - } - - if (__tbmSurface[bufferNum] == nullptr) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return; - } - - std::cout << __func__ << " destroy " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; - - wl_buffer_destroy(__wlBuffer[bufferNum]); - __wlBuffer[bufferNum] = nullptr; - tbm_surface_destroy(__tbmSurface[bufferNum]); - __tbmSurface[bufferNum] = nullptr; -} - -int WlClientSimpleRendering::RenderingBuffer(int bufferNum, unsigned char color) -{ - tbm_surface_h tbm_surface; - tbm_surface_info_s info; - int ret = 0; - - if (bufferNum >= BUF_NUM) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return -1; - } - - tbm_surface = __tbmSurface[bufferNum]; - if (tbm_surface == nullptr) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return -1; - } - - ret = tbm_surface_map(tbm_surface, TBM_SURF_OPTION_WRITE, &info); - if (ret != 0) - { - std::cout << __func__ << " Error. fail to tbm_surface_map " << ret << std::endl; - return ret; - } - - memset(info.planes[0].ptr, color, info.planes[0].stride * info.height); - - tbm_surface_unmap(tbm_surface); - - return ret; -} - -void WlClientSimpleRendering::CommitBuffer(int bufferNum) -{ - if (__wlSurface == nullptr || __wlDisplay == nullptr) - { - std::cout << __func__ << " Error. execute connect first" << std::endl; - return; - } - - if (bufferNum >= BUF_NUM || __wlBuffer[bufferNum] == nullptr) - { - std::cout << __func__ << " Error. invalid buffer number" << bufferNum << std::endl; - return; - } - - wl_surface_attach(__wlSurface, __wlBuffer[bufferNum], 0, 0); - wl_surface_damage(__wlSurface, 0, 0, __width, __height); - wl_surface_commit(__wlSurface); - - std::cout << __func__ << " commit " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; - -#if 0 - int ret = 0; - - ret = wl_display_dispatch(__wlDisplay); - if (ret < 0) { - std::cout << __func__ << " Error. wl_display_dispatch error:" << ret << std::endl; - return; - } -#endif - - wl_display_roundtrip(__wlDisplay); -} - -int main (void) -{ - WlClientSimpleRendering *simpleRenderSample = nullptr; - int count = 0; - int ret = 0; - int i; - unsigned char color; - - ecore_wl2_init(); - - simpleRenderSample = new WlClientSimpleRendering(BUF_WIDTH, BUF_HEIGHT, TBM_FORMAT_ARGB8888); - if (simpleRenderSample == nullptr) - { - std::cout << __func__ << " Error. fail create WlClientSimpleRendering" << std::endl; - ecore_wl2_shutdown(); - return -1; - } - - ret = simpleRenderSample->ConnectDisplay(); - if (ret) - { - std::cout << __func__ << " Error. fail ConnectDisplay" << std::endl; - ecore_wl2_shutdown(); - return -1; - } - - for (i = 0; i < BUF_NUM; i++) - { - ret = simpleRenderSample->CreateBuffer(i); - if (ret) - { - std::cout << __func__ << " Error. fail CreateBuffer " << i << std::endl; - goto finish; - } - } - - zxdg_surface_v6_get_toplevel(simpleRenderSample->__zxdgShellSurface); - - /* main loop */ - i = 0; - color = 0x11; - std::cout << __func__ << " loop start." << std::endl; - while (count < TEST_COUNT) { - simpleRenderSample->RenderingBuffer(i, color); - simpleRenderSample->CommitBuffer(i); - count++; - i++; - if (i == BUF_NUM) i = 0; - if (color == 0xff) - color = 0x11; - else - color += 0x11; - std::cout << __func__ << " loop running " << count << std::endl; - usleep(100000); - } - std::cout << __func__ << " loop end." << std::endl; - -finish: - simpleRenderSample->DisconnectDisplay(); - - delete simpleRenderSample; - - ecore_wl2_shutdown(); - - return 0; -} diff --git a/samples/exampleCompositor.cpp b/samples/exampleCompositor.cpp deleted file mode 100644 index 872ec8c..0000000 --- a/samples/exampleCompositor.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "DSDebugLog.h" - -using namespace display_server; - -// MyCompositor has to inherit DSCompositor. -class MyCompositor : public DSCompositor -{ -public: - MyCompositor() - : __canvas{nullptr}, - __seat{nullptr}, - __policyArea{nullptr}, - __displayArea{nullptr} - {} - - virtual ~MyCompositor() - {} - - // The _onInitialized is called when the DSCompositor is ready to run. - // Make a seat and a policy area. Attach the seat to the policy area. - // Attach the policy area and the display area to canvas and return it. - std::shared_ptr _onInitialized() override - { - int width = __displayArea->getWidth(); - int height = __displayArea->getHeight(); - - /* create a seat */ - __seat = std::make_shared(this, "default"); - - __policyArea = std::make_shared(); - __policyArea->setPosition(0, 0); - __policyArea->setSize(width, height); - __policyArea->attachSeat(__seat); - - __canvas = std::make_shared(); - - if (!__canvas->attachPolicyArea(__policyArea)) - return nullptr; - - if (!__canvas->attachDisplayArea(__displayArea)) - return nullptr; - - __textInput = std::make_shared(); - - __traceInfo = std::make_shared(); - __traceInfo->attachPolicyArea(__policyArea); - - return __canvas; - } - - // The _onOutputAdded is called when the IDSOutput is added. - void _onOutputAdded(std::shared_ptr output) override - { - // set the resolution. - output->applyResolutionAuto(); - - // make a display area. - __displayArea = std::make_shared(output); - } - - // The _onOutputAdded is called when the IDSOutput is removed. - void _onOutputRemoved(std::shared_ptr output) override - { - __displayArea.reset(); // delete shared_ptr - } - - // TODO: - void _onInputAdded(std::shared_ptr input) override - {} - - // TODO: - void _onInputRemoved(std::shared_ptr input) override - {} - -private: - std::shared_ptr __canvas; - std::shared_ptr __seat; - std::shared_ptr __policyArea; - std::shared_ptr __displayArea; - std::shared_ptr __textInput; - std::shared_ptr __traceInfo; -}; - -int main() { - DSCompositor *compositor = new MyCompositor(); - - compositor->run(); - - delete compositor; -} diff --git a/samples/exampleObjectPimpl.cpp b/samples/exampleObjectPimpl.cpp deleted file mode 100644 index 0ea9beb..0000000 --- a/samples/exampleObjectPimpl.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include - -/* RESULT - -=== ObjectPimpl *myobj = new ObjectPimpl() === -Constructor 'ObjectPimplPrivate' : ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl*) -Constructor 'ObjectPimpl' : ObjectPimpl::ObjectPimpl() - -=== ObjectPimpl *myobj2 = new ObjectPimpl() === -Constructor 'ObjectPimplPrivate' : ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl*) -Constructor 'ObjectPimpl' : ObjectPimpl::ObjectPimpl() - -=== delete myobj === -Destructor 'ObjectPimpl' : virtual ObjectPimpl::~ObjectPimpl() -Destructor 'ObjectPimplPrivate' : virtual ObjectPimplPrivate::~ObjectPimplPrivate() - -=== delete myobj2 === -Destructor 'ObjectPimpl' : virtual ObjectPimpl::~ObjectPimpl() -Destructor 'ObjectPimplPrivate' : virtual ObjectPimplPrivate::~ObjectPimplPrivate() - -*/ - -using namespace display_server; - -class ObjectPimpl; - -class ObjectPimplPrivate : public DSObjectPrivate -{ -public: - ObjectPimplPrivate() = delete; - ObjectPimplPrivate(ObjectPimpl *p_ptr); - ~ObjectPimplPrivate(); -}; - -class ObjectPimpl : public DSObject -{ -public: - explicit ObjectPimpl(); - virtual ~ObjectPimpl(); - -private: - inline ObjectPimplPrivate *__d_func() - { - return reinterpret_cast(_d_ptr.get()); - } - inline const ObjectPimplPrivate *__d_func() const - { - return reinterpret_cast(_d_ptr.get()); - } - friend class ObjectPimplPrivate; -}; - -ObjectPimplPrivate::ObjectPimplPrivate(ObjectPimpl *p_ptr) - : DSObjectPrivate(p_ptr) -{ - std::cout << "Constructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; -} - -ObjectPimplPrivate::~ObjectPimplPrivate() -{ - std::cout << "Destructor 'ObjectPimplPrivate' : " << __PRETTY_FUNCTION__ << std::endl; -} - -ObjectPimpl::ObjectPimpl() - : DSObject(std::make_unique(this)) -{ - std::cout << "Constructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; -} - -ObjectPimpl::~ObjectPimpl() -{ - std::cout << "Destructor 'ObjectPimpl' : " << __PRETTY_FUNCTION__ << std::endl; -} - -int exampleObjectPimpl(void) -{ - std::cout << "\n=== ObjectPimpl *myobj = new ObjectPimpl() ===" << std::endl; - ObjectPimpl *myobj = new ObjectPimpl(); - - std::cout << "\n=== ObjectPimpl *myobj2 = new ObjectPimpl() ===" << std::endl; - ObjectPimpl *myobj2 = new ObjectPimpl(); - - std::cout << "\n=== delete myobj ===" << std::endl; - delete myobj; - - std::cout << "\n=== delete myobj2 ===" << std::endl; - delete myobj2; - - return 0; -} - -int main() -{ - return exampleObjectPimpl(); -} diff --git a/samples/exampleProperty.cpp b/samples/exampleProperty.cpp deleted file mode 100644 index 379af73..0000000 --- a/samples/exampleProperty.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include - -/* RESULT -=== Property *myproperty = new Property() === -Constructor 'Property' : Property::Property() - -=== Property *myproperty2 = new Property() === -Constructor 'Property' : Property::Property() - -=== Add Property [myProperty:1234(int)] to myproperty -Try get Property (key:"myProperty", type:int) of myproperty -myProperty: 1234 -Try get Property (key:"myProperty", type:float) of myproperty -ERR: Unexpected index - -=== Add Property [myProperty:0x11fd378(ptr)] to myproperty === -Try get Property (key:"myProperty", type:int) of myproperty -ERR: Unexpected index -Try get Property (key:"myProperty", type:void *) of myproperty -myProperty: 0x####### -Try get Property (key:"yourProperty", type:DSPropertyVariant&) of myproperty -SUCCESS: NOT_EXIST - -=== delete myproperty === -Destructor 'Property' : virtual Property::~Property() - -=== delete myproperty2 === -Destructor 'Property' : virtual Property::~Property() -*/ - -using namespace display_server; - -class Property : public DSObject -{ -public: - explicit Property(); - virtual ~Property(); -}; - -Property::Property() -{ - std::cout << "Constructor 'Property' : " << __PRETTY_FUNCTION__ << std::endl; -} - -Property::~Property() -{ - std::cout << "Destructor 'Property' : " << __PRETTY_FUNCTION__ << std::endl; -} - -int main() -{ - std::cout << "\n=== Property *myproperty = new Property() ===" << std::endl; - Property *myproperty = new Property(); - - std::cout << "\n=== Property *myproperty2 = new Property() ===" - << std::endl; - Property *myproperty2 = new Property(); - - std::cout << "\n=== Add Property [myProperty:1234(int)] to myproperty ===" - << std::endl; - myproperty->setProperty("myProperty", 1234, DSPropertyType::INTEGER); - - try { - std::cout - << "Try get Property (key:\"myProperty\", type:int) of myproperty" - << std::endl; - std::cout << "myProperty: " - << std::get(myproperty->getProperty("myProperty")) - << std::endl; - } catch (std::exception &e) { - std::cout << "ERR: " << e.what() << std::endl; - } - - try { - std::cout - << "Try get Property (key:\"myProperty\", type:float) of myproperty" - << std::endl; - std::cout << std::get(myproperty->getProperty("myProperty")) - << std::endl; - } catch (std::exception &e) { - std::cout << "ERR: " << e.what() << std::endl; - } - - std::cout << "\n=== Add Property [myProperty:" << myproperty2 - << "(ptr)] to myproperty ===" << std::endl; - myproperty->setProperty("myProperty", static_cast(myproperty2), - DSPropertyType::POINTER); - - try { - std::cout - << "Try get Property (key:\"myProperty\", type:int) of myproperty" - << std::endl; - std::cout << std::get(myproperty->getProperty("myProperty")) - << std::endl; - } catch (std::exception &e) { - std::cout << "ERR: " << e.what() << std::endl; - } - - try { - std::cout - << "Try get Property (key:\"myProperty\", type:void *) of myproperty" - << std::endl; - Property *mypropertyptr = static_cast( - std::get(myproperty->getProperty("myProperty"))); - std::cout << "myProperty: " << mypropertyptr << std::endl; - } catch (std::exception &e) { - std::cout << "ERR: " << e.what() << std::endl; - } - - try { - std::cout - << "Try get Property (key:\"yourProperty\", type:DSPropertyVariant&) of myproperty" - << std::endl; - const DSPropertyVariant &ptr = myproperty->getProperty("yourProperty"); - std::cout << " THIS LINE SHOULD BE NOT PRINTED! yourProperty: " << &ptr - << std::endl; - } catch (std::exception &e) { - std::cout << "SUCCESS: " << e.what() << std::endl; - } - - std::cout << "\n=== delete myproperty ===" << std::endl; - delete myproperty; - - std::cout << "\n=== delete myproperty2 ===" << std::endl; - delete myproperty2; - - return 0; -} diff --git a/samples/exampleSignalSlot.cpp b/samples/exampleSignalSlot.cpp deleted file mode 100644 index be91d27..0000000 --- a/samples/exampleSignalSlot.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include -#include - -/* RESULT -construct Sender -construct Sender -construct Receiver -construct Receiver -slotA invoked! a:1234 -slotA2 invoked! a:1234 -slotB invoked! a:45.67 -Lambda slot invoked! val: 45.67 -destruct Receiver(ref: 0) -slotB invoked! a:5678 -slotA invoked! a:90 -destruct Sender -destruct Sender -destruct Receiver(ref: 1) - */ - -using namespace display_server; - -using SignalAType = DSSignal; -using SignalBType = DSSignal; - -class Sender : public DSObject -{ -public: - Sender() : DSObject() - { - std::cout << "construct Sender" << std::endl; - } - ~Sender() - { - std::cout << "destruct Sender " << getName() << std::endl; - } - - struct SignalA : public SignalAType - { - void emit(int val) - { - SignalAType::emit(val); - } - } signalA; - - struct SignalB : public SignalBType - { - void emit(double val) - { - SignalBType::emit(val); - } - } signalB; -}; - -class Receiver : public DSObject, public DSRefBase -{ -public: - Receiver() : DSObject(), DSRefBase() - { - std::cout << "construct Receiver" << std::endl; - } - ~Receiver() - { - std::cout << "destruct Receiver(ref: " << getref() << ") " << getName() - << std::endl; - } - - static void slotA(int a) - { - std::cout << "slotA invoked! a:" << a << std::endl; - }; - static void slotA2(int a) - { - std::cout << "slotA2 invoked! a:" << a << std::endl; - } - static void slotB(double a) - { - std::cout << "slotB invoked! a:" << a << std::endl; - }; -}; - -int main(void) -{ - Sender *sender = new Sender(); - Sender *sender2 = new Sender(); - Receiver *receiver = new Receiver(); - Receiver *receiver2 = new Receiver(); - - sender->signalA.connect(receiver, Receiver::slotA); - sender->signalA.connect(receiver2, Receiver::slotA2); - sender->signalB.connect(receiver, Receiver::slotB); - sender->signalB.connect(receiver2, [](double val) { - std::cout << "Lambda slot invoked! val: " << val << std::endl; - }); - - sender->signalA.emit(1234); - sender->signalB.emit(45.67); - - if (receiver2->getref() == 1) { - receiver2->unref(); - receiver2 = nullptr; - } - - sender->signalB.emit(5678); - sender->signalA.emit(90.1); - - delete sender; - delete sender2; - delete receiver; - - return 0; -} diff --git a/samples/meson.build b/samples/meson.build deleted file mode 100644 index 28c5e1b..0000000 --- a/samples/meson.build +++ /dev/null @@ -1,60 +0,0 @@ -executable('exampleSignalSlot', - 'exampleSignalSlot.cpp', - dependencies : libds_declared_dep, - install_dir : libds_prefix_bindir, - install : true - ) - -executable('exampleObjectPimpl', - 'exampleObjectPimpl.cpp', - dependencies : libds_declared_dep, - install_dir : libds_prefix_bindir, - install : true - ) - -executable('exampleProperty', - 'exampleProperty.cpp', - dependencies : libds_declared_dep, - install_dir : libds_prefix_bindir, - install : true - ) - -executable('exampleCompositor', - 'exampleCompositor.cpp', - dependencies : libds_declared_dep, - install_dir : libds_prefix_bindir, - install : true - ) - -# exampleClient written for testing exampleCompositor -wayland_client_dep = dependency('wayland-client') -tizen_extension_client_dep = dependency('tizen-extension-client') -xdg_shell_client_dep = dependency('xdg-shell-unstable-v6-client') -tizen_launch_client_dep = dependency('tizen-launch-client') -libxkbcommon_dep = dependency('xkbcommon') -executable('exampleClient', - 'exampleClient.c', - dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, xdg_shell_client_dep, libxkbcommon_dep, tizen_launch_client_dep], - install_dir : libds_prefix_bindir, - install : true - ) - - -ecore_wayland2_dep = dependency('ecore-wl2') -wayland_tbm_client_dep = dependency('wayland-tbm-client') -executable('exampleClientNoShellRendering', - 'exampleClientNoShellRendering.cpp', - dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], - install_dir : libds_prefix_bindir, - install : true - ) - -wayland_tbm_client_dep = dependency('wayland-tbm-client') -xdg_shell_client_dep = dependency('xdg-shell-client') -xdg_shell_unstable_v6_client_dep = dependency('xdg-shell-unstable-v6-client') -executable('exampleClientShellRendering', - 'exampleClientShellRendering.cpp', - dependencies : [libds_declared_dep, wayland_client_dep, xdg_shell_client_dep, xdg_shell_unstable_v6_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], - install_dir : libds_prefix_bindir, - install : true - ) diff --git a/src/DSBase/DSRefBase.cpp b/src/DSBase/DSRefBase.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/DSBase/DSRefBase.h b/src/DSBase/DSRefBase.h deleted file mode 100644 index a2579f7..0000000 --- a/src/DSBase/DSRefBase.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_REF_BASE_H_ -#define __DS_REF_BASE_H_ - -namespace display_server -{ - -class DSRefBase -{ -public: - DSRefBase() - : __count(1) - {} - virtual ~DSRefBase() - {} - - void ref() - { - ++__count; - } - - inline void unref() - { - if (--__count == 0) - delete this; - } - - const int getref() const - { - return __count; - } - -private: - int __count; -}; - -} - -#endif diff --git a/src/DSBuffer/DSBufferManager.cpp b/src/DSBuffer/DSBufferManager.cpp deleted file mode 100644 index 3e2b7ae..0000000 --- a/src/DSBuffer/DSBufferManager.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSBufferManager.h" -#include "DSBufferManagerPrivate.h" -#include "DSDebugLog.h" -#include "DSBufferTBMImpl.h" -#include "DSUtilSocket.h" - -namespace display_server -{ - -int DSBufferManager::__refCount { 0 }; -std::mutex DSBufferManager::__mutex; -DSBufferManager* DSBufferManager::__bufferManager { nullptr }; - -struct BufferDestroyListener : ::wl_listener -{ - BufferDestroyListener() - { - notify = DSBufferManagerPrivate::bufferDestroyListenerCallback; - wl_list_init(&this->link); - } - - DSBufferManagerPrivate *bufferManager = nullptr; -}; - -/* Begin Public Class Implementation */ -DSBufferManager::DSBufferManager(DSObject *parent) - : DS_INIT_PRIVATE_PTR(DSBufferManager) -{ -} - -DSBufferManager::~DSBufferManager() -{ -} - -DSBufferManager *DSBufferManager::getInstance() -{ - std::lock_guard tLock(__mutex); - - if (!__bufferManager && (__refCount == 0)) - { - __bufferManager = new DSBufferManager(new DSObject); - DSLOG_INF("DSBufferManager", - "DSBufferManager instance has been created !"); - } - - ++__refCount; - return __bufferManager; -} - -void DSBufferManager::releaseInstance() -{ - std::lock_guard tLock(__mutex); - - --__refCount; - if (__refCount < 0) - __refCount = 0; - - if ((0 == __refCount) && __bufferManager) - { - delete __bufferManager; - __bufferManager = nullptr; - DSLOG_INF("DSBufferManager", - "DSBufferManager instance has been removed !"); - } -} - -void DSBufferManagerPrivate::bufferDestroyListenerCallback(struct ::wl_listener *listener, void *data) -{ - BufferDestroyListener *destroyListener = static_cast(listener); - struct ::wl_resource *bufferResource = static_cast(data); - DSBufferManagerPrivate *bufferManager = destroyListener->bufferManager; - std::shared_ptr dsBuffer = nullptr; - - wl_list_remove(&destroyListener->link); - delete destroyListener; - - auto it = bufferManager->__resourceMap.find(bufferResource); - if (it == bufferManager->__resourceMap.end()) - return; - - dsBuffer = it->second; - dsBuffer->setClientDestroyed(); - bufferManager->__resourceMap.erase(it); -} - -std::shared_ptr DSBufferManager::getDSBuffer(struct ::wl_resource *bufferResource) -{ - DS_GET_PRIV(DSBufferManager); - - return priv->getDSBuffer(bufferResource); -} - -DSBufferManagerPrivate::DSBufferManagerPrivate(DSBufferManager *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __wlTbmServer(nullptr) -{ - tbm_bufmgr bufmgr = nullptr; - - __waylandCompositor = DSWaylandCompositor::getInstance(); - - if (__waylandCompositor) { - wl_display_init_shm(__waylandCompositor->display()); - __wlTbmServer = wayland_tbm_server_init(__waylandCompositor->display(), NULL, -1, 0); - } else { - DSLOG_ERR("DSBufferManagerPrivate", "fail to get DSWaylandCompostior"); - } - - if (__wlTbmServer) { - bufmgr = static_cast(wayland_tbm_server_get_bufmgr(__wlTbmServer)); - } else { - DSLOG_ERR("DSBufferManagerPrivate", "fail to get tbm_bufmgr"); - } - - if (__waylandCompositor && bufmgr) - tbm_bufmgr_bind_native_display(bufmgr, __waylandCompositor->display()); - - DSUtilSocket *utilSocket = DSUtilSocket::getInstance(); - utilSocket->initSocket("tbm-drm-auth"); - utilSocket->releaseInstance(); - -} - -std::shared_ptr DSBufferManagerPrivate::getDSBuffer(struct ::wl_resource *bufferResource) -{ - std::shared_ptr dsBuffer; - tbm_surface_h tbm_surface; - - auto it = __resourceMap.find(bufferResource); - if (it != __resourceMap.end()) { - return it->second; - } - - tbm_surface = wayland_tbm_server_get_surface(NULL, bufferResource); - if (tbm_surface) - dsBuffer = std::make_shared(tbm_surface, bufferResource); - - if (dsBuffer.get() == nullptr) { - return nullptr; - } - - auto [itr, success] = __resourceMap.emplace(bufferResource, dsBuffer); - if (!success) - return nullptr; - - auto *destroyListener = new BufferDestroyListener; - destroyListener->bufferManager = this; - wl_resource_add_destroy_listener(bufferResource, destroyListener); - - return dsBuffer; -} - -DSBufferManagerPrivate::~DSBufferManagerPrivate() -{ - wayland_tbm_server_deinit(__wlTbmServer); - DSWaylandCompositor::releaseInstance(); -} - -} // namespace display_server diff --git a/src/DSBuffer/DSBufferManager.h b/src/DSBuffer/DSBufferManager.h deleted file mode 100644 index eddc501..0000000 --- a/src/DSBuffer/DSBufferManager.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_BUFFER_MANAGER_H__ -#define __DS_BUFFER_MANAGER_H__ - -#include -#include -#include -#include -#include "dswayland-server-wayland.h" - -namespace display_server -{ - -class DSBufferManagerPrivate; - -class DSBufferManager : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSBufferManager); -public: - static DSBufferManager *getInstance(); - static void releaseInstance(); - - std::shared_ptr getDSBuffer(struct ::wl_resource *bufferResource); - -private: - static std::mutex __mutex; - static DSBufferManager *__bufferManager; - static int __refCount; - - DSBufferManager() = delete; - ~DSBufferManager(); - DSBufferManager(DSObject *parent); - DSBufferManager& operator=(const DSBufferManager&) = delete; -}; - -} - -#endif diff --git a/src/DSBuffer/DSBufferManagerPrivate.h b/src/DSBuffer/DSBufferManagerPrivate.h deleted file mode 100644 index 24e80ba..0000000 --- a/src/DSBuffer/DSBufferManagerPrivate.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_BUFFER_MANAGER_PRIVATE_H__ -#define __DS_BUFFER_MANAGER_PRIVATE_H__ - -#include "DSBufferManager.h" -#include -#include -#include -#include - -namespace display_server -{ - -class DSBufferManagerPrivate : public DSObjectPrivate -{ - DS_PIMPL_USE_PUBLIC(DSBufferManager); -public: - DSBufferManagerPrivate() = delete; - DSBufferManagerPrivate(DSBufferManager *p_ptr); - ~DSBufferManagerPrivate(); - - std::shared_ptr getDSBuffer(struct ::wl_resource *bufferResource); - -private: - struct ::wayland_tbm_server * __wlTbmServer; - DSWaylandCompositor *__waylandCompositor; - std::unordered_map > __resourceMap; - - friend struct BufferDestroyListener; - static void bufferDestroyListenerCallback(struct ::wl_listener *listener, void *data); -}; - -} - -#endif diff --git a/src/DSBuffer/DSBufferQueueTBMImpl.cpp b/src/DSBuffer/DSBufferQueueTBMImpl.cpp deleted file mode 100644 index 4640d3a..0000000 --- a/src/DSBuffer/DSBufferQueueTBMImpl.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSBufferQueueTBMImpl.h" -#include "DSBufferTBMImpl.h" -#include "DSDebugLog.h" -#include - -namespace display_server -{ - -// the static variables. -DSSignal DSBufferQueueTBMImpl::__aquirableSignal; - -DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(int slotSize, int bufferWidth, int bufferHeight, IDSBuffer::Format format) - : __slotSize{slotSize}, - __bufferWidth{bufferWidth}, - __bufferHeight{bufferHeight}, - __format{format} -{ - __tqueue = tbm_surface_queue_create(__slotSize, __bufferWidth, __bufferHeight, DSBufferTBMImpl::getTBMFormat(__format), TBM_BO_SCANOUT); - if (!__tqueue) { - DSLOG_ERR("DSBufferTBM", "tbm_surface_queue_create fails."); - } - - tbm_surface_queue_add_acquirable_cb(__tqueue, __onAquireable, this); -} - -DSBufferQueueTBMImpl::DSBufferQueueTBMImpl(tbm_surface_queue_h tqueue) - : __slotSize{tbm_surface_queue_get_size(tqueue)}, - __bufferWidth{tbm_surface_queue_get_width(tqueue)}, - __bufferHeight{tbm_surface_queue_get_height(tqueue)}, - __format{DSBufferTBMImpl::getBufferFormat(tbm_surface_queue_get_format(tqueue))}, - __tqueue{tqueue} -{ - tbm_surface_queue_add_acquirable_cb(__tqueue, __onAquireable, this); -} - -DSBufferQueueTBMImpl::~DSBufferQueueTBMImpl() -{ - __bufferVector.erase(__bufferVector.begin(), __bufferVector.end()); - tbm_surface_queue_destroy(__tqueue); -} - -int DSBufferQueueTBMImpl::getBufferWidth() -{ - return __bufferWidth; -} - -int DSBufferQueueTBMImpl::getBufferHeight() -{ - return __bufferHeight; -} - -void *DSBufferQueueTBMImpl::getNativeBufferQueue() -{ - return (void *)__tqueue; -} - -std::shared_ptr DSBufferQueueTBMImpl::dequeueBuffer() -{ - tbm_surface_queue_error_e terror = TBM_SURFACE_QUEUE_ERROR_NONE; - tbm_surface_h tsurface; - - terror = tbm_surface_queue_dequeue(__tqueue, &tsurface); - if (terror != TBM_SURFACE_QUEUE_ERROR_NONE) { - DSLOG_ERR("BuffeQueueTBM", "tbm_surface_queue_dequeue fails."); - return nullptr; - } - - auto isMatchFunc = [tsurface](std::shared_ptr buffer) -> bool { - return ((tbm_surface_h)buffer->getNativeBuffer() == tsurface); - }; - - auto iter= std::find_if(__bufferVector.begin(), __bufferVector.end(), isMatchFunc); - if (iter == __bufferVector.end()) { - // create a IDSBuffer with tsurface. - __bufferVector.push_back(std::make_shared(__bufferWidth, __bufferWidth, __format, tsurface)); - - return __bufferVector.back(); - } - - return *iter; -} - -bool DSBufferQueueTBMImpl::enqueueBuffer(std::shared_ptr buffer) -{ - tbm_surface_queue_error_e terror = TBM_SURFACE_QUEUE_ERROR_NONE; - tbm_surface_h tsurface = (tbm_surface_h)buffer->getNativeBuffer(); - - terror = tbm_surface_queue_enqueue(__tqueue, tsurface); - if (terror != TBM_SURFACE_QUEUE_ERROR_NONE) { - DSLOG_ERR("BuffeQueueTBM", "tbm_surface_queue_enqueue fails."); - return false; - } - - return true; -} - -std::shared_ptr DSBufferQueueTBMImpl::acquireBuffer() -{ - tbm_surface_queue_error_e terror = TBM_SURFACE_QUEUE_ERROR_NONE; - tbm_surface_h tsurface; - - terror = tbm_surface_queue_acquire(__tqueue, &tsurface); - if (terror != TBM_SURFACE_QUEUE_ERROR_NONE) { - DSLOG_ERR("BuffeQueueTBM", "tbm_surface_queue_enqueue fails."); - return nullptr; - } - - auto isMatchFunc = [tsurface](std::shared_ptr buffer) -> bool { - return ((tbm_surface_h)buffer->getNativeBuffer() == tsurface); - }; - - auto iter= std::find_if(__bufferVector.begin(), __bufferVector.end(), isMatchFunc); - if (iter == __bufferVector.end()) { - // create a IDSBuffer with tsurface. - __bufferVector.push_back(std::make_shared(__bufferWidth, __bufferWidth, __format, tsurface)); - - return __bufferVector.back(); - } - - return *iter; -} - -bool DSBufferQueueTBMImpl::releaseBuffer(std::shared_ptr buffer) -{ - tbm_surface_queue_error_e terror = TBM_SURFACE_QUEUE_ERROR_NONE; - - terror = tbm_surface_queue_release(__tqueue, (tbm_surface_h)buffer->getNativeBuffer()); - if (terror != TBM_SURFACE_QUEUE_ERROR_NONE) { - DSLOG_ERR("BuffeQueueTBM", "tbm_surface_queue_release fails."); - return false; - } - - return true; -} - -bool DSBufferQueueTBMImpl::canAcquireBuffer(bool wait) -{ - if (!tbm_surface_queue_can_acquire(__tqueue, wait)) - return false; - - return true; -} - -void DSBufferQueueTBMImpl::registerCallbackAcquirable(DSObject *slot, std::function func) -{ - __aquirableSignal.connect(slot, func); -} - -void DSBufferQueueTBMImpl::__onAquireable(tbm_surface_queue_h surface_queue, void *data) -{ - __aquirableSignal.emit(data); -} - -} diff --git a/src/DSBuffer/DSBufferQueueTBMImpl.h b/src/DSBuffer/DSBufferQueueTBMImpl.h deleted file mode 100644 index f74a94e..0000000 --- a/src/DSBuffer/DSBufferQueueTBMImpl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_BUFFER_QUEUE_TBM_IMPL_H_ -#define __DS_BUFFER_QUEUE_TBM_IMPL_H_ - -#include "IDSBufferQueue.h" -#include "DSSignal.h" -#include -#include - -namespace display_server -{ - -class DSBufferQueueTBMImpl : public IDSBufferQueue -{ -public: - DSBufferQueueTBMImpl(int slotSize, int bufferWidth, int bufferHeight, IDSBuffer::Format format); - DSBufferQueueTBMImpl(tbm_surface_queue_h tqueue); - ~DSBufferQueueTBMImpl(); - - int getBufferWidth() override; - int getBufferHeight() override; - void *getNativeBufferQueue() override; - - std::shared_ptr dequeueBuffer() override; - bool enqueueBuffer(std::shared_ptr buffer) override; - std::shared_ptr acquireBuffer() override; - bool releaseBuffer(std::shared_ptr buffer) override; - - bool canAcquireBuffer(bool wait) override; - void registerCallbackAcquirable(DSObject *slot, std::function func) override; - -private: - int __slotSize; - int __bufferWidth; - int __bufferHeight; - IDSBuffer::Format __format; - tbm_surface_queue_h __tqueue; - std::vector> __bufferVector; - - static void __onAquireable(tbm_surface_queue_h surface_queue, void *data); - static DSSignal __aquirableSignal; -}; - -} - -#endif diff --git a/src/DSBuffer/DSBufferRef.cpp b/src/DSBuffer/DSBufferRef.cpp deleted file mode 100644 index 01c38cc..0000000 --- a/src/DSBuffer/DSBufferRef.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSBufferRef.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -DSBufferRef::DSBufferRef(std::shared_ptr dsBuffer) - : __dsBuffer(dsBuffer) -{ - __dsBuffer->ref(); -} - -DSBufferRef::~DSBufferRef() -{ - __dsBuffer->unref(); -} - -std::shared_ptr DSBufferRef::refDSBufferGet() -{ - return __dsBuffer; -} - -} // namespace display_server diff --git a/src/DSBuffer/DSBufferRef.h b/src/DSBuffer/DSBufferRef.h deleted file mode 100644 index a56d38c..0000000 --- a/src/DSBuffer/DSBufferRef.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_BUFFER_REF_H__ -#define __DS_BUFFER_REF_H__ - -#include -#include - -namespace display_server -{ - -class DSBufferRef -{ -public: - explicit DSBufferRef(std::shared_ptr dsBuffer); - virtual ~DSBufferRef(); - - std::shared_ptr refDSBufferGet(); - -private: - std::shared_ptr __dsBuffer; -}; - -} - -#endif diff --git a/src/DSBuffer/DSBufferTBMImpl.cpp b/src/DSBuffer/DSBufferTBMImpl.cpp deleted file mode 100644 index 6cfcc3b..0000000 --- a/src/DSBuffer/DSBufferTBMImpl.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSBufferTBMImpl.h" -#include "DSDebugLog.h" -#include - -namespace display_server -{ - -DSBufferTBMImpl::DSBufferTBMImpl(int width, int height, IDSBuffer::Format format) - : __width{width}, - __height{height}, - __format{format}, - __refCount(0), - __resource(nullptr), - __type(DSBufferTBMImpl::Type::SERVER) - -{ - __tsurface = tbm_surface_create(__width, __height, getTBMFormat(__format)); - if (!__tsurface) { - DSLOG_ERR("DSBufferTBM", "tbm_surface_create fails."); - } -} - -DSBufferTBMImpl::DSBufferTBMImpl(int width, int height, IDSBuffer::Format format, tbm_surface_h tsurface) - : __width{width}, - __height{height}, - __format{format}, - __refCount(0), - __tsurface(tsurface), - __resource(nullptr), - __type(DSBufferTBMImpl::Type::SERVER) -{} - -DSBufferTBMImpl::DSBufferTBMImpl(tbm_surface_h tsurface, struct ::wl_resource *resource) - : __refCount(0), - __tsurface(tsurface), - __resource(resource), - __type(DSBufferTBMImpl::Type::CLIENT) -{ - __width = tbm_surface_get_width(tsurface); - __height = tbm_surface_get_height(tsurface); - __format = getBufferFormat(tbm_surface_get_format(tsurface)); - - tbm_surface_internal_ref(tsurface); -} - -DSBufferTBMImpl::~DSBufferTBMImpl() -{ - tbm_surface_destroy(__tsurface); -} - -void *DSBufferTBMImpl::getNativeBuffer() -{ - return (void *)__tsurface; -} - -void DSBufferTBMImpl::setClientDestroyed() -{ - this->__resource = nullptr; -} - -void DSBufferTBMImpl::ref() -{ - __refCount++; -} - -void DSBufferTBMImpl::unref() -{ - __refCount--; - - if (__refCount <= 0) { - if (this->__type == display_server::DSBufferTBMImpl::Type::CLIENT) { - if (this->__resource) - wl_buffer_send_release(this->__resource); - } - } -} - -std::shared_ptr DSBufferTBMImpl::getSize() -{ - std::shared_ptr bufferSize = std::make_shared(); - bufferSize->w = __width; - bufferSize->h = __height; - - return bufferSize; -} - -tbm_format DSBufferTBMImpl::getTBMFormat(const IDSBuffer::Format &format) -{ - tbm_format tformat = 0; // what is the error format? - - switch (format) { - case IDSBuffer::Format::FORMAT_ARGB8888 : - tformat = TBM_FORMAT_ARGB8888; - break; - default: - DSLOG_ERR("DSBufferTBM", "(%d) format is not supported.", format); - } - - return tformat; -} - -IDSBuffer::Format DSBufferTBMImpl::getBufferFormat(const tbm_format &tformat) -{ - IDSBuffer::Format format = IDSBuffer::Format::FORMAT_ARGB8888; - - switch (tformat) { - case TBM_FORMAT_ARGB8888 : - format = IDSBuffer::Format::FORMAT_ARGB8888 ; - break; - default: - DSLOG_ERR("DSBufferTBM", "(%d) format is not supported.", tformat); - } - - return format; -} - -} diff --git a/src/DSBuffer/DSBufferTBMImpl.h b/src/DSBuffer/DSBufferTBMImpl.h deleted file mode 100644 index 642ff4f..0000000 --- a/src/DSBuffer/DSBufferTBMImpl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_BUFFER_TBM_IMPL_H_ -#define __DS_BUFFER_TBM_IMPL_H_ - -#include "IDSBuffer.h" -#include "dswayland-server-wayland.h" -#include - -namespace display_server -{ - -class DSBufferTBMImpl : public IDSBuffer -{ -public: - DSBufferTBMImpl(int width, int height, IDSBuffer::Format format); - DSBufferTBMImpl(int width, int height, IDSBuffer::Format format, tbm_surface_h tsurface); - DSBufferTBMImpl(tbm_surface_h tsurface, struct ::wl_resource *resource); - ~DSBufferTBMImpl(); - - void *getNativeBuffer() override; - void setClientDestroyed() override; - void ref() override; - void unref() override; - std::shared_ptr getSize() override; - - static tbm_format getTBMFormat(const IDSBuffer::Format &format); - static IDSBuffer::Format getBufferFormat(const tbm_format &tformat); - - enum Type { - SERVER, - CLIENT - }; - -private: - int __width; - int __height; - IDSBuffer::Format __format; - int __refCount; - tbm_surface_h __tsurface; - struct ::wl_resource *__resource; - DSBufferTBMImpl::Type __type; -}; - -} - -#endif diff --git a/src/DSBuffer/IDSBuffer.h b/src/DSBuffer/IDSBuffer.h deleted file mode 100644 index ff3413c..0000000 --- a/src/DSBuffer/IDSBuffer.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __I_DS_BUFFER_H_ -#define __I_DS_BUFFER_H_ - -#include "DSCore.h" -#include "DSStruct.h" - -namespace display_server -{ - -class IDSBuffer -{ -public: - enum Format { - FORMAT_ARGB8888 - }; - -public: - virtual ~IDSBuffer() = default; - - virtual void *getNativeBuffer() = 0; - virtual void setClientDestroyed() = 0; - virtual void ref() = 0; - virtual void unref() = 0; - virtual std::shared_ptr getSize() = 0; -}; - -} - -#endif diff --git a/src/DSBuffer/IDSBufferQueue.h b/src/DSBuffer/IDSBufferQueue.h deleted file mode 100644 index 80ade8b..0000000 --- a/src/DSBuffer/IDSBufferQueue.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __I_DS_BUFFER_QUEUE_H__ -#define __I_DS_BUFFER_QUEUE_H__ - -#include "IDSBuffer.h" -#include "DSObject.h" - -namespace display_server -{ - -class IDSBufferQueue : public DSObject -{ -public: - virtual ~IDSBufferQueue() = default; - - virtual int getBufferWidth() = 0; - virtual int getBufferHeight() = 0; - virtual void *getNativeBufferQueue() = 0; - virtual std::shared_ptr dequeueBuffer() = 0; - virtual bool enqueueBuffer(std::shared_ptr ) = 0; - virtual std::shared_ptr acquireBuffer() = 0; - virtual bool releaseBuffer(std::shared_ptr ) = 0; - - virtual bool canAcquireBuffer(bool wait) = 0; - virtual void registerCallbackAcquirable(DSObject *slot, std::function func) = 0; -}; - -} - -#endif diff --git a/src/DSBuffer/README.md b/src/DSBuffer/README.md deleted file mode 100644 index 2f2bf49..0000000 --- a/src/DSBuffer/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# DSBuffer -Buffer - -## Requirements - -* Buffer를 생성해야 한다. with w, h, format -* drmbuf fd(TBM)를 받아서 Buffer를 생성할 수 있어야 한다. -* drmbuf fd(TBM)을 Buffer로 부터 얻을 수 있어야 한다. -* shm_id를 받아서 Buffer를 생성할 수 있어야 한다. -* Buffer를 Reference 관리할 수 있어야 한다.(ref/unref) -* NativeBuffer가 있어야 한다. NativeBuffer라 함은, tbmBuffer, shmBuffer and others -* Buffer에서 virtual address(memory 시작 pointer)를 얻을 수 있어야 한다. - - diff --git a/src/DSBuffer/plantuml/IDSBuffer.plantuml b/src/DSBuffer/plantuml/IDSBuffer.plantuml deleted file mode 100644 index e839d38..0000000 --- a/src/DSBuffer/plantuml/IDSBuffer.plantuml +++ /dev/null @@ -1,25 +0,0 @@ -class Client -{ -} - -Client "1" o-right- "0..*" IDSBuffer - -interface IDSBuffer -{ -} - -IDSBuffer <|-down-- DSBufferTBMImpl -IDSBuffer <|-down-- DSBufferSHMImpl - -class DSBufferTBMImpl -{ - + DSBufferTBMImpl(int width, int height, IDSBuffer::Format format); - + DSBufferTBMImpl(); - + static tbm_format &getTBMFormat(IDSBuffer::Format &format); - - - int __width; - - int __height; - - IDSBuffer::Format __format; - - tbm_surface_h __tsurface; -} - diff --git a/src/DSBuffer/plantuml/IDSBufferQueue.plantuml b/src/DSBuffer/plantuml/IDSBufferQueue.plantuml deleted file mode 100755 index 65fc114..0000000 --- a/src/DSBuffer/plantuml/IDSBufferQueue.plantuml +++ /dev/null @@ -1,47 +0,0 @@ -@startuml -class Client -{ -} - -Client "1" o-right- "0..*" IDSBufferQueue -Client -[hidden]- IDSBuffer - -interface IDSBufferQueue -{ - + virtual bool enqueueBuffer(std::shared_ptr buffer) = 0; - + virtual std::shared_ptr dequeueBuffer() = 0; - + virtual std::shared_ptr acquireBuffer() = 0; - + virtual bool releaseBuffer(std::shared_ptr buffer) = 0; -} - -IDSBuffer "0..*" *-up- "1" DSBufferQueueTBMImpl -IDSBuffer "0..*" *-up- "1" DSBufferQueueSHMImpl - -abstract class IDSBuffer -{ -} - -IDSBufferQueue <|-down-- DSBufferQueueTBMImpl -IDSBufferQueue <|-down-- DSBufferQueueSHMImpl - -class DSBufferQueueTBMImpl -{ - + DSBufferQueueTBMImpl(int slotSize, int bufferWidth, int bufferHeight, IDSBuffer::Format format); - + ~DSBufferQueueTBMImpl(); - - + bool enqueueBuffer(std::shared_ptr buffer) override; - + IDSBuffer *dequeueBuffer() override; - + IDSBuffer *acquireBuffer() override; - + bool releaseBuffer(std::shared_ptr buffer) override; - - - int __slotSize; - - int __bufferWidth; - - int __bufferHeight; - - IDSBuffer::Format __format; - - tbm_surface_queue_h __tqueue; -} - -IDSBuffer <|-down-- DSBufferTBMImpl -IDSBuffer <|-down-- DSBufferSHMImpl -@enduml - diff --git a/src/DSCallback/DSCallback.h b/src/DSCallback/DSCallback.h deleted file mode 100644 index 477ca7c..0000000 --- a/src/DSCallback/DSCallback.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_CALLBACK_H_ -#define __DS_CALLBACK_H_ - -#include - -namespace display_server -{ -template -class DSCallback -{ -protected: - DSCallback(const DSCallback &cb) - {} - virtual ~DSCallback() - {} - - bool operator==(const DSCallback &cb); - -private: - std::function __function; -}; - -template -class DSCallbackUnique : public DSCallback -{ -public: - DSCallbackUnique((void)(*function)(Args...)); -}; - -template -class DSCallbackMember : public DSCallback -{ - -}; - -template -class DSCallbackSignal : public DSCallback -{ -}; - -} - -#endif diff --git a/src/DSCanvas/DSCanvas.cpp b/src/DSCanvas/DSCanvas.cpp deleted file mode 100644 index ded3bff..0000000 --- a/src/DSCanvas/DSCanvas.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSCanvas.h" -#include "DSCanvasPrivate.h" -#include "DSPolicyAreaPrivate.h" -#include "DSDisplayAreaPrivate.h" - -namespace display_server -{ - -DSCanvas::DSCanvas() - : DS_INIT_PRIVATE_PTR(DSCanvas) -{} - -DSCanvas::~DSCanvas() -{} - -bool DSCanvas::attachPolicyArea(std::shared_ptr policyArea) -{ - DS_GET_PRIV(DSCanvas); - - if (!priv->attachPolicyArea(policyArea)) - return false; - - return true; -} - -bool DSCanvas::attachDisplayArea(std::shared_ptr displayArea) -{ - DS_GET_PRIV(DSCanvas); - - if (!priv->attachDisplayArea(displayArea)) - return false; - - return true; -} - -DSCanvasPrivate::DSCanvasPrivate(DSCanvas *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __zone(nullptr), - __policyArea(nullptr), - __displayArea(nullptr) -{} - -DSCanvasPrivate::~DSCanvasPrivate() -{} - -bool DSCanvasPrivate::attachPolicyArea(std::shared_ptr policyArea) -{ - if (__policyArea) { - DSLOG_ERR("DSCanvasPrivate", "canvas has already policyArea(%p).", __policyArea); - return false; - } - - __policyArea = policyArea; - - // add zone to DSDisplayAreaPrivate - if (__displayArea) { - DSDisplayAreaPrivate *displayAreaPriv = DSDisplayAreaPrivate::getPrivate(__displayArea.get()); - if (displayAreaPriv) { - DSPolicyAreaPrivate *policyAreaPriv = DSPolicyAreaPrivate::getPrivate(__policyArea.get()); - displayAreaPriv->addZone(policyAreaPriv->getZone()); - } - } - - return true; -} - -bool DSCanvasPrivate::attachDisplayArea(std::shared_ptr displayArea) -{ - if (__displayArea) { - DSLOG_ERR("DSCanvasPrivate", "canvas has already displayArea(%p).", __displayArea); - return false; - } - - __displayArea = displayArea; - - // add zone to DSDisplayAreaPrivate - if (__policyArea) { - DSDisplayAreaPrivate *displayAreaPriv = DSDisplayAreaPrivate::getPrivate(__displayArea.get()); - if (displayAreaPriv) { - DSPolicyAreaPrivate *policyAreaPriv = DSPolicyAreaPrivate::getPrivate(__policyArea.get()); - displayAreaPriv->addZone(policyAreaPriv->getZone()); - } - } - - return true; -} - -} // namespace display_server diff --git a/src/DSCanvas/DSCanvas.h b/src/DSCanvas/DSCanvas.h deleted file mode 100644 index 95c3f0e..0000000 --- a/src/DSCanvas/DSCanvas.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_CANVAS_H__ -#define __DS_CANVAS_H__ - -#include -#include -#include -#include - -namespace display_server -{ - -class DSCanvasPrivate; - -class DSCanvas : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSCanvas); -public: - explicit DSCanvas(); - virtual ~DSCanvas(); - - bool attachPolicyArea(std::shared_ptr polcyArea); - bool attachDisplayArea(std::shared_ptr displayArea); -}; - -} - -#endif diff --git a/src/DSCanvas/DSCanvasPrivate.h b/src/DSCanvas/DSCanvasPrivate.h deleted file mode 100644 index b1735f4..0000000 --- a/src/DSCanvas/DSCanvasPrivate.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_CANVAS_PRIVATE_H__ -#define __DS_CANVAS_PRIVATE_H__ - -#include "DSCanvas.h" -#include "DSZone.h" - -namespace display_server -{ - -class DSCanvasPrivate : public DSObjectPrivate, public DSObject -{ -DS_PIMPL_USE_PUBLIC(DSCanvas); -public: - DSCanvasPrivate() = delete; - DSCanvasPrivate(DSCanvas *p_ptr); - ~DSCanvasPrivate(); - - static DSCanvasPrivate *getPrivate(DSCanvas *q) { return q->__d_func(); } - bool attachPolicyArea(std::shared_ptr polcyArea); - bool attachDisplayArea(std::shared_ptr displayArea); - -private: - std::shared_ptr __zone; - std::shared_ptr __policyArea; - std::shared_ptr __displayArea; -}; - -} - -#endif diff --git a/src/DSClient/DSClient.cpp b/src/DSClient/DSClient.cpp deleted file mode 100644 index bc887e9..0000000 --- a/src/DSClient/DSClient.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSClient.h" -#include "DSClientPrivate.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandClient.h" -#include "DSWindow.h" - -namespace display_server -{ - -/* Begin Private Class Implementation */ -DSClientPrivate::DSClientPrivate(DSClient *client, DSWaylandClient *dswlClient) - : DSObjectPrivate(client), - __p_ptr(client), - __dswlComp(nullptr), - __dswlClient(dswlClient), - __numWindows(0) -{ - __windows.clear(); -} - -DSClientPrivate::~DSClientPrivate() -{ - __windows.clear(); -} - -bool DSClientPrivate::addWindow(DSWindow *window) -{ - if (window == nullptr) return false; - - for (auto win : __windows) - { - if (window == win) - { - DSLOG_ERR("DSClient", "Window(%p) exists already.", window); - return true; - } - } - - __windows.push_back(window); - __numWindows++; - return true; -} - -bool DSClientPrivate::delWindow(DSWindow *window) -{ - if (window == nullptr) return false; - - for (auto win : __windows) - { - if (window == win) - { - __windows.remove(window); - DSLOG_ERR("DSClient", "Window(%p) has been removed.", window); - __numWindows--; - if (__numWindows < 0) __numWindows = 0; - return true; - } - } - - return false; -} - -/* Begin Public Class Implementation */ -DSClient::DSClient(DSCompositor *compositor) - : _d_ptr(std::make_unique(this, nullptr)), - __compositor(compositor) -{ - -} -DSClient::DSClient(DSCompositor *compositor, DSWaylandClient *dswlClient) - : _d_ptr(std::make_unique(this, dswlClient)), - __compositor(compositor) -{ - -} - -DSClient::~DSClient() -{ -} - -bool DSClient::addWindow(DSWindow *window) -{ - DS_GET_PRIV(DSClient); - - return priv->addWindow(window); -} - -bool DSClient::removeWindow(DSWindow *window) -{ - DS_GET_PRIV(DSClient); - - return priv->delWindow(window); -} - -std::list DSClient::getWindows() -{ - DS_GET_PRIV(DSClient); - - return priv->__windows; -} - -uint32_t DSClient::numWindows() -{ - DS_GET_PRIV(DSClient); - - return priv->__numWindows; -} - -bool DSClient::hasWindow() -{ - DS_GET_PRIV(DSClient); - - return priv->__numWindows ? true : false; -} - -} // namespace display_server diff --git a/src/DSClient/DSClient.h b/src/DSClient/DSClient.h deleted file mode 100644 index 5e457d4..0000000 --- a/src/DSClient/DSClient.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_SEAT_H__ -#define __DS_SEAT_H__ - -#include "DSCore.h" -#include "DSObject.h" - -namespace display_server -{ - -class DSClientPrivate; -class DSWaylandClient; -class DSCompositor; -class DSWindow; - -class DSClient : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSClient) -public: - DSClient() = delete; - DSClient(DSCompositor *compositor); - DSClient(DSCompositor *compositor, DSWaylandClient *dswlClient); - ~DSClient() override; - - bool addWindow(DSWindow *window); - bool removeWindow(DSWindow *window); - std::list getWindows(); - uint32_t numWindows(); - bool hasWindow(); - -private: - DSCompositor *__compositor; -}; - -} - -#endif //__DS_SEAT_H__ diff --git a/src/DSClient/DSClientPrivate.h b/src/DSClient/DSClientPrivate.h deleted file mode 100644 index 2f4a90b..0000000 --- a/src/DSClient/DSClientPrivate.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_SEAT_PRIVATE_H__ -#define __DS_SEAT_PRIVATE_H__ - -#include "DSCore.h" -#include "DSObjectPrivate.h" - -namespace display_server -{ - -class DSClient; -class DSWaylandCompositor; - -class DSClientPrivate : public DSObjectPrivate -{ - DS_PIMPL_USE_PUBLIC(DSClient); -public: - DSClientPrivate() = delete; - DSClientPrivate(DSClient *client, DSWaylandClient *dswlClient); - ~DSClientPrivate() override; - - bool addWindow(DSWindow *win); - bool delWindow(DSWindow *win); - -private: - DSWaylandCompositor *__dswlComp; - DSWaylandClient *__dswlClient; - std::list __windows;//use if one or more windows in a client - int __numWindows; -}; - -} - -#endif //__DS_SEAT_PRIVATE_H__ diff --git a/src/DSCompositor/DSCompositor.cpp b/src/DSCompositor/DSCompositor.cpp deleted file mode 100644 index 30e8d02..0000000 --- a/src/DSCompositor/DSCompositor.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSCore.h" -#include "DSCompositor.h" -#include "DSCompositorPrivate.h" -#include "DSDebugLog.h" -#include "DSDisplayDeviceTDMImpl.h" -#include "DSOutputImpl.h" -#include "DSSeat.h" -#include "DSInput.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandProtocolTrace.h" -#include - -namespace display_server -{ - -DSCompositor::DSCompositor() - : DS_INIT_PRIVATE_PTR(DSCompositor) -{} - -DSCompositor::~DSCompositor() -{} - -bool DSCompositor::run() -{ - DS_GET_PRIV(DSCompositor); - - if (!priv->run()) { - DSLOG_ERR("Compositor", "priv->run() fails."); - return false; - } - - return true; -} - -bool DSCompositor::quit() -{ - DS_GET_PRIV(DSCompositor); - - if (!priv->quit()) { - DSLOG_ERR("Compositor", "priv->quit() fails."); - return false; - } - - return true; -} - -DSCompositorPrivate::DSCompositorPrivate(DSCompositor *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __displayDevice(nullptr), - __canvas(nullptr), - __dsBufferManager(nullptr), - __dsAppinfoMgr(nullptr), - __dsWindowMgr(nullptr), - __protocolTrace(nullptr) - -{ - __eventLoop = DSEventLoop::getInstance(); - __wlCompositor = DSWaylandCompositor::getInstance(); - __displayDevice = std::make_unique(); -} - -DSCompositorPrivate::~DSCompositorPrivate() -{ - DSWindowManager::releaseInstance(); - DSWaylandCompositor::releaseInstance(); - DSBufferManager::releaseInstance(); - DSEventLoop::releaseInstance(); - DSTizenAppinfoMgr::releaseInstance(); - DSWaylandProtocolTrace::releaseInstance(); -} - -bool DSCompositorPrivate::run() -{ - DS_GET_PUB(DSCompositor); - - __initializeWlDisplay(); - __initializeOutputs(); - __initializeBufferManager(); - __initializeTizenAppinfoMgr(); - __initializeWindowManager(); - __initializeProtocolTrace(); - __canvas = pub->_onInitialized(); - if (!__canvas) { - DSLOG_ERR("Compositor", "_onInitialized() fails."); - return false; - } - - if (!__eventLoop->run()) { - DSLOG_ERR("Compositor", "__eventLoop->run() fails."); - return false; - } - - return true; -} - -bool DSCompositorPrivate::quit() -{ - if (!__eventLoop->quit()) { - DSLOG_ERR("Compositor", "__eventLoop->quit() fails."); - return false; - } - - return true; -} - -void DSCompositorPrivate::__initializeWlDisplay() -{ - __wlCompositor->create(); -} - -void DSCompositorPrivate::__initializeOutputs() -{ - DS_GET_PUB(DSCompositor); - - auto displayDeviceOutputList = __displayDevice->getOutputList(); - if (displayDeviceOutputList.empty()) { - DSLOG_INF("Compositor", "displayDeviceOutputList.empty()."); - return; - } - - // make a IDSOutput only when the IDSDisplayDeviceOutput is connected and - // then call the _onOutputAdded() - for (auto displayDeviceOutput : displayDeviceOutputList) { - if (displayDeviceOutput->getConnectState() == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - __outputList.push_back(std::make_shared(displayDeviceOutput)); - pub->_onOutputAdded(__outputList.back()); - } -} - -void DSCompositorPrivate::__initializeBufferManager() -{ - __dsBufferManager = DSBufferManager::getInstance(); -} - -void DSCompositorPrivate::__initializeTizenAppinfoMgr() -{ - __dsAppinfoMgr = DSTizenAppinfoMgr::getInstance(); -} - -void DSCompositorPrivate::__initializeWindowManager() -{ - __dsWindowMgr = DSWindowManager::getInstance(); -} - -void DSCompositorPrivate::__initializeProtocolTrace() -{ - __protocolTrace = DSWaylandProtocolTrace::getInstance(); - if(__protocolTrace){ - if(__protocolTrace->init()) - __protocolTrace->enableProtocolTrace(true); - } -} -} // namespace display_server diff --git a/src/DSCompositor/DSCompositor.h b/src/DSCompositor/DSCompositor.h deleted file mode 100644 index 2307859..0000000 --- a/src/DSCompositor/DSCompositor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_COMPOSITOR_H__ -#define __DS_COMPOSITOR_H__ - -#include -#include -#include -#include -#include - -namespace display_server -{ - -class DSCompositorPrivate; - -class DSCompositor : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSCompositor); -public: - explicit DSCompositor(); - virtual ~DSCompositor(); - - bool run(); - bool quit(); - -protected: - virtual std::shared_ptr _onInitialized() = 0; - virtual void _onOutputAdded(std::shared_ptr output) = 0; - virtual void _onOutputRemoved(std::shared_ptr output) = 0; - virtual void _onInputAdded(std::shared_ptr input) = 0; - virtual void _onInputRemoved(std::shared_ptr input) = 0; -}; - -} - -#endif diff --git a/src/DSCompositor/DSCompositorPrivate.h b/src/DSCompositor/DSCompositorPrivate.h deleted file mode 100644 index 5f072d8..0000000 --- a/src/DSCompositor/DSCompositorPrivate.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_COMPOSITORPRIVATE_H__ -#define __DS_COMPOSITORPRIVATE_H__ - -#include "DSCompositor.h" -#include "DSEventLoop.h" -#include "IDSDisplayDevice.h" -#include "DSBufferManager.h" -#include "DSTizenAppinfoMgr.h" -#include "DSWindowManager.h" -#include "DSWaylandProtocolTrace.h" - -namespace display_server -{ - -class DSSeat; -class DSInput; -class DSWaylandCompositor; -class DSTizenAppinfoMgr; - -class DSCompositorPrivate : public DSObjectPrivate -{ -DS_PIMPL_USE_PUBLIC(DSCompositor); -public: - DSCompositorPrivate() = delete; - DSCompositorPrivate(DSCompositor *p_ptr); - ~DSCompositorPrivate(); - - bool run(); - bool quit(); - - static DSCompositorPrivate *getPrivate(DSCompositor *q) { return q->__d_func(); } - -protected: - -private: - DSEventLoop *__eventLoop; - std::unique_ptr __displayDevice; - DSWaylandCompositor *__wlCompositor; - - std::list> __outputList; - std::shared_ptr __canvas; - DSBufferManager *__dsBufferManager; - DSTizenAppinfoMgr * __dsAppinfoMgr; - DSWindowManager *__dsWindowMgr; - DSWaylandProtocolTrace *__protocolTrace; - - void __initializeWlDisplay(); - void __initializeOutputs(); - void __initializeBufferManager(); - void __initializeTizenAppinfoMgr(); - void __initializeWindowManager(); - void __initializeProtocolTrace(); -}; - -} - -#endif diff --git a/src/DSCore/DSCore.h b/src/DSCore/DSCore.h deleted file mode 100644 index cacf7b7..0000000 --- a/src/DSCore/DSCore.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_CORE_H__ -#define __DS_CORE_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Macros for visibility */ -#define DS_DECL_EXPORT __attribute__((visibility("default"))) -#define DS_DECL_HIDDEN __attribute__((visibility("hidden"))) - -/* Macros for supporting PImpl(Pointer to implementation) Idiom */ -/* Regarding PImpl Idiom, refer to https://www.geeksforgeeks.org/pimpl-idiom-in-c-with-examples */ -#define DS_PIMPL_USE_PRIVATE(Class) \ - protected: \ - std::unique_ptr _d_ptr; \ - \ - private: \ - inline Class##Private *__d_func() \ - { return reinterpret_cast(_d_ptr.get()); } \ - inline const Class##Private *__d_func() const \ - { return reinterpret_cast(_d_ptr.get()); } \ - friend class Class##Private; - -#define DS_PIMPL_USE_PUBLIC(Class) \ - protected: \ - inline Class* p_func() { return static_cast(__p_ptr); } \ - inline const Class* p_func() const { return static_cast(__p_ptr); } \ - friend class Class; \ - \ - private: \ - Class* __p_ptr; - -#define DS_INIT_PRIVATE_PTR(Class) \ - _d_ptr(std::make_unique(this)) - -#define DS_GET_PRIV(Class) \ - Class##Private* const priv = __d_func() - -#define DS_GET_PUB(Class) \ - Class * const pub = p_func() - -/* Macros for getting the pointer of the given 'Class' - * from the wl_resource via the Private class of the given 'Class' - */ -#define DS_WAYLAND_DEFINE_FROM_RESOURCE(Class) \ - public: \ - static Class *fromWlResource(struct ::wl_resource *resource); - -#define DS_WAYLAND_IMPL_FROM_RESOURCE(Class) \ - static Class##Private *__getPrivatePtrFromWlResource(struct ::wl_resource *resource) \ - { \ - auto rsrc = std::remove_pointer::type::Resource::fromResource(resource); \ - return rsrc ? static_cast(rsrc->object()) : nullptr; \ - } \ - \ - Class *Class::fromWlResource(struct ::wl_resource *resource) \ - { \ - Class##Private* privat = __getPrivatePtrFromWlResource(resource); \ - return privat? privat->p_func() : nullptr; \ - } - -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif - -#endif //__DS_CORE_H__ - diff --git a/src/DSCore/DSStruct.h b/src/DSCore/DSStruct.h deleted file mode 100644 index eb6da6c..0000000 --- a/src/DSCore/DSStruct.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_STRUCT_H__ -#define __DS_STRUCT_H__ - -#include - -namespace display_server -{ - -using stPosition = struct _stPosition; -using stSize = struct _stSize; -using stRect = struct _stRect; -using stGeometry = struct _stGeometry; - -struct _stPosition -{ - int x; - int y; -}; - -struct _stSize -{ - unsigned int w; - unsigned int h; -}; - -struct _stRect -{ - int x; - int y; - uint32_t w; - uint32_t h; -}; - -struct _stGeometry -{ - int x; - int y; - unsigned int w; - unsigned int h; -}; - -} // namespace display_server - -#endif //__DS_STRUCT_H__ - diff --git a/src/DSDebug/DSDebugLog.cpp b/src/DSDebug/DSDebugLog.cpp deleted file mode 100644 index f6e3581..0000000 --- a/src/DSDebug/DSDebugLog.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include "DSDebugLog.h" -#include - -#define COLOR_RED "\x1b[31m" /* for error */ -#define COLOR_YELLOW "\x1b[33m" /* for warning */ -#define COLOR_GREEN "\x1b[32m" /* for info */ -#define COLOR_RESET "\x1b[0m" - -namespace display_server -{ -/*LCOV_EXCL_START*/ - -DSDebugLog::DSDebugLog() : mLogLevel(LOG_LEVEL_DEBUG), __enableDlog(false) -{ - char *tmp = getenv("DSLOG_DLOG_ENABLE"); - if (!tmp) return; - - char *env = strdup(tmp); - if (!env) return; - - int value = atoi(env); - - free(env); - - if (value == 1) - __enableDlog = true; -} - -DSDebugLog::~DSDebugLog() -{} - -DSDebugLog *DSDebugLog::mInstance { nullptr }; -std::mutex DSDebugLog::mMutex; - -DSDebugLog *DSDebugLog::GetInstance() -{ - if (mInstance == nullptr) { - std::lock_guard lock(mMutex); - if (mInstance == nullptr) { - mInstance = new DSDebugLog(); - } - } - - return mInstance; -} - -void DSDebugLog::printLog(int logLevel, const char *domain, const char *funcName, int line, const char *fmt, ...) -{ - //TODO: apply logLevel - //TODO: use dlog or stdout - //TODO: use dlog filters - va_list arg; - - if (__enableDlog) - { - const log_priority dlogLevel[] = { DLOG_DEBUG, DLOG_INFO, DLOG_WARN, DLOG_ERROR }; - char buf[512] = {0,}; - - va_start(arg, fmt); - vsnprintf((char *)buf, sizeof(buf), fmt, arg); - va_end(arg); - - dlog_print(dlogLevel[logLevel], "LIBDS", "[%s][%s:%d] %s", domain, funcName, line, buf); - } - else - { - const char *lvl_str[] = { "DS_DBG", "DS_INF", "DS_WRN", "DS_ERR" }; - const char *color[] = { COLOR_RESET, COLOR_GREEN, COLOR_YELLOW, COLOR_RED }; - - va_start(arg, fmt); - printf( "%s", color[logLevel]); - printf( "[%s]", lvl_str[logLevel]); - printf( "[%s]", domain); - printf( ":[%s(%d)]:", funcName, line); - vprintf( fmt, arg); - printf( "\n"); - va_end(arg); - } -} - -int DSDebugLog::getLogLevel() -{ - return mLogLevel; -} - -/*LCOV_EXCL_STOP*/ -} // namespace display_serer diff --git a/src/DSDebug/DSDebugLog.h b/src/DSDebug/DSDebugLog.h deleted file mode 100644 index a1e8dfd..0000000 --- a/src/DSDebug/DSDebugLog.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DSDEBUG_H_ -#define _DSDEBUG_H_ - -#include -#include - -namespace display_server -{ -class DSDebugLog -{ -public: - enum Log_Level - { - LOG_LEVEL_DEBUG, - LOG_LEVEL_INFO, - LOG_LEVEL_WARN, - LOG_LEVEL_ERR, - }; - -public: - DSDebugLog(DSDebugLog &other) = delete; // should not be cloneable - void operator=(const DSDebugLog &) = delete; // should not be assignable - - static DSDebugLog *GetInstance(); - void printLog(int logLevel, const char *domain, const char *funcName, int line, const char *fmt, ...); - int getLogLevel(); - -private: - DSDebugLog(); // private constructor - ~DSDebugLog(); // private desctructor - - static DSDebugLog *mInstance; // singleton instance - static std::mutex mMutex; // mutex - int mLogLevel; // current log level - bool __enableDlog; -}; - -#define DSLOG_DBG(domain, fmt, args...) \ - do { \ - DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, domain, __func__, __LINE__, fmt, \ - ##args); \ - } while (0) - -#define DSLOG_INF(domain, fmt, args...) \ - do { \ - DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_INFO, domain, __func__, __LINE__, fmt, \ - ##args); \ - } while (0) - -#define DSLOG_WRN(domain, fmt, args...) \ - do { \ - DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_WARN, domain, __func__, __LINE__, fmt, \ - ##args); \ - } while (0) - -#define DSLOG_ERR(domain, fmt, args...) \ - do { \ - DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_ERR, domain, __func__, __LINE__, fmt, \ - ##args); \ - } while (0) -} - -#endif diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp deleted file mode 100644 index ec84dc0..0000000 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSDisplayArea.h" -#include "DSDisplayAreaPrivate.h" -#include "DSOutputImpl.h" -#include "DSRenderEngineEcoreEvasImpl.h" -#include "DSRenderEngineDaliImpl.h" - -namespace display_server -{ - -DSDisplayArea::DSDisplayArea(std::shared_ptr output) - : _d_ptr(std::make_unique(this, output)) -{} - -DSDisplayArea::~DSDisplayArea() -{} - -int DSDisplayArea::getWidth() -{ - DS_GET_PRIV(DSDisplayArea); - - return priv->getWidth(); -} - -int DSDisplayArea::getHeight() -{ - DS_GET_PRIV(DSDisplayArea); - - return priv->getHeight(); -} - -std::shared_ptr DSDisplayArea::getOutput() -{ - DS_GET_PRIV(DSDisplayArea); - - return priv->getOutput(); -} - -DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr output) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __output(output), - __displayDeviceOutput(nullptr), - __displayDeviceHWC(nullptr), - __zone(nullptr), - __renderEngine(nullptr), - __eventLoop(nullptr), - __x(0), - __y(0), - __width(0), - __height(0) -{ - auto outputImpl = std::dynamic_pointer_cast(output); // down-casting of std::shared_ptr - - __displayDeviceOutput = outputImpl->getDisplayDeviceOutput(); - if (!__displayDeviceOutput) - DSLOG_ERR("DSCanvasPrivate", "__displayDeviceOutput is null."); - - __displayDeviceHWC = __displayDeviceOutput->getHWC(); - if (!__displayDeviceHWC) - DSLOG_ERR("DSCanvasPrivate", "__displayDeviceHWC is null."); - - auto bufferQueue = __displayDeviceHWC->getTargetBufferQueue(); - if (!bufferQueue) - DSLOG_ERR("DSDisplayAreaPrivate", "bufferQueue is null."); - - __renderEngine = std::make_shared(bufferQueue); - if (!__renderEngine) - DSLOG_ERR("DSCanvasPrivate", "__RenderEngine is null."); - - __eventLoop = DSEventLoop::getInstance(); - - // register idle enterer callback on __onEventIdleEnterer for rendereing and displaying - __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSDisplayAreaPrivate::__onEventIdleEnterer, this, std::placeholders::_1)); - - // The size of DSDisplayArea is the one of DSOutput - __width = outputImpl->getResolutionWidth(); - __height = outputImpl->getResolutionHeight(); -} - -DSDisplayAreaPrivate::~DSDisplayAreaPrivate() -{ - DSEventLoop::releaseInstance(); -} - -int DSDisplayAreaPrivate::getWidth() -{ - if (__output == nullptr) - return -1; - - return __width; -} - -int DSDisplayAreaPrivate::getHeight() -{ - if (__output == nullptr) - return -1; - - return __height; -} - -std::shared_ptr DSDisplayAreaPrivate::getOutput() -{ - return __output; -} - -bool DSDisplayAreaPrivate::addZone(std::shared_ptr zone) -{ - __zone = zone; - __zone->registerCallbackWindowCreated(this, std::bind(&DSDisplayAreaPrivate::__onWindowCreated, this, std::placeholders::_1)); - - return true; -} - -void DSDisplayAreaPrivate::__onWindowCreated(std::shared_ptr window) -{ - // make a render view and set to the window. - auto renderView = __renderEngine->makeRenderView(); - window->setRenderView(renderView); - - // make a hwc window and set to the window. - auto displayDeviceHWCWindow = __displayDeviceHWC->makeHWCWindow(); - window->setDisplayDeviceHWCWindow(displayDeviceHWCWindow); -} - -void DSDisplayAreaPrivate::__onEventIdleEnterer(void *data) -{ - //DSLOG_INF("DSDisplayAreaPrivate", "__onEventIdleEnterer"); - - __displayDeviceHWC->commit(); - __renderEngine->renderFrame(); -} - -} // namespace display_server diff --git a/src/DSDisplayArea/DSDisplayArea.h b/src/DSDisplayArea/DSDisplayArea.h deleted file mode 100644 index b743b1d..0000000 --- a/src/DSDisplayArea/DSDisplayArea.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_DISPLAY_AREA_H__ -#define __DS_DISPLAY_AREA_H__ - -#include -#include -#include - -namespace display_server -{ -class DSDisplayAreaPrivate; - -class DSDisplayArea : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSDisplayArea); -public: - explicit DSDisplayArea(std::shared_ptr output); - virtual ~DSDisplayArea(); - - int getWidth(); - int getHeight(); - std::shared_ptr getOutput(); -}; - -} - -#endif diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h deleted file mode 100644 index 693458b..0000000 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_DISPLAY_AREA_PRIVATE_H__ -#define __DS_DISPLAY_AREA_PRIVATE_H__ - -#include "DSDisplayArea.h" -#include "DSWindow.h" -#include "DSZone.h" -#include "IDSRenderEngine.h" -#include -#include "IDSDisplayDeviceOutput.h" -#include "IDSDisplayDeviceHWC.h" -#include "DSEventLoop.h" - -namespace display_server -{ - -class DSDisplayAreaPrivate : public DSObjectPrivate, public DSObject -{ -DS_PIMPL_USE_PUBLIC(DSDisplayArea); -public: - DSDisplayAreaPrivate() = delete; - DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr output); - virtual ~DSDisplayAreaPrivate(); - - static DSDisplayAreaPrivate *getPrivate(DSDisplayArea *q) { return q->__d_func(); } - int getWidth(); - int getHeight(); - - bool setOutput(std::shared_ptr output); - std::shared_ptr getOutput(); - bool addZone(std::shared_ptr zone); - -private: - void __onWindowCreated(std::shared_ptr window); - void __onEventIdleEnterer(void *data); - - std::shared_ptr __output; - std::shared_ptr __displayDeviceOutput; - std::shared_ptr __displayDeviceHWC; - std::shared_ptr __zone; - std::shared_ptr __renderEngine; - DSEventLoop *__eventLoop; - int __x, __y; - int __width, __height; -}; - -} - -#endif diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp deleted file mode 100644 index 2355e11..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSDisplayDeviceHWCTDMImpl.h" -#include "DSDisplayDeviceHWCWindowTDMImpl.h" -#include "DSDisplayDeviceHWCWindowTDMTargetImpl.h" -#include "DSDebugLog.h" -#include - -namespace display_server -{ - -DSDisplayDeviceHWCTDMImpl::DSDisplayDeviceHWCTDMImpl(tdm_hwc *thwc) - : __thwc(thwc), - __bufferQueue(nullptr) -{} - -DSDisplayDeviceHWCTDMImpl::~DSDisplayDeviceHWCTDMImpl() -{ - clearVisibleHWCWindows(); -} - -std::shared_ptr DSDisplayDeviceHWCTDMImpl::getTargetBufferQueue() -{ - tdm_error terror; - tbm_surface_queue_h tqueue; - - if (__bufferQueue) { - DSLOG_INF("TDM_HWC", "return the existed IDSBufferQueue."); - return __bufferQueue; - } - - tqueue = tdm_hwc_get_client_target_buffer_queue(__thwc, &terror); - if (terror != TDM_ERROR_NONE) { -/*LCOV_EXCL_START*/ - DSLOG_ERR("HWCTDM", "tdm_hwc_get_client_target_buffer_queue fails."); -/*LCOV_EXCL_STOP*/ - } - - __bufferQueue = std::make_shared(tqueue); - - __targetWindow = std::make_unique(this, __bufferQueue); - - return __bufferQueue; -} - -bool DSDisplayDeviceHWCTDMImpl::setTargetBuffer(std::shared_ptr buffer) -{ - tdm_error terror; - tdm_region fb_damage; - std::memset(&fb_damage, 0, sizeof (tdm_region)); - - terror = tdm_hwc_set_client_target_buffer(__thwc, (tbm_surface_h)buffer->getNativeBuffer(), fb_damage); - if (terror != TDM_ERROR_NONE) { -/*LCOV_EXCL_START*/ - DSLOG_ERR("TDM_HWC", "tdm_hwc_set_client_target_buffer fails."); - return false; -/*LCOV_EXCL_STOP*/ - } - - return true; -} - -std::shared_ptr DSDisplayDeviceHWCTDMImpl::makeHWCWindow() -{ - std::shared_ptr deviceHWCWindow; - tdm_error terror; - tdm_hwc_window *twindow; - - twindow = tdm_hwc_create_window(__thwc, &terror); - if (!twindow) { -/*LCOV_EXCL_START*/ - DSLOG_ERR("HWCTDM", "tdm_hwc_create_window fails."); - return nullptr; -/*LCOV_EXCL_STOP*/ - } - - deviceHWCWindow = std::make_shared(twindow); - if (!deviceHWCWindow) { -/*LCOV_EXCL_START*/ - DSLOG_ERR("HWCTDM", "new DSDisplayDeviceHWCWindowTDMImpl fails."); - return nullptr; -/*LCOV_EXCL_STOP*/ - } - - return deviceHWCWindow; -} - -bool DSDisplayDeviceHWCTDMImpl::addVisibleHWCWindow(std::shared_ptr deviceHWCWindow) -{ - __visibleDeviceHWCWindowList.push_back(deviceHWCWindow); - - return true; -} - -bool DSDisplayDeviceHWCTDMImpl::removeVisibleHWCWindow(std::shared_ptr deviceHWCWindow) -{ - __visibleDeviceHWCWindowList.remove(deviceHWCWindow); - - return true; -} - -void DSDisplayDeviceHWCTDMImpl::clearVisibleHWCWindows() -{ - __visibleDeviceHWCWindowList.clear(); -} - -bool DSDisplayDeviceHWCTDMImpl::commit() -{ - tdm_error terror; - uint32_t numChanges; - - if (!__updateFrameWindows()) { - //DSLOG_INF("HWCTDM", "no update windows."); - return false; - } - - if (!__validate(numChanges)) { - DSLOG_ERR("HWCTDM", "__validate fails."); - return false; - } - - if (numChanges > 0) { - if (!__updateChanges(numChanges)) { - DSLOG_ERR("HWCTDM", "__updateChanges fails."); - return false; - } - } - - if (!__acceptValidation()) { - DSLOG_ERR("HWCTDM", "__acceptValidation fails."); - return false; - } - - if (!__presentFrameWindows()) { - DSLOG_ERR("HWCTDM", "__presentFrameWindows fails."); - return false; - } - - //TODO: commit with async - terror = tdm_hwc_commit(__thwc, true, NULL, NULL); - if (terror != TDM_ERROR_NONE) { -/*LCOV_EXCL_START*/ - DSLOG_ERR("HWCTDM", "tdm_hwc_commit fails."); - __presentFrameDoneWindows(); - return false; -/*LCOV_EXCL_STOP*/ - } - - DSLOG_INF("HWCTDM", "HWC COMMIT COMMIT COMMIT ~#######"); - - __presentFrameDoneWindows(); - - return true; -} - -bool DSDisplayDeviceHWCTDMImpl::__validate(uint32_t &numChanges) -{ - int numVisibleHWCWins = __visibleDeviceHWCWindowList.size(); - tdm_error terror; - tdm_hwc_window **thwc_windows; - int i = 0; - - // get the thwc_windows to request validate. - thwc_windows = (tdm_hwc_window **)calloc(numVisibleHWCWins, sizeof(tdm_hwc_window *)); - if (thwc_windows == nullptr) { - DSLOG_ERR("TDM_HWC", "calloc thwc_windows fails."); - return false; - } - - for (auto &&deviceHWCWindow : __visibleDeviceHWCWindowList) { - auto deviceHWCWindowTDM = std::dynamic_pointer_cast(deviceHWCWindow); - thwc_windows[i++] = deviceHWCWindowTDM->getNativeHWCWindow(); - } - - // validate thwc_windows - terror = tdm_hwc_validate(__thwc, thwc_windows, numVisibleHWCWins, &numChanges); - if (terror != TDM_ERROR_NONE) { -/*LCOV_EXCL_START*/ - DSLOG_ERR("TDM_HWC", "tdm_hwc_validate fails."); - free(thwc_windows); - return false; -/*LCOV_EXCL_STOP*/ - } - - free(thwc_windows); - - return true; -} - -bool DSDisplayDeviceHWCTDMImpl::__updateChanges(uint32_t numChanges) -{ - tdm_error terror; - tdm_hwc_window **changed_thwc_window = NULL; - tdm_hwc_window_composition *tcomposition_types = NULL; - int i; - - changed_thwc_window = (tdm_hwc_window **)calloc(numChanges, sizeof(tdm_hwc_window *)); - if (changed_thwc_window == nullptr) { - DSLOG_ERR("TDM_HWC", "calloc changed_thwc_window fails."); - return false; - } - - // get changed_types - tcomposition_types = (tdm_hwc_window_composition *)calloc(numChanges, sizeof(tdm_hwc_window_composition)); - if (tcomposition_types == nullptr) { - DSLOG_ERR("TDM_HWC", "calloc changed_thwc_window fails."); - free(changed_thwc_window); - return false; - } - - terror = tdm_hwc_get_changed_composition_types(__thwc, &numChanges, changed_thwc_window, tcomposition_types); - if (terror != TDM_ERROR_NONE) { - DSLOG_ERR("TDM_HWC", "tdm_hwc_get_changed_composition_types fails."); - free(tcomposition_types); - free(changed_thwc_window); - return false; - } - - for (i = 0; i < (int)numChanges; ++i) { - //TODO: change the TYPES of HWCWindows - } - - free(tcomposition_types); - free(changed_thwc_window); - - return true; -} - -bool DSDisplayDeviceHWCTDMImpl::__acceptValidation() -{ - tdm_error terror; - - // TODO: accept_validation is depending on the transitions. - terror = tdm_hwc_accept_validation(__thwc); - if (terror != TDM_ERROR_NONE) { -/*LCOV_EXCL_STOP*/ - DSLOG_ERR("TDM_HWC", "tdm_hwc_accept_validation fails."); - return false; -/*LCOV_EXCL_STOP*/ - } - - return true; -} - -bool DSDisplayDeviceHWCTDMImpl::__updateFrameWindows() -{ - if (!__targetWindow->updateFrame()) { - return false; - } - - return true; -} - -bool DSDisplayDeviceHWCTDMImpl::__presentFrameWindows() -{ - __targetWindow->presentFrame(); - - return true; -} - -bool DSDisplayDeviceHWCTDMImpl::__presentFrameDoneWindows() -{ - __targetWindow->onPresentFrameDone(); - - return true; -} - -} diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h deleted file mode 100644 index d33efaa..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_DISPLAY_DEVICE_HWC_TDM_IMPL_H_ -#define _DS_DISPLAY_DEVICE_HWC_TDM_IMPL_H_ - -#include "IDSDisplayDeviceHWC.h" -#include "DSBufferQueueTBMImpl.h" -#include -#include - -namespace display_server -{ -class DSDisplayDeviceHWCTDMImpl : public IDSDisplayDeviceHWC -{ -public: - DSDisplayDeviceHWCTDMImpl(tdm_hwc *thwc); - ~DSDisplayDeviceHWCTDMImpl(); - - std::shared_ptr getTargetBufferQueue() override; - bool setTargetBuffer(std::shared_ptr buffer) override; - std::shared_ptr makeHWCWindow() override; - bool addVisibleHWCWindow(std::shared_ptr deviceHWCWindow) override; - bool removeVisibleHWCWindow(std::shared_ptr deviceHWCWindow) override; - void clearVisibleHWCWindows() override; - bool commit() override; - -private: - tdm_hwc *__thwc; - std::shared_ptr __bufferQueue; - std::list> __visibleDeviceHWCWindowList; - std::unique_ptr __targetWindow; - - - bool __validate(uint32_t &numChanges); - bool __updateChanges(uint32_t numChanges); - bool __acceptValidation(); - bool __updateFrameWindows(); - bool __presentFrameWindows(); - bool __presentFrameDoneWindows(); -}; -} - -#endif diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp deleted file mode 100644 index 121ca63..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSDisplayDeviceHWCWindowTDMImpl.h" -#include "DSDebugLog.h" - -namespace display_server -{ -DSDisplayDeviceHWCWindowTDMImpl::DSDisplayDeviceHWCWindowTDMImpl(tdm_hwc_window *twindow) - : __twindow(twindow) -{} - -DSDisplayDeviceHWCWindowTDMImpl::~DSDisplayDeviceHWCWindowTDMImpl() -{ - tdm_hwc_window_destroy(__twindow); -} -tdm_hwc_window *DSDisplayDeviceHWCWindowTDMImpl::getNativeHWCWindow() -{ - return __twindow; -} - -bool DSDisplayDeviceHWCWindowTDMImpl::updateFrame() -{ - // temp always false update - return false; -} - -void DSDisplayDeviceHWCWindowTDMImpl::presentFrame() -{ - /* TODO:: */ -} - -void DSDisplayDeviceHWCWindowTDMImpl::onPresentFrameDone() -{ - /* TODO:: */ -} - -} diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h deleted file mode 100644 index 2cc68c3..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _I_DS_DISPLAY_DEVICE_HWC_WINDOW_TDM_IMPL_H_ -#define _I_DS_DISPLAY_DEVICE_HWC_WINDOW_TDM_IMPL_H_ - -#include "IDSDisplayDeviceHWCWindow.h" -#include "DSWindow.h" -#include "IDSBuffer.h" -#include - -namespace display_server -{ -class DSDisplayDeviceHWCWindowTDMImpl : public IDSDisplayDeviceHWCWindow -{ -public: - DSDisplayDeviceHWCWindowTDMImpl(tdm_hwc_window *twindow); - ~DSDisplayDeviceHWCWindowTDMImpl(); - tdm_hwc_window *getNativeHWCWindow(); - - bool updateFrame() override; - void presentFrame() override; - void onPresentFrameDone() override; - -private: - tdm_hwc_window *__twindow; -}; - -} - -#endif diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp deleted file mode 100644 index fc67c7c..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSDisplayDeviceHWCWindowTDMTargetImpl.h" -#include "DSDebugLog.h" -# include - -namespace display_server -{ - -DSDisplayDeviceHWCWindowTDMTargetImpl::DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr bufferQueue) - : __deviceHWC(deviceHWC), - __bufferQueue(bufferQueue), - __ecoreFdHandler(nullptr) -{ - if (!ecore_init()) { -/*LCOV_EXCL_START*/ - DSLOG_ERR("EventLoop", "ecore_init() fails."); -/*LCOV_EXCL_STOP*/ - } - - __eventFd = eventfd(0, EFD_NONBLOCK); - __ecoreFdHandler = ecore_main_fd_handler_add(__eventFd, ECORE_FD_READ, __onFdHandler, this, NULL, NULL); - __bufferQueue->registerCallbackAcquirable(this, std::bind(&DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable, this, std::placeholders::_1)); -} - -DSDisplayDeviceHWCWindowTDMTargetImpl::~DSDisplayDeviceHWCWindowTDMTargetImpl() -{ - ecore_main_fd_handler_del(__ecoreFdHandler); - close(__eventFd); - - ecore_shutdown(); -} - -bool DSDisplayDeviceHWCWindowTDMTargetImpl::updateFrame() -{ - std::shared_ptr dsBuffer; - - if (!__bufferQueue->canAcquireBuffer(false)) { - //DSLOG_INF("TDM_HWC", "no acquirable buffer."); - return false; - } - - dsBuffer = __bufferQueue->acquireBuffer(); - if (!dsBuffer) { - DSLOG_ERR("TDM_HWC", "acquire buffer fails."); - return false; - } - - if (__buffer) { - __bufferQueue->releaseBuffer(__buffer); - __buffer = nullptr; - } - - __buffer = dsBuffer; - __deviceHWC->setTargetBuffer(__buffer); - - return true; -} - -void DSDisplayDeviceHWCWindowTDMTargetImpl::presentFrame() -{ - if (__buffer) { - __presentBuffer = std::move(__buffer); - } -} - -void DSDisplayDeviceHWCWindowTDMTargetImpl::onPresentFrameDone() -{ - if (__presentedBuffer) - __bufferQueue->releaseBuffer(__presentedBuffer); - - __presentedBuffer = std::move(__presentBuffer); -} - -Eina_Bool DSDisplayDeviceHWCWindowTDMTargetImpl::__onFdHandler(void *data, Ecore_Fd_Handler *hdlr) -{ -/*LCOV_EXCL_START*/ - int len; - int fd; - char buffer[64]; - - fd = ecore_main_fd_handler_fd_get(hdlr); - if (fd < 0) - return ECORE_CALLBACK_RENEW; - - len = read(fd, buffer, sizeof(buffer)); - if (len == -1) - DSLOG_WRN("DSDisplayDeviceHWCWindowTDMTargetImpl", "failed to read buffer from event fd:%m"); - - return ECORE_CALLBACK_RENEW; -/*LCOV_EXCL_STOP*/ -} - -void DSDisplayDeviceHWCWindowTDMTargetImpl::__onAcquirable(void *data) -{ - uint64_t value = 1; - int ret; - - ret = write(__eventFd, &value, sizeof(value)); - if (ret == -1) { -/*LCOV_EXCL_START*/ - DSLOG_WRN("DSDisplayDeviceHWCWindowTDMTargetImpl", "failed to write a value on event fd:%m"); -/*LCOV_EXCL_STOP*/ - } - -} - -} diff --git a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h b/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h deleted file mode 100644 index 4f644f6..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _I_DS_DISPLAY_DEVICE_HWC_WINDOW_TDM_TARGET_IMPL_H_ -#define _I_DS_DISPLAY_DEVICE_HWC_WINDOW_TDM_TARGET_IMPL_H_ - -#include "IDSDisplayDeviceHWCWindow.h" -#include "IDSDisplayDeviceHWC.h" -#include "IDSBufferQueue.h" -#include "IDSBuffer.h" -#include -#include - -namespace display_server -{ -class DSDisplayDeviceHWCWindowTDMTargetImpl : public IDSDisplayDeviceHWCWindow, public DSObject -{ -public: - DSDisplayDeviceHWCWindowTDMTargetImpl(IDSDisplayDeviceHWC *deviceHWC, std::shared_ptr __bufferQueue); - ~DSDisplayDeviceHWCWindowTDMTargetImpl(); - - bool updateFrame() override; - void presentFrame() override; - void onPresentFrameDone() override; - -private: - static Eina_Bool __onFdHandler(void *data, Ecore_Fd_Handler *hdlr); - void __onAcquirable(void *data); - - IDSDisplayDeviceHWC *__deviceHWC; - std::shared_ptr __bufferQueue; - std::shared_ptr __buffer; - std::shared_ptr __presentBuffer; - std::shared_ptr __presentedBuffer; - int __eventFd; - Ecore_Fd_Handler *__ecoreFdHandler; -}; - -} - -#endif diff --git a/src/DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.cpp deleted file mode 100644 index cbae76e..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSDisplayDeviceOutputModeTDMImpl.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -DSDisplayDeviceOutputModeTDMImpl::DSDisplayDeviceOutputModeTDMImpl(const tdm_output_mode *tmode) - : __tmode{tmode} -{} - -DSDisplayDeviceOutputModeTDMImpl::~DSDisplayDeviceOutputModeTDMImpl() -{} - -unsigned int DSDisplayDeviceOutputModeTDMImpl::getRefreshRate() -{ - return __tmode->vrefresh; -} - -unsigned int DSDisplayDeviceOutputModeTDMImpl::getHorizontalSize() -{ - return __tmode->hdisplay; -} - -unsigned int DSDisplayDeviceOutputModeTDMImpl::getVertialSize() -{ - return __tmode->vdisplay; -} - -std::string DSDisplayDeviceOutputModeTDMImpl::getName() -{ - std::string name(__tmode->name); - - return name; -} - -const tdm_output_mode *DSDisplayDeviceOutputModeTDMImpl::getNative() -{ - return __tmode; -} - -} diff --git a/src/DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.h deleted file mode 100644 index 29a4ba4..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_DISPLAY_DEVICE_OUTPUT_MODE_TDM_IMPL_H__ -#define __DS_DISPLAY_DEVICE_OUTPUT_MODE_TDM_IMPL_H__ - -#include "IDSDisplayDeviceOutputMode.h" -#include - -namespace display_server -{ - -class DSDisplayDeviceOutputModeTDMImpl : public IDSDisplayDeviceOutputMode -{ -public: - DSDisplayDeviceOutputModeTDMImpl(const tdm_output_mode *tmode); - ~DSDisplayDeviceOutputModeTDMImpl(); - - unsigned int getRefreshRate() override; - unsigned int getHorizontalSize() override; - unsigned int getVertialSize() override; - std::string getName() override; - - const tdm_output_mode *getNative(); - -private: - const tdm_output_mode *__tmode; -}; - -} - -#endif diff --git a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp deleted file mode 100644 index b167a01..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp +++ /dev/null @@ -1,316 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSDisplayDeviceOutputTDMImpl.h" -#include "DSDisplayDeviceHWCTDMImpl.h" -#include "DSDisplayDeviceOutputModeTDMImpl.h" -#include "DSDebugLog.h" -#include - -namespace display_server -{ - -DSDisplayDeviceOutputTDMImpl::DSDisplayDeviceOutputTDMImpl() - : __toutput(nullptr), - __resolutionWidth(0), - __resolutionHeight(0), - __physicalMMWidth(0), - __physicalMMHeight(0), - __refreshRate(0), - __outputMode(nullptr), - __dpmsMode(IDSDisplayDeviceOutput::DPMS_OFF), - __displayDeviceHWC(nullptr) -{ - __initializeConnectorType(); - __updateConnectState(); -} - -DSDisplayDeviceOutputTDMImpl::DSDisplayDeviceOutputTDMImpl(tdm_output *toutput) - : __toutput(toutput), - __resolutionWidth(0), - __resolutionHeight(0), - __physicalMMWidth(0), - __physicalMMHeight(0), - __refreshRate(0), - __outputMode(nullptr), - __dpmsMode(IDSDisplayDeviceOutput::DPMS_OFF), - __displayDeviceHWC(nullptr) -{ - tdm_error terror; - tdm_hwc *thwc; - - __initializeConnectorType(); - __updateConnectState(); - if (__connectState != IDSDisplayDeviceOutput::STATE_DISCONNECTED) { - __updatePhysicalMMSize(); - __updateAvailableModeList(); - } - - thwc = tdm_output_get_hwc(toutput, &terror); - if (thwc) { - __displayDeviceHWC = std::make_shared(thwc); - } else { - //TODO: need fallback for HWC - DSLOG_WRN("TDM OUTPUT", "tdm_output_get_hwc fails."); - } -} - -DSDisplayDeviceOutputTDMImpl::~DSDisplayDeviceOutputTDMImpl() -{ - __deleteAvailableModeList(); -} - -IDSDisplayDeviceOutput::ConnectorType DSDisplayDeviceOutputTDMImpl::getConnectType() -{ - return __connectorType; -} - -IDSDisplayDeviceOutput::ConnectState DSDisplayDeviceOutputTDMImpl::getConnectState() -{ - return __connectState; -} - -std::list> DSDisplayDeviceOutputTDMImpl::getAvailableModes() -{ - return __availableModeList; -} - -int DSDisplayDeviceOutputTDMImpl::getResolutionWidth() -{ - return __resolutionWidth; -} - -int DSDisplayDeviceOutputTDMImpl::getResolutionHeight() -{ - return __resolutionHeight; -} - -int DSDisplayDeviceOutputTDMImpl::getPhysicalMMWidth() -{ - return __physicalMMWidth; -} - -int DSDisplayDeviceOutputTDMImpl::getPhysicalMMHeight() -{ - return __physicalMMHeight; -} - -int DSDisplayDeviceOutputTDMImpl::getRefreshRate() -{ - return __refreshRate; -} - -std::string DSDisplayDeviceOutputTDMImpl::getName() -{ - return __name; -} - -bool DSDisplayDeviceOutputTDMImpl::setMode(std::shared_ptr outputMode) -{ - tdm_error terror; - auto outputModeTDM = std::dynamic_pointer_cast(outputMode); // down-casting of std::shared_ptr - const tdm_output_mode *ttmode = outputModeTDM->getNative(); - - terror = tdm_output_set_mode(__toutput, ttmode); - if (terror != TDM_ERROR_NONE) { - DSLOG_ERR("TDM OUTPUT", "tdm_output_set_mode fails."); - return false; - } - - __outputMode = outputMode; - __resolutionWidth = __outputMode->getHorizontalSize(); - __resolutionHeight = __outputMode->getVertialSize(); - __refreshRate = __outputMode->getRefreshRate(); - __name = __outputMode->getName(); - - return true; -} - -std::shared_ptr DSDisplayDeviceOutputTDMImpl::getMode() -{ - return __outputMode; -} - -bool DSDisplayDeviceOutputTDMImpl::setDPMSMode(DPMSMode dpmsMode) -{ - return false; -} - -IDSDisplayDeviceOutput::DPMSMode DSDisplayDeviceOutputTDMImpl::getDPMSMode() -{ - return __dpmsMode; -} - -std::shared_ptr DSDisplayDeviceOutputTDMImpl::getHWC() -{ - return __displayDeviceHWC; -} - -void DSDisplayDeviceOutputTDMImpl::__initializeConnectorType() -{ - tdm_error terror; - tdm_output_type ttype; - - terror = tdm_output_get_output_type(__toutput, &ttype); - if (terror != TDM_ERROR_NONE) { - DSLOG_ERR("TDM OUTPUT", "tdm_output_get_output_type fails."); - return; - } - - if (ttype == TDM_OUTPUT_TYPE_Unknown) - __connectorType = IDSDisplayDeviceOutput::TYPE_UNKNOWN; - else if (ttype == TDM_OUTPUT_TYPE_VGA) - __connectorType = IDSDisplayDeviceOutput::TYPE_VGA; - else if (ttype == TDM_OUTPUT_TYPE_DVII) - __connectorType = IDSDisplayDeviceOutput::TYPE_DVII; - if (ttype == TDM_OUTPUT_TYPE_DVID) - __connectorType = IDSDisplayDeviceOutput::TYPE_DVID; - if (ttype == TDM_OUTPUT_TYPE_DVIA) - __connectorType = IDSDisplayDeviceOutput::TYPE_DVIA; - if (ttype == TDM_OUTPUT_TYPE_Composite) - __connectorType = IDSDisplayDeviceOutput::TYPE_COMPOSITE; - if (ttype == TDM_OUTPUT_TYPE_SVIDEO) - __connectorType = IDSDisplayDeviceOutput::TYPE_SVIDEO; - if (ttype == TDM_OUTPUT_TYPE_LVDS) - __connectorType = IDSDisplayDeviceOutput::TYPE_LVDS; - if (ttype == TDM_OUTPUT_TYPE_Component) - __connectorType = IDSDisplayDeviceOutput::TYPE_COMPONENT; - if (ttype == TDM_OUTPUT_TYPE_9PinDIN) - __connectorType = IDSDisplayDeviceOutput::TYPE_9PinDIN; - if (ttype == TDM_OUTPUT_TYPE_DisplayPort) - __connectorType = IDSDisplayDeviceOutput::TYPE_DISPLAYPORT; - if (ttype == TDM_OUTPUT_TYPE_HDMIA) - __connectorType = IDSDisplayDeviceOutput::TYPE_HDMIA; - if (ttype == TDM_OUTPUT_TYPE_HDMIB) - __connectorType = IDSDisplayDeviceOutput::TYPE_HDMIB; - if (ttype == TDM_OUTPUT_TYPE_TV) - __connectorType = IDSDisplayDeviceOutput::TYPE_TV; - if (ttype == TDM_OUTPUT_TYPE_eDP) - __connectorType = IDSDisplayDeviceOutput::TYPE_EDP; - if (ttype == TDM_OUTPUT_TYPE_VIRTUAL) - __connectorType = IDSDisplayDeviceOutput::TYPE_VIRTUAL; - if (ttype == TDM_OUTPUT_TYPE_DSI) - __connectorType = IDSDisplayDeviceOutput::TYPE_DSI; - else - __connectorType = IDSDisplayDeviceOutput::TYPE_UNKNOWN; -} - -void DSDisplayDeviceOutputTDMImpl::__updateConnectState() -{ - tdm_error terror; - tdm_output_conn_status tstatus; - - terror = tdm_output_get_conn_status(__toutput, &tstatus); - if (terror != TDM_ERROR_NONE) { - DSLOG_ERR("TDM OUTPUT", "tdm_output_get_conn_status fails."); - return; - } - - if (tstatus == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) - __connectState = IDSDisplayDeviceOutput::STATE_DISCONNECTED; - else if (tstatus == TDM_OUTPUT_CONN_STATUS_CONNECTED) - __connectState = IDSDisplayDeviceOutput::STATE_CONNECTED; - else if (tstatus == TDM_OUTPUT_CONN_STATUS_MODE_SETTED) - __connectState = IDSDisplayDeviceOutput::STATE_MODESET; - else - __connectState = IDSDisplayDeviceOutput::STATE_NONE; -} - - -void DSDisplayDeviceOutputTDMImpl::__updatePhysicalMMSize() -{ - tdm_error terror; - - terror = tdm_output_get_physical_size(__toutput, &__physicalMMWidth, &__physicalMMHeight); - if (terror != TDM_ERROR_NONE) { - DSLOG_ERR("TDM OUTPUT", "tdm_output_get_physical_size fails."); - __physicalMMWidth = 0; - __physicalMMHeight = 0; - } -} - -void DSDisplayDeviceOutputTDMImpl::__deleteAvailableModeList() -{ - __availableModeList.clear(); -} - -void DSDisplayDeviceOutputTDMImpl::__updateAvailableModeList() -{ - tdm_error terror; - const tdm_output_mode *tmodes, *tmode; - int count = 0; - - // delete the existing availableModeList. - __deleteAvailableModeList(); - - terror = tdm_output_get_available_modes(__toutput, &tmodes, &count); - if (terror != TDM_ERROR_NONE) { - DSLOG_ERR("TDM OUTPUT", "tdm_output_get_available_modes fails."); - return; - } - - for (int i = 0; i < count; i++) { - tmode = &tmodes[i]; - __availableModeList.push_back(std::make_shared(tmode)); - } - - auto sortBestModeFunc = [](auto first, auto second) -> bool { - unsigned int firstPrio = first->getRefreshRate() * first->getHorizontalSize() * first->getVertialSize(); - unsigned int secondPrio = second->getRefreshRate() * second->getHorizontalSize() * second->getVertialSize(); - return firstPrio < secondPrio; - }; - - __availableModeList.sort(sortBestModeFunc); -} - -void DSDisplayDeviceOutputTDMImpl::registerCallbackOutputConnected(DSObject *slot, std::function)> func) -{ - this->__connectedSignal.connect(slot, func); -} - -void DSDisplayDeviceOutputTDMImpl::registerCallbackOutputDisconnected(DSObject *slot, std::function)> func) -{ - this->__disconnectedSignal.connect(slot, func); -} - -void DSDisplayDeviceOutputTDMImpl::registerCallbackOutputResolutionSet(DSObject *slot, std::function)> func) -{ - this->__resolutionSetSignal.connect(slot, func); -} - -void DSDisplayDeviceOutputTDMImpl::callCallbackOutputConnected() -{ - this->__connectedSignal.emit(shared_from_this()); -} - -void DSDisplayDeviceOutputTDMImpl::callCallbackOutputDisconnected() -{ - this->__disconnectedSignal.emit(shared_from_this()); -} - -void DSDisplayDeviceOutputTDMImpl::callCallbackOutputResolutionSet() -{ - this->__resolutionSetSignal.emit(shared_from_this()); -} - -} // namespace display_server diff --git a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h deleted file mode 100644 index 6f411ab..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _I_DS_DISPLAY_DEVICE_OUTPUT_TDM_IMPL_H_ -#define _I_DS_DISPLAY_DEVICE_OUTPUT_TDM_IMPL_H_ - -#include "IDSDisplayDeviceOutput.h" -#include "IDSDisplayDeviceHWC.h" -#include "DSSignal.h" -#include - -namespace display_server -{ -class DSDisplayDeviceOutputTDMImpl : public IDSDisplayDeviceOutput, public std::enable_shared_from_this -{ -public: - DSDisplayDeviceOutputTDMImpl(); - DSDisplayDeviceOutputTDMImpl(tdm_output *toutput); - ~DSDisplayDeviceOutputTDMImpl(); - - IDSDisplayDeviceOutput::ConnectorType getConnectType() override; - IDSDisplayDeviceOutput::ConnectState getConnectState() override; - - int getResolutionWidth() override; - int getResolutionHeight() override; - int getPhysicalMMWidth() override; - int getPhysicalMMHeight() override; - int getRefreshRate() override; - std::string getName() override; - - std::list> getAvailableModes() override; - bool setMode(std::shared_ptr outputMode) override; - std::shared_ptr getMode() override; - - bool setDPMSMode(IDSDisplayDeviceOutput::DPMSMode dpmsMode) override; - DPMSMode getDPMSMode() override; - - std::shared_ptr getHWC() override; - - // register callback functions - void registerCallbackOutputConnected(DSObject *slot, std::function)> func) override; - void registerCallbackOutputDisconnected(DSObject *slot, std::function)> func) override; - void registerCallbackOutputResolutionSet(DSObject *slot, std::function)> func) override; - - // emit functions - void callCallbackOutputConnected(); - void callCallbackOutputDisconnected(); - void callCallbackOutputResolutionSet(); - -private: - void __initializeConnectorType(); - void __updateConnectState(); - void __updatePhysicalMMSize(); - void __deleteAvailableModeList(); - void __updateAvailableModeList(); - - tdm_output *__toutput; - - IDSDisplayDeviceOutput::ConnectState __connectState; - IDSDisplayDeviceOutput::ConnectorType __connectorType; - std::list> __availableModeList; - unsigned int __resolutionWidth, __resolutionHeight; - unsigned int __physicalMMWidth, __physicalMMHeight; - unsigned int __refreshRate; - std::string __name; - std::shared_ptr __outputMode; - IDSDisplayDeviceOutput::DPMSMode __dpmsMode; - - std::shared_ptr __displayDeviceHWC; - - // signals - DSSignal> __connectedSignal; - DSSignal> __disconnectedSignal; - DSSignal> __resolutionSetSignal; -}; -} - -#endif diff --git a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp deleted file mode 100644 index b2c4339..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSDisplayDeviceTDMImpl.h" -#include "DSDisplayDeviceOutputTDMImpl.h" -#include "DSDisplayDeviceHWCTDMImpl.h" -#include "DSDebugLog.h" -#include "DSUtilSocket.h" - -namespace display_server -{ - -DSDisplayDeviceTDMImpl::DSDisplayDeviceTDMImpl() - : __numOutputs(0) -{ - tdm_error terror; - tdm_output *toutput; - - __tdisplay = tdm_display_init(&terror); - if (terror != TDM_ERROR_NONE) { - DSLOG_ERR("TDM DEVICE", "tdm_display_init fails."); - } - - terror = tdm_display_get_output_count(__tdisplay, &__numOutputs); - if (__numOutputs <= 0) { - DSLOG_ERR("TDM DEVICE", "tdm_display_get_output_count fails."); - return; - } - - for (int i = 0; i < __numOutputs; ++i) { - toutput = tdm_display_get_output(__tdisplay, i, &terror); - if (terror != TDM_ERROR_NONE) { - DSLOG_ERR("TDM DEVICE", "tdm_display_get_output fails.(output num: %d)", i); - return; - } - - __outputList.emplace_back(std::make_shared(toutput)); - } - - DSUtilSocket *utilSocket = DSUtilSocket::getInstance(); - utilSocket->initSocket("tdm-socket"); - utilSocket->releaseInstance(); -} - -DSDisplayDeviceTDMImpl::~DSDisplayDeviceTDMImpl() -{ - // Clear the visible hwc windows before tdm_display_deinit. - // Otherwise, the process will block inside libtdm - // when it calls tdm_hwc_window_destroy() function at ~DSDisplayDeviceHWCWindowTDMImpl() - // because the mutex_lock(private_display->lock) is destroyed at tdm_display_deinit(). - for (auto displayDeviceOutput: __outputList) { - std::shared_ptr displayDeviceHWC = displayDeviceOutput->getHWC(); - if (displayDeviceHWC) { - displayDeviceHWC->clearVisibleHWCWindows(); - } - } - - tdm_display_deinit(__tdisplay); -} - -std::list> DSDisplayDeviceTDMImpl::getOutputList() -{ - return __outputList; -} - -void DSDisplayDeviceTDMImpl::registerCallbackOutputAdded(DSObject *slot, std::function)> func) -{ - this->__outputAddedSignal.connect(slot, func); -} - -void DSDisplayDeviceTDMImpl::registerCallbackOutputRemoved(DSObject *slot, std::function)> func) -{ - this->__outputRemovedSignal.connect(slot, func); -} - -void DSDisplayDeviceTDMImpl::callCallbackOutputAdded() -{ - //TODO: create the new IDSDisplayDeviceOutput instance and put the parameter of the emit function. - this->__outputAddedSignal.emit(nullptr); -} - -void DSDisplayDeviceTDMImpl::callCallbackOutputRemoved() -{ - //TODO: create the new IDSDisplayDeviceOutput instance and put the parameter of the emit function. - this->__outputRemovedSignal.emit(nullptr); -} - -} // namespace display_server diff --git a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h deleted file mode 100644 index 5c6078b..0000000 --- a/src/DSDisplayDevice/DSDisplayDeviceTDMImpl.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_DISPLAY_DEVICE_TDM_IMPL_H_ -#define _DS_DISPLAY_DEVICE_TDM_IMPL_H_ - -#include "IDSDisplayDevice.h" -#include "DSSignal.h" -#include - -namespace display_server -{ - -class DSDisplayDeviceTDMImpl : public IDSDisplayDevice -{ -public: - DSDisplayDeviceTDMImpl(); - ~DSDisplayDeviceTDMImpl(); - - std::list> getOutputList() override; - - // register callback functions - void registerCallbackOutputAdded(DSObject *slot, std::function)> func) override; - void registerCallbackOutputRemoved(DSObject *slot, std::function)> func) override; - - // emit functions - void callCallbackOutputAdded(); - void callCallbackOutputRemoved(); - -private: - tdm_display *__tdisplay; - int __numOutputs; - std::list> __outputList; - - // signals - DSSignal> __outputAddedSignal; - DSSignal> __outputRemovedSignal; -}; - -} - -#endif diff --git a/src/DSDisplayDevice/IDSDisplayDevice.h b/src/DSDisplayDevice/IDSDisplayDevice.h deleted file mode 100644 index 18ea745..0000000 --- a/src/DSDisplayDevice/IDSDisplayDevice.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _I_DS_DISPLAY_DEVICE_H_ -#define _I_DS_DISPLAY_DEVICE_H_ - -#include "DSObject.h" -#include "IDSDisplayDeviceOutput.h" -#include - -namespace display_server -{ -class IDSDisplayDevice : public DSObject -{ -public: - virtual ~IDSDisplayDevice() = default; - - virtual std::list> getOutputList() = 0; - virtual void registerCallbackOutputAdded(DSObject *slot, std::function)> func) = 0; - virtual void registerCallbackOutputRemoved(DSObject *slot, std::function)> func) = 0; -}; -} - -#endif diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWC.h b/src/DSDisplayDevice/IDSDisplayDeviceHWC.h deleted file mode 100644 index 050316b..0000000 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWC.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _I_DS_DISPLAY_DEVICE_HWC_H_ -#define _I_DS_DISPLAY_DEVICE_HWC_H_ - -#include "IDSDisplayDeviceHWCWindow.h" -#include "IDSBufferQueue.h" - -namespace display_server -{ - -class DSWindow; - -class IDSDisplayDeviceHWC -{ -public: - virtual ~IDSDisplayDeviceHWC() = default; - - virtual std::shared_ptr getTargetBufferQueue() = 0; - virtual bool setTargetBuffer(std::shared_ptr buffer) = 0; - virtual std::shared_ptr makeHWCWindow() = 0; - virtual bool addVisibleHWCWindow(std::shared_ptr deviceHWCWindow) = 0; - virtual bool removeVisibleHWCWindow(std::shared_ptr deviceHWCWindow) = 0; - virtual void clearVisibleHWCWindows() = 0; - virtual bool commit() = 0; -}; - -} - -#endif diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h b/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h deleted file mode 100644 index b3d5e21..0000000 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWCWindow.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _I_DS_DISPLAY_DEVICE_HWC_WINDOW_H_ -#define _I_DS_DISPLAY_DEVICE_HWC_WINDOW_H_ - -namespace display_server -{ -class IDSDisplayDeviceHWCWindow -{ -public: - virtual ~IDSDisplayDeviceHWCWindow() = default; - virtual bool updateFrame() = 0; - virtual void presentFrame() = 0; - virtual void onPresentFrameDone() = 0; -}; -} - -#endif diff --git a/src/DSDisplayDevice/IDSDisplayDeviceOutput.h b/src/DSDisplayDevice/IDSDisplayDeviceOutput.h deleted file mode 100644 index 0a2d378..0000000 --- a/src/DSDisplayDevice/IDSDisplayDeviceOutput.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _I_DS_DISPLAY_DEVICE_OUTPUT_H_ -#define _I_DS_DISPLAY_DEVICE_OUTPUT_H_ - -#include "DSObject.h" -#include "IDSDisplayDeviceHWC.h" -#include "IDSDisplayDeviceOutputMode.h" -#include -#include -#include - -#define NAME_LEN 64 - -namespace display_server -{ - -class IDSDisplayDeviceOutput : public DSObject -{ -public: - enum ConnectState { - STATE_NONE, - STATE_DISCONNECTED, - STATE_CONNECTED, - STATE_MODESET - }; - enum ConnectorType { - TYPE_UNKNOWN, /**< unknown */ - TYPE_VGA, /**< VGA connection */ - TYPE_DVII, /**< DVII connection */ - TYPE_DVID, /**< DVID connection */ - TYPE_DVIA, /**< DVIA connection */ - TYPE_COMPOSITE, /**< Composite connection */ - TYPE_SVIDEO, /**< SVIDEO connection */ - TYPE_LVDS, /**< LVDS connection */ - TYPE_COMPONENT, /**< Component connection */ - TYPE_9PinDIN, /**< 9PinDIN connection */ - TYPE_DISPLAYPORT, /**< DisplayPort connection */ - TYPE_HDMIA, /**< HDMIA connection */ - TYPE_HDMIB, /**< HDMIB connection */ - TYPE_TV, /**< TV connection */ - TYPE_EDP, /**< eDP connection */ - TYPE_VIRTUAL, /**< Virtual connection for WiFi Display */ - TYPE_DSI /**< DSI connection */ - }; - enum DPMSMode { - DPMS_ON, - DPMS_STANDBY, - DPMS_SUSPEND, - DPMS_OFF - }; - -public: - virtual ~IDSDisplayDeviceOutput() = default; - - virtual ConnectorType getConnectType() = 0; - virtual ConnectState getConnectState() = 0; - - virtual int getResolutionWidth() = 0; - virtual int getResolutionHeight() = 0; - virtual int getPhysicalMMWidth() = 0; - virtual int getPhysicalMMHeight() = 0; - virtual int getRefreshRate() = 0; - virtual std::string getName() = 0; - - virtual std::list> getAvailableModes() = 0; - virtual bool setMode(std::shared_ptr outputMode) = 0; - virtual std::shared_ptr getMode() = 0; - - virtual bool setDPMSMode(DPMSMode dpmsMode) = 0; - virtual DPMSMode getDPMSMode() = 0; - - virtual std::shared_ptr getHWC() = 0; - - // Callback methods - virtual void registerCallbackOutputConnected(DSObject *slot, std::function)> func) = 0; - virtual void registerCallbackOutputDisconnected(DSObject *slot, std::function)> func) = 0; - virtual void registerCallbackOutputResolutionSet(DSObject *slot, std::function)> func) = 0; -}; - -} - -#endif diff --git a/src/DSDisplayDevice/IDSDisplayDeviceOutputMode.h b/src/DSDisplayDevice/IDSDisplayDeviceOutputMode.h deleted file mode 100644 index c3509bd..0000000 --- a/src/DSDisplayDevice/IDSDisplayDeviceOutputMode.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __I_DS_DISPLAY_DEVICE_OUTPUT_MODE_H__ -#define __I_DS_DISPLAY_DEVICE_OUTPUT_MODE_H__ - -#include - -namespace display_server -{ - -class IDSDisplayDeviceOutputMode -{ -public: - virtual ~IDSDisplayDeviceOutputMode() = default; - - virtual unsigned int getRefreshRate() = 0; - virtual unsigned int getHorizontalSize() = 0; - virtual unsigned int getVertialSize() = 0; - virtual std::string getName() = 0; -}; - -} - -#endif diff --git a/src/DSEventLoop/DSEventLoop.cpp b/src/DSEventLoop/DSEventLoop.cpp deleted file mode 100644 index f79af6d..0000000 --- a/src/DSEventLoop/DSEventLoop.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSEventLoop.h" -#include "DSDebugLog.h" -#include - -namespace display_server -{ - -DSEventLoop *DSEventLoop::__instance { nullptr }; -std::mutex DSEventLoop::__mutex; -int DSEventLoop::__refCount { 0 }; -Ecore_Idle_Enterer *DSEventLoop::__ecoreIdleEnterer { nullptr }; -DSSignal DSEventLoop::__idleEntererSignal; - -DSEventLoop::DSEventLoop() - : __running(false) -{ - if (!ecore_init()) { - DSLOG_ERR("EventLoop", "ecore_init() fails."); - } -} - -DSEventLoop::~DSEventLoop() -{ - if (__ecoreIdleEnterer) - ecore_idle_enterer_del(__ecoreIdleEnterer); - - ecore_shutdown(); -} - -DSEventLoop *DSEventLoop::getInstance() -{ - std::lock_guard lock(__mutex); - - if (!__instance) { - __instance = new DSEventLoop(); - if (!__instance) { - DSLOG_ERR("DSEventLoop", "new DSEventLoop() fails."); - return nullptr; - } - DSLOG_INF("DSEventLoop", "DSEventLoop instance has been created !"); - - __ecoreIdleEnterer = ecore_idle_enterer_add(&DSEventLoop::__emitIdleEntererFuncs, nullptr); - if (!__ecoreIdleEnterer) - DSLOG_ERR("DSEventLoop", "ecore_idle_enterer_add() fails."); - } - - ++__refCount; - - return __instance; -} - -void DSEventLoop::releaseInstance() -{ - std::lock_guard lock(__mutex); - - --__refCount; - DSLOG_INF("DSEventLoop", "__refCount=%d", __refCount); - if (__refCount <= 0) { - delete __instance; - __instance = nullptr; - __ecoreIdleEnterer = nullptr; - DSLOG_INF("DSEventLoop", "DSEventLoop instance has been removed !"); - } -} - -bool DSEventLoop::isRunning() -{ - return __running; -} - -bool DSEventLoop::run() -{ - if (__running) - return true; - - __running = true; - ecore_main_loop_begin(); - __running = false; - - return true; -} - -bool DSEventLoop::quit() -{ - if (!__running) { - return false; - } - - ecore_main_loop_quit(); - - return true; -} - -void DSEventLoop::registerCallbackIdleEnterer(DSObject *slot, std::function func) -{ - __idleEntererSignal.connect(slot, func); -} - -Eina_Bool DSEventLoop::__emitIdleEntererFuncs(void *data) -{ - __idleEntererSignal.emit(data); - - return EINA_TRUE; -} - -// for test cases only -Eina_Bool DSEventLoop::testEmitIdleEntererFuncs(void *data) -{ - __idleEntererSignal.emit(data); - - return EINA_TRUE; -} - -} // namespace display_server diff --git a/src/DSEventLoop/DSEventLoop.h b/src/DSEventLoop/DSEventLoop.h deleted file mode 100644 index 1cc365b..0000000 --- a/src/DSEventLoop/DSEventLoop.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_EVENT_LOOP_H__ -#define __DS_EVENT_LOOP_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSSignal.h" -#include -#include - -namespace display_server -{ - -class DSEventLoop : public DSObject -{ -public: - static DSEventLoop *getInstance(); - static void releaseInstance(); - - bool run(); - bool quit(); - - bool isRunning(); - - // register callback functions - void registerCallbackIdleEnterer(DSObject *slot, std::function func); - - static Eina_Bool testEmitIdleEntererFuncs(void *data); // for test cases only - -private: - DSEventLoop(); // private constructor - ~DSEventLoop(); // private desctructor - DSEventLoop(DSEventLoop &other) = delete; // should not be cloneable - void operator=(const DSEventLoop &) = delete; // should not be assignable - - static Eina_Bool __emitIdleEntererFuncs(void *data); // emit functions which registered at registerCallbackIdleEnterer - - static DSEventLoop *__instance; // singleton instance - static std::mutex __mutex; // mutex - static int __refCount; - - bool __running; - - static Ecore_Idle_Enterer *__ecoreIdleEnterer; - static DSSignal __idleEntererSignal; -}; - -} - -#endif diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp deleted file mode 100644 index c5b745c..0000000 --- a/src/DSInput/DSInput.cpp +++ /dev/null @@ -1,627 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSInput.h" -#include "DSInputPrivate.h" -#include "DSSeat.h" -#include "DSInputEvent.h" -#include "DSXkb.h" - -namespace display_server -{ - -DSInputPrivate::DSInputPrivate(DSInput * p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __dsLibinput(nullptr) -{ -} - -DSInputPrivate::~DSInputPrivate() -{ - if (__dsLibinput) - delete __dsLibinput; -} - -void DSInputPrivate::Init() -{ - __dsLibinput = new DSLibinput(this); - DS_ASSERT(__dsLibinput != nullptr); -} - -void DSInputPrivate::PostDeviceAddEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass) -{ - DS_GET_PUB(DSInput); - - pub->deviceAdd(name, identifier, devClass, DSInput::NoneSubclass); -} - -void DSInputPrivate::PostDeviceRemoveEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass) -{ - DS_GET_PUB(DSInput); - - pub->deviceRemove(name, identifier, devClass, DSInput::NoneSubclass); -} - -/*LCOV_EXCL_START*/ -void DSInputPrivate::PostKeyboardEvent(int keycode, bool pressed, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DS_GET_PUB(DSInput); - - if (pressed) - pub->keyDown(keycode, devIdentifier, devClass, timestamp); - else - pub->keyUp(keycode, devIdentifier, devClass, timestamp); -} - -void DSInputPrivate::PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DS_GET_PUB(DSInput); - - if (type == DSInputEvent::MouseDownEvent) - pub->mouseDown(button, x, y, z, devIdentifier, devClass, timestamp); - else if (type == DSInputEvent::MouseMoveEvent) - pub->mouseMove(button, x, y, z, devIdentifier, devClass, timestamp); - else if (type == DSInputEvent::MouseUpEvent) - pub->mouseUp(button, x, y, z, devIdentifier, devClass, timestamp); -} - -void DSInputPrivate::PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DS_GET_PUB(DSInput); - - if (type == DSInputEvent::TouchDownEvent) - pub->touchDown(index, x, y, devIdentifier, devClass, timestamp); - else if (type == DSInputEvent::TouchMoveEvent) - pub->touchMove(index, x, y, devIdentifier, devClass, timestamp); - else if (type == DSInputEvent::TouchUpEvent) - pub->touchUp(index, x, y, devIdentifier, devClass, timestamp); -} -/*LCOV_EXCL_STOP*/ - -int DSInput::DS_INPUT_EVENT_KEY_DOWN = 0; -int DSInput::DS_INPUT_EVENT_KEY_UP = 0; -int DSInput::DS_INPUT_EVENT_MOUSE_DOWN = 0; -int DSInput::DS_INPUT_EVENT_MOUSE_MOVE = 0; -int DSInput::DS_INPUT_EVENT_MOUSE_UP = 0; -int DSInput::DS_INPUT_EVENT_TOUCH_DOWN = 0; -int DSInput::DS_INPUT_EVENT_TOUCH_MOVE = 0; -int DSInput::DS_INPUT_EVENT_TOUCH_UP = 0; - -void DSInput::__initiaiize_ecore_event_types() -{ - if (!DS_INPUT_EVENT_KEY_DOWN) - DS_INPUT_EVENT_KEY_DOWN = ecore_event_type_new(); - if (!DS_INPUT_EVENT_KEY_UP) - DS_INPUT_EVENT_KEY_UP = ecore_event_type_new(); - if (!DS_INPUT_EVENT_MOUSE_DOWN) - DS_INPUT_EVENT_MOUSE_DOWN = ecore_event_type_new(); - if (!DS_INPUT_EVENT_MOUSE_MOVE) - DS_INPUT_EVENT_MOUSE_MOVE = ecore_event_type_new(); - if (!DS_INPUT_EVENT_MOUSE_UP) - DS_INPUT_EVENT_MOUSE_UP = ecore_event_type_new(); - if (!DS_INPUT_EVENT_TOUCH_DOWN) - DS_INPUT_EVENT_TOUCH_DOWN = ecore_event_type_new(); - if (!DS_INPUT_EVENT_TOUCH_MOVE) - DS_INPUT_EVENT_TOUCH_MOVE = ecore_event_type_new(); - if (!DS_INPUT_EVENT_TOUCH_UP) - DS_INPUT_EVENT_TOUCH_UP = ecore_event_type_new(); -} - -DSInput::DSInput() - : DS_INIT_PRIVATE_PTR(DSInput), - __seat(nullptr), - __xkb(nullptr) -{ - __initiaiize_ecore_event_types(); -} - -DSInput::DSInput(DSSeat *seat) - : DS_INIT_PRIVATE_PTR(DSInput), - __seat(seat), - __xkb(nullptr) -{ - if (seat == nullptr) - { - DSLOG_ERR("DSInput", "DSSeat ptr is required."); - return; - } - - __initiaiize_ecore_event_types(); -} - -DSInput::DSInput(DSSeat *seat, DSXkb *xkb) - : DS_INIT_PRIVATE_PTR(DSInput), - __seat(seat), - __xkb(xkb) -{ - if (seat == nullptr) - { - DSLOG_ERR("DSInput", "DSSeat ptr is required."); - return; - } - - __initiaiize_ecore_event_types(); -} - - -DSInput::~DSInput() -{ - for (auto eventHandler : __eventHandlerList) - { - ecore_event_handler_del(eventHandler); - } - __eventHandlerList.clear(); -} - -void DSInput::init() -{ - DS_GET_PRIV(DSInput); - - priv->Init(); -} - -void DSInput::deviceAdd(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass) -{ - DSInputDevice *device = new DSInputDevice(name, identifier, devClass, devSubclass); - - for (auto dev : devList) - { - if (*dev == *device) - { - delete device; - return; - } - } - - this->__deviceAddSignal.emit(std::make_shared(*device)); - - devList.push_back(device); -} - -void DSInput::deviceRemove(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass) -{ - DSInputDevice *device = new DSInputDevice(name, identifier, devClass, devSubclass); - - for (auto dev : devList) - { - if (*dev == *device) - { - this->__deviceRemoveSignal.emit(std::make_shared(*dev)); - - devList.remove(dev); - delete dev; - break; - } - } - - delete device; -} - -/*LCOV_EXCL_START*/ -DSInputDevice *DSInput::findDevice(std::string devIdentifier, DSInput::DeviceClass devClass) -{ - for (auto dev : devList) - { - if ((dev->getClass() == devClass) && (dev->getIdentifier().compare(devIdentifier) == 0)) - { - return dev; - } - } - return nullptr; -} - -void DSInput::keyDown(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DSLOG_DBG("DSInput", "[keyDown] keycode: %d, identifier: %d\n", keycode, devIdentifier); - DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputKeyboardEvent *ev = new DSInputKeyboardEvent(std::make_shared(*device), DSInputEvent::KeyDownEvent, timestamp, keycode); - if (__xkb) - { - __xkb->updateModifier(keycode, true); - ev->setKeyname(__xkb->getKeyname(keycode)); - } - ecore_event_add(DS_INPUT_EVENT_KEY_DOWN, (void *)ev, nullptr, nullptr); -} - -void DSInput::keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DSLOG_DBG("DSInput", "[keyUp] keycode: %d, identifier: %d\n", keycode, devIdentifier); - DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputKeyboardEvent *ev = new DSInputKeyboardEvent(std::make_shared(*device), DSInputEvent::KeyUpEvent, timestamp, keycode); - if (__xkb) - { - __xkb->updateModifier(keycode, false); - ev->setKeyname(__xkb->getKeyname(keycode)); - } - ecore_event_add(DS_INPUT_EVENT_KEY_UP, (void *)ev, nullptr, nullptr); -} - -void DSInput::mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DSLOG_DBG("DSInput", "[mouseDown] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); - DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseDownEvent, timestamp, button, x, y, z); - ecore_event_add(DS_INPUT_EVENT_MOUSE_DOWN, (void *)ev, nullptr, nullptr); -} - -void DSInput::mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DSLOG_DBG("DSInput", "[mouseMove] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); - DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseMoveEvent, timestamp, button, x, y, z); - ecore_event_add(DS_INPUT_EVENT_MOUSE_MOVE, (void *)ev, nullptr, nullptr); -} - -void DSInput::mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DSLOG_DBG("DSInput", "[mouseUp] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier); - DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseUpEvent, timestamp, button, x, y, z); - ecore_event_add(DS_INPUT_EVENT_MOUSE_UP, (void *)ev, nullptr, nullptr); -} - -void DSInput::touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DSLOG_DBG("DSInput", "[touchDown] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); - DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchDownEvent, timestamp, index, x, y); - ecore_event_add(DS_INPUT_EVENT_TOUCH_DOWN, (void *)ev, nullptr, nullptr); -} - -void DSInput::touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DSLOG_DBG("DSInput", "[touchMove] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); - DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchMoveEvent, timestamp, index, x, y); - ecore_event_add(DS_INPUT_EVENT_TOUCH_MOVE, (void *)ev, nullptr, nullptr); -} - -void DSInput::touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) -{ - DSLOG_DBG("DSInput", "[touchUp] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier); - DSInputDevice *device = findDevice(devIdentifier, devClass); - DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchUpEvent, timestamp, index, x, y); - ecore_event_add(DS_INPUT_EVENT_TOUCH_UP, (void *)ev, nullptr, nullptr); -} -/*LCOV_EXCL_STOP*/ - -void DSInput::registerCallbackDeviceAdd(DSObject *slot, std::function)> func) -{ - this->__deviceAddSignal.connect(slot, func); -} - -void DSInput::registerCallbackDeviceRemove(DSObject *slot, std::function)> func) -{ - this->__deviceRemoveSignal.connect(slot, func); -} - -void DSInput::registerCallbackKeyDown(DSObject *slot, Ecore_Event_Handler_Cb func) -{ - __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_KEY_DOWN, func, slot)); -} - -void DSInput::registerCallbackKeyUp(DSObject *slot, Ecore_Event_Handler_Cb func) -{ - __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_KEY_UP, func, slot)); -} - -void DSInput::registerCallbackMouseDown(DSObject *slot, Ecore_Event_Handler_Cb func) -{ - __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_DOWN, func, slot)); -} - -void DSInput::registerCallbackMouseMove(DSObject *slot, Ecore_Event_Handler_Cb func) -{ - __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_MOVE, func, slot)); -} - -void DSInput::registerCallbackMouseUp(DSObject *slot, Ecore_Event_Handler_Cb func) -{ - __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_UP, func, slot)); -} - -void DSInput::registerCallbackTouchDown(DSObject *slot, Ecore_Event_Handler_Cb func) -{ - __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_DOWN, func, slot)); -} - -void DSInput::registerCallbackTouchMove(DSObject *slot, Ecore_Event_Handler_Cb func) -{ - __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_MOVE, func, slot)); -} - -void DSInput::registerCallbackTouchUp(DSObject *slot, Ecore_Event_Handler_Cb func) -{ - __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_UP, func, slot)); -} - - -DSInputDevice::DSInputDevice() - : __deviceName(""), - __deviceIdentifier(""), - __deviceClass(DSInput::DeviceClass::NoneClass), - __deviceSubclass(DSInput::DeviceSubclass::NoneSubclass) -{ -} - -DSInputDevice::DSInputDevice(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass) - : __deviceName(name), - __deviceIdentifier(identifier), - __deviceClass(devClass), - __deviceSubclass(devSubclass) -{ -} - -DSInputDevice::~DSInputDevice() -{ -} - -void DSInputDevice::print() -{ - DSLOG_INF("DSInputDevice", "DeviceInfo: name: %s, identifier: %s , class: %d, subclass: %d", getName().c_str(), getIdentifier().c_str(), getClass(), getSubclass()); -} - -bool DSInputDevice::operator==(DSInputDevice& device) -{ - if ((getName().compare(device.getName()) == 0) && - (getIdentifier().compare(device.getIdentifier()) == 0) && - (getClass() == device.getClass())) - { - return true; - } - - return false; -} - -std::string DSInputDevice::getName() const -{ - return __deviceName; -} - -void DSInputDevice::setName(std::string name) -{ - __deviceName = name; -} - -std::string DSInputDevice::getIdentifier() const -{ - return __deviceIdentifier; -} - -void DSInputDevice::setIdentifier(std::string identifier) -{ - __deviceIdentifier = identifier; -} - -DSInput::DeviceClass DSInputDevice::getClass() const -{ - return __deviceClass; -} - -void DSInputDevice::setClass(DSInput::DeviceClass devClass) -{ - __deviceClass = devClass; -} - -DSInput::DeviceSubclass DSInputDevice::getSubclass() const -{ - return __deviceSubclass; -} - -void DSInputDevice::setSubclass(DSInput::DeviceSubclass devSubclass) -{ - __deviceSubclass = devSubclass; -} - -DSInputEvent::DSInputEvent(std::shared_ptr device, Type type, uint32_t timestamp) - : __device(device), - __type(type), - __timestamp(timestamp) -{ -} - -DSInputEvent::~DSInputEvent() -{ -} - -std::shared_ptr DSInputEvent::getDevice() -{ - return __device; -} - -const DSInputEvent::Type DSInputEvent::getType() -{ - return __type; -} - -const int DSInputEvent::getTimestamp() -{ - return __timestamp; -} - -void DSInputEvent::registerEventDeviceBroadcater(DSObject *slot, std::function)> func) -{ - __eventDeviceBroadCastSignal.connect(slot, func); -} - -void DSInputEvent::eventDeviceBroadcast(std::shared_ptr device) -{ - __eventDeviceBroadCastSignal.emit(device); -} - -DSInputKeyboardEvent::DSInputKeyboardEvent() - : DSInputEvent(nullptr, NoneEvent, 0), - __keycode(0), - __keyname("") -{ -} - -DSInputKeyboardEvent::DSInputKeyboardEvent(std::shared_ptr device, Type type, uint32_t timestamp, int keycode) - : DSInputEvent(device, type, timestamp), - __keycode(keycode), - __keyname("") -{ - /* FIXME: __keyname will be defined after xkb is implied */ -} - - -DSInputKeyboardEvent::~DSInputKeyboardEvent() -{ -} - -const int DSInputKeyboardEvent::getKeycode() -{ - return __keycode; -} - -const std::string DSInputKeyboardEvent::getKeyname() -{ - return __keyname; -} - -void DSInputKeyboardEvent::setKeyname(std::string name) -{ - __keyname = name; -} - - -DSInputMouseEvent::DSInputMouseEvent() - : DSInputEvent(nullptr, NoneEvent, 0), - __button(0), __x(0), __y(0), __z(0), __winX(0), __winY(0), __winZ(0) -{ -} - -DSInputMouseEvent::DSInputMouseEvent(std::shared_ptr device, Type type, uint32_t timestamp, int button, int x, int y, int z) - : DSInputEvent(device, type, timestamp), - __button(button), __x(x), __y(y), __z(z), __winX(0), __winY(0), __winZ(0) -{ -} - - -DSInputMouseEvent::~DSInputMouseEvent() -{ -} - -const int DSInputMouseEvent::getButton() -{ - return __button; -} - -const int DSInputMouseEvent::getX() -{ - return __x; -} - -const int DSInputMouseEvent::getY() -{ - return __y; -} - -const int DSInputMouseEvent::getZ() -{ - return __z; -} - -const int DSInputMouseEvent::getWinX() -{ - return __winX; -} - -const int DSInputMouseEvent::getWinY() -{ - return __winY; -} - -const int DSInputMouseEvent::getWinZ() -{ - return __winZ; -} - -void DSInputMouseEvent::setWinX(int winX) -{ - __winX = winX; -} - -void DSInputMouseEvent::setWinY(int winY) -{ - __winY = winY; -} - -void DSInputMouseEvent::setWinZ(int winZ) -{ - __winZ = winZ; -} - -DSInputTouchEvent::DSInputTouchEvent() - : DSInputEvent(nullptr, NoneEvent, 0), - __index(0), __x(0), __y(0), __winX(0), __winY(0) -{ -} - -DSInputTouchEvent::DSInputTouchEvent(std::shared_ptr device, Type type, uint32_t timestamp, int index, int x, int y) - : DSInputEvent(device, type, timestamp), - __index(index), __x(x), __y(y), __winX(0), __winY(0) -{ -} - -DSInputTouchEvent::~DSInputTouchEvent() -{ -} - -const int DSInputTouchEvent::getIndex() -{ - return __index; -} - -const int DSInputTouchEvent::getX() -{ - return __x; -} - -const int DSInputTouchEvent::getY() -{ - return __y; -} - -const int DSInputTouchEvent::getWinX() -{ - return __winX; -} - -const int DSInputTouchEvent::getWinY() -{ - return __winY; -} - -void DSInputTouchEvent::setWinX(int winX) -{ - __winX = winX; -} - -void DSInputTouchEvent::setWinY(int winY) -{ - __winY = winY; -} - -} // namespace display_server diff --git a/src/DSInput/DSInput.h b/src/DSInput/DSInput.h deleted file mode 100644 index f8c89ab..0000000 --- a/src/DSInput/DSInput.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DSINPUT_H_ -#define _DSINPUT_H_ - -#include -#include -#include - -#include - -namespace display_server -{ - -class DSSeat; -class DSInputPrivate; -class DSInputDevice; -class DSXkb; - -class DSInput : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSInput); -public: - enum DeviceClass { - NoneClass, - PointerClass, - KeyboardClass, - TouchClass, - }; - enum DeviceSubclass { - NoneSubclass, - }; -public: - DSInput(); - DSInput(DSSeat *seat); - DSInput(DSSeat *seat, DSXkb *xkb); - ~DSInput() override; - - void init(); - - void deviceAdd(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass); - void deviceRemove(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass); - void keyDown(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - - void registerCallbackDeviceAdd(DSObject *slot, std::function)> func); - void registerCallbackDeviceRemove(DSObject *slot, std::function)> func); - void registerCallbackKeyDown(DSObject *slot, Ecore_Event_Handler_Cb func); - void registerCallbackKeyUp(DSObject *slot, Ecore_Event_Handler_Cb func); - void registerCallbackMouseDown(DSObject *slot, Ecore_Event_Handler_Cb func); - void registerCallbackMouseMove(DSObject *slot, Ecore_Event_Handler_Cb func); - void registerCallbackMouseUp(DSObject *slot, Ecore_Event_Handler_Cb func); - void registerCallbackTouchDown(DSObject *slot, Ecore_Event_Handler_Cb func); - void registerCallbackTouchMove(DSObject *slot, Ecore_Event_Handler_Cb func); - void registerCallbackTouchUp(DSObject *slot, Ecore_Event_Handler_Cb func); - - DSInputDevice *findDevice(std::string devIdentifier, DSInput::DeviceClass devClass); - -private: - DSSeat* __seat; - DSXkb* __xkb; - std::list devList; - - DSSignal> __deviceAddSignal; - DSSignal> __deviceRemoveSignal; - - std::list __eventHandlerList; - - static int DS_INPUT_EVENT_KEY_DOWN; - static int DS_INPUT_EVENT_KEY_UP; - static int DS_INPUT_EVENT_MOUSE_DOWN; - static int DS_INPUT_EVENT_MOUSE_MOVE; - static int DS_INPUT_EVENT_MOUSE_UP; - static int DS_INPUT_EVENT_TOUCH_DOWN; - static int DS_INPUT_EVENT_TOUCH_MOVE; - static int DS_INPUT_EVENT_TOUCH_UP; - - void __initiaiize_ecore_event_types(); -}; - -class DSInputDevice -{ -public: - DSInputDevice(); - DSInputDevice(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass); - ~DSInputDevice(); - - void print(); - bool operator==(DSInputDevice& device); - - std::string getName() const; - void setName(std::string name); - - std::string getIdentifier() const; - void setIdentifier(std::string identifier); - - DSInput::DeviceClass getClass() const; - void setClass(DSInput::DeviceClass devClass); - - DSInput::DeviceSubclass getSubclass() const; - void setSubclass(DSInput::DeviceSubclass devSubclass); - -private: - std::string __deviceName; - std::string __deviceIdentifier; - DSInput::DeviceClass __deviceClass; - DSInput::DeviceSubclass __deviceSubclass; -}; - -} - -#endif diff --git a/src/DSInput/DSInputEvent.h b/src/DSInput/DSInputEvent.h deleted file mode 100644 index 1df1f03..0000000 --- a/src/DSInput/DSInputEvent.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_INPUT_EVENT_H_ -#define _DS_INPUT_EVENT_H_ - -#include "DSInput.h" - -namespace display_server -{ - -class DSInputEvent -{ -public: - enum Type { - NoneEvent, - KeyEnterEvent, - KeyLeaveEvent, - KeyDownEvent, - KeyUpEvent, - MouseInEvent, - MouseOutEvent, - MouseDownEvent, - MouseMoveEvent, - MouseUpEvent, - MouseWheelEvent, - MouseHWheelEvent, - TouchDownEvent, - TouchMoveEvent, - TouchUpEvent - }; - - DSInputEvent(std::shared_ptr device, Type type, uint32_t timestamp); - virtual ~DSInputEvent(); - - std::shared_ptr getDevice(); - const Type getType(); - const int getTimestamp(); - //DSWindow getTargetWindow(); - - void registerEventDeviceBroadcater(DSObject *slot, std::function)> func); - void eventDeviceBroadcast(std::shared_ptr device); - -protected: - std::shared_ptr __device; - Type __type; - uint32_t __timestamp; - DSSignal> __eventDeviceBroadCastSignal; - //DSWindow __targetWindow; -}; - -class DSInputKeyboardEvent : public DSInputEvent -{ -public: - DSInputKeyboardEvent(); - DSInputKeyboardEvent(std::shared_ptr device, Type type, uint32_t timestamp, int keycode); - ~DSInputKeyboardEvent() override; - - const int getKeycode(); - const std::string getKeyname(); - void setKeyname(std::string name); - -protected: - int __keycode; - std::string __keyname; -}; - -class DSInputMouseEvent : public DSInputEvent -{ -public: - DSInputMouseEvent(); - DSInputMouseEvent(std::shared_ptr device, Type type, uint32_t timestamp, int button, int x, int y, int z); - ~DSInputMouseEvent() override; - - const int getButton(); - const int getX(); - const int getY(); - const int getZ(); - const int getWinX(); - const int getWinY(); - const int getWinZ(); - void setWinX(int winX); - void setWinY(int winY); - void setWinZ(int winZ); - -protected: - int __button; - int __x; - int __y; - int __z; - int __winX; - int __winY; - int __winZ; -}; - -class DSInputTouchEvent : public DSInputEvent -{ -public: - DSInputTouchEvent(); - DSInputTouchEvent(std::shared_ptr device, Type type, uint32_t timestamp, int index, int x, int y); - ~DSInputTouchEvent() override; - - const int getIndex(); - const int getX(); - const int getY(); - const int getWinX(); - const int getWinY(); - void setWinX(int winX); - void setWinY(int winY); - -protected: - int __index; - int __x; - int __y; - int __winX; - int __winY; -}; - -} - -#endif - diff --git a/src/DSInput/DSInputPrivate.h b/src/DSInput/DSInputPrivate.h deleted file mode 100644 index 377db91..0000000 --- a/src/DSInput/DSInputPrivate.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DSINPUTPRIVATE_H_ -#define _DSINPUTPRIVATE_H_ - -#include "DSInput.h" -#include "DSLibinput.h" -#include "DSInputEvent.h" - -namespace display_server -{ - -class DSLibinput; - -class DSInputPrivate : public DSObjectPrivate -{ -DS_PIMPL_USE_PUBLIC(DSInput); -public: - DSInputPrivate() = delete; - DSInputPrivate(DSInput *p_ptr); - ~DSInputPrivate() override; - - void Init(); - - void PostDeviceAddEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass); - void PostDeviceRemoveEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass); - void PostKeyboardEvent(int keycode, bool pressed, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - -private: - DSLibinput *__dsLibinput; -}; - -} - -#endif diff --git a/src/DSInput/DSLibinput.cpp b/src/DSInput/DSLibinput.cpp deleted file mode 100644 index c81f61e..0000000 --- a/src/DSInput/DSLibinput.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSLibinput.h" -#include -#include -#include - -namespace display_server -{ - -const struct ::libinput_interface DSLibinput::__input_interface = { - .open_restricted = DSLibinput::__handleOpenRestricted, - .close_restricted = DSLibinput::__handleCloseRestricted -}; - -DSLibinput::DSLibinput(DSInputPrivate *p_ptr) - : __libinput(nullptr), - __udev(nullptr), - __libinput_handler(nullptr) -{ - inputPrivate = p_ptr; - ecore_init(); - __udev = udev_new(); - DS_ASSERT(__udev); - __libinput = libinput_udev_create_context(&__input_interface, this, __udev); - if (!__libinput) - { - udev_unref(__udev); - DS_ASSERT(false); - } - - if (libinput_udev_assign_seat(__libinput, "seat0")) - { - libinput_unref(__libinput); - udev_unref(__udev); - DS_ASSERT(false); - } - - __fd = libinput_get_fd(__libinput); - __libinput_handler = ecore_main_fd_handler_add(__fd, ECORE_FD_READ, __handleEvents, this, NULL, NULL); - - this->__handleEvents(this, __libinput_handler); -} - -DSLibinput::~DSLibinput() -{ - if (__libinput_handler) - { - ecore_main_fd_handler_del(__libinput_handler); - } - ecore_shutdown(); - libinput_unref(__libinput); - udev_unref(__udev); -} - -int DSLibinput::__handleOpenRestricted(const char *path, int flags, void *user_data) -{ - int fd = open(path, flags); - - return fd; -} - -void DSLibinput::__handleCloseRestricted(int fd, void *user_data) -{ - close(fd); -} - -Eina_Bool DSLibinput::__handleEvents(void *data, Ecore_Fd_Handler *hdlr) -{ - DSLibinput *dsLibinput = (DSLibinput *)data; - struct ::libinput_event *event; - - if (libinput_dispatch(dsLibinput->__libinput) != 0) - { - //log("Failed to dispatch libinput events: %m"); - } - - while ((event = libinput_get_event(dsLibinput->__libinput))) - { - switch (libinput_event_get_type(event)) - { - case LIBINPUT_EVENT_DEVICE_ADDED: - dsLibinput->__processDeviceAddEvent(event); - break; - case LIBINPUT_EVENT_DEVICE_REMOVED: - dsLibinput->__processDeviceRemoveEvent(event); - break; -/*LCOV_EXCL_START*/ - case LIBINPUT_EVENT_KEYBOARD_KEY: - dsLibinput->__processKeyboardKeyEvent(event); - break; - case LIBINPUT_EVENT_POINTER_MOTION: - dsLibinput->__processPointerMotionEvent(event); - break; - case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: - dsLibinput->__processPointerMotionAbsoluteEvent(event); - break; - case LIBINPUT_EVENT_POINTER_BUTTON: - dsLibinput->__processPointerButtonEvent(event); - break; - case LIBINPUT_EVENT_POINTER_AXIS: - dsLibinput->__processPointerAxisEvent(event); - break; - case LIBINPUT_EVENT_TOUCH_DOWN: - dsLibinput->__processTouchDownEvent(event); - break; - case LIBINPUT_EVENT_TOUCH_MOTION: - dsLibinput->__processTouchMotionEvent(event); - break; - case LIBINPUT_EVENT_TOUCH_UP: - dsLibinput->__processTouchUpEvent(event); - break; - case LIBINPUT_EVENT_TOUCH_CANCEL: - dsLibinput->__processTouchCancelEvent(event); - break; - case LIBINPUT_EVENT_TOUCH_FRAME: - dsLibinput->__processTouchFrameEvent(event); - break; - case LIBINPUT_EVENT_TOUCH_AUX_DATA: - dsLibinput->__processTouchAuxDataEvent(event); - break; - default: - break; -/*LCOV_EXCL_STOP*/ - } - libinput_event_destroy(event); - } - return EINA_TRUE; -} - -void DSLibinput::__processDeviceAddEvent(struct ::libinput_event *event) -{ - struct ::libinput_seat *libinput_seat; - struct ::libinput_device *device; - std::string seatName, devName, identifier; - - device = libinput_event_get_device(event); - libinput_seat = libinput_device_get_seat(device); - - seatName = libinput_seat_get_logical_name(libinput_seat); - devName = libinput_device_get_name(device); - identifier= (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); - - if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) - { - inputPrivate->PostDeviceAddEvent(seatName, devName, identifier, DSInput::KeyboardClass); - } - else if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER)) - { - inputPrivate->PostDeviceAddEvent(seatName, devName, identifier, DSInput::PointerClass); - } - else if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) - { - inputPrivate->PostDeviceAddEvent(seatName, devName, identifier, DSInput::TouchClass); - } -} - -void DSLibinput::__processDeviceRemoveEvent(struct ::libinput_event *event) -{ - struct ::libinput_seat *libinput_seat; - struct ::libinput_device *device; - std::string seatName, devName, identifier; - - device = libinput_event_get_device(event); - libinput_seat = libinput_device_get_seat(device); - - seatName = libinput_seat_get_logical_name(libinput_seat); - devName = libinput_device_get_name(device); - identifier= (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); - - if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) - { - inputPrivate->PostDeviceRemoveEvent(seatName, devName, identifier, DSInput::KeyboardClass); - } - else if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER)) - { - inputPrivate->PostDeviceRemoveEvent(seatName, devName, identifier, DSInput::PointerClass); - } - else if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) - { - inputPrivate->PostDeviceRemoveEvent(seatName, devName, identifier, DSInput::TouchClass); - } -} - -/*LCOV_EXCL_START*/ -void DSLibinput::__processKeyboardKeyEvent(struct:: libinput_event *event) -{ - struct:: libinput_event_keyboard *keyboard_event = libinput_event_get_keyboard_event(event); - int keycode = libinput_event_keyboard_get_key(keyboard_event) + 8; - int state = libinput_event_keyboard_get_key_state(keyboard_event); - uint32_t timestamp = libinput_event_keyboard_get_time(keyboard_event); - bool pressed = false; - - if (state == LIBINPUT_KEY_STATE_PRESSED) pressed = true; - - struct ::libinput_device *device = libinput_event_get_device(event); - std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); - - inputPrivate->PostKeyboardEvent(keycode, pressed, identifier, DSInput::KeyboardClass, timestamp); -} - -void DSLibinput::__processPointerMotionEvent(struct ::libinput_event *event) -{ - struct:: libinput_event_pointer *pointer_event = libinput_event_get_pointer_event(event); - int dx, dy; - uint32_t timestamp = libinput_event_pointer_get_time(pointer_event); - struct ::libinput_device *device = libinput_event_get_device(event); - std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); - - dx = libinput_event_pointer_get_dx(pointer_event); - dy = libinput_event_pointer_get_dy(pointer_event); - - inputPrivate->PostPointerEvent(0, dx, dy, 0, DSInputEvent::MouseMoveEvent, identifier, DSInput::PointerClass, timestamp); -} - -void DSLibinput::__processPointerMotionAbsoluteEvent(struct ::libinput_event *event) -{ - ; -} - -void DSLibinput::__processPointerButtonEvent(struct ::libinput_event *event) -{ - struct:: libinput_event_pointer *pointer_event = libinput_event_get_pointer_event(event); - DSInputEvent::Type eventType; - int button; - int state; - uint32_t timestamp = libinput_event_pointer_get_time(pointer_event); - - struct ::libinput_device *device = libinput_event_get_device(event); - std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); - - button = libinput_event_pointer_get_button(pointer_event); - state = libinput_event_pointer_get_button_state(pointer_event); - - if (state) - eventType = DSInputEvent::MouseDownEvent; - else - eventType = DSInputEvent::MouseUpEvent; - - inputPrivate->PostPointerEvent(button, 0, 0, 0, eventType, identifier, DSInput::PointerClass, timestamp); -} - -void DSLibinput::__processPointerAxisEvent(struct ::libinput_event *event) -{ - ; -} - -void DSLibinput::__processTouchDownEvent(struct ::libinput_event *event) -{ - struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); - int index, x, y; - uint32_t timestamp = libinput_event_touch_get_time(touch_event); - - struct ::libinput_device *device = libinput_event_get_device(event); - std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); - - index = libinput_event_touch_get_slot(touch_event); - x = libinput_event_touch_get_x(touch_event); - y = libinput_event_touch_get_y(touch_event); - - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchDownEvent, identifier, DSInput::TouchClass, timestamp); -} - -void DSLibinput::__processTouchMotionEvent(struct ::libinput_event *event) -{ - struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); - int index, x, y; - uint32_t timestamp = libinput_event_touch_get_time(touch_event); - - struct ::libinput_device *device = libinput_event_get_device(event); - std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); - - index = libinput_event_touch_get_slot(touch_event); - x = libinput_event_touch_get_x(touch_event); - y = libinput_event_touch_get_y(touch_event); - - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchMoveEvent, identifier, DSInput::TouchClass, timestamp); -} - -void DSLibinput::__processTouchUpEvent(struct ::libinput_event *event) -{ - struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); - int index, x, y; - uint32_t timestamp = libinput_event_touch_get_time(touch_event); - - struct ::libinput_device *device = libinput_event_get_device(event); - std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); - - index = libinput_event_touch_get_slot(touch_event); - x = 0; - y = 0; - - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchUpEvent, identifier, DSInput::TouchClass, timestamp); -} - -void DSLibinput::__processTouchCancelEvent(struct ::libinput_event *event) -{ - ; -} - -void DSLibinput::__processTouchFrameEvent(struct ::libinput_event *event) -{ - ; -} - -void DSLibinput::__processTouchAuxDataEvent(struct ::libinput_event *event) -{ - ; -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server diff --git a/src/DSInput/DSLibinput.h b/src/DSInput/DSLibinput.h deleted file mode 100644 index 409a987..0000000 --- a/src/DSInput/DSLibinput.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DSLIBINPUT_H_ -#define _DSLIBINPUT_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "DSInputPrivate.h" - -namespace display_server -{ - -class DSLibinput -{ -public: - DSLibinput() = delete; - DSLibinput(DSInputPrivate *p_ptr); - ~DSLibinput(); - -private: - DSInputPrivate *inputPrivate; - struct ::libinput *__libinput; - udev *__udev; - int __fd; - Ecore_Fd_Handler *__libinput_handler; - - static const struct ::libinput_interface __input_interface; - - static int __handleOpenRestricted(const char *path, int flags, void *user_data); - static void __handleCloseRestricted(int fd, void *user_data); - static Eina_Bool __handleEvents(void *data, Ecore_Fd_Handler *hdlr); - - void __processDeviceAddEvent(struct ::libinput_event *event); - void __processDeviceRemoveEvent(struct ::libinput_event *event); - void __processKeyboardKeyEvent(struct ::libinput_event *event); - void __processPointerMotionEvent(struct ::libinput_event *event); - void __processPointerMotionAbsoluteEvent(struct ::libinput_event *event); - void __processPointerButtonEvent(struct ::libinput_event *event); - void __processPointerAxisEvent(struct ::libinput_event *event); - void __processTouchDownEvent(struct ::libinput_event *event); - void __processTouchMotionEvent(struct ::libinput_event *event); - void __processTouchUpEvent(struct ::libinput_event *event); - void __processTouchCancelEvent(struct ::libinput_event *event); - void __processTouchFrameEvent(struct ::libinput_event *event); - void __processTouchAuxDataEvent(struct ::libinput_event *event); -}; - -} - -#endif diff --git a/src/DSObject/DSObject.cpp b/src/DSObject/DSObject.cpp deleted file mode 100644 index d20665e..0000000 --- a/src/DSObject/DSObject.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSObject.h" - -namespace display_server -{ - -DSObject::DSObject() - : _d_ptr(std::make_unique(this)) -{} - -DSObject::~DSObject() -{ - __d_func()->notifyDestroy(); -} - -void DSObject::attachDestroyObserver(IDSObjectObserver *ob) -{ - __d_func()->attachDestroyObserver(ob); -} - -void DSObject::detachDestroyObserver(IDSObjectObserver *ob) -{ - __d_func()->detachDestroyObserver(ob); -} - -void DSObject::setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) -{ - __d_func()->setProperty(key, data, type); -} - -const DSPropertyVariant &DSObject::getProperty(std::string key) -{ - return __d_func()->getProperty(key); -} - -std::string DSObject::getName(void) -{ - return __d_func()->getName(); -} - -void DSObject::setName(std::string name) -{ - __d_func()->setName(name); -} - -DSObject::DSObject(std::unique_ptr ptr) -{ - _d_ptr = std::move(ptr); -} - -} // namespace display_server diff --git a/src/DSObject/DSObject.h b/src/DSObject/DSObject.h deleted file mode 100644 index 6c79fbb..0000000 --- a/src/DSObject/DSObject.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_OBJECT_H_ -#define __DS_OBJECT_H_ - -#include "DSCore.h" -#include "IDSObjectObserver.h" -#include "DSObjectPrivate.h" -#include "DSProperty.h" - -namespace display_server -{ - -class DSObject -{ -public: - explicit DSObject(); - virtual ~DSObject(); - - void attachDestroyObserver(IDSObjectObserver *ob); - void detachDestroyObserver(IDSObjectObserver *ob); - void setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); - const DSPropertyVariant &getProperty(std::string key); - std::string getName(void); - void setName(std::string name); - -protected: - DSObject(std::unique_ptr ptr); - std::unique_ptr _d_ptr; - -private: - inline DSObjectPrivate *__d_func() - { - return _d_ptr.get(); - } - inline const DSObjectPrivate *__d_func() const - { - return _d_ptr.get(); - } -}; - -} // namespace display_server - -#endif - diff --git a/src/DSObject/DSObjectPrivate.cpp b/src/DSObject/DSObjectPrivate.cpp deleted file mode 100644 index af09cc5..0000000 --- a/src/DSObject/DSObjectPrivate.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSObject.h" - -namespace display_server -{ - DSObjectPrivate::DSObjectPrivate(DSObject *p_ptr) : - __p_ptr(p_ptr) - {} - - DSObjectPrivate::~DSObjectPrivate() - { - __type_info.name.clear(); - __observers.clear(); - __properties.clear(); - } - - void DSObjectPrivate::attachDestroyObserver(IDSObjectObserver *ob) - { - __observers.push_back(ob); - } - - void DSObjectPrivate::detachDestroyObserver(IDSObjectObserver *ob) - { - __observers.remove(ob); - } - - void DSObjectPrivate::setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) - { - std::unordered_map::const_iterator ci = __properties.find(key); - - if (ci == __properties.end()) { - __properties.emplace(key, DSProperty(key, data, type)); - } else { - __properties[key] = DSProperty(key, data, type); - } - } - - const DSPropertyVariant &DSObjectPrivate::getProperty(std::string key) - { - std::unordered_map::const_iterator ci = __properties.find(key); - - if (ci == __properties.end()) { - throw DSPropertyException("NOT_EXIST"); - } - return __properties[key].getData(); - } - - void DSObjectPrivate::notifyDestroy(void) - { - for (IDSObjectObserver *ob : __observers) - ob->destroyed(__p_ptr); - __observers.clear(); - } - - std::string DSObjectPrivate::getName(void) - { - return __type_info.name; - } - - void DSObjectPrivate::setName(std::string name) - { - __type_info.name = name; - } - -/*LCOV_EXCL_START*/ - DSObjectPrivate& DSObjectPrivate::operator=(DSObjectPrivate &&p) - { - if (__p_ptr) - return *this; - - __type_info.name = p.__type_info.name; - __p_ptr = p.__p_ptr; - __observers = std::move(p.__observers); - __properties = std::move(p.__properties); - - p.__type_info.name.clear(); - p.__p_ptr = nullptr; - p.__observers.clear(); - p.__properties.clear(); - - return *this; - } -/*LCOV_EXCL_STOP*/ - -} // namespace display_server diff --git a/src/DSObject/DSObjectPrivate.h b/src/DSObject/DSObjectPrivate.h deleted file mode 100644 index 8712b9a..0000000 --- a/src/DSObject/DSObjectPrivate.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_OBJECT_PRIVATE_H_ -#define __DS_OBJECT_PRIVATE_H_ - -#include "DSObject.h" -#include "DSProperty.h" -#include -#include -#include -#include - -namespace display_server -{ - -class DSObject; - -class DSObjectPrivate { -public: - DSObjectPrivate() = delete; - DSObjectPrivate(DSObject *p_ptr); - virtual ~DSObjectPrivate(); - - void attachDestroyObserver(IDSObjectObserver *ob); - void detachDestroyObserver(IDSObjectObserver *ob); - void notifyDestroy(); - void setProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); - const DSPropertyVariant &getProperty(std::string key); - std::string getName(void); - void setName(std::string name); - - DSObjectPrivate &operator=(DSObjectPrivate &&p); //move assignment - - inline const DSObject *p_func() const - { - return __p_ptr; - } - -private: - struct - { - std::string name; - } __type_info; - - DSObject *__p_ptr; - - std::list __observers; - std::unordered_map __properties; -}; - -} // namespace display_server - -#endif diff --git a/src/DSObject/IDSObjectObserver.h b/src/DSObject/IDSObjectObserver.h deleted file mode 100644 index 516c265..0000000 --- a/src/DSObject/IDSObjectObserver.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __I_DS_OBJECT_OBSERVER_H_ -#define __I_DS_OBJECT_OBSERVER_H_ - -namespace display_server -{ - -class DSObject; - -class IDSObjectObserver -{ -public: - virtual ~IDSObjectObserver() = default; - virtual void destroyed(DSObject *slot) = 0; -}; - -} - -#endif diff --git a/src/DSOutput/DSOutputImpl.cpp b/src/DSOutput/DSOutputImpl.cpp deleted file mode 100644 index 3a8b7e8..0000000 --- a/src/DSOutput/DSOutputImpl.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSOutputImpl.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -DSOutputImpl::DSOutputImpl(std::shared_ptr displayDeviceOutput) - : __displayDeviceOutput{displayDeviceOutput} -{} - -DSOutputImpl::~DSOutputImpl() -{} - -int DSOutputImpl::getResolutionWidth() -{ - return __displayDeviceOutput->getResolutionWidth(); -} - -int DSOutputImpl::getResolutionHeight() -{ - return __displayDeviceOutput->getResolutionHeight(); -} - -bool DSOutputImpl::applyResolutionAuto() -{ - if (!__displayDeviceOutput) { - DSLOG_ERR("DSOutputImpl", "__displayDeviceOutput is null."); - return false; - } - - std::list> modes = __displayDeviceOutput->getAvailableModes(); - if (modes.empty()) { - DSLOG_ERR("DSOutputImpl", "modes are empty."); - return false; - } - - auto bestMode = modes.front(); - if (!bestMode) { - DSLOG_ERR("DSOutputImpl", "bestMode is null."); - return false; - } - - if (!__displayDeviceOutput->setMode(bestMode)) { - DSLOG_ERR("DSOutputImpl", "output->setMode(bestMode) fails."); - return false; - } - - // TODO: get more information from DSOutputImpl to set them toDSWaylandOutput. - __waylandOutput = std::make_shared(DSWaylandCompositor::getInstance(), - __displayDeviceOutput->getName(), "tm1", "tm1", - 0, 0, __displayDeviceOutput->getResolutionWidth(), __displayDeviceOutput->getResolutionHeight(), - __displayDeviceOutput->getPhysicalMMWidth(), __displayDeviceOutput->getPhysicalMMHeight(), - __displayDeviceOutput->getRefreshRate(), 0, 0); - DSWaylandCompositor::releaseInstance(); - - // send output information - __waylandOutput->sendWaylandOutputInfo(); - - return true; -} - -std::shared_ptr DSOutputImpl::getDisplayDeviceOutput() -{ - return __displayDeviceOutput; -} - -} // namespace display_server diff --git a/src/DSOutput/DSOutputImpl.h b/src/DSOutput/DSOutputImpl.h deleted file mode 100644 index 39757b2..0000000 --- a/src/DSOutput/DSOutputImpl.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __I_DS_OUTPUT_IMPL_H__ -#define __I_DS_OUTPUT_IMPL_H__ - -#include "IDSOutput.h" -#include "IDSDisplayDeviceOutput.h" -#include "DSWaylandOutput.h" - -namespace display_server -{ - -class DSOutputImpl : public IDSOutput -{ -public: - DSOutputImpl(std::shared_ptr displayDeviceOutput); - ~DSOutputImpl(); - - int getResolutionWidth() override; - int getResolutionHeight() override; - bool applyResolutionAuto() override; - - std::shared_ptr getDisplayDeviceOutput(); - -private: - std::shared_ptr __displayDeviceOutput; - std::shared_ptr __waylandOutput; -}; - -} - -#endif diff --git a/src/DSOutput/IDSOutput.h b/src/DSOutput/IDSOutput.h deleted file mode 100644 index 543d753..0000000 --- a/src/DSOutput/IDSOutput.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __I_DS_OUTPUT_H__ -#define __I_DS_OUTPUT_H__ - -namespace display_server -{ - -class IDSOutput -{ -public: - virtual ~IDSOutput() = default; - - virtual int getResolutionWidth() = 0; - virtual int getResolutionHeight() = 0; - virtual bool applyResolutionAuto() = 0; -}; - -} - -#endif diff --git a/src/DSOutput/README.md b/src/DSOutput/README.md deleted file mode 100644 index 1caeb55..0000000 --- a/src/DSOutput/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# DSOutput -Output - -## Requirements -* Output의 정보를 받을 수 있어야 한다. - * state 변경 - connect, disconnect, create, destroy - * dpms 변경 - dpms on, stanby, suspend, off -* Output state 변경 Noti를 보낼 수 있어야 한다. -* Output mode setting을 할 수 있어야 한다.(virtual mode도 setting가능해야 한다.DSOutput에서 관리해서 transform하여 display할 수 있는) -* Output dpms를 set/get을 할 수 있어야 한다. -* Output property set/get을 할 수 있어야 한다. -* Output commit을 할 수 있어야 한다. -* Output transform을 setting할 수 있어야 한다. -* <<향후 추가>> diff --git a/src/DSPolicyArea/DSPolicyArea.cpp b/src/DSPolicyArea/DSPolicyArea.cpp deleted file mode 100644 index 3a380ae..0000000 --- a/src/DSPolicyArea/DSPolicyArea.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSPolicyArea.h" -#include "DSPolicyAreaPrivate.h" - -namespace display_server -{ - -DSPolicyArea::DSPolicyArea() - : DS_INIT_PRIVATE_PTR(DSPolicyArea) -{} - -DSPolicyArea::~DSPolicyArea() -{} - -bool DSPolicyArea::setPosition(int x, int y) -{ - DS_GET_PRIV(DSPolicyArea); - - if (!priv->setPosition(x, y)) - return false; - - return true; -} - -bool DSPolicyArea::setSize(int width, int height) -{ - DS_GET_PRIV(DSPolicyArea); - - if (!priv->setSize(width, height)) - return false; - - return true; -} - -bool DSPolicyArea::attachSeat(std::shared_ptr seat) -{ - DS_GET_PRIV(DSPolicyArea); - - if (!priv->attachSeat(seat)) - return false; - - return true; -} - -DSPolicyAreaPrivate::DSPolicyAreaPrivate(DSPolicyArea *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __x(0), - __y(0), - __width(0), - __height(0), - __seat(nullptr) -{ - __zone = std::make_shared(); -} - -DSPolicyAreaPrivate::~DSPolicyAreaPrivate() -{} - -bool DSPolicyAreaPrivate::setPosition(int x, int y) -{ - stPosition position; - - position.x = x; - position.y = y; - - __zone->setPosition(position); - - return true; -} - -bool DSPolicyAreaPrivate::setSize(int width, int height) -{ - stSize size; - - size.w = width; - size.h = height; - - __zone->setSize(size); - - return true; -} - -bool DSPolicyAreaPrivate::attachSeat(std::shared_ptr seat) -{ - if (__seat) - { - DSLOG_INF("DSPolicyAreaPrivate", "Seat has been changed. (%p -> %p)", __seat, seat); - } - - __seat = seat; - __seat->attachZone(__zone); - - return true; -} - -std::shared_ptr DSPolicyAreaPrivate::getZone() -{ - return __zone; -} - - -} // namespace display_server diff --git a/src/DSPolicyArea/DSPolicyArea.h b/src/DSPolicyArea/DSPolicyArea.h deleted file mode 100644 index 74c9b26..0000000 --- a/src/DSPolicyArea/DSPolicyArea.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_POLICY_AREA_H__ -#define __DS_POLICY_AREA_H__ - -#include -#include -#include - -namespace display_server -{ - -class DSPolicyAreaPrivate; - -class DSPolicyArea : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSPolicyArea); -public: - DSPolicyArea(); - virtual ~DSPolicyArea(); - - bool setPosition(int x, int y); - bool setSize(int width, int height); - bool attachSeat(std::shared_ptr seat); -}; - -} - -#endif diff --git a/src/DSPolicyArea/DSPolicyAreaPrivate.h b/src/DSPolicyArea/DSPolicyAreaPrivate.h deleted file mode 100644 index c6431c2..0000000 --- a/src/DSPolicyArea/DSPolicyAreaPrivate.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_POLICY_AREA_PRIVATE_H__ -#define __DS_POLICY_AREA_PRIVATE_H__ - -#include "DSPolicyArea.h" -#include "DSZone.h" - -namespace display_server -{ - -class DSPolicyAreaPrivate : public DSObjectPrivate -{ -DS_PIMPL_USE_PUBLIC(DSPolicyArea); -public: - DSPolicyAreaPrivate() = delete; - DSPolicyAreaPrivate(DSPolicyArea *p_ptr); - virtual ~DSPolicyAreaPrivate(); - - static DSPolicyAreaPrivate *getPrivate(DSPolicyArea *q) { return q->__d_func(); } - bool setPosition(int x, int y); - bool setSize(int width, int height); - bool attachSeat(std::shared_ptr seat); - std::shared_ptr getZone(); - -private: - int __x, __y; - int __width, __height; - std::shared_ptr __seat; - std::shared_ptr __zone; -}; - -} - -#endif diff --git a/src/DSProperty/DSProperty.cpp b/src/DSProperty/DSProperty.cpp deleted file mode 100644 index d65d029..0000000 --- a/src/DSProperty/DSProperty.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSProperty.h" - -namespace display_server -{ - -DSProperty::DSProperty() - : __d_ptr(new DSPropertyPrivate(this)) -{} - -DSProperty::DSProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type) - : __d_ptr(new DSPropertyPrivate(this, key, data, type)) -{ - __d_func()->__setKey(key); - __d_func()->__setData(data, type); -} - -DSProperty::DSProperty(const DSProperty &property) - : __d_ptr(new DSPropertyPrivate(this)) -{ - __d_func()->__setKey(property.getKey()); - __d_func()->__setData(property.getData(), property.getType()); -} - -DSProperty::~DSProperty() -{} - -DSProperty &DSProperty::operator=(DSProperty &property) // Copy Assign -{ - __d_func()->__setKey(property.getKey()); - __d_func()->__setData(property.getData(), property.getType()); - - return *this; -} - -DSProperty &DSProperty::operator=(const DSProperty &property) // Copy Assign -{ - __d_func()->__setKey(property.getKey()); - __d_func()->__setData(property.getData(), property.getType()); - - return *this; -} - -const DSPropertyVariant &DSProperty::getData(void) const -{ - return __d_func()->__getData(); -} - -const std::string DSProperty::getKey(void) const -{ - return __d_func()->__getKey(); -} - -const DSPropertyType DSProperty::getType(void) const -{ - return __d_func()->__getType(); -} - -} // namespace display_server diff --git a/src/DSProperty/DSProperty.h b/src/DSProperty/DSProperty.h deleted file mode 100644 index d3abdd0..0000000 --- a/src/DSProperty/DSProperty.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_PROPERTY_H_ -#define __DS_PROPERTY_H_ - -#include "DSCore.h" -#include "DSPropertyPrivate.h" - -namespace display_server -{ - -class DSPropertyPrivate; - -struct DSPropertyException : public std::exception -{ -public: - DSPropertyException(std::string str) - : __msg(str) - {} - - virtual const char *what() const noexcept override - { - return __msg.c_str(); - } - -private: - std::string __msg; -}; - -class DSProperty -{ -public: - DSProperty(); - DSProperty(std::string key, const DSPropertyVariant &data, DSPropertyType type); - DSProperty(const DSProperty &property); - virtual ~DSProperty(); - - const DSPropertyVariant &getData(void) const; - const std::string getKey(void) const; - const DSPropertyType getType(void) const; - - DSProperty &operator=(DSProperty &property); - DSProperty &operator=(const DSProperty &property); - -private: - std::unique_ptr __d_ptr; - - inline DSPropertyPrivate *__d_func() - { - return __d_ptr.get(); - } - inline const DSPropertyPrivate *__d_func() const - { - return __d_ptr.get(); - } - - friend class DSPropertyPrivate; - friend class DSObject; -}; - -} // namespace display_server - -#endif diff --git a/src/DSProperty/DSPropertyPrivate.cpp b/src/DSProperty/DSPropertyPrivate.cpp deleted file mode 100644 index c6f2ae8..0000000 --- a/src/DSProperty/DSPropertyPrivate.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSProperty.h" - -namespace display_server { - -DSPropertyPrivate::DSPropertyPrivate(DSProperty *p_ptr) - : __p_ptr(p_ptr) -{ - __type = DSPropertyType::NONE; -} - -DSPropertyPrivate::DSPropertyPrivate(DSProperty *p_ptr, std::string key, const DSPropertyVariant &data, DSPropertyType type) - : __p_ptr(p_ptr), __key(key), __type(type) -{ - switch (__type) { // copy case - case DSPropertyType::INTEGER: - case DSPropertyType::DOUBLE: - case DSPropertyType::FLOAT: - case DSPropertyType::STRING: - __data = data; // value copy - break; - case DSPropertyType::POINTER: - __data = data; // address copy - break; - default: - break; - } -} - -DSPropertyPrivate::~DSPropertyPrivate() -{ - __key.clear(); -} - -const std::string DSPropertyPrivate::__getKey() const -{ - return __key; -} - -const DSPropertyVariant &DSPropertyPrivate::__getData() const -{ - return __data; -} - -const DSPropertyType DSPropertyPrivate::__getType() const -{ - return __type; -} - -void DSPropertyPrivate::__setKey(std::string key) -{ - __key = key; -} - -void DSPropertyPrivate::__setData(DSPropertyVariant data, DSPropertyType type) -{ - __type = type; - - switch (__type) { // copy case - case DSPropertyType::INTEGER: - case DSPropertyType::DOUBLE: - case DSPropertyType::FLOAT: - case DSPropertyType::STRING: - __data = data; // value copy - break; - case DSPropertyType::POINTER: - __data = data; // address copy - break; - default: - break; - } -} - -} // namespace display_server diff --git a/src/DSProperty/DSPropertyPrivate.h b/src/DSProperty/DSPropertyPrivate.h deleted file mode 100644 index 59c6002..0000000 --- a/src/DSProperty/DSPropertyPrivate.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_PROPERTY_PRIVATE_H_ -#define __DS_PROPERTY_PRIVATE_H_ - -#include "DSCore.h" -#include "DSProperty.h" - -namespace display_server -{ - -class DSProperty; - -using DSPropertyType = enum type { - NONE, - INTEGER, //int - FLOAT, //float - DOUBLE, //double - STRING, //std::string - POINTER, //void* -}; - -using DSPropertyVariant = std::variant; - -class DSPropertyPrivate -{ -public: - DSPropertyPrivate() = delete; - DSPropertyPrivate(DSProperty *p_ptr); - DSPropertyPrivate(DSProperty *p_ptr, std::string key, const DSPropertyVariant &data, DSPropertyType type); - virtual ~DSPropertyPrivate(); - - inline const DSProperty *p_func() const - { - return __p_ptr; - } - -private: - DSProperty *__p_ptr; - std::string __key; - DSPropertyVariant __data; - DSPropertyType __type; - - const std::string __getKey(void) const; - const DSPropertyVariant &__getData(void) const; - const DSPropertyType __getType(void) const; - - void __setKey(std::string key); - void __setData(DSPropertyVariant data, DSPropertyType type); - - friend class DSProperty; -}; - -} // namespace display_server - -#endif diff --git a/src/DSRender/DSRenderEngineDaliImpl.cpp b/src/DSRender/DSRenderEngineDaliImpl.cpp deleted file mode 100644 index e1d13c2..0000000 --- a/src/DSRender/DSRenderEngineDaliImpl.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSRenderEngineDaliImpl.h" -#include "DSRenderViewDaliImpl.h" -#include "DSDebugLog.h" - -#include - -#include - -using namespace Dali; - -namespace display_server -{ - -DSRenderEngineDaliImpl::DSRenderEngineDaliImpl(std::shared_ptr bufferQueue) - : __bufferQueue(bufferQueue), - __needToRender(false) -{ - tbm_surface_queue_h nativeBufferQueue = (tbm_surface_queue_h)bufferQueue->getNativeBufferQueue(); - __offscreenApplication = OffscreenApplication::New(nativeBufferQueue, OffscreenApplication::RenderMode::MANUAL); - - __offscreenApplication.InitSignal().Connect(this, &DSRenderEngineDaliImpl::onInitialize); - - __offscreenApplication.Start(); -} - -DSRenderEngineDaliImpl::~DSRenderEngineDaliImpl() -{ -} - -void DSRenderEngineDaliImpl::onInitialize() -{ - OffscreenWindow window = __offscreenApplication.GetWindow(); - window.SetBackgroundColor(Color::TRANSPARENT); -} - -std::shared_ptr DSRenderEngineDaliImpl::makeRenderView() -{ - std::shared_ptr renderView = std::make_shared(__offscreenApplication.GetWindow()); - - // callbacks - renderView->registerCallbackUpdated(this, std::bind(&DSRenderEngineDaliImpl::__onRenderViewUpdated, this, std::placeholders::_1)); - - return renderView; -} - -bool DSRenderEngineDaliImpl::renderFrame() -{ - if (__needToRender) { - Adaptor::Get().RenderOnce(); - DSLOG_DBG("DSRenderEngineDaliImpl", "RENDER RENDER RENDER~!!!!"); - } - - __needToRender = false; - - return true; -} - -void DSRenderEngineDaliImpl::__onRenderViewUpdated(void *data) -{ - if (!__needToRender) { - DSLOG_DBG("DSRenderEngineDaliImpl", "Something updated on RenderView!! with buffer(%p)"); - __needToRender = true; - } -} - -} // namespace display_server diff --git a/src/DSRender/DSRenderEngineDaliImpl.h b/src/DSRender/DSRenderEngineDaliImpl.h deleted file mode 100644 index d35b209..0000000 --- a/src/DSRender/DSRenderEngineDaliImpl.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_RENDER_ENGINE_DALI_IMPL_H_ -#define __DS_RENDER_ENGINE_DALI_IMPL_H_ - -#include "IDSRenderEngine.h" -#include "IDSBufferQueue.h" - -#include -#include -#include -#include - -namespace display_server -{ - -class DSRenderEngineDaliImpl : public IDSRenderEngine, public Dali::ConnectionTracker, public DSObject -{ -public: - DSRenderEngineDaliImpl(std::shared_ptr bufferQueue); - ~DSRenderEngineDaliImpl(); - - std::shared_ptr makeRenderView() override; - bool renderFrame() override; - - void onInitialize(); - -private: - void __onRenderViewUpdated(void *data); - - std::shared_ptr __bufferQueue; - Dali::OffscreenApplication __offscreenApplication; - - bool __needToRender; -}; - -} - -#endif diff --git a/src/DSRender/DSRenderEngineEcoreEvasImpl.cpp b/src/DSRender/DSRenderEngineEcoreEvasImpl.cpp deleted file mode 100644 index ae03499..0000000 --- a/src/DSRender/DSRenderEngineEcoreEvasImpl.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSRenderEngineEcoreEvasImpl.h" -#include "DSRenderViewEcoreEvasImpl.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -DSRenderEngineEcoreEvasImpl::DSRenderEngineEcoreEvasImpl(std::shared_ptr bufferQueue) - : __bufferQueue(bufferQueue), - __bufferWidth{bufferQueue->getBufferWidth()}, - __bufferHeight{bufferQueue->getBufferHeight()}, - __ee{nullptr} -{ - if (!evas_init()) { - DSLOG_ERR("RENDER_ENGINE_ECORE_EVAS", "evas_init fails"); - } - - if (!ecore_evas_init()) { - DSLOG_ERR("RENDER_ENGINE_ECORE_EVAS", "ecore_evas_init fails"); - } - - auto alloc_func = [](void *data, int w, int h) -> void * { - IDSBufferQueue *bufferQueue = static_cast(data); - void *nativeBufferQueue = bufferQueue->getNativeBufferQueue(); - - return nativeBufferQueue; - }; - - auto free_func = [](void *data, void *tqueue) -> void {}; - - __ee = ecore_evas_tbm_allocfunc_new("gl_tbm", __bufferWidth, __bufferHeight, alloc_func, free_func, (void *)bufferQueue.get()); - if (!__ee) { - DSLOG_ERR("RENDER_ENGINE_ECORE_EVAS", "ecore_evas_tbm_allocfunc_new fails."); - } - - ecore_evas_manual_render_set(__ee, 1); - ecore_evas_show(__ee); -} - -DSRenderEngineEcoreEvasImpl::~DSRenderEngineEcoreEvasImpl() -{ - ecore_evas_free(__ee); - ecore_evas_shutdown(); - evas_shutdown(); -} - -std::shared_ptr DSRenderEngineEcoreEvasImpl::makeRenderView() -{ - std::shared_ptr renderView = std::make_shared(__ee); - - return renderView; -} - -bool DSRenderEngineEcoreEvasImpl::renderFrame() -{ - ecore_evas_manual_render(__ee); - - return true; -} - -} // namespace display_server diff --git a/src/DSRender/DSRenderEngineEcoreEvasImpl.h b/src/DSRender/DSRenderEngineEcoreEvasImpl.h deleted file mode 100644 index 23b2837..0000000 --- a/src/DSRender/DSRenderEngineEcoreEvasImpl.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_RENDER_ENGINE_ECORE_EVAS_IMPL_H_ -#define __DS_RENDER_ENGINE_ECORE_EVAS_IMPL_H_ - -#include "IDSRenderEngine.h" -#include "IDSBufferQueue.h" -#include - -namespace display_server -{ - -class DSRenderEngineEcoreEvasImpl : public IDSRenderEngine -{ -public: - DSRenderEngineEcoreEvasImpl(std::shared_ptr bufferQueue); - ~DSRenderEngineEcoreEvasImpl(); - - std::shared_ptr makeRenderView() override; - bool renderFrame() override; - -private: - std::shared_ptr __bufferQueue; - int __bufferWidth; - int __bufferHeight; - Ecore_Evas *__ee; -}; - -} - -#endif diff --git a/src/DSRender/DSRenderView.cpp b/src/DSRender/DSRenderView.cpp deleted file mode 100644 index fa7caf2..0000000 --- a/src/DSRender/DSRenderView.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSRenderView.h" - -namespace display_server -{ - -DSRenderView::DSRenderView() -{} - -DSRenderView::~DSRenderView() -{} - -} // namespace display_server diff --git a/src/DSRender/DSRenderView.h b/src/DSRender/DSRenderView.h deleted file mode 100644 index 0696c16..0000000 --- a/src/DSRender/DSRenderView.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_RENDER_VIEW_H__ -#define __DS_RENDER_VIEW_H__ - -#include "IDSBuffer.h" -#include "DSObject.h" -#include "DSSignal.h" - -namespace display_server -{ - -class DSRenderView -{ -public: - DSRenderView(); - virtual ~DSRenderView(); - - virtual bool setBuffer(std::shared_ptr buffer) = 0; - virtual void raiseToTop() = 0; - virtual void lowerToBottom() = 0; - virtual void setPosition(int x, int y) = 0; - virtual void registerCallbackUpdated(DSObject *slot, std::function func) = 0; - -private: - /* data */ -}; - -} - -#endif diff --git a/src/DSRender/DSRenderViewDaliImpl.cpp b/src/DSRender/DSRenderViewDaliImpl.cpp deleted file mode 100644 index b8f4881..0000000 --- a/src/DSRender/DSRenderViewDaliImpl.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSRenderViewDaliImpl.h" -#include - -using namespace Dali; - -namespace display_server -{ - -const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( - attribute mediump vec2 aPosition;\n - varying mediump vec2 vTexCoord;\n - uniform highp mat4 uMvpMatrix;\n - uniform mediump vec3 uSize;\n - varying mediump vec2 sTexCoordRect;\n - void main()\n - {\n - gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0);\n - vTexCoord = aPosition + vec2(0.5);\n - }\n -); - -const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( - uniform lowp vec4 uColor;\n - varying mediump vec2 vTexCoord;\n - uniform samplerExternalOES sTexture;\n - void main()\n - {\n - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n - }\n -); - -Geometry DSRenderViewDaliImpl::CreateTexturedQuad() -{ - struct Vertex - { - Vector2 position; - Vector2 texCoord; - }; - - static const Vertex data[] = { { Vector2(-0.5f, -0.5f), Vector2(0.0f, 0.0f) }, - { Vector2(0.5f, -0.5f), Vector2(1.0f, 0.0f) }, - { Vector2(-0.5f, 0.5f), Vector2(0.0f, 1.0f) }, - { Vector2(0.5f, 0.5f), Vector2(1.0f, 1.0f) } }; - - VertexBuffer vertexBuffer; - Property::Map vertexFormat; - vertexFormat["aPosition"] = Property::VECTOR2; - vertexFormat["aTexCoord"] = Property::VECTOR2; - - //Create a vertex buffer for vertex positions and texture coordinates - vertexBuffer = VertexBuffer::New(vertexFormat); - vertexBuffer.SetData(data, 4u); - - //Create the geometry - Geometry geometry = Geometry::New(); - geometry.AddVertexBuffer(vertexBuffer); - geometry.SetType(Geometry::TRIANGLE_STRIP); - - return geometry; -} - -DSRenderViewDaliImpl::DSRenderViewDaliImpl(Dali::OffscreenWindow offscreenWindow) - : __offscreenWindow(offscreenWindow) -{ - std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n"; - fragmentShader += FRAGMENT_SHADER; - Dali::Shader __shader = Shader::New(VERTEX_SHADER, fragmentShader); - Dali::Geometry __geometry = DSRenderViewDaliImpl::CreateTexturedQuad(); - - __renderer = Renderer::New(__geometry, __shader); - __textureViewActor = Actor::New(); - - __textureViewActor.AddRenderer(__renderer); - - // Actor's default properties - __textureViewActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); - __textureViewActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); - __textureViewActor.SetProperty(Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f )); - - offscreenWindow.Add(__textureViewActor); - - DSLOG_INF("DSRenderViewDaliImpl", "RenderView(%p) created.", this); -} - -DSRenderViewDaliImpl::~DSRenderViewDaliImpl() -{ - DSLOG_INF("DSRenderViewDaliImpl", "RenderView(%p) destroyed", this); - - __textureViewActor.RemoveRenderer(__renderer); - __offscreenWindow.Remove(__textureViewActor); - - __updatedSignal.emit(nullptr); -} - -bool DSRenderViewDaliImpl::setBuffer(std::shared_ptr buffer) -{ - if (buffer) { - std::shared_ptr bufferSize = buffer->getSize(); - - __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); - __textureViewActor.SetProperty(Actor::Property::SIZE, Vector2(bufferSize->w, bufferSize->h)); - - tbm_surface_h nativeBuffer = (tbm_surface_h)buffer->getNativeBuffer(); - - NativeImageSourcePtr nativeImageSource = NativeImageSource::New(Any(nativeBuffer)); - - Texture nativeTexture = Texture::New(*nativeImageSource); - - TextureSet textureSet = TextureSet::New(); - textureSet.SetTexture(0u, nativeTexture); - - __renderer.SetTextures(textureSet); - - DSLOG_INF("DSRenderViewDaliImpl", "Buffer set. buffer(%p) size(%d, %d)", buffer.get(), bufferSize->w, bufferSize->h); - } else { - __textureViewActor.SetProperty(Actor::Property::VISIBLE, false); - - DSLOG_INF("DSRenderViewDaliImpl", "buffer set NULL."); - } - - __updatedSignal.emit(nullptr); - - return true; -} - -void DSRenderViewDaliImpl::raiseToTop() -{ - DSLOG_INF("DSRenderViewDaliImpl", ""); - - __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); - __textureViewActor.RaiseToTop(); - - __updatedSignal.emit(nullptr); -} - -void DSRenderViewDaliImpl::lowerToBottom() -{ - DSLOG_INF("DSRenderViewDaliImpl", ""); - - __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); - __textureViewActor.LowerToBottom(); - - __updatedSignal.emit(nullptr); -} - -void DSRenderViewDaliImpl::setPosition(int x, int y) -{ - DSLOG_INF("DSRenderViewDaliImpl", ""); - - __textureViewActor.SetProperty(Actor::Property::VISIBLE, true); - __textureViewActor.SetProperty(Actor::Property::POSITION, Vector3(x, y, 0.0f)); - - __updatedSignal.emit(nullptr); -} - -void DSRenderViewDaliImpl::registerCallbackUpdated(DSObject *slot, std::function func) -{ - __updatedSignal.connect(slot, func); -} - -} // namespace display_server diff --git a/src/DSRender/DSRenderViewDaliImpl.h b/src/DSRender/DSRenderViewDaliImpl.h deleted file mode 100644 index 53ea9bf..0000000 --- a/src/DSRender/DSRenderViewDaliImpl.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_RENDER_VIEW_DALI_IMPL_H_ -#define __DS_RENDER_VIEW_DALI_IMPL_H_ - -#include "DSRenderView.h" -#include "DSObject.h" - -#include -#include -#include - -namespace display_server -{ - -class DSRenderViewDaliImpl : public DSRenderView, public DSObject -{ -public: - DSRenderViewDaliImpl(Dali::OffscreenWindow offscreenWindow); - ~DSRenderViewDaliImpl(); - - bool setBuffer(std::shared_ptr buffer) override; - void raiseToTop() override; - void lowerToBottom() override; - void setPosition(int x, int y) override; - - void registerCallbackUpdated(DSObject *slot, std::function func) override; - - Dali::Geometry CreateTexturedQuad(); - -private: - void __onWindowBufferChanged(std::shared_ptr buffer); - void __onWindowRaiseToTopChanged(void *data); - void __onWindowLowerToBottomChanged(void *data); - void __onWindowPositionChanged(void *data); - - Dali::OffscreenWindow __offscreenWindow; - Dali::Renderer __renderer; - Dali::Actor __textureViewActor; - - DSSignal __updatedSignal; -}; - -} - -#endif diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp b/src/DSRender/DSRenderViewEcoreEvasImpl.cpp deleted file mode 100644 index d829ee4..0000000 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSRenderViewEcoreEvasImpl.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -DSRenderViewEcoreEvasImpl::DSRenderViewEcoreEvasImpl(Ecore_Evas *ee) -{ - __evasView = evas_object_image_filled_add(ecore_evas_get(ee)); - evas_object_image_border_center_fill_set(__evasView, EVAS_BORDER_FILL_SOLID); - evas_object_image_colorspace_set(__evasView, EVAS_COLORSPACE_ARGB8888); -} - -DSRenderViewEcoreEvasImpl::~DSRenderViewEcoreEvasImpl() -{ - evas_object_del(__evasView); -} - -bool DSRenderViewEcoreEvasImpl::setBuffer(std::shared_ptr buffer) -{ - Evas_Native_Surface ns; - - ns.type = EVAS_NATIVE_SURFACE_TBM; - ns.version = EVAS_NATIVE_SURFACE_VERSION; - ns.data.tbm.buffer = buffer->getNativeBuffer(); - evas_object_image_native_surface_set(__evasView, &ns); - - std::shared_ptr bufferSize = buffer->getSize(); - - evas_object_image_size_set(__evasView, bufferSize->w, bufferSize->h); - evas_object_image_pixels_dirty_set(__evasView, 1); - evas_object_resize(__evasView, bufferSize->w, bufferSize->h); - evas_object_show(__evasView); - - DSLOG_INF("DSRenderViewEcoreEvasImpl", "Window Buffer changed. buffer(%p) size(%d, %d)", buffer.get(), bufferSize->w, bufferSize->h); - - return true; -} - -void DSRenderViewEcoreEvasImpl::raiseToTop() -{ - //TODO: -} - -void DSRenderViewEcoreEvasImpl::lowerToBottom() -{ - //TODO: -} - -void DSRenderViewEcoreEvasImpl::setPosition(int x, int y) -{ - //TODO: -} - -void DSRenderViewEcoreEvasImpl::registerCallbackUpdated(DSObject *slot, std::function func) -{ - // No updated signal at ecore evas implementation yet. - //__updatedSignal.connect(slot, func); -} - -} // namespace display_server diff --git a/src/DSRender/DSRenderViewEcoreEvasImpl.h b/src/DSRender/DSRenderViewEcoreEvasImpl.h deleted file mode 100644 index 717c23a..0000000 --- a/src/DSRender/DSRenderViewEcoreEvasImpl.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_RENDER_VIEW_ECORE_EVAS_IMPL_H_ -#define __DS_RENDER_VIEW_ECORE_EVAS_IMPL_H_ - -#include "DSRenderView.h" -#include "DSObject.h" -#include - -namespace display_server -{ - -class DSRenderViewEcoreEvasImpl : public DSRenderView, public DSObject -{ -public: - DSRenderViewEcoreEvasImpl(Ecore_Evas *ee); - ~DSRenderViewEcoreEvasImpl(); - - bool setBuffer(std::shared_ptr buffer) override; - void raiseToTop() override; - void lowerToBottom() override; - void setPosition(int x, int y) override; - - void registerCallbackUpdated(DSObject *slot, std::function func) override; - -private: - Evas_Object *__evasView; - - DSSignal __updatedSignal; -}; - - -} - -#endif diff --git a/src/DSRender/IDSRenderEngine.h b/src/DSRender/IDSRenderEngine.h deleted file mode 100644 index b616da9..0000000 --- a/src/DSRender/IDSRenderEngine.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __I_DS_RENDER_ENGINE_H_ -#define __I_DS_RENDER_ENGINE_H_ - -#include "DSRenderView.h" - -namespace display_server -{ - -class IDSRenderEngine -{ -public: - virtual ~IDSRenderEngine() = default; - - virtual std::shared_ptr makeRenderView() = 0; - virtual bool renderFrame() = 0; -}; - -} - -#endif diff --git a/src/DSRender/README.md b/src/DSRender/README.md deleted file mode 100644 index 5dfc6d8..0000000 --- a/src/DSRender/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# DSRender -Render and View. - -## Requirements -### Render - * Renderer를 Trigger할 수 있어야 한다. (feat. ecore_evas_manual_render()) - ** View들의 상하관계에 따라서 Rendering을 DSTBUFFER(????????)에 할 수 있어야 한다. - * View들을 Renderer에 add할 수 있어야 한다. - * tbm_surface_queue를 Renderer에 setting할 수 있어야 한다. - * Renderer는 size가 있어야 한다.(feat. canvas) - * <<향후 추가>> -### View - * View는 Renderer의 Src이다. - * buffer를 View에 넣어 View 내부적으로 texture mapping할 수 있어야 한다. - * View는 Render좌표계에서 상대좌표를 가진다.(x,y) - * View는 size를 가진다. - * View의 position은 Renderer size를 벗어날 수 있다.(?) - * <<향후 추가>> diff --git a/src/DSRender/plantuml/IDSRenderEngine.plantuml b/src/DSRender/plantuml/IDSRenderEngine.plantuml deleted file mode 100644 index f991b17..0000000 --- a/src/DSRender/plantuml/IDSRenderEngine.plantuml +++ /dev/null @@ -1,33 +0,0 @@ -class Client -{ -} - -interface IDSRenderEngine -{ - + virtual std::shared_ptr makeRenderView() = 0; - + virtual bool renderFrame() = 0; -} - -Client "1" o-right- "0..*" IDSRenderEngine - -DSRenderEngineEcoreEvasImpl -up..|> IDSRenderEngine -DSRenderEngineDaliImpl -up..|> IDSRenderEngine - -class DSRenderEngineEcoreEvasImpl -{ -} - -class DSRenderEngineDaliImpl -{ -} - -abstract class DSRenderView -{ - + virtual bool setBuffer(std::shared_ptr buffer) = 0; -} - -DSRenderView <|-down-- DSRenderViewEcoreEvasImpl -DSRenderView <|-down-- DSRenderViewDaliImpl - - - diff --git a/src/DSSeat/DSKeyboard.cpp b/src/DSSeat/DSKeyboard.cpp deleted file mode 100644 index 6b1180f..0000000 --- a/src/DSSeat/DSKeyboard.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSKeyboard.h" -#include "DSSeat.h" -#include "DSWindow.h" -#include "DSInputEvent.h" -#include "DSWaylandKeyboard.h" -#include "DSWaylandSurface.h" - -namespace display_server -{ - -DSKeyboard::DSKeyboard(DSSeat *seat) - : __seat(seat), - __dswlKeyboard(nullptr), - __dswlCompositor(nullptr), - __kbdFocus(nullptr) -{ - if (nullptr == __dswlKeyboard) - { - //TODO : register slot for monitoring the creation of DSWaylandKeyboard - ; - } -} - -DSKeyboard::DSKeyboard(DSSeat *seat, DSWaylandKeyboard *keyboard) - : __seat(seat), - __dswlKeyboard(keyboard), - __dswlCompositor(nullptr), - __kbdFocus(nullptr) -{ -} - -DSKeyboard::~DSKeyboard() -{} - -/*LCOV_EXCL_START*/ -void DSKeyboard::processEvent(DSInputKeyboardEvent *ev, void *data) -{ - //TODO : get kbdFocus and send event to it via DSWaylandKeyboard instance - - if (!__kbdFocus) - { - DSLOG_ERR("DSKeyboard", "No kbdFocus available."); - return; - } - - if (ev->getType() == DSInputEvent::KeyDownEvent) - { - DSLOG_DBG("DSSeat", "[keyDown] name: %s, keycode: %d, devicename: %s, timestamp: %u\n", - ev->getKeyname().c_str(), ev->getKeycode(), ev->getDevice()->getName().c_str(), ev->getTimestamp()); - keyDown(ev->getKeycode()); - } - else - { - DSLOG_DBG("DSSeat", "[keyUp] name: %s, keycode: %d, devicename: %s, timestamp: %u\n", - ev->getKeyname().c_str(), ev->getKeycode(), ev->getDevice()->getName().c_str(), ev->getTimestamp()); - keyDown(ev->getKeycode()); - } - -} -/*LCOV_EXCL_STOP*/ - -void DSKeyboard::keyDown(uint32_t keycode) -{ - if (__dswlKeyboard) - { - __dswlKeyboard->sendKeyDown(keycode); - } -} - -void DSKeyboard::keyUp(uint32_t keycode) -{ - if (__dswlKeyboard) - { - __dswlKeyboard->sendKeyUp(keycode); - } -} - -void DSKeyboard::setRepeatRate(uint32_t rate) -{ - if (__dswlKeyboard) - { - __dswlKeyboard->setRepeatRate(rate); - } -} - -void DSKeyboard::setRepeatDelay(uint32_t delay) -{ - if (__dswlKeyboard) - { - __dswlKeyboard->setRepeatDelay(delay); - } -} - -/*LCOV_EXCL_START*/ -void DSKeyboard::setFocus(std::shared_ptr window) -{ - if (!window) - { - DSLOG_ERR("DSKeyboard", "Given window is INVALID. (window : %p)", window); - __kbdFocus = window; - if (__dswlKeyboard) - __dswlKeyboard->setFocus(nullptr); - return; - } - - DSWaylandSurface * waylandSurface = window->surface(); - - if (!waylandSurface) - { - DSLOG_ERR("DSKeyboard", "Wayland surface of the given window is INVALID. (window : %p (%p), surface : %p)", window, window.get(), waylandSurface); - return; - } - - DSLOG_INF("DSKeyboard", "focus window has been changed. (%p -> %p)", __kbdFocus ? __kbdFocus.get() : nullptr, window ? window.get() : nullptr); - __kbdFocus = window; - - if (!__dswlKeyboard) - { - DSLOG_ERR("DSKeyboard", "waylandKeyboard is NOT available !"); - return; - } - - __dswlKeyboard->setFocus(waylandSurface); - -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSKeyboard::resetFocus() -{ - if (__kbdFocus) - { - __kbdFocus = nullptr; - DSLOG_INF("DSKeyboard", "kbdFocus has been reset."); - } - - if (__dswlKeyboard) - __dswlKeyboard->resetFocus(); -} -/*LCOV_EXCL_STOP*/ - -std::shared_ptr DSKeyboard::getFocus() -{ - return __kbdFocus; -} - -} // namespace display_server diff --git a/src/DSSeat/DSKeyboard.h b/src/DSSeat/DSKeyboard.h deleted file mode 100644 index 2e6e4dd..0000000 --- a/src/DSSeat/DSKeyboard.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DSKEYBOARD_H__ -#define __DSKEYBOARD_H__ - -#include "DSCore.h" -#include "DSObject.h" - -namespace display_server -{ - -class DSSeat; -class DSWindow; -class DSInputKeyboardEvent; -class DSWaylandKeyboard; -class DSWaylandCompositor; - -class DSKeyboard : public DSObject -{ -public: - DSKeyboard() = delete; - DSKeyboard(DSSeat *seat); - DSKeyboard(DSSeat *seat, DSWaylandKeyboard *keyboard); - virtual ~DSKeyboard(); - - void processEvent(DSInputKeyboardEvent *ev, void *data); - - void keyDown(uint32_t keycode); - void keyUp(uint32_t keycode); - - void setRepeatRate(uint32_t rate); - void setRepeatDelay(uint32_t delay); - - void setFocus(std::shared_ptr window); - void resetFocus(); - std::shared_ptr getFocus(); - -private: - DSSeat *__seat; - DSWaylandKeyboard *__dswlKeyboard; - DSWaylandCompositor *__dswlCompositor; - std::shared_ptr __kbdFocus; -}; - -} - -#endif //__DSKEYBOARD_H__ diff --git a/src/DSSeat/DSPointer.cpp b/src/DSSeat/DSPointer.cpp deleted file mode 100644 index 2f7b1e1..0000000 --- a/src/DSSeat/DSPointer.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSPointer.h" -#include "DSSeat.h" -#include "DSWindow.h" -#include "DSInputEvent.h" -#include "DSWaylandPointer.h" -#include "DSWaylandSurface.h" -#include "DSStruct.h" - -namespace display_server -{ - -DSPointer::DSPointer(DSSeat *seat) - : __seat(seat), - __dswlPointer(nullptr), - __dswlCompositor(nullptr), - __ptrFocus(nullptr) -{ -} - -DSPointer::DSPointer(DSSeat *seat, DSWaylandPointer *pointer) - : __seat(seat), - __dswlPointer(pointer), - __dswlCompositor(nullptr), - __ptrFocus(nullptr) -{ -} - -DSPointer::~DSPointer() -{} - -/*LCOV_EXCL_START*/ -void DSPointer::processEvent(DSInputMouseEvent *ev, void *data) -{ - //TODO : get ptrFocus and send event to it via DSWaylandPointer instance - - if (!__ptrFocus) - { - DSLOG_ERR("DSPointer", "No ptrFocus available."); - return; - } - - if (ev->getType() == DSInputEvent::MouseInEvent) - { - DSLOG_DBG("DSTouch", "[mouseIn] devicename: %s, timestamp: %u, x: %d (winX: %d), y: %d (winY: %d)\n", - ev->getDevice()->getName().c_str(), ev->getTimestamp(), - ev->getX(), ev->getWinX(), ev->getY(), ev->getWinY()); - mouseIn(ev->getWinX(), ev->getWinY()); - } - else if (ev->getType() == DSInputEvent::MouseOutEvent) - { - DSLOG_DBG("DSTouch", "[mouseOut] devicename: %s, timestamp: %u\n", - ev->getDevice()->getName().c_str(), ev->getTimestamp()); - mouseOut(); - } - else if (ev->getType() == DSInputEvent::MouseDownEvent) - { - DSLOG_DBG("DSTouch", "[MouseDown] devicename: %s, timestamp: %u\n", - ev->getDevice()->getName().c_str(), ev->getTimestamp()); - mouseDown(ev->getButton()); - } - else if (ev->getType() == DSInputEvent::MouseMoveEvent) - { - DSLOG_DBG("DSTouch", "[mouseMove] devicename: %s, timestamp: %u, x: %d (winX: %d), y: %d (winY: %d)\n", - ev->getDevice()->getName().c_str(), ev->getTimestamp(), - ev->getX(), ev->getWinX(), ev->getY(), ev->getWinY()); - mouseMove(ev->getWinX(), ev->getWinY()); - } - else if (ev->getType() == DSInputEvent::MouseUpEvent) - { - DSLOG_DBG("DSTouch", "[mouseUp] devicename: %s, timestamp: %u\n", - ev->getDevice()->getName().c_str(), ev->getTimestamp()); - mouseUp(ev->getButton()); - } - else - { - DSLOG_INF("DSPointer", "Event type %d won't be handled right now.", ev->getType()); - return; - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSPointer::mouseDown(uint32_t button) -{ - if (__ptrFocus && __dswlPointer) - { - __dswlPointer->sendButtonDown(button); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSPointer::mouseUp(uint32_t button) -{ - if (__ptrFocus && __dswlPointer) - { - __dswlPointer->sendButtonUp(button); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSPointer::mouseMove(int x, int y) -{ - if (__ptrFocus && __dswlPointer) - { - __dswlPointer->sendMotion(x, y); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSPointer::mouseIn(int x, int y) -{ - if (__dswlPointer) - { - __dswlPointer->sendEnter(x, y); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSPointer::mouseOut() -{ - if (__dswlPointer) - { - __dswlPointer->sendLeave(); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSPointer::setFocus(std::shared_ptr window) -{ - if (!window) - { - DSLOG_ERR("DSPointer", "__ptrFocus has been changed (%p -> %p)", __ptrFocus, window); - __ptrFocus = window; - if (__dswlPointer) - __dswlPointer->setFocus(nullptr); - return; - } - - DSWaylandSurface * waylandSurface = window->surface(); - - if (!waylandSurface) - { - DSLOG_ERR("DSPointer", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface); - return; - } - - DSLOG_INF("DSPointer", "focus window has been changed. (%p -> %p)", __ptrFocus, window); - __ptrFocus = window; - - if (!__dswlPointer) - { - DSLOG_ERR("DSPointer", "waylandPointer is NOT available !"); - return; - } - - __dswlPointer->setFocus(waylandSurface); -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSPointer::resetFocus() -{ - if (__ptrFocus) - { - __ptrFocus = nullptr; - DSLOG_INF("DSPointer", "ptrFocus has been reset."); - } - - if (__dswlPointer) - __dswlPointer->resetFocus(); -} -/*LCOV_EXCL_STOP*/ - -std::shared_ptr DSPointer::getFocus() -{ - return __ptrFocus; -} - -} // namespace display_server diff --git a/src/DSSeat/DSPointer.h b/src/DSSeat/DSPointer.h deleted file mode 100644 index 79dc209..0000000 --- a/src/DSSeat/DSPointer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DSPOINTER_H__ -#define __DSPOINTER_H__ - -#include "DSCore.h" -#include "DSObject.h" - -namespace display_server -{ - -class DSSeat; -class DSWindow; -class DSInputMouseEvent; -class DSWaylandPointer; -class DSWaylandCompositor; - -class DSPointer : public DSObject -{ -public: - DSPointer() = delete; - DSPointer(DSSeat *seat); - DSPointer(DSSeat *seat, DSWaylandPointer *pointer); - virtual ~DSPointer(); - - void processEvent(DSInputMouseEvent *ev, void *data); - void mouseDown(uint32_t button); - void mouseUp(uint32_t button); - void mouseMove(int x, int y); - void mouseIn(int x, int y); - void mouseOut(); - void setFocus(std::shared_ptr window); - void resetFocus(); - std::shared_ptr getFocus(); - -private: - DSSeat *__seat; - DSWaylandPointer *__dswlPointer; - DSWaylandCompositor *__dswlCompositor; - std::shared_ptr __ptrFocus; -}; - -} - -#endif //__DSPOINTER_H__ diff --git a/src/DSSeat/DSSeat.cpp b/src/DSSeat/DSSeat.cpp deleted file mode 100644 index bc1470d..0000000 --- a/src/DSSeat/DSSeat.cpp +++ /dev/null @@ -1,686 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSSeat.h" -#include "DSInput.h" -#include "DSCompositor.h" -#include "DSWaylandSeat.h" -#include "DSWaylandCompositor.h" -#include "DSInputEvent.h" -#include "DSXkb.h" -#include "DSZone.h" -#include "DSWindow.h" - -#include "DSPointer.h" -#include "DSKeyboard.h" -#include "DSTouch.h" -#include "DSWaylandPointer.h" -#include "DSWaylandKeyboard.h" -#include "DSWaylandTouch.h" - -namespace display_server -{ - -DSSignal DSSeat::__signalHandleKeyEvent; -DSSignal DSSeat::__signalHandlePointerEvent; -DSSignal DSSeat::__signalHandleTouchEvent; - -DSSeat::DSSeat() - : __input(nullptr), - __dswlSeat(nullptr), - __dswlComp(nullptr), - __compositor(nullptr), - __xkb(new DSXkb(this)), - __zone(nullptr), - __keyboard(nullptr), - __pointer(nullptr), - __touch(nullptr), - __numPointer(0), - __numKeyboard(0), - __numTouch(0), - __focusWin(nullptr), - __stackChanged(false) -{ -} - -DSSeat::DSSeat(DSCompositor *compositor, std::string name) - : __input(nullptr), - __dswlSeat(nullptr), - __dswlComp(nullptr), - __compositor(compositor), - __xkb(new DSXkb(this)), - __zone(nullptr), - __keyboard(nullptr), - __pointer(nullptr), - __touch(nullptr), - __numPointer(0), - __numKeyboard(0), - __numTouch(0), - __focusWin(nullptr), - __stackChanged(false) -{ - if (!compositor) - return; - - __dswlComp = DSWaylandCompositor::getInstance(); - DS_ASSERT(__dswlComp != nullptr); - - __dswlSeat = __dswlComp->addSeat(DSWaylandSeat::capNone); - DS_ASSERT(__dswlSeat != nullptr); - - __dswlSeat->setXkb(__xkb); - - if (!name.empty()) - __dswlSeat->setName(name); - - __input = new DSInput(this, __xkb); - DS_ASSERT(__input != nullptr); - - __initSlots(); - __initEventHandlers(); - __input->init(); -} - -DSSeat::~DSSeat() -{ - if (__input) - delete __input; - - if (__dswlComp && __dswlSeat) - __dswlComp->removeSeat(__dswlSeat); - - if (__dswlComp) - DSWaylandCompositor::releaseInstance(); -} - -void DSSeat::__initSlots() -{ - __signalHandleKeyEvent.connect(this, std::bind(&DSSeat::__onKeyEvent, this, std::placeholders::_1)); - __signalHandlePointerEvent.connect(this, std::bind(&DSSeat::__onPointerEvent, this, std::placeholders::_1)); - __signalHandleTouchEvent.connect(this, std::bind(&DSSeat::__onTouchEvent, this, std::placeholders::_1)); -} - -void DSSeat:: __initEventHandlers() -{ - __input->registerCallbackDeviceAdd(this, std::bind(&DSSeat::slotDeviceAdd, this, std::placeholders::_1)); - __input->registerCallbackDeviceRemove(this, std::bind(&DSSeat::slotDeviceRemove, this, std::placeholders::_1)); - __input->registerCallbackKeyDown(this, inputEventHandlerKey); - __input->registerCallbackKeyUp(this, inputEventHandlerKey); - __input->registerCallbackMouseDown(this, inputEventHandlerMouse); - __input->registerCallbackMouseMove(this, inputEventHandlerMouse); - __input->registerCallbackMouseUp(this, inputEventHandlerMouse); - __input->registerCallbackTouchDown(this, inputEventHandlerTouch); - __input->registerCallbackTouchMove(this, inputEventHandlerTouch); - __input->registerCallbackTouchUp(this, inputEventHandlerTouch); -} - -bool DSSeat::attachZone(std::shared_ptr zone) -{ - DSLOG_INF("DSSeat", "The attached zone has been changed (%p -> %p)", __zone, zone); - - __zone = zone; - __zone->registerCallbackWindowCreated(this, std::bind(&DSSeat::__onWindowCreated, this, std::placeholders::_1)); - __zone->registerCallbackWindowStackChanged(this, std::bind(&DSSeat::__onWindowStackChanged, this, std::placeholders::_1)); - __zone->registerCallbackWindowDestroy(this, std::bind(&DSSeat::__onWindowDestroy, this, std::placeholders::_1)); - - return true; -} - -std::shared_ptr DSSeat::getZone() -{ - return __zone; -} - -bool DSSeat::detachZone() -{ - if (!__zone) - { - DSLOG_ERR("DSSeat", "No Zone is not available !"); - return false; - } - - //__zone->deregisterCallbackWindowCreated(this, std::bind(&DSSeat::__onWindowCreated, this, std::placeholders::_1)); - - DSLOG_INF("DSSeat", "Zone(%p) has been detached !", __zone); - __zone = nullptr; - - return true; -} - -void DSSeat::slotDeviceAdd(std::shared_ptr device) -{ - DSLOG_INF("DSSeat", ""); - device->print(); - - uint32_t cap = (uint32_t)__dswlSeat->getCapability(); - - if ((device->getClass() == DSInput::PointerClass) && (__numPointer++ == 0)) - { - cap = cap | DSWaylandSeat::capPointer; - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - DSWaylandPointer *dswlPointer = __dswlSeat->getPointer(); - __pointer = new DSPointer(this, dswlPointer); - DS_ASSERT(__pointer != nullptr); - } - else if ((device->getClass() == DSInput::KeyboardClass) && (__numKeyboard++ == 0)) - { - cap = cap | DSWaylandSeat::capKeyboard; - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - DSWaylandKeyboard *dswlKeyboard = __dswlSeat->getKeyboard(); - __keyboard = new DSKeyboard(this, dswlKeyboard); - DS_ASSERT(__keyboard != nullptr); - } - else if ((device->getClass() == DSInput::TouchClass) && (__numTouch++ == 0)) - { - cap = cap | DSWaylandSeat::capTouch; - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - DSWaylandTouch *dswlTouch = __dswlSeat->getTouch(); - __touch = new DSTouch(this, dswlTouch); - DS_ASSERT(__touch != nullptr); - } -} - -/*LCOV_EXCL_START*/ -void DSSeat::slotDeviceRemove(std::shared_ptr device) -{ - DSLOG_INF("DSSeat", ""); - device->print(); - - uint32_t cap = (uint32_t)__dswlSeat->getCapability(); - bool capNeedUpdate = false; - - if ((device->getClass() == DSInput::PointerClass) && ((--__numPointer) == 0)) - { - cap = cap & (~DSWaylandSeat::capPointer); - capNeedUpdate = true; - - if (__pointer) - { - delete __pointer; - __pointer = nullptr; - } - } - else if ((device->getClass() == DSInput::KeyboardClass) && ((--__numKeyboard) == 0)) - { - cap = cap & (~DSWaylandSeat::capKeyboard); - capNeedUpdate = true; - - if (__keyboard) - { - delete __keyboard; - __keyboard = nullptr; - } - } - else if ((device->getClass() == DSInput::TouchClass) && ((--__numTouch) == 0)) - { - cap = cap & (~DSWaylandSeat::capTouch); - capNeedUpdate = true; - - if (__touch) - { - delete __touch; - __touch = nullptr; - } - } - - if (capNeedUpdate) - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); -} -/*LCOV_EXCL_STOP*/ - -void DSSeat::addPointer() -{ - if (0 < __numPointer) - { - DSLOG_INF("DSSeat", "Pointer exists already. (num=%d)", __numPointer); - __numPointer++; - return; - } - - uint32_t cap = (uint32_t)__dswlSeat->getCapability(); - cap = cap | DSWaylandSeat::capPointer; - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - DSWaylandPointer *dswlPointer = __dswlSeat->getPointer(); - __pointer = new DSPointer(this, dswlPointer); - DS_ASSERT(__pointer != nullptr); - - __numPointer++; -} - -/*LCOV_EXCL_START*/ -void DSSeat::addKeyboard() -{ - if (0 < __numKeyboard) - { - DSLOG_INF("DSSeat", "Keyboard exists already. (num=%d)", __numKeyboard); - __numKeyboard++; - return; - } - - uint32_t cap = (uint32_t)__dswlSeat->getCapability(); - cap = cap | DSWaylandSeat::capKeyboard; - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - DSWaylandKeyboard *dswlKeyboard = __dswlSeat->getKeyboard(); - __keyboard = new DSKeyboard(this, dswlKeyboard); - DS_ASSERT(__keyboard != nullptr); - - __numKeyboard++; -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::addTouch() -{ - if (0 < __numTouch) - { - DSLOG_INF("DSSeat", "Touch exists already. (num=%d)", __numTouch); - __numTouch++; - return; - } - - uint32_t cap = (uint32_t)__dswlSeat->getCapability(); - cap = cap | DSWaylandSeat::capTouch; - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - DSWaylandTouch *dswlTouch = __dswlSeat->getTouch(); - __touch = new DSTouch(this, dswlTouch); - DS_ASSERT(__touch != nullptr); - - __numTouch++; -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::removePointer() -{ - if (0 >= __numPointer) - { - DSLOG_INF("DSSeat", "No pointer exists already. (num=%d)", __numPointer); - return; - } - - DS_ASSERT(__pointer != nullptr); - --__numPointer; - - if (0 == __numPointer) - { - uint32_t cap = (uint32_t)__dswlSeat->getCapability(); - cap = cap & (~DSWaylandSeat::capPointer); - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - delete __pointer; - __pointer = nullptr; - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::removeKeyboard() -{ - if (0 >= __numKeyboard) - { - DSLOG_INF("DSSeat", "No keyboard exists already. (num=%d)", __numKeyboard); - return; - } - - DS_ASSERT(__keyboard != nullptr); - --__numKeyboard; - - if (0 == __numKeyboard) - { - uint32_t cap = (uint32_t)__dswlSeat->getCapability(); - cap = cap & (~DSWaylandSeat::capKeyboard); - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - delete __keyboard; - __keyboard = nullptr; - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::removeTouch() -{ - if (0 >= __numTouch) - { - DSLOG_INF("DSSeat", "No touch exists already. (num=%d)", __numTouch); - return; - } - - DS_ASSERT(__touch != nullptr); - --__numTouch; - - if (0 == __numTouch) - { - uint32_t cap = (uint32_t)__dswlSeat->getCapability(); - cap = cap & (~DSWaylandSeat::capTouch); - __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap); - - delete __touch; - __touch = nullptr; - } -} -/*LCOV_EXCL_STOP*/ - -bool DSSeat::hasPointer() -{ - return !!__numPointer; -} - -bool DSSeat::hasKeyboard() -{ - return !!__numKeyboard; -} - -bool DSSeat::hasTouch() -{ - return !!__numTouch; -} - -DSXkb *DSSeat::getXkb() -{ - return __xkb; -} - -std::string DSSeat::getName() -{ - return __dswlSeat->getName(); -} - -/*LCOV_EXCL_START*/ -void DSSeat::__onKeyEvent(DSInputKeyboardEvent *ev) -{ - if (__keyboard == nullptr) - { - DSLOG_DBG("DSSeat", "No keyboard device exists. Key events will be dropped."); - return; - } - - __dswlSeat->setCurrentEventTime(ev->getTimestamp()); - __keyboard->processEvent(ev, nullptr); -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::__onPointerEvent(DSInputMouseEvent *ev) -{ - if (__pointer == nullptr) - { - DSLOG_DBG("DSSeat", "No pointer device exists. Mouse events will be dropped."); - return; - } - - __dswlSeat->setCurrentEventTime(ev->getTimestamp()); - - if (ev->getType() == DSInputEvent::MouseMoveEvent) - { - //get window whose geometry has intersection with the mouse coordinates - auto window = getTopWindowOnPosition(ev->getX(), ev->getY()); - - //check if the window is equal to the current pointer focus window - auto currentPointerFocus = __pointer->getFocus(); - - //if equal, no need to set focus / pointer enter/leave activities - if (window.get() != currentPointerFocus.get()) - { - //if not equal, send pointer leave to the current pointer focus window - std::shared_ptr evMouseOut = std::make_shared(ev->getDevice(), DSInputEvent::MouseOutEvent, ev->getTimestamp(), ev->getButton(), ev->getX(), ev->getY(), 0); - __pointer->processEvent(evMouseOut.get(), nullptr); - //TODO : emit MouseOut signal - - //set the window as pointer focus window - if (window) - { - int winX; - int winY; - stPosition pos; - - pos = window->getPosition(); - winX = ev->getX() - pos.x; - winY = ev->getY() - pos.y; - ev->setWinX(winX); - ev->setWinY(winY); - - __pointer->setFocus(window); - } - - //send pointer enter to the new pointer focus window - std::shared_ptr evMouseIn = std::make_shared(ev->getDevice(), DSInputEvent::MouseInEvent, ev->getTimestamp(), ev->getButton(), 0, 0, 0); - __pointer->processEvent(evMouseIn.get(), nullptr); - //TODO : emit MouseIn signal - } - } - - __pointer->processEvent(ev, nullptr); -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::__onTouchEvent(DSInputTouchEvent *ev) -{ - int winX; - int winY; - stPosition pos; - - if (__touch == nullptr) - { - DSLOG_DBG("DSSeat", "No touch device exists. Touch events will be dropped."); - return; - } - - if (ev->getType() == DSInputEvent::TouchDownEvent) - { - //get window whose geometry has intersection with the touch coordinates - auto window = getTopWindowOnPosition(ev->getX(), ev->getY()); - - DSLOG_INF("DSSeat", "window=%p, window.get()=%p", window, window.get()); - - //set the window as touch focus window - if (window) - { - pos = window->getPosition(); - winX = ev->getX() - pos.x; - winY = ev->getY() - pos.y; - ev->setWinX(winX); - ev->setWinY(winY); - - __touch->setFocus(window); - } - - //TODO : emit touch focus changed signal - } - else if (ev->getType() == DSInputEvent::TouchMoveEvent) - { - auto window = __touch->getFocus(); - - if (window) - { - pos = window->getPosition(); - winX = ev->getX() - pos.x; - winY = ev->getY() - pos.y; - ev->setWinX(winX); - ev->setWinY(winY); - } - } - - __dswlSeat->setCurrentEventTime(ev->getTimestamp()); - __touch->processEvent(ev, nullptr); -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::__onWindowStackChanged(std::shared_ptr topWindow) -{ - __stackChanged = true; -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::__onWindowCreated(std::shared_ptr window) -{ - DSLOG_INF("DSSeat", "window created : %p (%p)", window, window.get()); - - /* FIXME : get focus window for keyboard from DSWindowManager/DSWindowPolicy later */ - if (__keyboard) - { - std::shared_ptr focusWin = getTopWindow(nullptr); - DSWindow *currentWin = __focusWin ? __focusWin.get() : nullptr; - DSWindow *newWin = focusWin ? focusWin.get() : nullptr; - - if (currentWin != newWin) - { - DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", currentWin, newWin); - - if (focusWin) - { - if (__focusWin && __focusWin->hasFocus()) - __focusWin->unsetFocus(); - - __focusWin = focusWin; - __keyboard->setFocus(focusWin); - focusWin->setFocus(); - } - } - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSSeat::__onWindowDestroy(std::shared_ptr window) -{ - DSLOG_INF("DSSeat", "window destroy : %p (%p)", window, window.get()); - - std::shared_ptr currentFocus = nullptr; - - if (__keyboard && (currentFocus = __keyboard->getFocus()) && (currentFocus.get() == window.get())) - __keyboard->resetFocus(); - if (__pointer && (currentFocus = __pointer->getFocus()) && (currentFocus.get() == window.get())) - __pointer->resetFocus(); - if (__touch && (currentFocus = __touch->getFocus()) && (currentFocus.get() == window.get())) - __touch->resetFocus(); - - /* FIXME : get focus window for keyboard from DSWindowManager/DSWindowPolicy later */ - if (__keyboard) - { - std::shared_ptr focusWin = getTopWindow(window); - DSWindow *currentWin = __focusWin ? __focusWin.get() : nullptr; - DSWindow *newWin = focusWin ? focusWin.get() : nullptr; - - if (currentWin != newWin) - { - DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", currentWin, newWin); - - if (focusWin) - { - if (__focusWin && __focusWin->hasFocus()) - __focusWin->unsetFocus(); - - __focusWin = focusWin; - __keyboard->setFocus(focusWin); - focusWin->setFocus(); - } - else - { - __focusWin = nullptr; - } - } - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -Eina_Bool DSSeat::inputEventHandlerKey(void *data, int type, void *event) -{ - DSInputKeyboardEvent *ev = static_cast< DSInputKeyboardEvent* >(event); - __signalHandleKeyEvent.emit(ev); - - return EINA_TRUE; -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -Eina_Bool DSSeat::inputEventHandlerMouse(void *data, int type, void *event) -{ - DSInputMouseEvent *ev = static_cast< DSInputMouseEvent* >(event); - __signalHandlePointerEvent.emit(ev); - - return EINA_TRUE; -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event) -{ - DSInputTouchEvent *ev = static_cast< DSInputTouchEvent* >(event); - __signalHandleTouchEvent.emit(ev); - - return EINA_TRUE; -} -/*LCOV_EXCL_STOP*/ - -std::shared_ptr DSSeat::getTopWindow(std::shared_ptr winExcl) -{ - for (std::shared_ptr w : __zone->getWindowList()) - { - /* skip if w is not valid or has skip focus */ - if (!w || w->getSkipFocus()) - continue; - /* skip if w equals to winExcl */ - if (winExcl && winExcl.get() == w.get()) - continue; - - /* We suppose that the window located at the top of the window stack is at the front of the list. */ - return w; - - } - - return nullptr; -} - -std::shared_ptr DSSeat::getTopWindowOnPosition(int x, int y) -{ - stPosition wPos; - stSize wSize; - - for (std::shared_ptr w : __zone->getWindowList()) - { - wSize = w->getSize(); - wPos = w->getPosition(); - - if (x >= wPos.x && y >= wPos.y && x <= (int)(wPos.x+wSize.w) && y <= (int)(wPos.y+wSize.h)) - { - DSLOG_INF("DSSeat", "window(%p, x:%d, y:%d, w:%u, h:%u) contains (x:%d, y:%d)", w.get(), wPos.x, wPos.y, wSize.w, wSize.h, x, y); - return w; - } - } - - return nullptr; -} - -} // namespace display_server - diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h deleted file mode 100644 index 30bf0b2..0000000 --- a/src/DSSeat/DSSeat.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DSSEAT_H_ -#define _DSSEAT_H_ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSSignal.h" -#include -#include - -namespace display_server -{ - -class DSInput; -class DSKeyboard; -class DSPointer; -class DSTouch; -class DSInputDevice; -class DSCompositor; -class DSWaylandSeat; -class DSWaylandCompositor; -class DSXkb; -class DSZone; -class DSWindow; -class DSInputKeyboardEvent; -class DSInputMouseEvent; -class DSInputTouchEvent; - -class DSSeat : public DSObject -{ -public: - DSSeat(); - DSSeat(DSCompositor *compositor, std::string name); - virtual ~DSSeat(); - - bool attachZone(std::shared_ptr zone); - std::shared_ptr getZone(); - bool detachZone(); - - void slotDeviceAdd(std::shared_ptr device); - void slotDeviceRemove(std::shared_ptr device); - - std::string getName(); - - void addPointer(); - void addKeyboard(); - void addTouch(); - void removePointer(); - void removeKeyboard(); - void removeTouch(); - bool hasPointer(); - bool hasKeyboard(); - bool hasTouch(); - - DSXkb *getXkb(); - std::shared_ptr getTopWindow(std::shared_ptr winExcl); - std::shared_ptr getTopWindowOnPosition(int x, int y); - -private: - DSInput *__input; - DSWaylandSeat *__dswlSeat; - DSWaylandCompositor *__dswlComp; - DSCompositor *__compositor; - DSXkb *__xkb; - std::shared_ptr __zone; - - DSKeyboard *__keyboard; - DSPointer *__pointer; - DSTouch *__touch; - uint32_t __numPointer; - uint32_t __numKeyboard; - uint32_t __numTouch; - - std::shared_ptr __focusWin; - bool __stackChanged; - - void __initSlots(); - void __initEventHandlers(); - - /* ecore key/mouse/touch event handler */ - static Eina_Bool inputEventHandlerKey(void *data, int type, void *event); - static Eina_Bool inputEventHandlerMouse(void *data, int type, void *event); - static Eina_Bool inputEventHandlerTouch(void *data, int type, void *event); - - /* signals */ - static DSSignal __signalHandleKeyEvent; - static DSSignal __signalHandlePointerEvent; - static DSSignal __signalHandleTouchEvent; - - /* slots */ - void __onKeyEvent(DSInputKeyboardEvent *ev); - void __onPointerEvent(DSInputMouseEvent *ev); - void __onTouchEvent(DSInputTouchEvent *ev); - void __onWindowStackChanged(std::shared_ptr topWindow); - void __onWindowCreated(std::shared_ptr window); - void __onWindowDestroy(std::shared_ptr window); -}; - -} - -#endif diff --git a/src/DSSeat/DSTouch.cpp b/src/DSSeat/DSTouch.cpp deleted file mode 100644 index a9fe988..0000000 --- a/src/DSSeat/DSTouch.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSTouch.h" -#include "DSSeat.h" -#include "DSWindow.h" -#include "DSInputEvent.h" -#include "DSWaylandTouch.h" - -namespace display_server -{ - -DSTouch::DSTouch(DSSeat *seat) - : __seat(seat), - __dswlTouch(nullptr), - __dswlCompositor(nullptr), - __touchFocus(nullptr) -{ -} - -DSTouch::DSTouch(DSSeat *seat, DSWaylandTouch *touch) - : __seat(seat), - __dswlTouch(touch), - __dswlCompositor(nullptr), - __touchFocus(nullptr) -{ -} - -DSTouch::~DSTouch() -{} - -/*LCOV_EXCL_START*/ -void DSTouch::processEvent(DSInputTouchEvent *ev, void *data) -{ - //TODO : get touchFocus and send event to it via DSWaylandTouch instance - - if (!__touchFocus) - { - DSLOG_ERR("DSTouch", "No touchFocus available."); - return; - } - - if (ev->getType() == DSInputEvent::TouchDownEvent) - { - DSLOG_DBG("DSTouch", "[touchDown] devicename: %s, timestamp: %u, x: %d (winX: %d), y: %d (winY: %d)\n", - ev->getDevice()->getName().c_str(), ev->getTimestamp(), - ev->getX(), ev->getWinX(), ev->getY(), ev->getWinY()); - touchDown(ev->getIndex(), ev->getWinX(), ev->getWinY()); - } - else if (ev->getType() == DSInputEvent::TouchUpEvent) - { - DSLOG_DBG("DSTouch", "[touchDown] devicename: %s, timestamp: %u\n", - ev->getDevice()->getName().c_str(), ev->getTimestamp()); - touchUp(ev->getIndex()); - } - else//DSInputEvent::TouchMoveEvent - { - DSLOG_DBG("DSTouch", "[touchDown] devicename: %s, timestamp: %u, x: %d (winX: %d), y: %d (winY: %d)\n", - ev->getDevice()->getName().c_str(), ev->getTimestamp(), - ev->getX(), ev->getWinX(), ev->getY(), ev->getWinY()); - touchMove(ev->getIndex(), ev->getWinX(), ev->getWinY()); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSTouch::touchDown(int32_t id, int x, int y) -{ - if (__touchFocus && __dswlTouch) - { - __dswlTouch->sendDown(id, x, y); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSTouch::touchUp(int32_t id) -{ - if (__touchFocus && __dswlTouch) - { - __dswlTouch->sendUp(id); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSTouch::touchMove(int32_t id, int x, int y) -{ - if (__touchFocus && __dswlTouch) - { - __dswlTouch->sendMotion(id, x, y); - } -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSTouch::setFocus(std::shared_ptr window) -{ - if (!window) - { - DSLOG_ERR("DSTouch", "Given window is INVALID. (window : %p)", window); - __touchFocus = window; - if (__dswlTouch) - __dswlTouch->setFocus(nullptr); - return; - } - - DSWaylandSurface * waylandSurface = window->surface(); - - if (!waylandSurface) - { - DSLOG_ERR("DSTouch", "Wayland surface of the given window is INVALID. (window : %p, surface : %p)", window, waylandSurface); - return; - } - - DSLOG_INF("DSTouch", "focus window has been changed. (%p -> %p)", __touchFocus, window); - __touchFocus = window; - - if (!__dswlTouch) - { - DSLOG_ERR("DSTouch", "waylandTouch is NOT available !"); - return; - } - - __dswlTouch->setFocus(waylandSurface); -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSTouch::resetFocus() -{ - if (__touchFocus) - { - __touchFocus = nullptr; - DSLOG_INF("DSTouch", "touchFocus has been reset."); - } - - if (__dswlTouch) - __dswlTouch->resetFocus(); -} -/*LCOV_EXCL_STOP*/ - -std::shared_ptr DSTouch::getFocus() -{ - return __touchFocus; -} - -} // namespace display_server diff --git a/src/DSSeat/DSTouch.h b/src/DSSeat/DSTouch.h deleted file mode 100644 index ef164d9..0000000 --- a/src/DSSeat/DSTouch.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DSTOUCH_H__ -#define __DSTOUCH_H__ - -#include "DSCore.h" -#include "DSObject.h" - -namespace display_server -{ - -class DSSeat; -class DSWindow; -class DSWaylandTouch; -class DSInputTouchEvent; -class DSWaylandCompositor; - -class DSTouch : public DSObject -{ -public: - DSTouch() = delete; - DSTouch(DSSeat *seat); - DSTouch(DSSeat *seat, DSWaylandTouch *touch); - virtual ~DSTouch(); - - void processEvent(DSInputTouchEvent *ev, void *data); - void touchDown(int32_t id, int x, int y); - void touchUp(int32_t id); - void touchMove(int32_t id, int x, int y); - void setFocus(std::shared_ptr window); - void resetFocus(); - std::shared_ptr getFocus(); - -private: - DSSeat *__seat; - DSWaylandTouch *__dswlTouch; - DSWaylandCompositor *__dswlCompositor; - std::shared_ptr __touchFocus; -}; - -} - -#endif //__DSTOUCH_H__ diff --git a/src/DSSignal/DSSignal.cpp b/src/DSSignal/DSSignal.cpp deleted file mode 100644 index 9dba39e..0000000 --- a/src/DSSignal/DSSignal.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSSignal.h" - -namespace display_server { -void DSSlotsObserver::addSlot(DSObject *slot) -{ - _slotList.push_back(slot); -} - -void DSSlotsObserver::destroyed(DSObject *slot) -{ - _slotList.remove(slot); - if (_slotList.empty()) - delete this; -} -} // namespace display_server diff --git a/src/DSSignal/DSSignal.h b/src/DSSignal/DSSignal.h deleted file mode 100644 index cace4a8..0000000 --- a/src/DSSignal/DSSignal.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_SIGNAL_H_ -#define __DS_SIGNAL_H_ - -#include "DSObject.h" - -namespace display_server -{ - -class DSSlotsObserver : public IDSObjectObserver -{ -public: - DSSlotsObserver() = default; - ~DSSlotsObserver() = default; - - virtual void destroyed(DSObject *slot); - virtual void addSlot(DSObject *slot); - -protected: - std::list _slotList; -}; - -template -class DSSlotConnection : public DSSlotsObserver -{ -public: - DSSlotConnection() - : __func(nullptr) - {}; - DSSlotConnection(DSObject *slot, std::function func) - : __func(std::move(func)) - { - //TODO: make callback as callback iface - //std::unique_ptr ptr(new DSCallbackIface(func)); - //__func = std::move(ptr); - addSlot(slot); - } - - virtual ~DSSlotConnection() - { - for (auto &&slot : _slotList) - slot->detachDestroyObserver(this); - - _slotList.clear(); - } - - void addSlot(DSObject *slot) override - { - slot->attachDestroyObserver(this); - - _slotList.push_back(slot); - } - - void destroyed(DSObject *slot) override - { - _slotList.remove(slot); - - if (_slotList.empty()) - ;//TODO: delete from DSSignal connections list with [guard pointer] - } - - void invoke(Args... args) - { - if (!_slotList.empty()) - std::invoke(__func, args...); - } - -private: - //TODO: make callback as callback iface - //std::unique_ptr __func; - std::function __func; - template - friend class DSSignal; -}; - -template -class DSSignal -{ -public: - DSSignal() = default; - virtual ~DSSignal() = default; - - // functor - DSSignal &operator()(void) - { - return *this; - } - - void connect(DSObject *slot, std::function func) - { - if ((!slot) || (!func)) - return; - - if (auto connection = __findConnection(func)) - connection->addSlot(slot); - else - __connectionList.emplace_back(new DSSlotConnection(slot, func)); - } - - void emit(Args... args) - { - for (auto &&connection : __connectionList) - connection->invoke(args...); - } - -private: - DSSlotConnection *__findConnection(std::function func) - { - for (auto &&connection : __connectionList) { - if (&connection->__func == &func) - return connection.get(); - } - - return nullptr; - } - - std::list>> __connectionList; -}; - -} - -#endif diff --git a/src/DSSignal/DSSignalBroker.cpp b/src/DSSignal/DSSignalBroker.cpp deleted file mode 100644 index 58c53c2..0000000 --- a/src/DSSignal/DSSignalBroker.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include - -namespace display_server -{ - -std::mutex DSSignalBroker::__mutex; -DSSignalBroker* DSSignalBroker::__signalBroker { nullptr }; - -DSSignalBroker::DSSignalBroker(DSObject *parent) -{ -} - -DSSignalBroker::~DSSignalBroker() -{ - if (__signalBroker) - { - if (!__signalBroker->__signalHash.empty()) - { - for (auto hashpairs : __signalBroker->__signalHash) - { - delete hashpairs.second.signal; - } - } - } -} - -DSSignalBroker *DSSignalBroker::getInstance() -{ - std::lock_guard tLock(__mutex); - - if (!__signalBroker) - { - __signalBroker = new DSSignalBroker(new DSObject); - DSLOG_INF("DSSignalBroker", "DSSignalBroker instance has been created !"); - } - - return __signalBroker; -} - -void DSSignalBroker::releaseInstance() -{ - std::lock_guard tLock(__mutex); - - if (__signalBroker && __signalBroker->__signalHash.empty()) - { - delete __signalBroker; - __signalBroker = nullptr; - DSLOG_INF("DSSignalBroker", "DSSignalBroker instance has been removed !"); - } -} - -} // end of namespace display_server \ No newline at end of file diff --git a/src/DSSignal/DSSignalBroker.h b/src/DSSignal/DSSignalBroker.h deleted file mode 100644 index 5674ade..0000000 --- a/src/DSSignal/DSSignalBroker.h +++ /dev/null @@ -1,199 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_SIGNAL_BROKER_H__ -#define __DS_SIGNAL_BROKER_H__ - -#include -#include -#include - -namespace display_server -{ - -class DSSignalBroker : public DSObject -{ -public: - static DSSignalBroker *getInstance(); - static void releaseInstance(); - - template - bool registerSignal(std::string signalStr, DSObject *obj); - template - bool emitSignal(std::string signalStr, DSObject *obj, Args...); - template - bool registerCallback(std::string signalStr, DSObject *slot, std::function func); - template - bool deregisterCallback(std::string signalStr, DSObject *slot, std::function func); - -private: - static std::mutex __mutex; - static DSSignalBroker *__signalBroker; - - struct stRegisteredSignal - { - std::string signalName; - std::string className; - DSObject *obj; - DSSignal *signal; - - public: - stRegisteredSignal(std::string sn, DSObject *inpObj, DSSignal *inpSignal) - { - signalName = sn; - className = inpObj->getName(); - obj = inpObj; - signal = inpSignal; - } - - }; - - std::unordered_multimap __signalHash; - - DSSignalBroker() = delete; - ~DSSignalBroker(); - DSSignalBroker(DSObject *parent); -}; - -template -bool DSSignalBroker::registerSignal(std::string signalStr, DSObject *obj) -{ - if (!__signalBroker) return false; - - if (__signalBroker->__signalHash.find(signalStr) != __signalBroker->__signalHash.end()) - { - auto range = __signalBroker->__signalHash.equal_range(signalStr); - for (auto iter = range.first; - iter != range.second; - iter++) - { - if (iter->second.obj == obj) - { - DSLOG_INF("DSSignalBroker","emitSignal:: already registered signal: %s", signalStr.c_str()); - return false; - } - else - { - DSLOG_DBG("DSSignalBroker", "searching same item: %s, obj(%p):%s", iter->second.signalName.c_str(), iter->second.obj, iter->second.className.c_str()); - } - - } - } - DSSignal *signal = reinterpret_cast *> (new DSSignal()); - __signalBroker->__signalHash.insert(std::make_pair(signalStr, stRegisteredSignal(signalStr, obj, signal))); - - DSLOG_DBG("DSSignalBroker","registerSignal:: registered new signal (name:%s, class(%p):%s, signal:%p)", - signalStr.c_str(), obj, obj->getName().c_str(), signal); - - return true; -} - -template -bool DSSignalBroker::emitSignal(std::string signalStr, DSObject *obj, Args... args) -{ - if (!__signalBroker) return false; - - if (__signalBroker->__signalHash.find(signalStr) != __signalBroker->__signalHash.end()) - { - auto range = __signalBroker->__signalHash.equal_range(signalStr); - for (auto iter = range.first; - iter != range.second; - iter++) - { - if (iter->second.obj == obj)// || iter->second.className == obj->getName()) - { - DSSignal *signal = reinterpret_cast *>(iter->second.signal); - if (signal) - { - signal->emit(args...); - DSLOG_DBG("DSSignalBroker","emitSignal:: signal emit (name:%s, class(%p):%s, signal:%p)", - iter->second.signalName.c_str(), iter->second.obj, iter->second.obj->getName().c_str(), iter->second.signal); - } - else - return false; - - return true; - } - } - } - else - { - DSLOG_INF("DSSignalBroker","emitSignal:: cannot find registered signal: %s", signalStr.c_str()); - return false; - } - - return false; -} - -template -bool DSSignalBroker::registerCallback(std::string signalStr, DSObject *slot, std::function func) -{ - if (!__signalBroker) return false; - - if (__signalBroker->__signalHash.find(signalStr) != __signalBroker->__signalHash.end()) - { - auto range = __signalBroker->__signalHash.equal_range(signalStr); - for (auto iter = range.first; - iter != range.second; - iter++) - { - DSSignal *signal = reinterpret_cast *>(iter->second.signal); - if (signal) - signal->connect(slot, func); - } - } - else - { - DSLOG_INF("DSSignalBroker","registerCallback:: cannot find signal: %s", signalStr.c_str()); - return false; - } - - return true; -} - -template -bool DSSignalBroker::deregisterCallback(std::string signalStr, DSObject *slot, std::function func) -{ - // TODO: have to impl disconnect method in DSSignal - /* - if (!__signalBroker) return false; - - if (__signalBroker->__signalHash.find(signalStr) != __signalBroker->__signalHash.end()) - { - auto range = __signalBroker->__signalHash.equal_range(signalStr); - for (auto iter = range.first; - iter != range.second; - iter++) - { - DSSignal *signal = reinterpret_cast *>(iter->second.signal); - if (signal) - signal->disconnect(slot, func); - } - } - */ - return true; -} - -} // end of namespace display_server - -#endif // end of __DS_SIGNAL_BROKER_H__ diff --git a/src/DSTextInput/DSTextInput.cpp b/src/DSTextInput/DSTextInput.cpp deleted file mode 100644 index f97dcaa..0000000 --- a/src/DSTextInput/DSTextInput.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSTextInput.h" -#include "DSTextInputPrivate.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandTextInputManager.h" -#include "DSWaylandInputMethod.h" -#include "DSWaylandInputPanel.h" - -namespace display_server -{ - -DSTextInputPrivate::DSTextInputPrivate(DSTextInput *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), - __inputPanelState(InputPanelStateDidHide) -{ - __wlCompositor = DSWaylandCompositor::getInstance(); - __wlInputMethod = new DSWaylandInputMethod(__wlCompositor, this); - __wlInputPanel = new DSWaylandInputPanel(__wlCompositor, this); - __wlTextInputManager = new DSWaylandTextInputManager(__wlCompositor, this); -} - -DSTextInputPrivate::~DSTextInputPrivate() -{ - delete __wlTextInputManager; - delete __wlInputPanel; - delete __wlInputMethod; - DSWaylandCompositor::releaseInstance(); -} -/*LCOV_EXCL_START*/ -void DSTextInputPrivate::setInputPanelState(InputPanelState state) -{ - __inputPanelState = state; -} - -DSTextInputPrivate::InputPanelState DSTextInputPrivate::getInputPanelState() -{ - return __inputPanelState; -} - -void DSTextInputPrivate::activateTextInput(DSWaylandTextInput *wlTextInput, int id) -{ - __wlInputMethod->activate(id); -} - -void DSTextInputPrivate::deactivateTextInput(DSWaylandTextInput *wlTextInput) -{ - __wlInputMethod->deactivate(); -} - -void DSTextInputPrivate::showInputPanel(DSWaylandTextInput *wlTextInput, int id) -{ - __wlInputMethod->showInputPanel(id); -} - -void DSTextInputPrivate::hideInputPanel(int id) -{ - __wlInputMethod->hideInputPanel(id); -} - -void DSTextInputPrivate::resetTextInput() -{ - __wlInputMethod->resetTextInput(); -} - -void DSTextInputPrivate::setContentType(unsigned int hint, unsigned int purpose) -{ - __wlInputMethod->setContentType(hint, purpose); -} - -void DSTextInputPrivate::setPreferredLanguage(const std::string language) -{ - __wlInputMethod->setPreferredLanguage(language); -} - -void DSTextInputPrivate::commitState(unsigned int serial) -{ - __wlInputMethod->commitState(serial); -} - -void DSTextInputPrivate::invokeAction(unsigned int button, unsigned int index) -{ - __wlInputMethod->invokeAction(button, index); -} - -void DSTextInputPrivate::setReturnKeyType(unsigned int returnKeyType) -{ - __wlInputMethod->setReturnKeyType(returnKeyType); -} - -void DSTextInputPrivate::returnKeyDisabled(unsigned int returnKeyDisabled) -{ - __wlInputMethod->returnKeyDisabled(returnKeyDisabled); -} - -void DSTextInputPrivate::setInputPanelData(std::string inputPanelData, unsigned int inputPanelLength) -{ - __wlInputMethod->setInputPanelData(inputPanelData, inputPanelLength); -} - -void DSTextInputPrivate::bidiDirection(unsigned int direction) -{ - __wlInputMethod->bidiDirection(direction); -} - -void DSTextInputPrivate::setCursorPosition(unsigned int cursorPosition) -{ - __wlInputMethod->setCursorPosition(cursorPosition); -} - -void DSTextInputPrivate::processInputDeviceEvent(unsigned int eventType, std::string eventData, unsigned int eventLength) -{ - __wlInputMethod->processInputDeviceEvent(eventType, eventData, eventLength); -} - -void DSTextInputPrivate::filterKeyEvent(unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode) -{ - __wlInputMethod->filterKeyEvent(serial, time, keyName, state, modifiers, devName, devClass, devSubclass, keycode); -} - -void DSTextInputPrivate::setCapitalMode(unsigned int mode) -{ - __wlInputMethod->setCapitalMode(mode); -} - -void DSTextInputPrivate::predictionHint(std::string text) -{ - __wlInputMethod->predictionHint(text); -} - -void DSTextInputPrivate::setMimeType(std::string type) -{ - __wlInputMethod->setMimeType(type); -} - -void DSTextInputPrivate::finalizeContent(std::string text, unsigned int cursorPosition) -{ - __wlInputMethod->finalizeContent(text, cursorPosition); -} - -void DSTextInputPrivate::predictionHintData(std::string key, std::string value) -{ - __wlInputMethod->predictionHintData(key, value); -} - -void DSTextInputPrivate::updateTextInputPanelState(bool state) -{ - __wlTextInputManager->updateTextInputPanelState(state); -} - -void DSTextInputPrivate::setGeometryUpdated(bool updated) -{ - __wlTextInputManager->setGeometryUpdated(updated); -} - -DSWaylandSurface *DSTextInputPrivate::getTextInputSurface() -{ - return __wlTextInputManager->getTextInputSurface(); -} - - -void DSTextInputPrivate::contextCommitString(unsigned int serial, std::string text) -{ - __wlTextInputManager->contextCommitString(serial, text); -} - -void DSTextInputPrivate::contextPreeditString(unsigned int serial, std::string text, std::string commit) -{ - __wlTextInputManager->contextPreeditString(serial, text, commit); -} - -void DSTextInputPrivate::contextPreeditStyling(int index, unsigned int length, unsigned int style) -{ - __wlTextInputManager->contextPreeditStyling(index, length, style); -} - -void DSTextInputPrivate::contextPreeditCursor(int index) -{ - __wlTextInputManager->contextPreeditCursor(index); -} - -void DSTextInputPrivate::contextDeleteSurroundingText(int index, unsigned int length) -{ - __wlTextInputManager->contextDeleteSurroundingText(index, length); -} - -void DSTextInputPrivate::contextCursorPosition(int index, int anchor) -{ - __wlTextInputManager->contextCursorPosition(index, anchor); -} - -void DSTextInputPrivate::contextModifiersMap(std::string map) -{ - __wlTextInputManager->contextModifiersMap(map); -} - -void DSTextInputPrivate::contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) -{ - __wlTextInputManager->contextKeysym(serial, time, sym, state, modifiers); -} - -void DSTextInputPrivate::contextLanguage(unsigned int serial, std::string language) -{ - __wlTextInputManager->contextLanguage(serial, language); -} - -void DSTextInputPrivate::contextTextDirection(unsigned int serial, unsigned int direction) -{ - __wlTextInputManager->contextTextDirection(serial, direction); -} - -void DSTextInputPrivate::contextSelectionRegion(unsigned int serial, int start, int end) -{ - __wlTextInputManager->contextSelectionRegion(serial, start, end); -} - -void DSTextInputPrivate::contextPrivateCommand(unsigned int serial, std::string command) -{ - __wlTextInputManager->contextPrivateCommand(serial, command); -} - -void DSTextInputPrivate::contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) -{ - __wlTextInputManager->contextUpdateInputPanelData(serial, inputPanelData, inputPanelDataLength); -} - -void DSTextInputPrivate::contextShowInputPanel() -{ - __wlTextInputManager->contextShowInputPanel(); -} - -void DSTextInputPrivate::contextHideInputPanel() -{ - __wlTextInputManager->contextHideInputPanel(); -} - -void DSTextInputPrivate::contextGetSelectionText(int fd) -{ - __wlTextInputManager->contextGetSelectionText(fd); -} - -void DSTextInputPrivate::contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) -{ - __wlTextInputManager->contextGetSurroundingText(maxlenBefore, maxlenAfter, fd); -} - -void DSTextInputPrivate::contextFilterKeyEventDone(unsigned int serial, unsigned int state) -{ - __wlTextInputManager->contextFilterKeyEventDone(serial, state); -} - -void DSTextInputPrivate::contextUpdateIseGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height) -{ - __wlTextInputManager->contextUpdateIseGeometry(x, y, width, height); -} - -void DSTextInputPrivate::contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) -{ - __wlTextInputManager->contextRecaptureString(serial, index, length, preedit, preeditCommit, commit); -} - -void DSTextInputPrivate::contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) -{ - __wlTextInputManager->contextInputPanelEvent(serial, eventType, value); -} - -void DSTextInputPrivate::contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) -{ - __wlTextInputManager->contextCommitContent(serial, content, description, mimeTypes); -} - -void DSTextInputPrivate::updateInputPanelState(bool waitUpdate) -{ - __wlInputPanel->updateInputPanelState(waitUpdate); -} - -void DSTextInputPrivate::setInputPanelTransientFor(DSWaylandSurface *window) -{ - __wlInputPanel->setTransientFor(window); -} - -void DSTextInputPrivate::changeInputPanelVisibility(bool visible) -{ - __wlInputPanel->changeVisibility(visible); -} - -stGeometry DSTextInputPrivate::inputPanelGetGeometry(DSWaylandSurface *window) -{ - return __wlInputPanel->getSurfaceGeometry(window); -} -/*LCOV_EXCL_STOP*/ - -DSTextInput::DSTextInput() - : DS_INIT_PRIVATE_PTR(DSTextInput) -{ -} - -DSTextInput::~DSTextInput() -{ -} - -} // namespace display_server diff --git a/src/DSTextInput/DSTextInput.h b/src/DSTextInput/DSTextInput.h deleted file mode 100644 index a662568..0000000 --- a/src/DSTextInput/DSTextInput.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_TEXT_INPUT_H__ -#define __DS_TEXT_INPUT_H__ - -#include -#include -#include - -namespace display_server -{ - -class DSTextInputPrivate; - -class DSTextInput : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSTextInput); -public: - DSTextInput(); - ~DSTextInput() override; - -private: -}; - -} - -#endif diff --git a/src/DSTextInput/DSTextInputPrivate.h b/src/DSTextInput/DSTextInputPrivate.h deleted file mode 100644 index d99726a..0000000 --- a/src/DSTextInput/DSTextInputPrivate.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_TEXT_INPUT_PRIVATE_H__ -#define __DS_TEXT_INPUT_PRIVATE_H__ - -#include -#include -#include - -namespace display_server -{ - -class DSWaylandCompositor; -class DSWaylandTextInput; -class DSWaylandTextInputManager; -class DSWaylandInputMethod; -class DSWaylandInputMethodContext; -class DSWaylandInputPanel; -class DSWaylandInputPanelSurface; -class DSWaylandSurface; - -class DSTextInputPrivate : public DSObjectPrivate -{ -DS_PIMPL_USE_PUBLIC(DSTextInput); -public: - enum InputPanelState - { - InputPanelStateDidHide, - InputPanelStateWillHide, - InputPanelStateDidShow, - InputPanelStateWillShow - }; - - DSTextInputPrivate() = delete; - DSTextInputPrivate(DSTextInput *p_ptr); - ~DSTextInputPrivate(); - - void setInputPanelState(InputPanelState state); - InputPanelState getInputPanelState(); - - /* DSWaylandTextInput request */ - void activateTextInput(DSWaylandTextInput *wlTextInput, int id); - void deactivateTextInput(DSWaylandTextInput *wlTextInput); - void showInputPanel(DSWaylandTextInput *wlTextInput, int id); - void hideInputPanel(int id); - void resetTextInput(); - void setContentType(unsigned int hint, unsigned int purpose); - void setPreferredLanguage(const std::string language); - void commitState(unsigned int serial); - void invokeAction(unsigned int button, unsigned int index); - void setReturnKeyType(unsigned int returnKeyType); - void returnKeyDisabled(unsigned int returnKeyDisabled); - void setInputPanelData(std::string inputPanelData, unsigned int inputPanelLength); - void bidiDirection(unsigned int direction); - void setCursorPosition(unsigned int cursorPosition); - void processInputDeviceEvent(unsigned int eventType, std::string eventData, unsigned int eventLength); - void filterKeyEvent(unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode); - void setCapitalMode(unsigned int mode); - void predictionHint(std::string text); - void setMimeType(std::string type); - void finalizeContent(std::string text, unsigned int cursorPosition); - void predictionHintData(std::string key, std::string value); - void updateTextInputPanelState(bool state); - void setGeometryUpdated(bool updated); - DSWaylandSurface *getTextInputSurface(); - - /* DSWaylandInputMethodContext request */ - void contextCommitString(unsigned int serial, std::string text); - void contextPreeditString(unsigned int serial, std::string text, std::string commit); - void contextPreeditStyling(int index, unsigned int length, unsigned int style); - void contextPreeditCursor(int index); - void contextDeleteSurroundingText(int index, unsigned int length); - void contextCursorPosition(int index, int anchor); - void contextModifiersMap(std::string map); - void contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); - void contextLanguage(unsigned int serial, std::string language); - void contextTextDirection(unsigned int serial, unsigned int direction); - void contextSelectionRegion(unsigned int serial, int start, int end); - void contextPrivateCommand(unsigned int serial, std::string command); - void contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); - void contextShowInputPanel(); - void contextHideInputPanel(); - void contextGetSelectionText(int fd); - void contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); - void contextFilterKeyEventDone(unsigned int serial, unsigned int state); - void contextUpdateIseGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height); - void contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); - void contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); - void contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); - - /* DSWaylandInputPanel */ - void updateInputPanelState(bool waitUpdate); - void setInputPanelTransientFor(DSWaylandSurface *window); - void changeInputPanelVisibility(bool visible); - stGeometry inputPanelGetGeometry(DSWaylandSurface *window); - -private: - DSWaylandCompositor *__wlCompositor; - DSWaylandInputMethod *__wlInputMethod; - DSWaylandInputPanel *__wlInputPanel; - DSWaylandTextInputManager *__wlTextInputManager; - InputPanelState __inputPanelState; -}; - -} - -#endif diff --git a/src/DSTizenAppinfo/DSTizenAppinfo.cpp b/src/DSTizenAppinfo/DSTizenAppinfo.cpp deleted file mode 100644 index aed4335..0000000 --- a/src/DSTizenAppinfo/DSTizenAppinfo.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include - -namespace display_server -{ -DSTizenAppinfo::DSTizenAppinfo(std::string appid) - : __pid(-1), - __base_output_available(false), - __base_output_width(0), - __base_output_height(0) -{ - __appId = appid; -} - -DSTizenAppinfo::~DSTizenAppinfo() -{ -} - -void DSTizenAppinfo::setAppId(std::string appId) -{ - __appId = appId; -} - -void DSTizenAppinfo::setPid(pid_t pid) -{ - __pid = pid; -} - -void DSTizenAppinfo::setBaseOutputAvailable(bool isAvailable) -{ - __base_output_available = isAvailable; -} - -void DSTizenAppinfo::setBaseOutputWidth(int w) -{ - __base_output_width = w; -} - -void DSTizenAppinfo::setBaseOutputHeight(int h) -{ - __base_output_height = h; -} - -pid_t DSTizenAppinfo::getPid() -{ - return __pid; -} - -std::string DSTizenAppinfo::getAppId() -{ - return __appId; -} - -bool DSTizenAppinfo::getBaseOutputAvailable() -{ - return __base_output_available; -} - -int DSTizenAppinfo::getBaseOutputWidth() -{ - return __base_output_width; -} - -int DSTizenAppinfo::getBaseOutputHeight() -{ - return __base_output_height; -} - -} diff --git a/src/DSTizenAppinfo/DSTizenAppinfo.h b/src/DSTizenAppinfo/DSTizenAppinfo.h deleted file mode 100644 index 0564806..0000000 --- a/src/DSTizenAppinfo/DSTizenAppinfo.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_TIZENAPPINFO_H_ -#define _DS_TIZENAPPINFO_H_ - -#include - -namespace display_server -{ - -class DSTizenAppinfo : public DSObject -{ -public: - DSTizenAppinfo() = delete; - DSTizenAppinfo(std::string appid); - virtual ~DSTizenAppinfo(); - - void setAppId(std::string appId); - void setPid(pid_t pid); - void setBaseOutputAvailable(bool isAvailable); - void setBaseOutputWidth(int w); - void setBaseOutputHeight(int h); - - std::string getAppId(void); - pid_t getPid(void); - bool getBaseOutputAvailable(void); - int getBaseOutputWidth(void); - int getBaseOutputHeight(void); - -private: - std::string __appId; - pid_t __pid; - bool __base_output_available; - int __base_output_width; - int __base_output_height; -}; - -} -#endif diff --git a/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp b/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp deleted file mode 100644 index e63dc22..0000000 --- a/src/DSTizenAppinfo/DSTizenAppinfoMgr.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSTizenAppinfoMgr.h" -#include "DSTizenAppinfoMgrPrivate.h" -#include "DSWaylandTizenAppinfo.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -int DSTizenAppinfoMgr::__refCount { 0 }; -std::mutex DSTizenAppinfoMgr::__mutex; -DSTizenAppinfoMgr* DSTizenAppinfoMgr::__appinfoMgr { nullptr }; - -DSTizenAppinfoMgrPrivate::DSTizenAppinfoMgrPrivate(DSTizenAppinfoMgr *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ -} - -DSTizenAppinfoMgrPrivate::~DSTizenAppinfoMgrPrivate() -{ -} - -std::shared_ptr DSTizenAppinfoMgrPrivate::getTizenAppinfo(std::string appId) -{ - auto it = __appIdMap.find(appId); - if (it != __appIdMap.end()) { - return it->second; - } - return nullptr; -} - -std::shared_ptr DSTizenAppinfoMgrPrivate::getTizenAppinfo(pid_t pid) -{ - std::shared_ptr ptr_appinfo(nullptr); - DSTizenAppinfo * appinfo(nullptr); - - for (auto it = __appIdMap.begin(); it != __appIdMap.end(); it++) { - ptr_appinfo = it->second; - if (ptr_appinfo) - { - appinfo = ptr_appinfo.get() ; - if ((appinfo) && (appinfo->getPid() == pid)) { - return ptr_appinfo; - } - } - } - return nullptr; -} - -std::shared_ptr DSTizenAppinfoMgrPrivate::addTizenAppinfo(std::string appId) -{ - std::shared_ptr appinfo(nullptr); - - appinfo = std::make_shared(appId); - if (appinfo != nullptr) { - __appIdMap.emplace(appId, appinfo); - } - return appinfo; -} - -bool DSTizenAppinfoMgrPrivate::removeTizenAppinfo(std::string appId) -{ - auto it = __appIdMap.find(appId); - if (it != __appIdMap.end()) { - __appIdMap.erase(it); - return true; - } - return false; -} - -DSTizenAppinfoMgr::DSTizenAppinfoMgr(DSObject *parent) - : DS_INIT_PRIVATE_PTR(DSTizenAppinfoMgr) -{ -} - -DSTizenAppinfoMgr::~DSTizenAppinfoMgr() -{ -} - -DSTizenAppinfoMgr *DSTizenAppinfoMgr::getInstance() -{ - std::lock_guard tLock(__mutex); - - if (!__appinfoMgr && (__refCount == 0)) - { - __appinfoMgr = new DSTizenAppinfoMgr(new DSObject); - DSLOG_INF("DSTizenAppinfoMgr", - "DSTizenAppinfoMgr instance has been created !"); - } - - ++__refCount; - return __appinfoMgr; -} - -void DSTizenAppinfoMgr::releaseInstance() -{ - std::lock_guard tLock(__mutex); - - --__refCount; - if (__refCount < 0) - __refCount = 0; - - if ((0 == __refCount) && __appinfoMgr) - { - delete __appinfoMgr; - __appinfoMgr = nullptr; - DSLOG_INF("DSTizenAppinfoMgr", - "DSTizenAppinfoMgr instance has been removed !"); - } -} - -std::shared_ptr DSTizenAppinfoMgr::getTizenAppinfo(std::string appId) -{ - DS_GET_PRIV(DSTizenAppinfoMgr); - - return priv->getTizenAppinfo(appId); -} - -std::shared_ptr DSTizenAppinfoMgr::getTizenAppinfo(pid_t pid) -{ - DS_GET_PRIV(DSTizenAppinfoMgr); - - return priv->getTizenAppinfo(pid); -} - -std::shared_ptr DSTizenAppinfoMgr::addTizenAppinfo(std::string appId) -{ - DS_GET_PRIV(DSTizenAppinfoMgr); - - std::shared_ptr appinfo = getTizenAppinfo(appId); - if (appinfo == nullptr) { - appinfo = priv->addTizenAppinfo(appId); - DSLOG_INF("DSTizenAppinfoMgr", "New TizenAppinfo(apppId:%s) added", appId.c_str()); - return appinfo; - } - else { - DSLOG_INF("DSTizenAppinfoMgr", "Adding TizenAppinfo(apppId:%s) failed..", appId.c_str()); - return nullptr; - } -} - -bool DSTizenAppinfoMgr::removeTizenAppinfo(std::string appId) -{ - DS_GET_PRIV(DSTizenAppinfoMgr); - bool ret = false; - - ret = priv->removeTizenAppinfo(appId); - if (ret) - DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) removed", appId.c_str()); - else - DSLOG_INF("DSTizenAppinfoMgr", "Removing TizenAppinfo(appId:%s) failed..", appId.c_str()); - return ret; -} - -void DSTizenAppinfoMgr::updateTizenAppinfo(std::string appId, pid_t pid) -{ - std::shared_ptr ptr_appinfo(nullptr); - DSTizenAppinfo * appinfo(nullptr); - - ptr_appinfo = getTizenAppinfo(appId); - if (ptr_appinfo == nullptr) - return; - - appinfo = ptr_appinfo.get(); - if (appinfo != nullptr) - { - appinfo->setPid(pid); - DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) set to pid:%d", appId.c_str(), pid); - } -} - -bool DSTizenAppinfoMgr::getBaseOutputResolution(pid_t pid, int *res_w, int *res_h) -{ - std::shared_ptr ptr_appinfo(nullptr); - DSTizenAppinfo * appinfo(nullptr); - - ptr_appinfo = getTizenAppinfo(pid); - if (ptr_appinfo == nullptr) - return false; - - appinfo = ptr_appinfo.get(); - if ((appinfo) && (appinfo->getBaseOutputAvailable())) { - if (res_w) *res_w = appinfo->getBaseOutputWidth(); - if (res_h) *res_h = appinfo->getBaseOutputHeight(); - - return true; - } - return false; -} - -} diff --git a/src/DSTizenAppinfo/DSTizenAppinfoMgr.h b/src/DSTizenAppinfo/DSTizenAppinfoMgr.h deleted file mode 100644 index b553a66..0000000 --- a/src/DSTizenAppinfo/DSTizenAppinfoMgr.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_TIZENAPPINFO_MGR_H_ -#define _DS_TIZENAPPINFO_MGR_H_ - -#include -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -class DSTizenAppinfoMgrPrivate; - -class DSTizenAppinfoMgr : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSTizenAppinfoMgr); -public: - static DSTizenAppinfoMgr *getInstance(); - static void releaseInstance(); - - std::shared_ptr getTizenAppinfo(std::string appId); - std::shared_ptr getTizenAppinfo(pid_t pid); - - std::shared_ptr addTizenAppinfo(std::string appId); - - bool removeTizenAppinfo(std::string appId); - - void updateTizenAppinfo(std::string appId, pid_t pid); - - bool getBaseOutputResolution(pid_t pid, int *res_w, int *res_h); - -private: - static std::mutex __mutex; - static DSTizenAppinfoMgr *__appinfoMgr; - static int __refCount; - - DSTizenAppinfoMgr() = delete; - ~DSTizenAppinfoMgr(); - DSTizenAppinfoMgr(DSObject *parent); -}; - -} - -#endif diff --git a/src/DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h b/src/DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h deleted file mode 100644 index 0ac3795..0000000 --- a/src/DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_TIZENAPPINFO_MGR_PRIVATE_H_ -#define _DS_TIZENAPPINFO_MGR_PRIVATE_H_ - -#include "DSTizenAppinfoMgr.h" - -namespace display_server -{ - -class DSTizenAppinfoMgrPrivate : public DSObjectPrivate -{ - DS_PIMPL_USE_PUBLIC(DSTizenAppinfoMgr); -public: - DSTizenAppinfoMgrPrivate() = delete; - DSTizenAppinfoMgrPrivate(DSTizenAppinfoMgr *p_ptr); - ~DSTizenAppinfoMgrPrivate(); - - std::shared_ptr getTizenAppinfo(std::string appId); - std::shared_ptr getTizenAppinfo(pid_t pid); - - std::shared_ptr addTizenAppinfo(std::string appId); - bool removeTizenAppinfo(std::string appId); - -private: - std::unordered_map > __appIdMap; - -}; - -} - -#endif \ No newline at end of file diff --git a/src/DSTraceInfo/DSTraceInfo.cpp b/src/DSTraceInfo/DSTraceInfo.cpp deleted file mode 100644 index a5c357c..0000000 --- a/src/DSTraceInfo/DSTraceInfo.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSTraceInfo.h" -#include "DSPolicyAreaPrivate.h" - -namespace display_server -{ -DSTraceInfo::DSTraceInfo() - : __policyArea(nullptr), - __zone(nullptr), - __eventLoop(nullptr), - __windowUpdated(false) -{ - __eventLoop = DSEventLoop::getInstance(); - if (__eventLoop) - __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSTraceInfo::__onEventIdleEnterer, this, std::placeholders::_1)); -} - -DSTraceInfo::~DSTraceInfo() -{ - if (__eventLoop) - DSEventLoop::releaseInstance(); -} - -bool DSTraceInfo::attachPolicyArea(std::shared_ptr policyArea) -{ - __policyArea = policyArea; - - DSPolicyAreaPrivate *policyAreaPriv = DSPolicyAreaPrivate::getPrivate(__policyArea.get()); - __zone = policyAreaPriv->getZone(); - - if (__zone) { - __zone->registerCallbackWindowCreated(this, std::bind(&DSTraceInfo::__onWindowCreated, this, std::placeholders::_1)); - __zone->registerCallbackWindowStackChanged(this, std::bind(&DSTraceInfo::__onWindowStackChanged, this, std::placeholders::_1)); - __zone->registerCallbackWindowDestroy(this, std::bind(&DSTraceInfo::__onWindowDestroy, this, std::placeholders::_1)); - - __windowList = __zone->getWindowList(); - return true; - } - - DSLOG_ERR("DSTraceInfo", "No zone attached to this policyArea(%p)", policyArea); - return false; -} - -void DSTraceInfo::__onEventIdleEnterer(void *data) -{ - if (__windowUpdated) - { - printWindowsInfo(); - __windowUpdated = false; - } -} - -void DSTraceInfo::printWindowsInfo() -{ - stPosition pos{0,0}; - stSize sz{0,0}; - DSWaylandSurface *dwlSurface{nullptr}; - DSWaylandClient *dwClient{nullptr}; - pid_t pid = -1; - - DSLOG_INF("DSTraceInfo", "--------------Top level windows: %d--------------", __windowList.size()); - DSLOG_INF("DSTraceInfo", " No Win_ID PID w h x y (S)kipFoc has(F)ocus (U)serGeom (V)kbdFloating Parent Title"); - - for (std::shared_ptr w : __windowList) - { - pos = w->getPosition(); - sz = w->getSize(); - dwlSurface = w->surface(); - if (dwlSurface) { - dwClient = dwlSurface->getClient(); - if (dwClient) pid = dwClient->pid(); - } - - DSLOG_INF("DSTraceInfo", " %d: %p %d %4d %4d %4d %4d %c %c %c %c %p %s", w->getZOrder(), w.get(), pid, \ - sz.w, sz.h, pos.x, pos.y, w->getSkipFocus()?'S':' ', w->hasFocus()?'F':' ', w->isAllowUserGeometry()?'U':' ', w->getVkbdFloating()?'V':' ', \ - w->getParent(), (w->getTitle().compare("") == 0)?"No Title":w->getTitle().c_str()); - } - - DSLOG_INF("DSTraceInfo", "------------------------------------------------"); -} - -void DSTraceInfo::__onWindowCreated(std::shared_ptr window) -{ - __windowList.remove(window); - __windowList.push_front(window); - - __windowUpdated = true; -} - -void DSTraceInfo::__onWindowStackChanged(std::shared_ptr window) -{ - __windowList = __zone->getWindowList(); - - __windowUpdated = true; -} - -void DSTraceInfo::__onWindowDestroy(std::shared_ptr window) -{ - __windowList.remove(window); - - __windowUpdated = true; -} - -std::shared_ptr DSTraceInfo::getZone() -{ - return __zone; -} - -} \ No newline at end of file diff --git a/src/DSTraceInfo/DSTraceInfo.h b/src/DSTraceInfo/DSTraceInfo.h deleted file mode 100644 index 1f6d83c..0000000 --- a/src/DSTraceInfo/DSTraceInfo.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_TRACE_INFO_H__ -#define __DS_TRACE_INFO_H__ - -#include -#include "DSSignal.h" -#include "DSWindow.h" -#include "DSPolicyArea.h" -#include "DSZone.h" -#include "DSEventLoop.h" - -namespace display_server -{ - -class DSTraceInfo : public DSObject -{ -public: - explicit DSTraceInfo(); - virtual ~DSTraceInfo(); - - bool attachPolicyArea(std::shared_ptr policyArea); - void printWindowsInfo(); - std::shared_ptr getZone(); - -private: - void __onWindowCreated(std::shared_ptr window); - void __onWindowStackChanged(std::shared_ptr window); - void __onWindowDestroy(std::shared_ptr window); - - void __onEventIdleEnterer(void *data); - - std::shared_ptr __policyArea; - std::shared_ptr __zone; - std::list> __windowList; - - DSEventLoop *__eventLoop; - bool __windowUpdated; -}; - -} - -#endif \ No newline at end of file diff --git a/src/DSUtil/DSUtilSocket.cpp b/src/DSUtil/DSUtilSocket.cpp deleted file mode 100644 index 0e25111..0000000 --- a/src/DSUtil/DSUtilSocket.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSUtilSocket.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace display_server -{ - -/* reference count, mutex and compositor pointer for DSUtilSocket singleton */ -int DSUtilSocket::__refCount { 0 }; -std::mutex DSUtilSocket::__mutex; -DSUtilSocket* DSUtilSocket::__utilSocket { nullptr }; - -DSUtilSocket::DSUtilSocket() -{ -} - -DSUtilSocket::~DSUtilSocket() -{ -} - -/* getInstance for DSUtilSocket singleton */ -//static -DSUtilSocket *DSUtilSocket::getInstance() -{ - std::lock_guard tLock(__mutex); - - DSLOG_INF("DSUtilSocket", - "[Get] instance __refCount=%d !", __refCount); - - if (!__utilSocket && (__refCount == 0)) - { - __utilSocket = new DSUtilSocket(); - DSLOG_INF("DSUtilSocket", - "DSUtilSocket instance has been created !"); - } - - ++__refCount; - return __utilSocket; -} - -/* releaseInstance for DSUtilSocket singleton */ -// static -void DSUtilSocket::releaseInstance() -{ - std::lock_guard tLock(__mutex); - - --__refCount; - if (__refCount < 0) - __refCount = 0; - DSLOG_INF("DSUtilSocket", - "[Release] instance __refCount=%d !", __refCount); - - if ((0 == __refCount) && __utilSocket) - { - delete __utilSocket; - __utilSocket = nullptr; - DSLOG_INF("DSUtilSocket", - "DSUtilSocket instance has been removed !"); - } -} - -void DSUtilSocket::initSocket(std::string socketName) -{ - char *dir = nullptr; - int res; -#undef STRERR_BUFSIZE -#define STRERR_BUFSIZE 1024 - char buf[STRERR_BUFSIZE]; - - if (socketName.empty()) return; - - dir = getenv("XDG_RUNTIME_DIR"); - if (!dir) return; - - std::string xdgDir(dir); - - /* check whether buffer size is less than concatenated string which - * is made of XDG_RUNTIME_DIR, '/', socket name and NULL. - */ - - int dirLength = xdgDir.length(); - int nameLength = socketName.length(); - if ((dirLength + nameLength + 2) > STRERR_BUFSIZE) - { - /*LCOV_EXCL_START*/ - DSLOG_WRN("DSUtilSocket", "Size of buffer is not enough. dir:%s name:%s", xdgDir, socketName); - return; - /*LCOV_EXCL_STOP*/ - } - - //snprintf(socket_path, sizeof(socket_path), "%s/%s", dir, name); - std::string socketPath = xdgDir + "/" + socketName; - - uid_t uid = __getpwnam("root"); - gid_t gid = __getgrnam("display"); - - res = chmod(socketPath.c_str(), 509); - if (res < 0) - { - /*LCOV_EXCL_START*/ - DSLOG_WRN("DSUtilSocket", "Could not change modes of socket file:%s (%s)", socketPath.c_str(), strerror_r(errno, buf, STRERR_BUFSIZE)); - //PRCTL("[Winsys] Could not chane modes of socket file: %s", socketPath.c_str()); - return; - /*LCOV_EXCL_STOP*/ - } - - res = chown(socketPath.c_str(), uid, gid); - if (res < 0) - { - /*LCOV_EXCL_START*/ - DSLOG_WRN("DSUtilSocket", "Could not change owner of socket file:%s (%s)", socketPath.c_str(), strerror_r(errno, buf, STRERR_BUFSIZE)); - //PRCTL("[Winsys] Could not change owner of socket file: %s", socketPath.c_str()); - return; - /*LCOV_EXCL_STOP*/ - } -} - -int DSUtilSocket::__getpwnam(std::string name) -{ - struct ::passwd *u; - struct ::passwd *uRes; - char* buf; - size_t bufLen; - int ret; -#undef BUFLEN -#define BUFLEN 2048 - bufLen = sysconf(_SC_GETPW_R_SIZE_MAX); - if ((int)bufLen == -1) /* Value was indeterminate */ - bufLen = BUFLEN; /* Should be more than enough */ -#undef BUFLEN - - buf = (char *)malloc(bufLen); - if (buf == NULL) - { - /*LCOV_EXCL_START*/ - DSLOG_WRN("DSUtilSocket", "failed to create buffer"); - return 0; - /*LCOV_EXCL_STOP*/ - } - - u = (struct ::passwd *)malloc(sizeof(struct passwd)); - if (!u) - { - /*LCOV_EXCL_START*/ - DSLOG_WRN("DSUtilSocket", "failed to create password struct"); - free(buf); - return 0; - /*LCOV_EXCL_STOP*/ - } - - ret = getpwnam_r(name.c_str(), u, buf, bufLen, &uRes); - if (uRes == nullptr) - { - /*LCOV_EXCL_START*/ - if (ret == 0) DSLOG_WRN("DSUtilSocket", "password not found"); - else DSLOG_WRN("DSUtilSocket", "errno returned by getpwnam_r is %d", ret); - free(buf); - free(u); - return 0; - /*LCOV_EXCL_STOP*/ - } - ret = u->pw_uid; - free(buf); - free(u); - - return ret; -} - -int DSUtilSocket::__getgrnam(std::string name) -{ - struct ::group *g; - struct ::group *grpRes; - char* buf; - size_t bufLen; - int ret; -#undef BUFLEN -#define BUFLEN 2048 - bufLen = sysconf(_SC_GETGR_R_SIZE_MAX); - if ((int)bufLen == -1) /* Value was indeterminate */ - bufLen = BUFLEN; /* Should be more than enough */ -#undef BUFLEN - - buf = (char *)malloc(bufLen); - if (buf == nullptr) - { - /*LCOV_EXCL_START*/ - DSLOG_WRN("DSUtilSocket", "failed to create buffer"); - return 0; - /*LCOV_EXCL_STOP*/ - } - - g = (struct ::group *)malloc(sizeof(struct group)); - if (!g) - { - /*LCOV_EXCL_START*/ - DSLOG_WRN("DSUtilSocket", "failed to create group struct"); - free(buf); - return 0; - /*LCOV_EXCL_STOP*/ - } - - ret = getgrnam_r(name.c_str(), g, buf, bufLen, &grpRes); - if (grpRes == NULL) - { - /*LCOV_EXCL_START*/ - if (ret == 0) DSLOG_WRN("DSUtilSocket", "Group not found"); - else DSLOG_WRN("DSUtilSocket", "errno returned by getpwnam_r is %d", ret); - free(buf); - free(g); - return 0; - /*LCOV_EXCL_STOP*/ - } - - ret = g->gr_gid; - free(buf); - free(g); - return ret; -} - - - -} diff --git a/src/DSUtil/DSUtilSocket.h b/src/DSUtil/DSUtilSocket.h deleted file mode 100644 index dffdee4..0000000 --- a/src/DSUtil/DSUtilSocket.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_UTIL_SOCKET_H_ -#define __DS_UTIL_SOCKET_H_ - -#include - -namespace display_server -{ - -class DSUtilSocket -{ -public: - static DSUtilSocket *getInstance(); - static void releaseInstance(); - - void initSocket(std::string socketName); - -private: - DSUtilSocket(); - ~DSUtilSocket(); - DSUtilSocket& operator=(const DSUtilSocket&) = delete; - int __getpwnam(std::string name); - int __getgrnam(std::string name); - - static std::mutex __mutex; - static DSUtilSocket *__utilSocket; - static int __refCount; -}; - -} - -#endif diff --git a/src/DSWaylandExtension/DSWaylandExtension.cpp b/src/DSWaylandExtension/DSWaylandExtension.cpp deleted file mode 100644 index e6c5906..0000000 --- a/src/DSWaylandExtension/DSWaylandExtension.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandExtension.h" -#include "DSWaylandExtensionPrivate.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandZxdgShellV6.h" -#include "DSWaylandTizenPolicy.h" -#include "DSWaylandTizenAppinfo.h" -#include "DSWaylandTizenLaunchEffect.h" -#include "DSWaylandTizenSurface.h" -#include "DSWaylandTizenPolicyExt.h" - -namespace display_server -{ - -DSWaylandExtensionPrivate::DSWaylandExtensionPrivate(DSWaylandExtension *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), __compositor(nullptr) -{ -} - -DSWaylandExtensionPrivate::~DSWaylandExtensionPrivate() -{ - -} - -bool DSWaylandExtensionPrivate::init(DSWaylandCompositor *compositor) -{ - if (__compositor) - { - DSLOG_ERR("DSWaylandExtension", "ERROR. Compositor already exist!"); - return false; - } - - __compositor = compositor; - - try - { - __initShell(); - __initTizenPolicy(); - __initTizenAppinfo(); - __initTizenLaunchEffect(); - __initTizenSurface(); - __initTizenPolicyExt(); - } - catch(const std::runtime_error& e) - { - DSLOG_ERR("DSWaylandExtension", "ERROR. %s is failed.", e.what()); - /* - do something for release resource - */ - return false; - } - - DSLOG_INF("DSWaylandExtension", "Initialize succeed"); - return true; -} - -bool DSWaylandExtensionPrivate::__initShell(void) -{ - __zxdgShell = std::make_shared(__compositor); - if (__zxdgShell == nullptr) - { - throw std::runtime_error(__func__); - return false; - } - - __compositor->setShell(__zxdgShell.get()); - - return true; -} - -bool DSWaylandExtensionPrivate::__initTizenPolicy(void) -{ - __tzPolicy = std::make_shared(__compositor); - if (__tzPolicy == nullptr) - { - throw std::runtime_error(__func__); - return false; - } - - return true; -} - -bool DSWaylandExtensionPrivate::__initTizenAppinfo(void) -{ - __tzAppinfo = std::make_shared(__compositor); - if (__tzAppinfo == nullptr) - { - throw std::runtime_error(__func__); - return false; - } - - return true; -} - -bool DSWaylandExtensionPrivate::__initTizenLaunchEffect(void) -{ - __tzLaunchEffect = std::make_shared(__compositor); - if (__tzLaunchEffect == nullptr) - { - throw std::runtime_error(__func__); - return false; - } - - return true; -} - -bool DSWaylandExtensionPrivate::__initTizenSurface(void) -{ - __tzSurface = std::make_shared(__compositor); - if (__tzSurface == nullptr) - { - throw std::runtime_error(__func__); - return false; - } - - return true; -} - -bool DSWaylandExtensionPrivate::__initTizenPolicyExt(void) -{ - __tzPolicyExt = std::make_shared(__compositor); - if (__tzPolicyExt == nullptr) - { - throw std::runtime_error(__func__); - return false; - } - - return true; -} - - -DSWaylandExtension::DSWaylandExtension(DSWaylandCompositor *compositor) - : DS_INIT_PRIVATE_PTR(DSWaylandExtension) -{ - __init(compositor); -} - -DSWaylandExtension::~DSWaylandExtension() -{ -} - -bool DSWaylandExtension::__init(DSWaylandCompositor *compositor) -{ - if (compositor == nullptr) - { - DSLOG_ERR("DSWaylandExtension", "There is no compositor. CRITICAL!"); - return false; - } - - struct ::wl_display *display = nullptr; - display = compositor->display(); - if (display == nullptr) - { - DSLOG_ERR("DSWaylandExtension", "There is no wl_display. CRITICAL!"); - return false; - } - - DS_GET_PRIV(DSWaylandExtension); - - return priv->init(compositor); -} - - -} // namespace display_server diff --git a/src/DSWaylandExtension/DSWaylandExtension.h b/src/DSWaylandExtension/DSWaylandExtension.h deleted file mode 100644 index ea885d1..0000000 --- a/src/DSWaylandExtension/DSWaylandExtension.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_EXTENSION_H__ -#define __DS_WAYLAND_EXTENSION_H__ - -#include "DSCore.h" -#include "DSStruct.h" -#include "DSObject.h" - -namespace display_server -{ - -class DSWaylandExtensionPrivate; -class DSWaylandCompositor; - -class DSWaylandExtension : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandExtension) - -public: - DSWaylandExtension() = delete; - DSWaylandExtension(DSWaylandCompositor *compositor); - virtual ~DSWaylandExtension(); - -private: - bool __init(DSWaylandCompositor *compositor); - -private: -}; - -} // namespace display_server - -#endif // __DS_WAYLAND_EXTENSION_H__ diff --git a/src/DSWaylandExtension/DSWaylandExtensionPrivate.h b/src/DSWaylandExtension/DSWaylandExtensionPrivate.h deleted file mode 100644 index 7ac92cd..0000000 --- a/src/DSWaylandExtension/DSWaylandExtensionPrivate.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_EXTENSION_PRIVATE_H__ -#define __DS_WAYLAND_EXTENSION_PRIVATE_H__ - -namespace display_server -{ - -class DSWaylandZxdgShellV6; -class DSWaylandTizenPolicy; -class DSWaylandTizenAppinfo; -class DSWaylandTizenLaunchEffect; -class DSWaylandTizenSurface; -class DSWaylandTizenPolicyExt; - -class DSWaylandExtensionPrivate : public DSObjectPrivate -{ -DS_PIMPL_USE_PUBLIC(DSWaylandExtension) - -public: - DSWaylandExtensionPrivate() = delete; - DSWaylandExtensionPrivate(DSWaylandExtension *p_ptr); - virtual ~DSWaylandExtensionPrivate(); - - bool init(DSWaylandCompositor *compositor); - -private: - bool __initShell(void); - bool __initTizenPolicy(void); - bool __initTizenAppinfo(void); - bool __initTizenLaunchEffect(void); - bool __initTizenSurface(void); - bool __initTizenPolicyExt(void); - -private: - DSWaylandCompositor *__compositor; - std::shared_ptr __zxdgShell; - std::shared_ptr __tzPolicy; - std::shared_ptr __tzAppinfo; - std::shared_ptr __tzLaunchEffect; - std::shared_ptr __tzSurface; - std::shared_ptr __tzPolicyExt; - -}; - -} // namespace display_server - -#endif // __DS_WAYLAND_EXTENSION_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandBuffer.cpp b/src/DSWaylandServer/DSWaylandBuffer.cpp deleted file mode 100644 index 3f32057..0000000 --- a/src/DSWaylandServer/DSWaylandBuffer.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandBuffer.h" -#include "DSWaylandBufferPrivate.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -DSWaylandBufferPrivate::DSWaylandBufferPrivate(DSWaylandBuffer *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ -} - -DSWaylandBufferPrivate::~DSWaylandBufferPrivate() -{ -} - -void DSWaylandBufferPrivate::buffer_bind_resource(Resource *resource) -{ -} - -void DSWaylandBufferPrivate::buffer_destroy_resource(Resource *resource) -{ -} - -DSWaylandBuffer::DSWaylandBuffer() - : DSObject(std::make_unique(this)) -{ -} - -DSWaylandBuffer::~DSWaylandBuffer() -{ -} - -void DSWaylandBuffer::sendRelease() -{ - DS_GET_PRIV(DSWaylandBuffer); - - priv->send_release(); -} -/*LCOV_EXCL_STOP*/ - -} /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandBuffer.h b/src/DSWaylandServer/DSWaylandBuffer.h deleted file mode 100644 index a9bfca4..0000000 --- a/src/DSWaylandServer/DSWaylandBuffer.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_BUFFER_H_ -#define _DS_WAYLAND_BUFFER_H_ - -#include -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandBufferPrivate; - -class DSWaylandBuffer : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandBuffer); -public: - DSWaylandBuffer(); - virtual ~DSWaylandBuffer(); - - void sendRelease(); -}; -/*LCOV_EXCL_STOP*/ - -} /* namespace display_server */ - -#endif /* _DS_WAYLAND_BUFFER_H_ */ diff --git a/src/DSWaylandServer/DSWaylandBufferPrivate.h b/src/DSWaylandServer/DSWaylandBufferPrivate.h deleted file mode 100644 index 31342f6..0000000 --- a/src/DSWaylandServer/DSWaylandBufferPrivate.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_BUFFER_PRIVATE_H_ -#define _DS_WAYLAND_BUFFER_PRIVATE_H_ - -#include "dswayland-server-wayland.h" -#include "DSWaylandBuffer.h" - -namespace display_server -{ - -class DSWaylandBufferPrivate : public DSObjectPrivate, public DSWaylandServer::wl_buffer -{ - DS_PIMPL_USE_PUBLIC(DSWaylandBuffer); -public: - DSWaylandBufferPrivate() = delete; - DSWaylandBufferPrivate(DSWaylandBuffer *p_ptr); - ~DSWaylandBufferPrivate() override; - -protected: - void buffer_bind_resource(Resource *resource) override; - void buffer_destroy_resource(Resource *resource) override; - -private: - -}; - -} /* namespace display_server */ - -#endif /* _DS_WAYLAND_BUFFER_PRIVATE_H_ */ diff --git a/src/DSWaylandServer/DSWaylandCallback.cpp b/src/DSWaylandServer/DSWaylandCallback.cpp deleted file mode 100644 index 04a6047..0000000 --- a/src/DSWaylandServer/DSWaylandCallback.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandCallback.h" -#include "DSWaylandCallbackPrivate.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -DSWaylandCallbackPrivate::DSWaylandCallbackPrivate(DSWaylandCallback *p_ptr) - : DSObjectPrivate(p_ptr) -{ -} - -DSWaylandCallbackPrivate::~DSWaylandCallbackPrivate() -{ -} - -void DSWaylandCallbackPrivate::callback_bind_resource(Resource *resource) -{ -} - -void DSWaylandCallbackPrivate::callback_destroy_resource(Resource *resource) -{ -} - -DSWaylandCallback::DSWaylandCallback() - : DSObject(std::make_unique(this)) -{ -} - -DSWaylandCallback::~DSWaylandCallback() -{ -} -/*LCOV_EXCL_STOP*/ - -} /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandCallback.h b/src/DSWaylandServer/DSWaylandCallback.h deleted file mode 100644 index ec82760..0000000 --- a/src/DSWaylandServer/DSWaylandCallback.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_CALLBACK_H_ -#define _DS_WAYLAND_CALLBACK_H_ - -#include - -namespace display_server -{ - -class DSWaylandCallbackPrivate; - - -class DSWaylandCallback : public DSObject -{ -public: - DSWaylandCallback(); - virtual ~DSWaylandCallback(); - -private: - inline DSWaylandCallbackPrivate *__d_func() - { - return reinterpret_cast(_d_ptr.get()); - } - - inline const DSWaylandCallbackPrivate *__d_func() const - { - return reinterpret_cast(_d_ptr.get()); - } - - friend class DSWaylandCallbackPrivate; -}; - -} /* namespace display_server */ - -#endif /* _DS_WAYLAND_CALLBACK_H_ */ diff --git a/src/DSWaylandServer/DSWaylandCallbackPrivate.h b/src/DSWaylandServer/DSWaylandCallbackPrivate.h deleted file mode 100644 index 31979a7..0000000 --- a/src/DSWaylandServer/DSWaylandCallbackPrivate.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_CALLBACK_PRIVATE_H_ -#define _DS_WAYLAND_CALLBACK_PRIVATE_H_ - -#include "dswayland-server-wayland.h" -#include "DSWaylandCallback.h" - -namespace display_server -{ - -class DSWaylandCallbackPrivate : public DSObjectPrivate, public DSWaylandServer::wl_callback -{ -public: - DSWaylandCallbackPrivate() = delete; - DSWaylandCallbackPrivate(DSWaylandCallback *p_ptr); - ~DSWaylandCallbackPrivate() override; - -protected: - void callback_bind_resource(Resource *resource) override; - void callback_destroy_resource(Resource *resource) override; - -private: - -}; - -} /* namespace display_server */ - -#endif /* _DS_WAYLAND_CALLBACK_PRIVATE_H_ */ diff --git a/src/DSWaylandServer/DSWaylandClient.cpp b/src/DSWaylandServer/DSWaylandClient.cpp deleted file mode 100644 index aeea89f..0000000 --- a/src/DSWaylandServer/DSWaylandClient.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandClient.h" -#include "DSWaylandClientPrivate.h" -#include "DSWaylandCompositor.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -/* Begin Private Class Implementation */ -DSWaylandClientPrivate::DSWaylandClientPrivate(DSWaylandCompositor *compositor, DSWaylandClient *client) - : DSObjectPrivate(client), - __p_ptr(client), - __wlClient(nullptr), - __pid(0), - __uid(0), - __gid(0), - __compositor(compositor) -{ -} - -DSWaylandClientPrivate::~DSWaylandClientPrivate() -{ -} - -void DSWaylandClientPrivate::client_destroy_callback(struct ::wl_listener *listener, void *data) -{ - struct ::wl_client *wlClient = (struct ::wl_client *)data; - - (void) wlClient; - - DSWaylandClient *client = reinterpret_cast(listener)->parent; - if (client != nullptr) - { - DSLOG_INF("DSWaylandClientPrivate", "Client(%p) is going to be destroyed with wlClient(%p) ! (pid:%d, uid:%d, gid:%d)", - client, wlClient, client->pid(), client->uid(), client->gid()); - - delete client; - } -} - -/* Begin Public Class Implementation */ -DSWaylandClient::DSWaylandClient(DSWaylandCompositor *compositor, struct ::wl_client *wlClient) - : DSObject(), - _d_ptr(std::make_unique(compositor, this)) -{ - pid_t pid = 0; - uid_t uid = 0; - gid_t gid = 0; - - DS_GET_PRIV(DSWaylandClient); - - if (wlClient) - { - wl_client_get_credentials(wlClient, &pid, &uid, &gid); - - priv->__pid = pid; - priv->__uid = uid; - priv->__gid = gid; - priv->__wlClient = wlClient; - - priv->m_clientDestroyListener.parent = this; - priv->m_clientDestroyListener.listener.notify = DSWaylandClientPrivate::client_destroy_callback; - wl_client_add_destroy_listener(wlClient, &priv->m_clientDestroyListener.listener); - - DSLOG_INF("DSWaylandClient", "wlClient=%p", wlClient); - - DSWaylandCompositor::getInstance(); - compositor->addClient(this); - } - else - { - priv->__pid = 0; - priv->__uid = 0; - priv->__gid = 0; - priv->__wlClient = nullptr; - - DSLOG_ERR("DSWaylandClient", "wlClient is invalid."); - } -} - -DSWaylandClient::~DSWaylandClient() -{ - DS_GET_PRIV(DSWaylandClient); - - if (priv->__wlClient) - { - wl_list_remove(&priv->m_clientDestroyListener.listener.link); - - DSLOG_INF("DSWaylandClient", "priv->__wlClient=%p", priv->__wlClient); - getCompositor()->removeClient(this); - DSWaylandCompositor::releaseInstance(); - } - else - { - DSLOG_ERR("DSWaylandClient", "wlClient is invalid."); - } -} - -DSWaylandClient *DSWaylandClient::fromWlClient(wl_client *wlClient) -{ - if (!wlClient) - { - DSLOG_ERR("DSWaylandClient", "Invalid wlClient !"); - return nullptr; - } - - struct ::wl_listener *listener = wl_client_get_destroy_listener( - wlClient, - DSWaylandClientPrivate::client_destroy_callback); - - if (!listener) - { - DSLOG_ERR("DSWaylandClient", "No listener from the given wlClient(%p) !", wlClient); - return nullptr; - } - - DSWaylandClient *dswlClient = reinterpret_cast( - wl_container_of(listener, - (DSWaylandClientPrivate::ClientDestroyListener *)nullptr, - listener))->parent; - - if (!dswlClient) - { - DSLOG_ERR("DSWaylandClient", "No DSWaylandClient pointer available from listener(%p) !", listener); - return nullptr; - } - - DSLOG_INF("DSWaylandClient", "wlClient=%p, dswlClient=%p", wlClient, dswlClient); - - return dswlClient; -} - -pid_t DSWaylandClient::pid(void) -{ - DS_GET_PRIV(DSWaylandClient); - - return priv->__pid; -} - -uid_t DSWaylandClient::uid(void) -{ - DS_GET_PRIV(DSWaylandClient); - - return priv->__uid; -} - -gid_t DSWaylandClient::gid(void) -{ - DS_GET_PRIV(DSWaylandClient); - - return priv->__gid; -} - -wl_client *DSWaylandClient::wlClient(void) -{ - DS_GET_PRIV(DSWaylandClient); - - return priv->__wlClient; -} - -DSWaylandCompositor *DSWaylandClient::getCompositor() -{ - DS_GET_PRIV(DSWaylandClient); - - return priv->__compositor; -} - -} diff --git a/src/DSWaylandServer/DSWaylandClient.h b/src/DSWaylandServer/DSWaylandClient.h deleted file mode 100644 index 7010286..0000000 --- a/src/DSWaylandServer/DSWaylandClient.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_CLIENT_H__ -#define __DS_WAYLAND_CLIENT_H__ - -#include "DSCore.h" -#include "DSObject.h" - -struct wl_client; - -namespace display_server -{ - -class DSWaylandClientPrivate; -class DSWaylandCompositor; -class DS_DECL_EXPORT DSWaylandClient : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWaylandClient); -public: - DSWaylandClient(DSWaylandCompositor *compositor, struct ::wl_client *wlClient); - ~DSWaylandClient() override; - - static DSWaylandClient *fromWlClient(wl_client *wlClient); - - pid_t pid(void); - uid_t uid(void); - gid_t gid(void); - - wl_client *wlClient(void); - DSWaylandCompositor *getCompositor(void); - - //TODO - -protected: - -private: - -}; - -} - -#endif //__DS_WAYLAND_CLIENT_H__ diff --git a/src/DSWaylandServer/DSWaylandClientPrivate.h b/src/DSWaylandServer/DSWaylandClientPrivate.h deleted file mode 100644 index 266cfa2..0000000 --- a/src/DSWaylandServer/DSWaylandClientPrivate.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_CLIENT_PRIVATE_H__ -#define __DS_WAYLAND_CLIENT_PRIVATE_H__ - -#include "DSCore.h" -#include "DSObjectPrivate.h" - -#include - -namespace display_server -{ - -class DSWaylandClient; -class DSWaylandCompositor; -class DS_DECL_EXPORT DSWaylandClientPrivate : public DSObjectPrivate -{ - DS_PIMPL_USE_PUBLIC(DSWaylandClient); -public: - DSWaylandClientPrivate(DSWaylandCompositor *compositor, DSWaylandClient *client); - ~DSWaylandClientPrivate() override; - - static void client_destroy_callback(struct ::wl_listener *listener, void *data); - struct ClientDestroyListener - { - struct ::wl_listener listener; - DSWaylandClient *parent = nullptr; - }; - ClientDestroyListener m_clientDestroyListener; - -protected: - -private: - wl_client *__wlClient; - pid_t __pid; - uid_t __uid; - gid_t __gid; - DSWaylandCompositor *__compositor; -}; - -} - -#endif //__DS_WAYLAND_CLIENT_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandCompositor.cpp b/src/DSWaylandServer/DSWaylandCompositor.cpp deleted file mode 100644 index 438cfd2..0000000 --- a/src/DSWaylandServer/DSWaylandCompositor.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandCompositor.h" -#include "DSWaylandCompositorPrivate.h" -#include "DSWaylandExtension.h" -#include "DSWaylandClient.h" -#include "DSWaylandSeat.h" -#include "DSWaylandSurface.h" -#include "DSWaylandRegion.h" -#include "DSDebugLog.h" -#include "DSUtilSocket.h" - -namespace display_server -{ - -/* reference count, mutex and compositor pointer for DSWaylandCompositor singleton */ -int DSWaylandCompositor::__refCount { 0 }; -std::mutex DSWaylandCompositor::__mutex; -DSWaylandCompositor* DSWaylandCompositor::__comp { nullptr }; - -/* Begin Private Class Implementation */ -DSWaylandCompositorPrivate::DSWaylandCompositorPrivate(DSWaylandCompositor *compositor) - : DSObjectPrivate(compositor), - __p_ptr(compositor), - m_clientCreatedListener({nullptr, nullptr}), - _created(false), - _socketFD(-1), - _socketName(), - _display(nullptr), - _loop(nullptr), - _socket_fd_handler(nullptr), - _compositor(compositor), - __wlExtension(nullptr), - __shell(nullptr) -{ - if (!ecore_init()) - { - DSLOG_ERR("DSWaylandCompositor", "ecore_init() fails.\n"); - return; - } - - _display = wl_display_create(); - DS_ASSERT(_display != nullptr); - - m_clientCreatedListener.notify = DSWaylandCompositorPrivate::client_created_callback; - m_clientCreatedListener.parent = this; - wl_display_add_client_created_listener(_display, &m_clientCreatedListener); -} - -DSWaylandCompositorPrivate::~DSWaylandCompositorPrivate() -{ - //TODO : destroy all allocated resources - - wl_list_remove(&m_clientCreatedListener.link); - - _clients.clear(); - _seats.clear(); - _socketName.clear(); - - if (_socket_fd_handler) - { - ecore_main_fd_handler_del(_socket_fd_handler); - ecore_main_fd_handler_prepare_callback_set(_socket_fd_handler, nullptr, nullptr); - _socket_fd_handler = nullptr; - } - - if (_display) - { - wl_display_destroy(_display); - _display = nullptr; - } - - _created = false; - _socketFD = -1; - _loop = nullptr; - _compositor = nullptr; - __p_ptr = nullptr; - - ecore_shutdown(); -} - -void DSWaylandCompositorPrivate::client_created_callback(struct ::wl_listener *listener, void *data) -{ - struct ::wl_client *wlClient = (struct ::wl_client *)data; - DS_ASSERT(wlClient != nullptr); - - DSWaylandClient *client = nullptr; - DSWaylandCompositorPrivate *compPriv = reinterpret_cast(listener)->parent; - - if (compPriv != nullptr) - { - client = new DSWaylandClient(compPriv->_compositor, wlClient); - DS_ASSERT(client != nullptr); - - DSLOG_INF("DSWaylandCompositorPrivate", "Client created ! (pid:%d, uid:%d, gid:%d)", - client->pid(), client->uid(), client->gid()); - } -} - -void DSWaylandCompositorPrivate::initSocket(std::string sName, std::string sDir) -{ - std::string socketPath = std::move(sDir); - - socketPath.append(1, '/'); - socketPath.append(_socketName); - - (void) socketPath; - - DSUtilSocket *utilSocket = DSUtilSocket::getInstance(); - utilSocket->initSocket(sName); - utilSocket->releaseInstance(); - - //TODO : set permissions for Owner, Group and Other - //TODO : set Smack attributes for socket - //TODO : set symbolic link for socket -} - -bool DSWaylandCompositorPrivate::initCompositor() -{ - if (!_display) - { - DSLOG_ERR("DSWaylandCompositor", "_display(wl_display) is NULL !\n"); - return false; - } - - //Initialize needed interfaces - //TODO : get/set DSConfig::version("wl_compositor") - wl_compositor::init(_display, 4); - - //TODO : get socketName from DSConfig::socketName() - //TODO : create socket with wl_display_add_socket() if socketName not empty - _socketName = wl_display_add_socket_auto(_display); - - if (_socketName.empty()) - { - DSLOG_ERR("DSWaylandCompositor", "_socketName is empty()\n"); - return false; - } - - initSocket(_socketName, "/run"); - - //TODO : DSConfig::setEnv("WAYLAND_DISPLAY", _socketName); - - //TODO : initialize compositor signals (signals.surface.create/activate/kill) - //ex> implment using DSWaylandSignal class - //wl_signal_init(&cdata->signals.surface.create); - //-> DSWayalndSignal::add("surface_create", wl_notify_func_t *notify or ¬ify_func); - - //TODO : add event dispatcher for wayland socket and other fd(s) - _loop = wl_display_get_event_loop(_display); - - if (!_loop) - { - DSLOG_ERR("DSWaylandCompositor", "_loop is nullptr.\n"); - return false; - } - - _socketFD = wl_event_loop_get_fd(_loop); - - if (0 > _socketFD) - { - DSLOG_ERR("DSWaylandCompositor", "_socketFD is invalid. (_socketFD=%d)\n", _socketFD); - return false; - } - - auto evFlags = ECORE_FD_READ | ECORE_FD_ERROR; - - _socket_fd_handler = ecore_main_fd_handler_add(_socketFD, - static_cast(evFlags), - __readEvents, this, NULL, NULL); - - if (!_socket_fd_handler) - { - DSLOG_ERR("DSWaylandCompositor", "_socket_fd_handler is invalid.\n"); - } - - ecore_main_fd_handler_prepare_callback_set(_socket_fd_handler, - __prepareFunc, this); - - return true; -} - -bool DSWaylandCompositorPrivate::initExtension() -{ - if (__wlExtension) - { - DSLOG_INF("DSWaylandCompositor", "Already initialize Extension"); - return true; - } - - __wlExtension = std::make_unique(_compositor); - if (!__wlExtension) return false; - - return true; -} - -Eina_Bool DSWaylandCompositorPrivate::__readEvents(void *data, Ecore_Fd_Handler *hdlr) -{ - DSWaylandCompositorPrivate *compPrivate = (DSWaylandCompositorPrivate *) data; - - if (!compPrivate) - { - DSLOG_DBG("DSWaylandCompositor", "compPrivate is invalid.\n"); - return ECORE_CALLBACK_RENEW; - } - - (void) hdlr; - - /* dispatch pending wayland events */ - int ret = wl_event_loop_dispatch(compPrivate->_loop, 0); - - if (ret) - { - DSLOG_ERR("DSWaylandCompositor", "Failed on wl_event_loop_dispatch()\n"); - } - - return ECORE_CALLBACK_RENEW; -} - -void DSWaylandCompositorPrivate::__prepareFunc(void *data, Ecore_Fd_Handler *hdlr) -{ - DSWaylandCompositorPrivate *compPrivate = (DSWaylandCompositorPrivate *) data; - - if (!compPrivate) - { - DSLOG_DBG("DSWaylandCompositor", "compPrivate is invalid.\n"); - return; - } - - (void) hdlr; - - /* flush pending client events */ - wl_display_flush_clients(compPrivate->_display); -} - -void DSWaylandCompositorPrivate::compositor_bind_resource(wl_compositor::Resource *resource) -{ - //TODO : Leave log (pid/uid/gid and process name) - //TODO : Update connected client list (add) -} - -void DSWaylandCompositorPrivate::compositor_destroy_resource(wl_compositor::Resource *resource) -{ - //TODO : Leave log (pid/uid/gid and process name) - //TODO : Update connected client list (remove) -} - -void DSWaylandCompositorPrivate::compositor_create_surface(wl_compositor::Resource *resource, uint32_t id) -{ - DS_GET_PUB(DSWaylandCompositor); - - DSWaylandClient *waylandClient = DSWaylandClient::fromWlClient(resource->client()); - auto waylandSruface = std::make_shared(waylandClient, id); - - pub->__surfaceList.push_front(waylandSruface); - - // emit a signal of the surface created - pub->__surfaceCreatedSignal.emit(waylandSruface); -} - -void DSWaylandCompositorPrivate::compositor_create_region(wl_compositor::Resource *resource, uint32_t id) -{ - DS_GET_PUB(DSWaylandCompositor); - - DSWaylandClient *waylandClient = DSWaylandClient::fromWlClient(resource->client()); - auto waylandRegion = std::make_shared(waylandClient, id); - - pub->__regionList.push_front(waylandRegion); -} - -/* Begin Public Class Implementation */ -DSWaylandCompositor::DSWaylandCompositor(DSObject *parent) - : DS_INIT_PRIVATE_PTR(DSWaylandCompositor) -{ - //TODO -} - -DSWaylandCompositor::~DSWaylandCompositor() -{ - //TODO -} - -/* getInstance for DSWaylandCompositor singleton */ -DSWaylandCompositor *DSWaylandCompositor::getInstance() -{ - std::lock_guard tLock(__mutex); - - DSLOG_INF("DSWaylandCompositor", - "[Get] instance __refCount=%d !", __refCount); - - if (!__comp && (__refCount == 0)) - { - __comp = new DSWaylandCompositor(new DSObject); - DSLOG_INF("DSWaylandCompositor", - "DSWaylandCompositor instance has been created !"); - } - - ++__refCount; - return __comp; -} - -/* releaseInstance for DSWaylandCompositor singleton */ -void DSWaylandCompositor::releaseInstance() -{ - std::lock_guard tLock(__mutex); - - --__refCount; - if (__refCount < 0) - __refCount = 0; - DSLOG_INF("DSWaylandCompositor", - "[Release] instance __refCount=%d !", __refCount); - - if ((0 == __refCount) && __comp) - { - delete __comp; - __comp = nullptr; - DSLOG_INF("DSWaylandCompositor", - "DSWaylandCompositor instance has been removed !"); - } -} - -bool DSWaylandCompositor::create() -{ - DS_GET_PRIV(DSWaylandCompositor); - - bool res = false; - - res = priv->initCompositor(); - if (!res) - { - DSLOG_ERR("DSWaylandCompositor", "Failed on initCompositor ! (res=%d)\n", res); - return false; - } - - res = priv->initExtension(); - if (!res) - { - DSLOG_ERR("DSWaylandCompositor", "Failed on initExtension ! (res=%d)\n", res); - return false; - } - - priv->_created = true; - return true; -} - -bool DSWaylandCompositor::isCreated() -{ - DS_GET_PRIV(DSWaylandCompositor); - - return priv->_created; -} - -DSWaylandSeat *DSWaylandCompositorPrivate::addSeat(uint32_t cap) -{ - DSWaylandSeat *dswlSeat = new DSWaylandSeat(_compositor, (DSWaylandSeat::seatCapability)cap); - - if (!dswlSeat) - { - DSLOG_ERR("DSWaylandCompositorPrivate", "Failed to create DSWaylandSeat !"); - return nullptr; - } - - //TODO : check if the client is in clients already ? - _seats.push_back(dswlSeat); - - DSLOG_INF("DSWaylandCompositorPrivate", "Seat(%p) has been added.", dswlSeat); - - //TODO : emit seatAdded signal - - return dswlSeat; -} - -void DSWaylandCompositorPrivate::removeSeat(DSWaylandSeat *dswlSeat) -{ - DS_ASSERT(dswlSeat != nullptr); - - //TODO : check if the client is in clients already ? - _seats.remove(dswlSeat); - DSLOG_INF("DSWaylandCompositorPrivate", "Seat(%p) has been removed.", dswlSeat); - - //TODO : emit seatRemoved signal before deleting a seat; - delete dswlSeat; -} - -bool DSWaylandCompositorPrivate::setShell(IDSWaylandShell *shell) -{ - if (__shell) - { - DSLOG_ERR("DSWaylandCompositor", "Already register IDSWaylandShell!"); - return false; - } - - __shell = shell; - return true; -} - -IDSWaylandShell *DSWaylandCompositorPrivate::getShell(void) -{ - return __shell; -} - - -std::string DSWaylandCompositor::socketName() -{ - DS_GET_PRIV(DSWaylandCompositor); - - return priv->_socketName; -} - -struct ::wl_display *DSWaylandCompositor::display() -{ - DS_GET_PRIV(DSWaylandCompositor); - - return priv->_display; -} - -uint32_t DSWaylandCompositor::nextSerial() -{ - DS_GET_PRIV(DSWaylandCompositor); - - return wl_display_next_serial(priv->_display); -} - -uint32_t DSWaylandCompositor::currentTime() -{ - return ecore_time_unix_get(); -} - -void DSWaylandCompositor::addClient(DSWaylandClient *client) -{ - DS_GET_PRIV(DSWaylandCompositor); - - priv->addClient(client); -} - -void DSWaylandCompositor::removeClient(DSWaylandClient *client) -{ - DS_GET_PRIV(DSWaylandCompositor); - - priv->removeClient(client); -} - -DSWaylandSeat *DSWaylandCompositor::addSeat(uint32_t cap) -{ - DS_GET_PRIV(DSWaylandCompositor); - - return priv->addSeat(cap); -} - -void DSWaylandCompositor::removeSeat(DSWaylandSeat *seat) -{ - DS_GET_PRIV(DSWaylandCompositor); - - priv->removeSeat(seat); -} - -std::list DSWaylandCompositor::clients() -{ - DS_GET_PRIV(DSWaylandCompositor); - - return priv->_clients; -} - -DSWaylandSeat *DSWaylandCompositor::defaultSeat() -{ - DS_GET_PRIV(DSWaylandCompositor); - - if (!priv->_seats.empty()) - { - return priv->_seats.front(); - } - - return nullptr; -} - -bool DSWaylandCompositor::setShell(IDSWaylandShell *shell) -{ - DS_GET_PRIV(DSWaylandCompositor); - return priv->setShell(shell); -} - -IDSWaylandShell *DSWaylandCompositor::getShell(void) -{ - DS_GET_PRIV(DSWaylandCompositor); - return priv->getShell(); -} - -DSWaylandSurface *DSWaylandCompositor::getSurface(uint32_t id) -{ - for (auto s : __surfaceList) - { - if (s->getResourceId() == id) - { - return s.get(); - } - } - - return nullptr; -} - -DSWaylandSurface *DSWaylandCompositor::getSurface(struct ::wl_resource *surface) -{ - for (auto s : __surfaceList) - { - if (s->getWlResource() == surface) - { - return s.get(); - } - } - - return nullptr; -} - -void DSWaylandCompositor::sendSurfaceDestroy(DSWaylandSurface *dswSurface) -{ - for (auto s : __surfaceList) - { - if (s.get() == dswSurface) - { - __surfaceDestroySignal.emit(s); - __surfaceList.remove(s); - break; - } - } -} - -void DSWaylandCompositor::regionDestroy(DSWaylandRegion *dswRegion) -{ - for (auto s : __regionList) - { - if (s.get() == dswRegion) - { - __regionList.remove(s); - break; - } - } -} - -void DSWaylandCompositor::registerCallbackSurfaceCreated(DSObject *slot, std::function)> func) -{ - this->__surfaceCreatedSignal.connect(slot, func); -} - -void DSWaylandCompositor::registerCallbackSurfaceDestroy(DSObject *slot, std::function)> func) -{ - __surfaceDestroySignal.connect(slot, func); -} - -} diff --git a/src/DSWaylandServer/DSWaylandCompositor.h b/src/DSWaylandServer/DSWaylandCompositor.h deleted file mode 100644 index 6e89344..0000000 --- a/src/DSWaylandServer/DSWaylandCompositor.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_COMPOSITOR_H__ -#define __DS_WAYLAND_COMPOSITOR_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSSignal.h" -#include - -struct wl_display; -struct wl_resource; - -namespace display_server -{ - -class DSWaylandClient; -class DSWaylandSeat; -class DSWaylandSurface; -class IDSWaylandShell; -class DSWaylandRegion; - -class DSWaylandCompositorPrivate; - -class DS_DECL_EXPORT DSWaylandCompositor : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWaylandCompositor); -public: - static DSWaylandCompositor *getInstance(); - static void releaseInstance(); - - bool create(); - bool isCreated(); - - void addClient(DSWaylandClient *client); - void removeClient(DSWaylandClient *client); - DSWaylandSeat *addSeat(uint32_t cap); - void removeSeat(DSWaylandSeat *seat); - - std::string socketName(); - struct ::wl_display *display(); - uint32_t nextSerial(); - uint32_t currentTime(); - std::list clients(); - DSWaylandSeat *defaultSeat(); - - bool setShell(IDSWaylandShell *shell); - IDSWaylandShell *getShell(void); - - DSWaylandSurface *getSurface(uint32_t id); - DSWaylandSurface *getSurface(struct ::wl_resource *surface); - - void sendSurfaceDestroy(DSWaylandSurface *dswSurface); - void regionDestroy(DSWaylandRegion *dswRegion); - - // Callback methods - void registerCallbackSurfaceCreated(DSObject *slot, std::function)> func); - void registerCallbackSurfaceDestroy(DSObject *slot, std::function)> func); - -protected: - //TODO - -private: - static std::mutex __mutex; - static DSWaylandCompositor *__comp; - static int __refCount; - - DSWaylandCompositor() = delete; - ~DSWaylandCompositor(); - DSWaylandCompositor(DSObject *parent); - DSWaylandCompositor& operator=(const DSWaylandCompositor&) = delete; - - std::list> __surfaceList; - std::list> __regionList; - - // signals - DSSignal> __surfaceCreatedSignal; - DSSignal> __surfaceDestroySignal; -}; - -} - -#endif //__DS_WAYLAND_COMPOSITOR_H__ diff --git a/src/DSWaylandServer/DSWaylandCompositorPrivate.h b/src/DSWaylandServer/DSWaylandCompositorPrivate.h deleted file mode 100644 index edbf3b1..0000000 --- a/src/DSWaylandServer/DSWaylandCompositorPrivate.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_COMPOSITOR_PRIVATE_H__ -#define __DS_WAYLAND_COMPOSITOR_PRIVATE_H__ - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "dswayland-server-wayland.h" -#include "DSWaylandClient.h" -#include "DSDebugLog.h" - -#include -#include - -namespace display_server -{ - -class DSWaylandClient; -class DSWaylandSeat; -class DSWaylandCompositor; -class DSWaylandExtension; - -class DS_DECL_EXPORT DSWaylandCompositorPrivate : public DSObjectPrivate, public DSWaylandServer::wl_compositor -{ - DS_PIMPL_USE_PUBLIC(DSWaylandCompositor); -public: - DSWaylandCompositorPrivate(DSWaylandCompositor *compositor); - ~DSWaylandCompositorPrivate() override; - - bool initCompositor(); - bool initExtension(); - void initSocket(std::string sName, std::string sDir); - inline void addClient(DSWaylandClient *client); - inline void removeClient(DSWaylandClient *client); - DSWaylandSeat *addSeat(uint32_t cap); - void removeSeat(DSWaylandSeat *seat); - - bool setShell(IDSWaylandShell *shell); - IDSWaylandShell *getShell(void); - - static void client_created_callback(struct ::wl_listener *listener, void *data); - struct ClientCreatedListener : ::wl_listener { - DSWaylandCompositorPrivate *parent; - }; - ClientCreatedListener m_clientCreatedListener; - -protected: - //virtual Resource *compositor_allocate(); - void compositor_bind_resource(Resource *resource) override; - void compositor_destroy_resource(Resource *resource) override; - void compositor_create_surface(Resource *resource, uint32_t id) override; - void compositor_create_region(Resource *resource, uint32_t id) override; - - std::list _clients; - std::list _seats; - - bool _created; - int _socketFD; - std::string _socketName; - struct ::wl_display *_display; - wl_event_loop *_loop; - Ecore_Fd_Handler *_socket_fd_handler; - DSWaylandCompositor *_compositor; - - //TODO : add DSOutput list - //TODO : add DSWindow (DSSurface ?) list - -private: - static Eina_Bool __readEvents(void *data, Ecore_Fd_Handler *hdlr); - static void __prepareFunc(void *data, Ecore_Fd_Handler *hdlr); - - std::unique_ptr __wlExtension; - IDSWaylandShell *__shell; -}; - -void DSWaylandCompositorPrivate::addClient(DSWaylandClient *client) -{ - DS_ASSERT(client != nullptr); - - //TODO : check if the client is in clients already ? - _clients.push_back(client); - DSLOG_INF("DSWaylandCompositorPrivate", "Client(%p, PID:%d) has been added.", client, client->pid()); -} - -void DSWaylandCompositorPrivate::removeClient(DSWaylandClient *client) -{ - DS_ASSERT(client != nullptr); - - //TODO : check if the client is in clients already ? - _clients.remove(client); - DSLOG_INF("DSWaylandCompositorPrivate", "Client(%p, PID:%d) has been removed.", client, client->pid()); -} - -} - -#endif //__DS_WAYLAND_COMPOSITOR_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp deleted file mode 100644 index 93d3aee..0000000 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ /dev/null @@ -1,966 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandInputMethodContext.h" -#include "DSWaylandInputMethodContextPrivate.h" -#include "DSWaylandInputMethod.h" -#include "DSWaylandInputMethodPrivate.h" - -namespace display_server { - -/*LCOV_EXCL_START*/ -DSWaylandInputMethodContextPrivate::DSWaylandInputMethodContextPrivate(DSWaylandInputMethodContext *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __compositor(compositor) -{ -} - -DSWaylandInputMethodContextPrivate::~DSWaylandInputMethodContextPrivate() -{ -} - -void* DSWaylandInputMethodContextPrivate::createGlobal(void *client) -{ - Resource *resource = add((struct ::wl_client *)client, 1); - return resource->handle; - //init((struct ::wl_client *)client, 0, 1); -} - -void DSWaylandInputMethodContextPrivate::sendReset(void *contextResource) -{ - send_reset((struct ::wl_resource *)contextResource); -} - -void DSWaylandInputMethodContextPrivate::sendContentType(void *contextResource, unsigned int hint, unsigned int purpose) -{ - send_content_type((struct ::wl_resource *)contextResource, hint, purpose); -} - -void DSWaylandInputMethodContextPrivate::sendPreferredLanguage(void *contextResource, const std::string language) -{ - send_preferred_language((struct ::wl_resource *)contextResource, language); -} - -void DSWaylandInputMethodContextPrivate::sendCommitState(void *contextResource, unsigned int serial) -{ - send_commit_state((struct ::wl_resource *)contextResource, serial); -} - -void DSWaylandInputMethodContextPrivate::sendInvokeAction(void *contextResource, unsigned int button, unsigned int index) -{ - send_invoke_action((struct ::wl_resource *)contextResource, button, index); -} - -void DSWaylandInputMethodContextPrivate::sendReturnKeyType(void *contextResource, unsigned int returnKeyType) -{ - send_return_key_type((struct ::wl_resource *)contextResource, returnKeyType); -} - -void DSWaylandInputMethodContextPrivate::sendReturnKeyDisabled(void *contextResource, unsigned int returnKeyDisabled) -{ - send_return_key_disabled((struct ::wl_resource *)contextResource, returnKeyDisabled); -} - -void DSWaylandInputMethodContextPrivate::sendInputPanelData(void *contextResource, std::string inputPanelData, unsigned int inputPanelLength) -{ - send_input_panel_data((struct ::wl_resource *)contextResource, inputPanelData, inputPanelLength); -} - -void DSWaylandInputMethodContextPrivate::sendBidiDirection(void *contextResource, unsigned int direction) -{ - send_bidi_direction((struct ::wl_resource *)contextResource, direction); -} - -void DSWaylandInputMethodContextPrivate::sendCursorPosition(void *contextResource, unsigned int cursorPosition) -{ - send_cursor_position((struct ::wl_resource *)contextResource, cursorPosition); -} - -void DSWaylandInputMethodContextPrivate::sendProcessInputDeviceEvent(void *contextResource, unsigned int eventType, std::string eventData, unsigned int eventLength) -{ - send_process_input_device_event((struct ::wl_resource *)contextResource, eventType, eventData, eventLength); -} - -void DSWaylandInputMethodContextPrivate::sendFilterKeyEvent(void *contextResource, unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode) -{ - send_filter_key_event((struct ::wl_resource *)contextResource, serial, time, keyName, state, modifiers, devName, devClass, devSubclass, keycode); -} - -void DSWaylandInputMethodContextPrivate::sendCapitalMode(void *contextResource, unsigned int mode) -{ - send_capital_mode((struct ::wl_resource *)contextResource, mode); -} - -void DSWaylandInputMethodContextPrivate::sendPredictionHint(void *contextResource, std::string text) -{ - send_prediction_hint((struct ::wl_resource *)contextResource, text); -} - -void DSWaylandInputMethodContextPrivate::sendMimeType(void *contextResource, std::string type) -{ - send_mime_type((struct ::wl_resource *)contextResource, type); -} - -void DSWaylandInputMethodContextPrivate::sendFinalizedContent(void *contextResource, std::string text, unsigned int cursorPosition) -{ - send_finalized_content((struct ::wl_resource *)contextResource, text, cursorPosition); -} - -void DSWaylandInputMethodContextPrivate::sendPredictionHintData(void *contextResource, std::string key, std::string value) -{ - send_prediction_hint_data((struct ::wl_resource *)contextResource, key, value); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_destroy(Resource *resource) -{ -} - -void DSWaylandInputMethodContextPrivate::input_method_context_commit_string(Resource *resource, uint32_t serial, const std::string &text) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextCommitString(serial, text); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_preedit_string(Resource *resource, uint32_t serial, const std::string &text, const std::string &commit) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextPreeditString(serial, text, commit); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextPreeditStyling(index, length, style); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_preedit_cursor(Resource *resource, int32_t index) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextPreeditCursor(index); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextDeleteSurroundingText(index, length); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_cursor_position(Resource *resource, int32_t index, int32_t anchor) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextCursorPosition(index, anchor); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_modifiers_map(Resource *resource, wl_array *map) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - std::string mapData = (char *)map->data; - - pub->__inputMethod->contextModifiersMap(mapData); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - if (pub->__inputMethod->contextActivated()) - { - pub->__inputMethod->contextKeysym(serial, time, sym, state, modifiers); - } - else - { - /* TODO: generate key events for server */ - } -} - -void DSWaylandInputMethodContextPrivate::input_method_context_grab_keyboard(Resource *resource, uint32_t keyboard) -{ - /* TODO: this is optional, currently disable this option */ -} - -void DSWaylandInputMethodContextPrivate::input_method_context_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) -{ - /* Nothing to do in this request */ -} - -void DSWaylandInputMethodContextPrivate::input_method_context_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) -{ - /* Nothing to do in this request */ -} - -void DSWaylandInputMethodContextPrivate::input_method_context_language(Resource *resource, uint32_t serial, const std::string &language) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextLanguage(serial, language); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_text_direction(Resource *resource, uint32_t serial, uint32_t direction) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextTextDirection(serial, direction); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_selection_region(Resource *resource, uint32_t serial, int32_t start, int32_t end) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextSelectionRegion(serial, start, end); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_private_command(Resource *resource, uint32_t serial, const std::string &command) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextPrivateCommand(serial, command); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_update_input_panel_data(Resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextUpdateInputPanelData(serial, input_panel_data, input_panel_data_length); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_hide_input_panel(Resource *resource, uint32_t serial) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextHideInputPanel(serial); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_get_selection_text(Resource *resource, int32_t fd) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextGetSelectionText(fd); - - close(fd); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_get_surrounding_text(Resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextGetSurroundingText(maxlen_before, maxlen_after, fd); - - close(fd); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_filter_key_event_done(Resource *resource, uint32_t serial, uint32_t state) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextFilterKeyEventDone(serial, state); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_update_ise_geometry(Resource *resource, uint32_t serial, uint32_t x, uint32_t y, uint32_t width, uint32_t height) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextUpdateIseGeometry(serial, x, y, width, height); - pub->__inputMethod->setGeometryUpdated(true); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextRecaptureString(serial, index, length, preedit, preedit_commit, commit); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_input_panel_event(Resource *resource, uint32_t serial, uint32_t event_type, uint32_t value) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextInputPanelEvent(serial, event_type, value); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextCommitContent(serial, content, description, mime_types); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_update_candidate_state(Resource *resource, uint32_t state) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextUpdateCandidateState(state); -} - -void DSWaylandInputMethodContextPrivate::input_method_context_reshow_input_panel(Resource *resource) -{ - DS_GET_PUB(DSWaylandInputMethodContext); - - pub->__inputMethod->contextReshowInputPanel(); -} - - -DSWaylandInputMethodContext::DSWaylandInputMethodContext(DSWaylandCompositor *compositor, DSWaylandInputMethod *inputMethod) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __compositor(compositor), - __inputMethod(inputMethod) -{ -} - -DSWaylandInputMethodContext::~DSWaylandInputMethodContext() -{ -} - -void* DSWaylandInputMethodContext::createGlobal(void *client) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - return priv->createGlobal(client); -} - -void DSWaylandInputMethodContext::sendReset(void *contextResource) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendReset(contextResource); -} - -void DSWaylandInputMethodContext::sendContentType(void *contextResource, unsigned int hint, unsigned int purpose) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendContentType(contextResource, hint, purpose); -} - -void DSWaylandInputMethodContext::sendPreferredLanguage(void *contextResource, const std::string language) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendPreferredLanguage(contextResource, language); -} - -void DSWaylandInputMethodContext::sendCommitState(void *contextResource, unsigned int serial) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendCommitState(contextResource, serial); -} - -void DSWaylandInputMethodContext::sendInvokeAction(void *contextResource, unsigned int button, unsigned int index) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendInvokeAction(contextResource, button, index); -} - -void DSWaylandInputMethodContext::sendReturnKeyType(void *contextResource, unsigned int returnKeyType) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendReturnKeyType(contextResource, returnKeyType); -} - -void DSWaylandInputMethodContext::sendReturnKeyDisabled(void *contextResource, unsigned int returnKeyDisabled) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendReturnKeyDisabled(contextResource, returnKeyDisabled); -} - -void DSWaylandInputMethodContext::sendInputPanelData(void *contextResource, std::string inputPanelData, unsigned int inputPanelLength) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendInputPanelData(contextResource, inputPanelData, inputPanelLength); -} - -void DSWaylandInputMethodContext::sendBidiDirection(void *contextResource, unsigned int direction) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendBidiDirection(contextResource, direction); -} - -void DSWaylandInputMethodContext::sendCursorPosition(void *contextResource, unsigned int cursorPosition) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendCursorPosition(contextResource, cursorPosition); -} - -void DSWaylandInputMethodContext::sendProcessInputDeviceEvent(void *contextResource, unsigned int eventType, std::string eventData, unsigned int eventLength) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendProcessInputDeviceEvent(contextResource, eventType, eventData, eventLength); -} - -void DSWaylandInputMethodContext::sendFilterKeyEvent(void *contextResource, unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendFilterKeyEvent(contextResource, serial, time, keyName, state, modifiers, devName, devClass, devSubclass, keycode); -} - -void DSWaylandInputMethodContext::sendCapitalMode(void *contextResource, unsigned int mode) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendCapitalMode(contextResource, mode); -} - -void DSWaylandInputMethodContext::sendPredictionHint(void *contextResource, std::string text) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendPredictionHint(contextResource, text); -} - -void DSWaylandInputMethodContext::sendMimeType(void *contextResource, std::string type) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendMimeType(contextResource, type); -} - -void DSWaylandInputMethodContext::sendFinalizedContent(void *contextResource, std::string text, unsigned int cursorPosition) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendFinalizedContent(contextResource, text, cursorPosition); -} - -void DSWaylandInputMethodContext::sendPredictionHintData(void *contextResource, std::string key, std::string value) -{ - DS_GET_PRIV(DSWaylandInputMethodContext); - - if (contextResource) - return priv->sendPredictionHintData(contextResource, key, value); -} - - -DSWaylandInputMethodPrivate::DSWaylandInputMethodPrivate(DSWaylandInputMethod *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __compositor(compositor), - __resource(nullptr) -{ - if (!compositor) - return; - - zwp_input_method_v1::init(__compositor->display(), 1); -} - -DSWaylandInputMethodPrivate::~DSWaylandInputMethodPrivate() -{ -} - -int DSWaylandInputMethodPrivate::getResourceId(DSWaylandInputMethodContextPrivate::Resource *resource) -{ - int id = -1; - - std::multimap::iterator it; - for (it = __contextMap.begin(); it != __contextMap.end(); it++) - { - if (resource == (*it).first) - { - id = (*it).second; - break; - } - } - - return id; -} - -DSWaylandInputMethodContextPrivate::Resource* DSWaylandInputMethodPrivate::getResource(int id) -{ - DSWaylandInputMethodContextPrivate::Resource *resource = nullptr; - - - std::multimap::iterator it; - for (it = __contextMap.begin(); it != __contextMap.end(); it++) - { - if (id == (*it).second) - { - resource = (*it).first; - break; - } - } - - return resource; -} - -void DSWaylandInputMethodPrivate::sendActivate(void *contextResource, int textInputId) -{ - DSWaylandInputMethodContextPrivate::Resource *resource = DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)contextResource); - __contextMap.insert(std::pair(resource, textInputId)); - send_activate(__resource->handle, (struct ::wl_resource *)contextResource); -} - -void DSWaylandInputMethodPrivate::sendDeactivate(void *contextResource) -{ - DSWaylandInputMethodContextPrivate::Resource *resource = DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)contextResource); - __contextMap.erase(resource); - send_deactivate(__resource->handle, (struct ::wl_resource *)contextResource); -} - -void DSWaylandInputMethodPrivate::showInputPanel(void *contextResource, int textInputId) -{ - //Resource *resource = getResource(textInputId); - //FIXME: please, replace with current client's rotation degree - send_show_input_panel(__resource->handle, (struct ::wl_resource *)contextResource, 0); -} - -void DSWaylandInputMethodPrivate::hideInputPanel(void *contextResource, int textInputId) -{ - //Resource *resource = getResource(textInputId); - send_hide_input_panel(__resource->handle, (struct ::wl_resource *)contextResource); -} - -void DSWaylandInputMethodPrivate::openConnection(void *contextResource) -{ - //Resource *resource = getResource(textInputId); - send_open_connection(__resource->handle, (struct ::wl_resource *)contextResource); -} - -void DSWaylandInputMethodPrivate::closeConnection(void *contextResource) -{ - //Resource *resource = getResource(textInputId); - send_close_connection(__resource->handle, (struct ::wl_resource *)contextResource); -} - -void DSWaylandInputMethodPrivate::setTextInputId(void *contextResource, int textInputId) -{ - //Resource *resource = getResource(textInputId); - send_set_text_input_id(__resource->handle, (struct ::wl_resource *)contextResource, textInputId); -} - -void DSWaylandInputMethodPrivate::input_method_bind_resource(Resource *resource) -{ - __resource = resource; - //if (vconf_set_bool(VCONFKEY_ISF_BIND, 1) != 0) -} - -void DSWaylandInputMethodPrivate::input_method_destroy_resource(Resource *resource) -{ - __resource = nullptr; - //if (vconf_set_bool(VCONFKEY_ISF_BIND, 0) != 0) -} - - -DSWaylandInputMethod::DSWaylandInputMethod(DSWaylandCompositor *compositor) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __dsTextInputPrivate(nullptr), - __compositor(compositor), - __activateContext(nullptr), - __candidateState(0) -{ - __inputMethodContext = new DSWaylandInputMethodContext(compositor, this); -} - -DSWaylandInputMethod::DSWaylandInputMethod(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __dsTextInputPrivate(dsTextInputPrivate), - __compositor(compositor), - __activateContext(nullptr), - __candidateState(0) -{ - __inputMethodContext = new DSWaylandInputMethodContext(compositor, this); -} - -DSWaylandInputMethod::~DSWaylandInputMethod() -{ -} - -DSWaylandInputMethodContext* DSWaylandInputMethod::getContext() -{ - return __inputMethodContext; -} - -bool DSWaylandInputMethod::contextActivated() -{ - if (__activateContext) return true; - else return false; -} - -void DSWaylandInputMethod::activate(int textInputId) -{ - DS_GET_PRIV(DSWaylandInputMethod); - - if (!__activateContext) - { - if (priv->__resource) - __activateContext = __inputMethodContext->createGlobal((void *)(priv->__resource->client())); - } - - if (__activateContext) - priv->sendActivate(__activateContext, textInputId); -} - -void DSWaylandInputMethod::deactivate() -{ - DS_GET_PRIV(DSWaylandInputMethod); - - if (__activateContext) - { - priv->sendDeactivate(__activateContext); - __activateContext = nullptr; - } -} - -void DSWaylandInputMethod::showInputPanel(int textInputId) -{ - DS_GET_PRIV(DSWaylandInputMethod); - - if (__activateContext) - priv->showInputPanel(__activateContext, textInputId); -} - -void DSWaylandInputMethod::hideInputPanel(int textInputId) -{ - DS_GET_PRIV(DSWaylandInputMethod); - - if (textInputId < 0) - { - textInputId = priv->getResourceId(DSWaylandInputMethodContextPrivate::Resource::fromResource((struct ::wl_resource *)__activateContext)); - } - - if (__activateContext) - priv->hideInputPanel(__activateContext, textInputId); -} - -void DSWaylandInputMethod::openConnection() -{ - DS_GET_PRIV(DSWaylandInputMethod); - - if (__activateContext) - priv->openConnection(__activateContext); -} - -void DSWaylandInputMethod::closeConnection() -{ - DS_GET_PRIV(DSWaylandInputMethod); - - if (__activateContext) - priv->closeConnection(__activateContext); -} - -void DSWaylandInputMethod::setTextInputId(int textInputId) -{ - DS_GET_PRIV(DSWaylandInputMethod); - - if (__activateContext) - priv->setTextInputId(__activateContext, textInputId); -} - -void DSWaylandInputMethod::resetTextInput() -{ - __inputMethodContext->sendReset(__activateContext); -} - -void DSWaylandInputMethod::setContentType(unsigned int hint, unsigned int purpose) -{ - __inputMethodContext->sendContentType(__activateContext, hint, purpose); -} - -void DSWaylandInputMethod::setPreferredLanguage(const std::string language) -{ - __inputMethodContext->sendPreferredLanguage(__activateContext, language); -} - -void DSWaylandInputMethod::commitState(unsigned int serial) -{ - __inputMethodContext->sendCommitState(__activateContext, serial); -} - -void DSWaylandInputMethod::invokeAction(unsigned int button, unsigned int index) -{ - __inputMethodContext->sendInvokeAction(__activateContext, button, index); -} - -void DSWaylandInputMethod::setReturnKeyType(unsigned int returnKeyType) -{ - __inputMethodContext->sendReturnKeyType(__activateContext, returnKeyType); -} - -void DSWaylandInputMethod::returnKeyDisabled(unsigned int returnKeyDisabled) -{ - __inputMethodContext->sendReturnKeyDisabled(__activateContext, returnKeyDisabled); -} - -void DSWaylandInputMethod::setInputPanelData(std::string inputPanelData, unsigned int inputPanelLength) -{ - __inputMethodContext->sendInputPanelData(__activateContext, inputPanelData, inputPanelLength); -} - -void DSWaylandInputMethod::bidiDirection(unsigned int direction) -{ - __inputMethodContext->sendBidiDirection(__activateContext, direction); -} - -void DSWaylandInputMethod::setCursorPosition(unsigned int cursorPosition) -{ - __inputMethodContext->sendCursorPosition(__activateContext, cursorPosition); -} - -void DSWaylandInputMethod::processInputDeviceEvent(unsigned int eventType, std::string eventData, unsigned int eventLength) -{ - __inputMethodContext->sendProcessInputDeviceEvent(__activateContext, eventType, eventData, eventLength); -} - -void DSWaylandInputMethod::filterKeyEvent(unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode) -{ - __inputMethodContext->sendFilterKeyEvent(__activateContext, serial, time, keyName, state, modifiers, devName, devClass, devSubclass, keycode); -} - -void DSWaylandInputMethod::setCapitalMode(unsigned int mode) -{ - __inputMethodContext->sendCapitalMode(__activateContext, mode); -} - -void DSWaylandInputMethod::predictionHint(std::string text) -{ - __inputMethodContext->sendPredictionHint(__activateContext, text); -} - -void DSWaylandInputMethod::setMimeType(std::string type) -{ - __inputMethodContext->sendMimeType(__activateContext, type); -} - -void DSWaylandInputMethod::finalizeContent(std::string text, unsigned int cursorPosition) -{ - __inputMethodContext->sendFinalizedContent(__activateContext, text, cursorPosition); -} - -void DSWaylandInputMethod::predictionHintData(std::string key, std::string value) -{ - __inputMethodContext->sendPredictionHintData(__activateContext, key, value); -} - -void DSWaylandInputMethod::contextCommitString(unsigned int serial, std::string text) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextCommitString(serial, text); -} - -void DSWaylandInputMethod::contextPreeditString(unsigned int serial, std::string text, std::string commit) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextPreeditString(serial, text, commit); -} - -void DSWaylandInputMethod::contextPreeditStyling(int index, unsigned int length, unsigned int style) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextPreeditStyling(index, length, style); -} - -void DSWaylandInputMethod::contextPreeditCursor(int index) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextPreeditCursor(index); -} - -void DSWaylandInputMethod::contextDeleteSurroundingText(int index, unsigned int length) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextDeleteSurroundingText(index, length); -} - -void DSWaylandInputMethod::contextCursorPosition(int index, int anchor) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextCursorPosition(index, anchor); -} - -void DSWaylandInputMethod::contextModifiersMap(std::string map) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextModifiersMap(map); -} - -void DSWaylandInputMethod::contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextKeysym(serial, time, sym, state, modifiers); -} - -void DSWaylandInputMethod::contextLanguage(unsigned int serial, std::string language) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextLanguage(serial, language); -} - -void DSWaylandInputMethod::contextTextDirection(unsigned int serial, unsigned int direction) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextTextDirection(serial, direction); -} - -void DSWaylandInputMethod::contextSelectionRegion(unsigned int serial, int start, int end) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextSelectionRegion(serial, start, end); -} - -void DSWaylandInputMethod::contextPrivateCommand(unsigned int serial, std::string command) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextPrivateCommand(serial, command); -} - -void DSWaylandInputMethod::contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextUpdateInputPanelData(serial, inputPanelData, inputPanelDataLength); -} - -void DSWaylandInputMethod::contextHideInputPanel(unsigned int serial) -{ - DS_GET_PRIV(DSWaylandInputMethod); - - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextHideInputPanel(); - - if (__activateContext) - { - priv->hideInputPanel(__activateContext, -1); - } -} - -void DSWaylandInputMethod::contextGetSelectionText(int fd) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextGetSelectionText(fd); -} - -void DSWaylandInputMethod::contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextGetSurroundingText(maxlenBefore, maxlenAfter, fd); -} - -void DSWaylandInputMethod::contextFilterKeyEventDone(unsigned int serial, unsigned int state) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextFilterKeyEventDone(serial, state); -} - -void DSWaylandInputMethod::contextUpdateIseGeometry(unsigned int serial, unsigned int x, unsigned int y, unsigned int width, unsigned int height) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextUpdateIseGeometry(x, y, width, height); -} - -void DSWaylandInputMethod::contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextRecaptureString(serial, index, length, preedit, preeditCommit, commit); -} - -void DSWaylandInputMethod::contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextInputPanelEvent(serial, eventType, value); -} - -void DSWaylandInputMethod::contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) -{ - if (__dsTextInputPrivate) - __dsTextInputPrivate->contextCommitContent(serial, content, description, mimeTypes); -} - -void DSWaylandInputMethod::contextUpdateCandidateState(unsigned int state) -{ - if (!__dsTextInputPrivate) return; - - unsigned int prevCandidateState = __candidateState; - __candidateState = state; - - if (__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateDidHide) - { - prevCandidateState = (unsigned int)false; - } - - if (!state) - { - /* TODO: need to check g_disable_show_panel */ - if (!__candidateState && prevCandidateState) - { - __dsTextInputPrivate->contextHideInputPanel(); - } - } - else - { - /* TODO: need to check g_disable_show_panel */ - if (__candidateState && !prevCandidateState) - { - __dsTextInputPrivate->contextShowInputPanel(); - int x = 0, y = 0, w = 0, h = 0; - stGeometry geometry = __dsTextInputPrivate->inputPanelGetGeometry(nullptr); - x = geometry.x; - y = geometry.y; - w = geometry.w; - h = geometry.h; - __dsTextInputPrivate->contextUpdateIseGeometry(x, y, w, h); - } - } -} - -void DSWaylandInputMethod::contextReshowInputPanel() -{ - /* TODO: update input panel */ -} - -void DSWaylandInputMethod::setGeometryUpdated(bool updated) -{ - if (!__dsTextInputPrivate) return; - - __dsTextInputPrivate->setGeometryUpdated(updated); -} -/*LCOV_EXCL_STOP*/ - -} diff --git a/src/DSWaylandServer/DSWaylandInputMethod.h b/src/DSWaylandServer/DSWaylandInputMethod.h deleted file mode 100644 index 3610d84..0000000 --- a/src/DSWaylandServer/DSWaylandInputMethod.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_INPUT_METHOD_H__ -#define __DS_WAYLAND_INPUT_METHOD_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSWaylandCompositor.h" -#include "DSTextInputPrivate.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandInputMethodPrivate; -class DSWaylandInputMethodContext; - -class DS_DECL_EXPORT DSWaylandInputMethod : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandInputMethod); -public: - DSWaylandInputMethod(DSWaylandCompositor *compositor); - DSWaylandInputMethod(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate); - ~DSWaylandInputMethod() override; - - DSWaylandInputMethodContext* getContext(); - bool contextActivated(); - void activate(int textInputId); - void deactivate(); - void showInputPanel(int textInputId); - void hideInputPanel(int textInputId); - void openConnection(); - void closeConnection(); - void setTextInputId(int textInputId); - void resetTextInput(); - void setContentType(unsigned int hint, unsigned int purpose); - void setPreferredLanguage(const std::string language); - void commitState(unsigned int serial); - void invokeAction(unsigned int button, unsigned int index); - void setReturnKeyType(unsigned int returnKeyType); - void returnKeyDisabled(unsigned int returnKeyDisabled); - void setInputPanelData(std::string inputPanelData, unsigned int inputPanelLength); - void bidiDirection(unsigned int direction); - void setCursorPosition(unsigned int cursorPosition); - void processInputDeviceEvent(unsigned int eventType, std::string eventData, unsigned int eventLength); - void filterKeyEvent(unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode); - void setCapitalMode(unsigned int mode); - void predictionHint(std::string text); - void setMimeType(std::string type); - void finalizeContent(std::string text, unsigned int cursorPosition); - void predictionHintData(std::string key, std::string value); - - void contextCommitString(unsigned int serial, std::string text); - void contextPreeditString(unsigned int serial, std::string text, std::string commit); - void contextPreeditStyling(int index, unsigned int length, unsigned int style); - void contextPreeditCursor(int index); - void contextDeleteSurroundingText(int index, unsigned int length); - void contextCursorPosition(int index, int anchor); - void contextModifiersMap(std::string map); - void contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); - void contextLanguage(unsigned int serial, std::string language); - void contextTextDirection(unsigned int serial, unsigned int direction); - void contextSelectionRegion(unsigned int serial, int start, int end); - void contextPrivateCommand(unsigned int serial, std::string command); - void contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); - void contextHideInputPanel(unsigned int serial); - void contextGetSelectionText(int fd); - void contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); - void contextFilterKeyEventDone(unsigned int serial, unsigned int state); - void contextUpdateIseGeometry(unsigned int serial, unsigned int x, unsigned int y, unsigned int width, unsigned int height); - void contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); - void contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); - void contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); - void contextUpdateCandidateState(unsigned int state); - void contextReshowInputPanel(); - - void setGeometryUpdated(bool updated); - -protected: - -private: - DSTextInputPrivate *__dsTextInputPrivate; - DSWaylandCompositor *__compositor; - DSWaylandInputMethodContext *__inputMethodContext; - void *__activateContext; - unsigned int __candidateState; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_INPUT_METHOD_H__ diff --git a/src/DSWaylandServer/DSWaylandInputMethodContext.h b/src/DSWaylandServer/DSWaylandInputMethodContext.h deleted file mode 100644 index 94cd080..0000000 --- a/src/DSWaylandServer/DSWaylandInputMethodContext.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_INPUT_METHOD_CONTEXT_H__ -#define __DS_WAYLAND_INPUT_METHOD_CONTEXT_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandInputMethodContextPrivate; -class DSWaylandInputMethod; - -class DS_DECL_EXPORT DSWaylandInputMethodContext : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandInputMethodContext); -public: - DSWaylandInputMethodContext(DSWaylandCompositor *compositor, DSWaylandInputMethod *inputMethod); - ~DSWaylandInputMethodContext() override; - - void* createGlobal(void *client); - void sendReset(void *contextResource); - void sendContentType(void *contextResource, unsigned int hint, unsigned int purpose); - void sendPreferredLanguage(void *contextResource, const std::string language); - void sendCommitState(void *contextResource, unsigned int serial); - void sendInvokeAction(void *contextResource, unsigned int button, unsigned int index); - void sendReturnKeyType(void *contextResource, unsigned int returnKeyType); - void sendReturnKeyDisabled(void *contextResource, unsigned int returnKeyDisabled); - void sendInputPanelData(void *contextResource, std::string inputPanelData, unsigned int inputPanelLength); - void sendBidiDirection(void *contextResource, unsigned int direction); - void sendCursorPosition(void *contextResource, unsigned int cursorPosition); - void sendProcessInputDeviceEvent(void *contextResource, unsigned int eventType, std::string eventData, unsigned int eventLength); - void sendFilterKeyEvent(void *contextResource, unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode); - void sendCapitalMode(void *contextResource, unsigned int mode); - void sendPredictionHint(void *contextResource, std::string text); - void sendMimeType(void *contextResource, std::string type); - void sendFinalizedContent(void *contextResource, std::string text, unsigned int cursorPosition); - void sendPredictionHintData(void *contextResource, std::string key, std::string value); - -protected: - -private: - DSWaylandCompositor *__compositor; - DSWaylandInputMethod *__inputMethod; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_INPUT_METHOD_CONTEXT_H__ diff --git a/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h deleted file mode 100644 index 0df8a92..0000000 --- a/src/DSWaylandServer/DSWaylandInputMethodContextPrivate.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_INPUT_METHOD_CONTEXT_PRIVATE_H__ -#define __DS_WAYLAND_INPUT_METHOD_CONTEXT_PRIVATE_H__ - -#include "dswayland-server-input-method-unstable-v1.h" - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "DSWaylandInputMethodContext.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DS_DECL_EXPORT DSWaylandInputMethodContextPrivate : public DSObjectPrivate, public DSWaylandServer::zwp_input_method_context_v1 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandInputMethodContext); -public: - DSWaylandInputMethodContextPrivate(DSWaylandInputMethodContext *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandInputMethodContextPrivate() override; - - void* createGlobal(void *client); - void sendReset(void *contextResource); - void sendContentType(void *contextResource, unsigned int hint, unsigned int purpose); - void sendPreferredLanguage(void *contextResource, const std::string language); - void sendCommitState(void *contextResource, unsigned int serial); - void sendInvokeAction(void *contextResource, unsigned int button, unsigned int index); - void sendReturnKeyType(void *contextResource, unsigned int returnKeyType); - void sendReturnKeyDisabled(void *contextResource, unsigned int returnKeyDisabled); - void sendInputPanelData(void *contextResource, std::string inputPanelData, unsigned int inputPanelLength); - void sendBidiDirection(void *contextResource, unsigned int direction); - void sendCursorPosition(void *contextResource, unsigned int cursorPosition); - void sendProcessInputDeviceEvent(void *contextResource, unsigned int eventType, std::string eventData, unsigned int eventLength); - void sendFilterKeyEvent(void *contextResource, unsigned int serial, unsigned int time, std::string keyName, unsigned int state, unsigned int modifiers, std::string devName, unsigned int devClass, unsigned int devSubclass, unsigned int keycode); - void sendCapitalMode(void *contextResource, unsigned int mode); - void sendPredictionHint(void *contextResource, std::string text); - void sendMimeType(void *contextResource, std::string type); - void sendFinalizedContent(void *contextResource, std::string text, unsigned int cursorPosition); - void sendPredictionHintData(void *contextResource, std::string key, std::string value); - -protected: - void input_method_context_destroy(Resource *resource); - void input_method_context_commit_string(Resource *resource, uint32_t serial, const std::string &text); - void input_method_context_preedit_string(Resource *resource, uint32_t serial, const std::string &text, const std::string &commit); - void input_method_context_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style); - void input_method_context_preedit_cursor(Resource *resource, int32_t index); - void input_method_context_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length); - void input_method_context_cursor_position(Resource *resource, int32_t index, int32_t anchor); - void input_method_context_modifiers_map(Resource *resource, wl_array *map); - void input_method_context_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers); - void input_method_context_grab_keyboard(Resource *resource, uint32_t keyboard); - void input_method_context_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); - void input_method_context_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); - void input_method_context_language(Resource *resource, uint32_t serial, const std::string &language); - void input_method_context_text_direction(Resource *resource, uint32_t serial, uint32_t direction); - void input_method_context_selection_region(Resource *resource, uint32_t serial, int32_t start, int32_t end); - void input_method_context_private_command(Resource *resource, uint32_t serial, const std::string &command); - void input_method_context_update_input_panel_data(Resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length); - void input_method_context_hide_input_panel(Resource *resource, uint32_t serial); - void input_method_context_get_selection_text(Resource *resource, int32_t fd); - void input_method_context_get_surrounding_text(Resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd); - void input_method_context_filter_key_event_done(Resource *resource, uint32_t serial, uint32_t state); - void input_method_context_update_ise_geometry(Resource *resource, uint32_t serial, uint32_t x, uint32_t y, uint32_t width, uint32_t height); - void input_method_context_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit); - void input_method_context_input_panel_event(Resource *resource, uint32_t serial, uint32_t event_type, uint32_t value); - void input_method_context_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types); - void input_method_context_update_candidate_state(Resource *resource, uint32_t state); - void input_method_context_reshow_input_panel(Resource *resource); - -private: - DSWaylandCompositor *__compositor; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_INPUT_METHOD_CONTEXT_PRIVATE_H__ - diff --git a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h b/src/DSWaylandServer/DSWaylandInputMethodPrivate.h deleted file mode 100644 index cb4cc5d..0000000 --- a/src/DSWaylandServer/DSWaylandInputMethodPrivate.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_INPUT_METHOD_PRIVATE_H__ -#define __DS_WAYLAND_INPUT_METHOD_PRIVATE_H__ - -#include "dswayland-server-input-method-unstable-v1.h" - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "DSWaylandInputMethod.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandInputMethodContextPrivate; - -class DS_DECL_EXPORT DSWaylandInputMethodPrivate : public DSObjectPrivate, public DSWaylandServer::zwp_input_method_v1 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandInputMethod); -public: - DSWaylandInputMethodPrivate(DSWaylandInputMethod *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandInputMethodPrivate() override; - - void sendActivate(void *contextResource, int textInputId); - void sendDeactivate(void *contextResource); - void showInputPanel(void *contextResource, int textInputId); - void hideInputPanel(void *contextResource, int textInputId); - void openConnection(void *contextResource); - void closeConnection(void *contextResource); - void setTextInputId(void *contextResource, int textInputId); - int getResourceId(DSWaylandInputMethodContextPrivate::Resource *resource); - DSWaylandInputMethodContextPrivate::Resource* getResource(int id); - -protected: - void input_method_bind_resource(Resource *resource); - void input_method_destroy_resource(Resource *resource); - -private: - DSWaylandCompositor *__compositor; - Resource *__resource; - std::multimap __contextMap; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_INPUT_METHOD_PRIVATE_H__ - diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp deleted file mode 100644 index 2b63992..0000000 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ /dev/null @@ -1,692 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandInputPanel.h" -#include "DSWaylandInputPanelPrivate.h" -#include "DSWaylandInputPanelSurface.h" -#include "DSWaylandInputPanelSurfacePrivate.h" -#include "DSWaylandSurface.h" -#include "DSStruct.h" -#include "DSWindowManager.h" -#include "IDSBuffer.h" - -namespace display_server { - -/*LCOV_EXCL_START*/ -class DSWaylandInputPanelFloating -{ -public: - DSWaylandInputPanelFloating(DSWaylandInputPanel *inputPanel) - : movingRequest(false), mousePressed(false), initPortraitPos(false), initLandscapePos(false), - beforePos({0,0}), startPortraitPos({0,0}), startLandscapePos({0,0}), __inputPanel(inputPanel) {} - ~DSWaylandInputPanelFloating() {} - - void setPortraitPos(int x, int y) { startPortraitPos.x = x; startPortraitPos.y = y; initPortraitPos = true; } - void setLandscapePos(int x, int y) { startLandscapePos.x = x; startLandscapePos.y = y; initLandscapePos = true; } - - bool movingRequest; - bool mousePressed; - bool initPortraitPos; - bool initLandscapePos; - stPosition beforePos; - stPosition startPortraitPos; - stPosition startLandscapePos; - -private: - DSWaylandInputPanel *__inputPanel; -}; - -class DSWaylandInputPanelSurfaceData -{ -public: - DSWaylandInputPanelSurfaceData(DSWaylandServer::zwp_input_panel_surface_v1::Resource *resource, void *inputPanelResource) - : panel(false), showing(false), needShow(false), resizing(false), - __resource(resource), - __inputPanelResource(inputPanelResource), __wlSurface(nullptr) {} - DSWaylandInputPanelSurfaceData(DSWaylandServer::zwp_input_panel_surface_v1::Resource *resource, void *inputPanelResource, void *surfaceResource) - : panel(false), showing(false), needShow(false), resizing(false), - __resource(resource), - __inputPanelResource(inputPanelResource) { __wlSurface = DSWaylandSurface::fromWlResource((struct ::wl_resource *)surfaceResource); } - ~DSWaylandInputPanelSurfaceData() {} - - void *getInputPanelResource() {return __inputPanelResource;} - DSWaylandSurface* getWlSurface() {return __wlSurface;} - - bool panel; - bool showing; - bool needShow; - bool resizing; - -private: - DSWaylandServer::zwp_input_panel_surface_v1::Resource *__resource; - void *__inputPanelResource; - DSWaylandSurface *__wlSurface; -}; - -DSWaylandInputPanelPrivate::DSWaylandInputPanelPrivate(DSWaylandInputPanel *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), - __compositor(compositor) -{ - if (!compositor) - return; - - zwp_input_panel_v1::init(__compositor->display(), 1); -} - -DSWaylandInputPanelPrivate::~DSWaylandInputPanelPrivate() -{ -} - -void DSWaylandInputPanelPrivate::input_panel_destroy_resource(Resource *resource) -{ - DS_GET_PUB(DSWaylandInputPanel); - - pub->clearSurfaces(resource->handle); -} - -void DSWaylandInputPanelPrivate::input_panel_get_input_panel_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) -{ - DS_GET_PUB(DSWaylandInputPanel); - - pub->createSurface((void *)resource->client(), (void *)resource->handle, id, (void *)surface); -} - - -DSWaylandInputPanel::DSWaylandInputPanel(DSWaylandCompositor *compositor) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __compositor(compositor), - __dsTextInputPrivate(nullptr), - __eventLoop(nullptr), - __waitUpdate(false), - __rerunPanelShow(false), - __wlSurface(nullptr) -{ - __inputPanelSurface = new DSWaylandInputPanelSurface(__compositor, this); - __inputPanelFloating = new DSWaylandInputPanelFloating(this); - - __eventLoop = DSEventLoop::getInstance(); - __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSWaylandInputPanel::__onEventIdleEnterer, this, std::placeholders::_1)); -} - -DSWaylandInputPanel::DSWaylandInputPanel(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __compositor(compositor), - __dsTextInputPrivate(dsTextInputPrivate), - __eventLoop(nullptr), - __waitUpdate(false), - __rerunPanelShow(false), - __wlSurface(nullptr) -{ - __inputPanelSurface = new DSWaylandInputPanelSurface(__compositor, this); - __inputPanelFloating = new DSWaylandInputPanelFloating(this); - - __eventLoop = DSEventLoop::getInstance(); - __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSWaylandInputPanel::__onEventIdleEnterer, this, std::placeholders::_1)); -} - - -DSWaylandInputPanel::~DSWaylandInputPanel() -{ - DSEventLoop::releaseInstance(); - delete __inputPanelFloating; - delete __inputPanelSurface; -} - -void DSWaylandInputPanel::createSurface(void *client, void *inputPanelResource, unsigned int id, void *surface) -{ - __inputPanelSurface->createGlobal(client, inputPanelResource, id, surface); - - /* TODO: Find window from surface and set some data */ - DSWaylandSurface *wlSurface = DSWaylandSurface::fromWlResource((struct ::wl_resource *)surface); - __wlSurface = wlSurface; - - if (!wlSurface) - { - DSLOG_WRN("DSWaylandInputPanel", "%p wl_surface has no DSWaylandSurface", surface); - return; - } - - DSWindowManager *windowManager = DSWindowManager::getInstance(); - windowManager->setWindowTitle(wlSurface, "Keyboard"); - windowManager->setWindowAllowUserGeometry(wlSurface, true); - windowManager->releaseInstance(); - - wlSurface->registerCallbackSurfaceCommitted(this, std::bind(&DSWaylandInputPanel::__onSurfaceCommitted, this, std::placeholders::_1)); -} - -void DSWaylandInputPanel::clearSurfaces(void *inputPanelResource) -{ - __inputPanelSurface->clearGlobals(inputPanelResource); -} - -bool DSWaylandInputPanel::getWaitUpdate() -{ - return __waitUpdate; -} - -void DSWaylandInputPanel::setWaitUpdate(bool waitUpdate) -{ - __waitUpdate = waitUpdate; -} - -void DSWaylandInputPanel::updateInputPanelState(bool waitUpdate) -{ - __waitUpdate = waitUpdate; - - if (__waitUpdate) - { - /* TODO: Add Timer */ - __inputPanelSurface->flushFrame(); - /* TODO: Add buffer change event handler */ - } - else - { - /* TODO: remove buffer change event handler */ - } -} - -bool DSWaylandInputPanel::getRerunPanelShow() -{ - return __rerunPanelShow; -} - -void DSWaylandInputPanel::setRerunPanelShow(bool needShow) -{ - __rerunPanelShow = needShow; -} - -void DSWaylandInputPanel::setFloatingMovingRequest(bool enabled) -{ - if (!__inputPanelFloating) return; - - __inputPanelFloating->movingRequest = enabled; -} - -void DSWaylandInputPanel::setTransientFor(DSWaylandSurface *parent) -{ - DSWaylandSurface *curParent = parent; - if (curParent) - { - /* TODO: - * if curParent->remoteSurface.onScreenParent - * curParent = curParent->remoteSurface.onScreenParent - */ - } - - __inputPanelSurface->setTransientForSurface(curParent); -} - -void DSWaylandInputPanel::changeVisibility(bool visible) -{ - __rerunPanelShow = visible; - //vconf_set_int (VCONFKEY_ISF_INPUT_PANEL_STATE, visible ? VCONFKEY_ISF_INPUT_PANEL_STATE_SHOW : VCONFKEY_ISF_INPUT_PANEL_STATE_HIDE); - __inputPanelSurface->updateSurfaceVisibility(visible); - /* TODO: delete waitTimer */ -} - -bool DSWaylandInputPanel::isEffectRunning(DSWaylandSurface *window) -{ - /* TODO: - * if window is animating - * return true - */ - return false; -} - -void DSWaylandInputPanel::setFloatingPosition(int x, int y) -{ - __inputPanelSurface->setFloatingPosition(x, y); -} - -DSWaylandInputPanelFloating* DSWaylandInputPanel::getFloatingData() -{ - return __inputPanelFloating; -} - -stGeometry DSWaylandInputPanel::getSurfaceGeometry(DSWaylandSurface *wlSurface) -{ - return __inputPanelSurface->getGeometry(wlSurface); -} - -void DSWaylandInputPanel::updateTextInputPanelState(bool state) -{ - if (!__dsTextInputPrivate) return; - - __dsTextInputPrivate->updateTextInputPanelState(state); -} - -DSWaylandSurface *DSWaylandInputPanel::getTextInputSurface() -{ - if (!__dsTextInputPrivate) return nullptr; - - return __dsTextInputPrivate->getTextInputSurface(); -} - -void DSWaylandInputPanel::__onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo) -{ - if (!waylandSurfaceCommitInfo->bufferChanged()) - return; - - std::shared_ptr buffer = waylandSurfaceCommitInfo->getBuffer(); - std::shared_ptr bufferSize = buffer->getSize(); - - DSWindowManager *windowManager = DSWindowManager::getInstance(); - stGeometry geo = windowManager->getWindowGeometry(__wlSurface); - - /* FIXME: This calc is only for 0 angle. Use others calc if window is rotated */ - int nx = geo.x + (geo.w - bufferSize->w) / 2; - int ny = geo.y + geo.h - bufferSize->h; - - windowManager->setWindowGeometry(__wlSurface, nx, ny, bufferSize->w, bufferSize->h); - windowManager->releaseInstance(); -} - -void DSWaylandInputPanel::__onEventIdleEnterer(void *data) -{ -} - - -DSWaylandInputPanelSurfacePrivate::DSWaylandInputPanelSurfacePrivate(DSWaylandInputPanelSurface *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), - __compositor(compositor) -{ -} - -DSWaylandInputPanelSurfacePrivate::~DSWaylandInputPanelSurfacePrivate() -{ -} - -void DSWaylandInputPanelSurfacePrivate::createGlobal(void *client, void *inputPanelResource, unsigned int id, void *surface) -{ - Resource *resource = add((struct ::wl_client *)client, id, 1); - __appendSurface(resource, inputPanelResource, surface); -} - -void DSWaylandInputPanelSurfacePrivate::clearGlobals(void *inputPanelResource) -{ - for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) - { - DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - if (surfaceData->getInputPanelResource() == inputPanelResource) - { - it = __dataMap.erase(it); - /* TODO: clear window's data */ - } - } -} - -void DSWaylandInputPanelSurfacePrivate::flushFrame() -{ - for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) - { - DSWaylandInputPanelSurfaceData *_surfaceData = (*it).second; - if (_surfaceData->getWlSurface()) - { - /* TODO: clear pixmap image */ - } - } -} - -void DSWaylandInputPanelSurfacePrivate::show(DSWaylandInputPanelSurfaceData *surfaceData) -{ - DS_GET_PUB(DSWaylandInputPanelSurface); - -#if false - if (!surfaceData) - { - for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) - { - DSWaylandInputPanelSurfaceData *data = (*it).second; - if (!data) continue; - - DSWaylandSurface *wlSurface = data->getWlSurface(); - if (wlSurface->parent == DSKeyboard::getFocus()) - { - surfaceData = data; - break; - } - } - } -#endif - - if (!surfaceData) return; - - if (pub->__inputPanel->getWaitUpdate()) - { - pub->__inputPanel->setWaitUpdate(false); - pub->__inputPanel->changeVisibility(true); - pub->__inputPanel->updateTextInputPanelState(true); - /* TODO: - * if (getfocus(surfaceData->getWlSurface())->parent) - * { - * if (getfocus(surfaceData->getWlSurface())->parent == focused) - * { - * pub->__inputPanel->visibilityChange(true); - * pub->__inputPanel->updateInputPanelState(true); - * } - * else - * pub->__inputPanel->visibilityChange(false); - * } - * else - * pub->__inputPanel->visibilityChange(false); - */ - } -} - -void DSWaylandInputPanelSurfacePrivate::directShow(DSWaylandInputPanelSurfaceData *surfaceData) -{ - DS_GET_PUB(DSWaylandInputPanelSurface); - - pub->setPosition(nullptr, 0, 0); /* FIXME: set correct value */ - DSWindowManager *windowManager = DSWindowManager::getInstance(); - windowManager->activateWindow(surfaceData->getWlSurface()); - - windowManager->releaseInstance(); - - /* TODO: change window geometry */ -} - -void DSWaylandInputPanelSurfacePrivate::setTransientForSurface(DSWaylandSurface *parent) -{ - for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) - { - DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - DSWaylandSurface *child = surfaceData->getWlSurface(); - - // TODO: if current child has parent reset this - - DSWindowManager *windowManager = DSWindowManager::getInstance(); - windowManager->setWindowParent(child, parent); - windowManager->releaseInstance(); - } -} - -void DSWaylandInputPanelSurfacePrivate::updateSurfaceVisibility(bool visible) -{ - for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) - { - DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - surfaceData->showing = visible; - __updateSurfaceVisibility(surfaceData); - } -} - -void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y) -{ - DS_GET_PUB(DSWaylandInputPanelSurface); - DSWaylandInputPanelSurfaceData *floatingData = nullptr; - DSWaylandInputPanelFloating *inputPanelFloating; - - for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) - { - //DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - - /* TODO: - * if vkbd.floating - * floatingData = surfaceData - */ - } - - inputPanelFloating = pub->__inputPanel->getFloatingData(); - (void) inputPanelFloating; - (void) floatingData; - -#if 0//Unreachable code ! Thus, disable temporarily. - if (!floatingData || !inputPanelFloating) return; - - int curAngle = 0; - - /* TODO: - * if (floatingData->showing) - * curAngle = get ec angle - * else - * curAngle = get zone angle - */ - - switch (curAngle) - { - case 90: - case 270: - inputPanelFloating->setLandscapePos(x, y); - //__inputPanelFloating->startLandscapePos.x = x; - //__inputPanelFloating->startLandscapePos.y = y; - //__inputPanelFloating->initLandscapePos = true; - break; -// case 0: -// case 180: - default: - inputPanelFloating->setPortraitPos(x, y); - //__inputPanelFloating->startPortraitPos.x = x; - //__inputPanelFloating->startPortraitPos.y = y; - //__inputPanelFloating->initPortraitPos = true; - break; - } - - if (floatingData->showing) - pub->setPosition(nullptr, 0, 0); /* FIXME: set correct window and data */ -#endif -} - -stGeometry DSWaylandInputPanelSurfacePrivate::getGeometry(DSWaylandSurface *wlSurface) -{ - DSWindowManager *windowManager = DSWindowManager::getInstance(); - stGeometry geometry = {0, }; - for (auto it = __dataMap.begin(); it != __dataMap.end(); it++) - { - DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - if (!wlSurface || (wlSurface == surfaceData->getWlSurface())) - { - return windowManager->getWindowGeometry(surfaceData->getWlSurface()); - } - } - windowManager->releaseInstance(); - return geometry; -} - -void DSWaylandInputPanelSurfacePrivate::input_panel_surface_destroy_resource(Resource *resource) -{ - auto it = __dataMap.find(resource); - if (it != __dataMap.end()) - { - DSWaylandInputPanelSurfaceData *destroyData = (*it).second; - delete destroyData; - __dataMap.erase(resource); - } -} - -void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_toplevel(Resource *resource, struct ::wl_resource *output, uint32_t position) -{ - /* TODO? If this surface is not included in __dataMap, add this surface */ - - auto it = __dataMap.find(resource); - if (it != __dataMap.end()) - { - DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - surfaceData->panel = true; - } -} - -void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_overlay_panel(Resource *resource) -{ - /* TODO? If this surface is not included in __dataMap, add this surface */ - - auto it = __dataMap.find(resource); - if (it != __dataMap.end()) - { - DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - surfaceData->panel = true; - } -} - -void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_ready(Resource *resource, uint32_t state) -{ - auto it = __dataMap.find(resource); - if (it != __dataMap.end()) - { - DSWaylandInputPanelSurfaceData *surfaceData = (*it).second; - /* TODO: find DSWaylandSurface and update base_output resolution */ - show(surfaceData); - } -} - -void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_floating_panel(Resource *resource, uint32_t state) -{ - /* TODO: - * set DSWaylandSurface's vkbd.floating = !!state - * if true - * policy_conformant_part_del - * else - * policy_conformant_part_add - */ -} - -void DSWaylandInputPanelSurfacePrivate::input_panel_surface_set_floating_drag_enabled(Resource *resource, uint32_t enabled) -{ - DS_GET_PUB(DSWaylandInputPanelSurface); - - pub->__inputPanel->setFloatingMovingRequest(!!enabled); -} - -void DSWaylandInputPanelSurfacePrivate::__updateSurfaceVisibility(DSWaylandInputPanelSurfaceData *surfaceData) -{ - DS_GET_PUB(DSWaylandInputPanelSurface); - - if (surfaceData->showing) /* TODO: check pixmap is usable too*/ - { - if (pub->__inputPanel->getRerunPanelShow()) - pub->__inputPanel->setRerunPanelShow(false); - if (pub->isEffectRunning(nullptr)) // FIXME: change this to get window surfaceData->getDSWaylandSurface() - surfaceData->needShow = true; - else if (surfaceData->resizing) - surfaceData->needShow = true; - else - { - directShow(surfaceData); - surfaceData->needShow = false; - } - } - else - { - /* TODO: - * change window's property - */ - surfaceData->needShow = false; - } -} - -void DSWaylandInputPanelSurfacePrivate::__appendSurface(Resource *resource, void *inputPanelResource, void *surface) -{ - DS_GET_PUB(DSWaylandInputPanelSurface); - DSWaylandInputPanelSurfaceData *data = new DSWaylandInputPanelSurfaceData(resource, inputPanelResource, surface); - __dataMap.insert(std::pair(resource, data)); - - DSWaylandSurface *textInputSurface = pub->__inputPanel->getTextInputSurface(); - - if (textInputSurface) - { - pub->__inputPanel->setTransientFor(textInputSurface); - } - - if (pub->__inputPanel->getRerunPanelShow()) - { - pub->__inputPanel->changeVisibility(true); - } -} - - -DSWaylandInputPanelSurface::DSWaylandInputPanelSurface(DSWaylandCompositor *compositor, DSWaylandInputPanel *inputPanel) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __compositor(compositor), - __inputPanel(inputPanel) -{ -} - -DSWaylandInputPanelSurface::~DSWaylandInputPanelSurface() -{ -} - -void DSWaylandInputPanelSurface::createGlobal(void *client, void *inputPanelResource, unsigned int id, void *surface) -{ - DS_GET_PRIV(DSWaylandInputPanelSurface); - - if (!client || !inputPanelResource || !surface) return; - - priv->createGlobal(client, inputPanelResource, id, surface); -} - -void DSWaylandInputPanelSurface::clearGlobals(void *inputPanelResource) -{ - DS_GET_PRIV(DSWaylandInputPanelSurface); - - if (!inputPanelResource) return; - - priv->clearGlobals(inputPanelResource); -} - -void DSWaylandInputPanelSurface::flushFrame() -{ - DS_GET_PRIV(DSWaylandInputPanelSurface); - - priv->flushFrame(); -} - -void DSWaylandInputPanelSurface::setTransientForSurface(DSWaylandSurface *parent) -{ - DS_GET_PRIV(DSWaylandInputPanelSurface); - - priv->setTransientForSurface(parent); -} - -void DSWaylandInputPanelSurface::updateSurfaceVisibility(bool visible) -{ - DS_GET_PRIV(DSWaylandInputPanelSurface); - - priv->updateSurfaceVisibility(visible); -} - -bool DSWaylandInputPanelSurface::isEffectRunning(DSWaylandSurface *window) -{ - return __inputPanel->isEffectRunning(window); -} - -void DSWaylandInputPanelSurface::setPosition(DSWaylandSurface *window, int width, int height) -{ -} - -void DSWaylandInputPanelSurface::setFloatingPosition(int x, int y) -{ - DS_GET_PRIV(DSWaylandInputPanelSurface); - - priv->setFloatingPosition(x, y); -} - -stGeometry DSWaylandInputPanelSurface::getGeometry(DSWaylandSurface *wlSurface) -{ - DS_GET_PRIV(DSWaylandInputPanelSurface); - - return priv->getGeometry(wlSurface); -} -/*LCOV_EXCL_STOP*/ - -} - diff --git a/src/DSWaylandServer/DSWaylandInputPanel.h b/src/DSWaylandServer/DSWaylandInputPanel.h deleted file mode 100644 index c65ec60..0000000 --- a/src/DSWaylandServer/DSWaylandInputPanel.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_INPUT_PANEL_H__ -#define __DS_WAYLAND_INPUT_PANEL_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSStruct.h" -#include "DSWaylandCompositor.h" -#include "DSEventLoop.h" -#include "DSTextInputPrivate.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandInputPanelPrivate; -class DSWaylandInputPanelSurface; -class DSWaylandInputPanelFloating; -class DSWaylandSurface; -class DSWaylandSurfaceCommitInfo; - -class DS_DECL_EXPORT DSWaylandInputPanel : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandInputPanel); -public: - DSWaylandInputPanel(DSWaylandCompositor *compositor); - DSWaylandInputPanel(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate); - ~DSWaylandInputPanel() override; - - void createSurface(void *client, void *inputPanelResource, unsigned int id, void *surface); - void clearSurfaces(void *inputPanelResource); - bool getWaitUpdate(); - void setWaitUpdate(bool waitUpdate); - void updateInputPanelState(bool waitUpdate); - bool getRerunPanelShow(); - void setRerunPanelShow(bool needShow); - - void setFloatingMovingRequest(bool enabled); - void setTransientFor(DSWaylandSurface *parent); - void changeVisibility(bool visible); - bool isEffectRunning(DSWaylandSurface *window); - void setFloatingPosition(int x, int y); - DSWaylandInputPanelFloating *getFloatingData(); - stGeometry getSurfaceGeometry(DSWaylandSurface *wlSurface); - void updateTextInputPanelState(bool state); - DSWaylandSurface *getTextInputSurface(); - -private: - DSWaylandCompositor *__compositor; - DSTextInputPrivate *__dsTextInputPrivate; - DSEventLoop *__eventLoop; - DSWaylandInputPanelSurface *__inputPanelSurface; - DSWaylandInputPanelFloating *__inputPanelFloating; - bool __waitUpdate; - bool __rerunPanelShow; - DSWaylandSurface *__wlSurface; - - void __onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo); - void __onEventIdleEnterer(void *data); -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_INPUT_PANEL_H__ diff --git a/src/DSWaylandServer/DSWaylandInputPanelPrivate.h b/src/DSWaylandServer/DSWaylandInputPanelPrivate.h deleted file mode 100644 index b58135a..0000000 --- a/src/DSWaylandServer/DSWaylandInputPanelPrivate.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_INPUT_PANEL_PRIVATE_H__ -#define __DS_WAYLAND_INPUT_PANEL_PRIVATE_H__ - -#include "dswayland-server-input-method-unstable-v1.h" - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "DSWaylandInputPanel.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DS_DECL_EXPORT DSWaylandInputPanelPrivate : public DSObjectPrivate, public DSWaylandServer::zwp_input_panel_v1 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandInputPanel); -public: - DSWaylandInputPanelPrivate(DSWaylandInputPanel *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandInputPanelPrivate() override; - -protected: - void input_panel_destroy_resource(Resource *resource); - void input_panel_get_input_panel_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); - -private: - DSWaylandCompositor *__compositor; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_INPUT_PANEL_PRIVATE_H__ - diff --git a/src/DSWaylandServer/DSWaylandInputPanelSurface.h b/src/DSWaylandServer/DSWaylandInputPanelSurface.h deleted file mode 100644 index 825cb57..0000000 --- a/src/DSWaylandServer/DSWaylandInputPanelSurface.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_INPUT_PANEL_SURFACE_H__ -#define __DS_WAYLAND_INPUT_PANEL_SURFACE_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSStruct.h" -#include "DSWaylandInputPanel.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandInputPanelSurfacePrivate; -class DSWaylandSurface; - -class DS_DECL_EXPORT DSWaylandInputPanelSurface : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandInputPanelSurface); -public: - DSWaylandInputPanelSurface(DSWaylandCompositor *compositor, DSWaylandInputPanel *inputPanel); - ~DSWaylandInputPanelSurface() override; - - void createGlobal(void *client, void *inputPanelResource, unsigned int id, void *surface); - void clearGlobals(void *inputPanelResource); - void flushFrame(); - void setTransientForSurface(DSWaylandSurface *parent); - void updateSurfaceVisibility(bool visible); - bool isEffectRunning(DSWaylandSurface *window); - void setPosition(DSWaylandSurface *window, int width, int height); - void setFloatingPosition(int x, int y); - stGeometry getGeometry(DSWaylandSurface *wlSurface); - -protected: - -private: - DSWaylandCompositor *__compositor; - DSWaylandInputPanel *__inputPanel; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_INPUT_PANEL_SURFACE_H__ diff --git a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h b/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h deleted file mode 100644 index 8edd342..0000000 --- a/src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_INPUT_PANEL_SURFACE_PRIVATE_H__ -#define __DS_WAYLAND_INPUT_PANEL_SURFACE_PRIVATE_H__ - -#include "dswayland-server-input-method-unstable-v1.h" - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "DSStruct.h" -#include "DSWaylandInputPanelSurface.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandInputPanelSurfaceData; - -class DS_DECL_EXPORT DSWaylandInputPanelSurfacePrivate : public DSObjectPrivate, public DSWaylandServer::zwp_input_panel_surface_v1 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandInputPanelSurface); -public: - DSWaylandInputPanelSurfacePrivate(DSWaylandInputPanelSurface *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandInputPanelSurfacePrivate() override; - - void createGlobal(void *client, void *inputPanelResource, unsigned int id, void *surface); - void clearGlobals(void *inputPanelResource); - - void show(DSWaylandInputPanelSurfaceData *surfaceData); - void directShow(DSWaylandInputPanelSurfaceData *surfaceData); - void flushFrame(); - void setTransientForSurface(DSWaylandSurface *parent); - void updateSurfaceVisibility(bool visible); - void setFloatingPosition(int x, int y); - stGeometry getGeometry(DSWaylandSurface *wlSurface); - -protected: - void input_panel_surface_destroy_resource(Resource *resource); - - void input_panel_surface_set_toplevel(Resource *resource, struct ::wl_resource *output, uint32_t position); - void input_panel_surface_set_overlay_panel(Resource *resource); - void input_panel_surface_set_ready(Resource *resource, uint32_t state); - void input_panel_surface_set_floating_panel(Resource *resource, uint32_t state); - void input_panel_surface_set_floating_drag_enabled(Resource *resource, uint32_t enabled); - -private: - DSWaylandCompositor *__compositor; - std::multimap __dataMap; - - void __updateSurfaceVisibility(DSWaylandInputPanelSurfaceData *surfaceData); - void __appendSurface(Resource *resource, void *inputPanelResource, void *surface); -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_INPUT_PANEL_SURFACE_PRIVATE_H__ - diff --git a/src/DSWaylandServer/DSWaylandKeyboard.cpp b/src/DSWaylandServer/DSWaylandKeyboard.cpp deleted file mode 100644 index f61bba7..0000000 --- a/src/DSWaylandServer/DSWaylandKeyboard.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandKeyboard.h" -#include "DSWaylandKeyboardPrivate.h" -#include "DSWaylandClient.h" -#include "DSWaylandSeat.h" -#include "DSWaylandSurface.h" -#include "DSWaylandCompositor.h" -#include "DSXkb.h" - -#include - -namespace display_server -{ - -/* Begin Private Class Implementation */ -DSWaylandKeyboardPrivate::DSWaylandKeyboardPrivate(DSWaylandSeat *seat, DSWaylandKeyboard *keyboard) - : DSObjectPrivate(keyboard), - __p_ptr(keyboard), - __seat(seat), - __xkb(seat ? (seat->getXkb()) : nullptr), - __compositor(seat ? (seat->getCompositor()) : nullptr), - __focusSurface(nullptr), - __focusClient(nullptr), - __repeatRate(0), - __repeatDelay(0) -{ - if (__xkb) - { - __fdKeymap = __xkb->getKeymapFd(); - __fdKeymapSize = __xkb->getKeymapSize(); - __formatKeymap = WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1; - __depressed = __xkb->getModifierDepressed(); - __latched = __xkb->getModifierLatched(); - __locked = __xkb->getModifierLocked(); - __group = __xkb->getModifierGroup(); - } - else - { - /* open fd of null keymap */ - __fdKeymap = open("/dev/null", O_RDONLY); - __fdKeymapSize = 0; - __formatKeymap = WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP; - __depressed = 0; - __latched = 0; - __locked = 0; - __group = 0; - } - - DSLOG_INF("DSWaylandKeyboardPrivate", "__fdKeymap=%d, __fdKeymapSize=%d, __formatKeymap=%d", - __fdKeymap, __fdKeymapSize, __formatKeymap); - - wl_keyboard(); - wl_array_init(&__keys); -} - -DSWaylandKeyboardPrivate::~DSWaylandKeyboardPrivate() -{ - if (__fdKeymap >= 0) - close(__fdKeymap); - - wl_array_release(&__keys); -} - -/*LCOV_EXCL_START*/ -void DSWaylandKeyboardPrivate::keyboard_bind_resource(Resource *resource) -{ - DSLOG_INF("DSWaylandKeyboardPrivate",""); - - sendKeymap(resource); - sendRepeatInfo(resource); - - if (__focusSurface && __focusSurface->hasResource()) - { - DSLOG_INF("DSWaylandKeyboardPrivate", "Send enter to focusSurface(%p)", __focusSurface); - sendEnter(__focusSurface->getWlResource()); - } -} - -void DSWaylandKeyboardPrivate::keyboard_destroy_resource(Resource *resource) -{ - DSLOG_INF("DSWaylandKeyboardPrivate",""); -} - -void DSWaylandKeyboardPrivate::keyboard_release(Resource *resource) -{ - DSLOG_INF("DSWaylandKeyboardPrivate",""); - wl_resource_destroy(resource->handle); -} - -void DSWaylandKeyboardPrivate::sendKeymap(Resource *resource) -{ - send_keymap(resource->handle, __formatKeymap, __fdKeymap, __fdKeymapSize); -} - -void DSWaylandKeyboardPrivate::sendRepeatInfo(Resource *resource) -{ - if (WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION > resource->version()) - return; - - send_repeat_info(resource->handle, __repeatRate, __repeatDelay); -} - -void DSWaylandKeyboardPrivate::sendEnter(struct ::wl_resource *surface) -{ - auto client = wl_resource_get_client(surface); - auto resMap = resourceMap(); - auto func = [&](std::pair res) - { - if (res.first == client) - { - send_enter(res.second->handle, __compositor->nextSerial(), surface, &__keys); - } - }; - - std::for_each(resMap.begin(), resMap.end(), func); - - //TODO : send key press event(s) of the pressed key(s) to current focus window -} - -void DSWaylandKeyboardPrivate::sendLeave(struct ::wl_resource *surface) -{ - auto client = wl_resource_get_client(surface); - auto resMap = resourceMap(); - auto func = [&](std::pair res) - { - if (res.first == client) - { - send_leave(res.second->handle, __compositor->nextSerial(), surface); - } - }; - - //TODO : send key release events of the pressed keys to current focus window - - std::for_each(resMap.begin(), resMap.end(), func); -} - -void DSWaylandKeyboardPrivate::sendModifiers(struct ::wl_resource *surface) -{ - bool need_send = false; - uint32_t mod = 0; - - if (!__xkb) - return; - - mod = __xkb->getModifierDepressed(); - need_send |= (__depressed != mod); - __depressed = mod; - - mod = __xkb->getModifierLatched(); - need_send |= (__latched != mod); - __latched = mod; - - mod = __xkb->getModifierLocked(); - need_send |= (__locked != mod); - __locked = mod; - - mod = __xkb->getModifierGroup(); - need_send |= (__group != mod); - __group = mod; - - if (!need_send) - return; - - auto client = wl_resource_get_client(surface); - auto resMap = resourceMap(); - auto func = [&](std::pair res) - { - if (res.first == client) - { - send_modifiers(res.second->handle, __compositor->nextSerial(), __depressed, __latched, __locked, __group); - } - }; - std::for_each(resMap.begin(), resMap.end(), func); -} - -void DSWaylandKeyboardPrivate::sendKey(uint32_t key, uint32_t state) -{ - if (!__focusSurface) - { - DSLOG_INF("DSWaylandKeyboardPrivate", "No focusSurface !"); - return; - } - - auto resMap = resourceMap(); - auto func = [&](std::pair res) - { - if (res.first == __focusClient) - send_key(res.second->handle, __compositor->nextSerial(), __seat->getCurrentEventTime(), key - 8, state); - }; - std::for_each(resMap.begin(), resMap.end(), func); -} - -void DSWaylandKeyboardPrivate::__addClient(struct ::wl_client *wlClient, uint32_t id, int version) -{ - wl_keyboard::add(wlClient, id, version); - - if (__focusSurface && __focusSurface->hasResource()) - { - DSWaylandClient *waylandClient = __focusSurface->getClient(); - if (waylandClient && (waylandClient->wlClient() == wlClient)) - { - DSLOG_INF("DSWaylandKeyboardPrivate", "Send enter to focusSurface(%p)", __focusSurface); - sendEnter(__focusSurface->getWlResource()); - } - } -} -/*LCOV_EXCL_STOP*/ - -/* Begin Public Class Implementation */ -DSWaylandKeyboard::DSWaylandKeyboard(DSWaylandSeat *seat) - : DSObject(), _d_ptr(std::make_unique(seat, this)) -{ - //TODO : emit signal -} - -DSWaylandKeyboard::~DSWaylandKeyboard() -{ - //TODO : emit signal -} - -DSWaylandSeat *DSWaylandKeyboard::seat() -{ - DS_GET_PRIV(DSWaylandKeyboard); - - return priv->__seat; -} - -void DSWaylandKeyboard::setRepeatRate(uint32_t rate) -{ - DS_GET_PRIV(DSWaylandKeyboard); - - priv->__repeatRate = rate; -} - -void DSWaylandKeyboard::setRepeatDelay(uint32_t delay) -{ - DS_GET_PRIV(DSWaylandKeyboard); - - priv->__repeatDelay = delay; -} - -uint32_t DSWaylandKeyboard::repeatRate(void) -{ - DS_GET_PRIV(DSWaylandKeyboard); - - return priv->__repeatRate; -} - -uint32_t DSWaylandKeyboard::repeatDelay(void) -{ - DS_GET_PRIV(DSWaylandKeyboard); - - return priv->__repeatDelay; -} - -void DSWaylandKeyboard::addClient(DSWaylandClient *client, uint32_t id, int version) -{ - DS_GET_PRIV(DSWaylandKeyboard); - - DSLOG_INF("DSWaylandKeyboard", "addClient(dswlClient=%p, id=%u, version=%d", client, id, version); - - priv->__addClient(client->wlClient(), id, version); -} - -void DSWaylandKeyboard::setFocus(DSWaylandSurface *waylandSurface) -{ - DS_GET_PRIV(DSWaylandKeyboard); - - if (priv->__focusSurface != waylandSurface) - { - if (priv->__focusSurface && priv->__focusSurface->hasResource()) - { - struct ::wl_resource *surfaceToLeave = priv->__focusSurface->getWlResource(); - priv->sendModifiers(surfaceToLeave); - priv->sendLeave(surfaceToLeave); - } - - if (waylandSurface && waylandSurface->hasResource()) - { - struct ::wl_resource *surfaceToEnter = waylandSurface->getWlResource(); - priv->sendEnter(surfaceToEnter); - - priv->__focusSurface = waylandSurface; - priv->__focusClient = wl_resource_get_client(waylandSurface->getWlResource()); - } - } -} - -void DSWaylandKeyboard::resetFocus() -{ - DS_GET_PRIV(DSWaylandKeyboard); - priv->__focusSurface = nullptr; - priv->__focusClient = nullptr; -} - -DSWaylandSurface *DSWaylandKeyboard::getFocus() -{ - DS_GET_PRIV(DSWaylandKeyboard); - return priv->__focusSurface; -} - -void DSWaylandKeyboard::sendKeyDown(uint32_t keycode) -{ - DS_GET_PRIV(DSWaylandKeyboard); - priv->sendKey(keycode, WL_KEYBOARD_KEY_STATE_PRESSED); - - if (priv->__focusSurface) - priv->sendModifiers(priv->__focusSurface->getWlResource()); -} - -void DSWaylandKeyboard::sendKeyUp(uint32_t keycode) -{ - DS_GET_PRIV(DSWaylandKeyboard); - priv->sendKey(keycode, WL_KEYBOARD_KEY_STATE_RELEASED); - - if (priv->__focusSurface) - priv->sendModifiers(priv->__focusSurface->getWlResource()); -} - -} diff --git a/src/DSWaylandServer/DSWaylandKeyboard.h b/src/DSWaylandServer/DSWaylandKeyboard.h deleted file mode 100644 index 1a577b9..0000000 --- a/src/DSWaylandServer/DSWaylandKeyboard.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_KEYBOARD_H__ -#define __DS_WAYLAND_KEYBOARD_H__ - -#include "DSCore.h" -#include "DSObject.h" - -namespace display_server -{ - -class DSWaylandSeat; -class DSWaylandKeyboardPrivate; -class DSWaylandClient; -class DSWaylandSurface; - -class DS_DECL_EXPORT DSWaylandKeyboard : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWaylandKeyboard); -public: - DSWaylandKeyboard(DSWaylandSeat *seat); - ~DSWaylandKeyboard() override; - - DSWaylandSeat *seat(); - - void setRepeatRate(uint32_t rate); - void setRepeatDelay(uint32_t delay); - uint32_t repeatRate(void); - uint32_t repeatDelay(void); - - void addClient(DSWaylandClient *client, uint32_t id, int version); - void setFocus(DSWaylandSurface *waylandSurface); - void resetFocus(); - DSWaylandSurface *getFocus(); - - void sendKeyDown(uint32_t keycode); - void sendKeyUp(uint32_t keycode); - -protected: - -private: - -}; - -} - -#endif //__DS_WAYLAND_KEYBOARD_H__ diff --git a/src/DSWaylandServer/DSWaylandKeyboardPrivate.h b/src/DSWaylandServer/DSWaylandKeyboardPrivate.h deleted file mode 100644 index 48f4665..0000000 --- a/src/DSWaylandServer/DSWaylandKeyboardPrivate.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_KEYBOARD_PRIVATE_H__ -#define __DS_WAYLAND_KEYBOARD_PRIVATE_H__ - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "dswayland-server-wayland.h" -#include "wayland-util.h" - -struct wl_client; -struct wl_array; - -namespace display_server -{ - -class DSXkb; -class DSWaylandSeat; -class DSWaylandSurface; -class DSWaylandCompositor; - -class DS_DECL_EXPORT DSWaylandKeyboardPrivate : public DSObjectPrivate, public DSWaylandServer::wl_keyboard -{ - DS_PIMPL_USE_PUBLIC(DSWaylandKeyboard); -public: - DSWaylandKeyboardPrivate(DSWaylandSeat *seat, DSWaylandKeyboard *keyboard); - ~DSWaylandKeyboardPrivate() override; - - //TO DO - -protected: - //virtual Resource *keyboard_allocate(); - virtual void keyboard_bind_resource(Resource *resource); - virtual void keyboard_destroy_resource(Resource *resource); - virtual void keyboard_release(Resource *resource); - - /* APIs must be provided */ - void sendKey(uint32_t key, uint32_t state); - void sendKeymap(Resource *resource); - void sendRepeatInfo(Resource *resource); - void sendEnter(struct ::wl_resource *surface); - void sendLeave(struct ::wl_resource *surface); - void sendModifiers(struct ::wl_resource *surface); - -private: - void __addClient(struct ::wl_client *wlClient, uint32_t id, int version); - - DSWaylandSeat *__seat; - DSXkb *__xkb; - DSWaylandCompositor *__compositor; - DSWaylandSurface *__focusSurface; - struct ::wl_client *__focusClient; - - uint32_t __repeatRate; - uint32_t __repeatDelay; - struct ::wl_array __keys; - - int __fdKeymap; - uint32_t __fdKeymapSize; - uint32_t __formatKeymap; - - /* modifiers status */ - uint32_t __depressed; - uint32_t __latched; - uint32_t __locked; - uint32_t __group; -}; - -} - -#endif //__DS_WAYLAND_KEYBOARD_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandOutput.cpp b/src/DSWaylandServer/DSWaylandOutput.cpp deleted file mode 100644 index a0f5f7a..0000000 --- a/src/DSWaylandServer/DSWaylandOutput.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandOutput.h" -#include "DSWaylandOutputPrivate.h" -#include "DSWaylandClient.h" -#include "DSTizenAppinfoMgr.h" - -namespace display_server -{ - -DSWaylandOutputPrivate::DSWaylandOutputPrivate(DSWaylandOutput *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __outputRect({0,0,0,0}), - __phyWidth(0), - __phyHeight(0), - __refresh(0), - __subpixel(0), - __transform(0), - __scale(1.0) -{ - if (!compositor) return; - - wl_output::init(compositor->display(), 3); -} - -DSWaylandOutputPrivate::~DSWaylandOutputPrivate() -{ -} - -/*LCOV_EXCL_START*/ -void DSWaylandOutputPrivate::output_bind_resource(wl_output::Resource *resource) -{ - DSLOG_DBG("DSWaylandOutputPriv", ""); - int res_w, res_h; - - /* TODO: if the config of configured_output_resolution.use is set, use the congigured resolution values */ - //if (e_config->configured_output_resolution.use) - //{ - if (!getBaseResolutionFromAppinfo(resource, &res_w, &res_h)) { - /* TODO: Read configured resolution values */ - } - //} - //else - //{ - res_w = __outputRect.w; - res_h = __outputRect.h; - //} - sendWaylandOutputInfo(resource, res_w, res_h); -} - -void DSWaylandOutputPrivate::output_destroy_resource(Resource *resource) -{ -} - -void DSWaylandOutputPrivate::output_release(wl_output::Resource *resource) -{ -} - -void DSWaylandOutputPrivate::sendWaylandOutputInfo(Resource *resource) -{ - DSLOG_DBG("DSWaylandOutputPriv", "outputRect.x,y,w,h: (%d,%d,%d,%d), phyWidth,Height: (%d,%d)", __outputRect.x, __outputRect.y, __outputRect.w, __outputRect.h, __phyWidth, __phyHeight); - wl_output::send_scale(resource->handle, __scale); - wl_output::send_geometry(resource->handle, __outputRect.x, __outputRect.y, __phyWidth, __phyHeight, __subpixel, __make, __model, __transform); - wl_output::send_mode(resource->handle, mode_current | mode_preferred, __outputRect.w, __outputRect.h, __refresh); - wl_output::send_done(resource->handle); -} - -void DSWaylandOutputPrivate::sendWaylandOutputInfo(Resource *resource, int res_w, int res_h) -{ - DSLOG_DBG("DSWaylandOutputPriv", "resolution width,hight: (%d,%d)", res_w, res_h); - int w, h, phyw, phyh; - - /* TODO: calculate the ratio of resolution width/height and output values and change the configured output resolution and configured physical size */ - w = __outputRect.w; - h = __outputRect.h; - phyw = __phyWidth; - phyh = __phyHeight; - - wl_output::send_scale(resource->handle, __scale); - wl_output::send_geometry(resource->handle, __outputRect.x, __outputRect.y, phyw, phyh, __subpixel, __make, __model, __transform); - wl_output::send_mode(resource->handle, mode_current | mode_preferred, w, h, __refresh); - wl_output::send_done(resource->handle); -} - -bool DSWaylandOutputPrivate::getBaseResolutionFromAppinfo(Resource *resource, int *w, int *h) -{ - DSWaylandClient *client = DSWaylandClient::fromWlClient(resource->client()); - DSTizenAppinfoMgr *appinfoMgr = DSTizenAppinfoMgr::getInstance(); - pid_t pid = -1; - int res_w, res_h; - bool res = false; - - pid = client->pid(); - if (pid <= 0) { - return false; - } - res = appinfoMgr->getBaseOutputResolution(pid, &res_w, &res_h); - if (!res) - return false; - - if (w) *w = res_w; - if (h) *h = res_h; - - DSTizenAppinfoMgr::releaseInstance(); - return true; -} -/*LCOV_EXCL_STOP*/ - -void DSWaylandOutputPrivate::sendWaylandOutputInfo(void) -{ - std::multimap::iterator iter; - std::multimap resMap = resourceMap(); - - for (iter = resMap.begin(); iter != resMap.end(); iter++) - { - Resource *res = (*iter).second; - sendWaylandOutputInfo(res); - } -} - -void DSWaylandOutputPrivate::setWaylandOutputResolution(int x, int y, int w, int h) -{ - __outputRect.x = x; - __outputRect.y = y; - __outputRect.w = w; - __outputRect.h = h; -} - -void DSWaylandOutputPrivate::setWaylandOutputPhysicalSize(int phyWidth, int phyHeight) -{ - __phyWidth = phyWidth; - __phyHeight = phyHeight; -} - -void DSWaylandOutputPrivate::setWaylandOutputId(std::string id) -{ - __id = id; -} - -void DSWaylandOutputPrivate::setWaylandOutputMake(std::string make) -{ - __make = make; -} - -void DSWaylandOutputPrivate::setWaylandOutputModel(std::string model) -{ - __model = model; -} - -void DSWaylandOutputPrivate::setWaylandOutputRefresh(unsigned int refresh) -{ - __refresh = refresh; -} - -void DSWaylandOutputPrivate::setWaylandOutputSubpixel(unsigned int subpixel) -{ - __subpixel = subpixel; -} - -void DSWaylandOutputPrivate::setWaylandOutputTransform(unsigned int transform) -{ - __transform = transform; -} - -DSWaylandOutput::DSWaylandOutput(DSWaylandCompositor *compositor, - std::string id, std::string make, std::string model, - int x, int y, int w, int h, int pw, int ph, - unsigned int refresh, unsigned int subpixel, unsigned int transform) - : _d_ptr(std::make_unique(this, compositor)) -{ - _d_ptr->setWaylandOutputResolution(x, y, w, h); - _d_ptr->setWaylandOutputPhysicalSize(pw, ph); - _d_ptr->setWaylandOutputId(id); - _d_ptr->setWaylandOutputMake(make); - _d_ptr->setWaylandOutputModel(model); - _d_ptr->setWaylandOutputRefresh(refresh); - _d_ptr->setWaylandOutputSubpixel(subpixel); - _d_ptr->setWaylandOutputTransform(transform); -} - -DSWaylandOutput::~DSWaylandOutput() -{ -} - -void DSWaylandOutput::sendWaylandOutputInfo(void) -{ - DSLOG_INF("DSWaylandOutput", "send wayland output info to all client"); - DS_GET_PRIV(DSWaylandOutput); - - priv->sendWaylandOutputInfo(); -} - -} // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandOutput.h b/src/DSWaylandServer/DSWaylandOutput.h deleted file mode 100644 index 9c2445c..0000000 --- a/src/DSWaylandServer/DSWaylandOutput.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_OUTPUT_H_ -#define _DS_WAYLAND_OUTPUT_H_ - -#include -#include -#include -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -class DSWaylandOutputPrivate; - -class DS_DECL_EXPORT DSWaylandOutput : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandOutput); - -public: - DSWaylandOutput(DSWaylandCompositor *compositor, - std::string id, std::string make, std::string model, - int x, int y, int w, int h, int pw, int ph, - unsigned int refresh, unsigned int subpixel, unsigned int transform); - virtual ~DSWaylandOutput(); - - void sendWaylandOutputInfo(void); -}; - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandOutputPrivate.h b/src/DSWaylandServer/DSWaylandOutputPrivate.h deleted file mode 100644 index 7320781..0000000 --- a/src/DSWaylandServer/DSWaylandOutputPrivate.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_OUTPUT_PRIVATE_H_ -#define _DS_WAYLAND_OUTPUT_PRIVATE_H_ - -#include "dswayland-server-wayland.h" -#include "DSWaylandOutput.h" - -namespace display_server -{ - -class DS_DECL_EXPORT DSWaylandOutputPrivate : public DSObjectPrivate, public DSWaylandServer::wl_output -{ -DS_PIMPL_USE_PUBLIC(DSWaylandOutput); - -public: - DSWaylandOutputPrivate() = delete; - DSWaylandOutputPrivate(DSWaylandOutput *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandOutputPrivate() override; - -protected: - void output_bind_resource(Resource *resource) override; - void output_destroy_resource(Resource *resource) override; - void output_release(Resource *resource) override; - - void sendWaylandOutputInfo(Resource *resource); - void sendWaylandOutputInfo(Resource *resource, int res_w, int res_h); - void sendWaylandOutputInfo(void); - - void setWaylandOutputResolution(int x, int y, int w, int h); - void setWaylandOutputPhysicalSize(int phyWidth, int phyHeight); - void setWaylandOutputId(std::string id); - void setWaylandOutputMake(std::string make); - void setWaylandOutputModel(std::string model); - void setWaylandOutputRefresh(unsigned int refresh); - void setWaylandOutputSubpixel(unsigned int subpixel); - void setWaylandOutputTransform(unsigned int transform); - - bool getBaseResolutionFromAppinfo(Resource *resource, int *w, int *h); - -private: - stRect __outputRect; - int __phyWidth; - int __phyHeight; - unsigned int __refresh; - unsigned int __subpixel; - unsigned int __transform; - double __scale; - std::string __id; - std::string __make; - std::string __model; -}; - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandPointer.cpp b/src/DSWaylandServer/DSWaylandPointer.cpp deleted file mode 100644 index e856c64..0000000 --- a/src/DSWaylandServer/DSWaylandPointer.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandPointer.h" -#include "DSWaylandPointerPrivate.h" -#include "DSWaylandClient.h" -#include "DSWaylandSeat.h" -#include "DSWaylandSurface.h" -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -/* Begin Private Class Implementation */ -DSWaylandPointerPrivate::DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandPointer *pointer) - : DSObjectPrivate(pointer), - __p_ptr(pointer), - __seat(seat), - __compositor(seat ? (seat->getCompositor()) : nullptr), - __waylandSurface(nullptr), - __wlPointerResource(nullptr) -{ - wl_pointer(); -} - -DSWaylandPointerPrivate::~DSWaylandPointerPrivate() -{ -} - -void DSWaylandPointerPrivate::setFocus(DSWaylandSurface *waylandSurface) -{ - DSLOG_INF("DSWaylandPointerPrivate", "pointer focus changed (%p -> %p)", __waylandSurface, waylandSurface); - - __waylandSurface = waylandSurface; - - if (!waylandSurface || !waylandSurface->hasResource()) - { - __wlPointerResource = nullptr; - DSLOG_INF("DSWaylandPointerPrivate", "wlPointerResource has been set to null."); - return; - } - - /*LCOV_EXCL_START*/ - struct ::wl_resource *surface = waylandSurface->getWlResource(); - auto client = wl_resource_get_client(surface); - - std::multimap::iterator iter; - std::multimap resMap = resourceMap(); - - for (iter = resMap.begin(); iter != resMap.end(); iter++) - { - Resource *res = (*iter).second; - if (res->client() == client) - { - __wlPointerResource = res->handle; - break; - } - - } - - if (!__wlPointerResource) - { - DSLOG_INF("DSWaylandPointerPrivate", "no wlPointerResource available"); - return; - } - /*LCOV_EXCL_STOP*/ -} - -DSWaylandSurface *DSWaylandPointerPrivate::getFocus() -{ - return __waylandSurface; -} - -/*LCOV_EXCL_START*/ -void DSWaylandPointerPrivate::pointer_bind_resource(Resource *resource) -{ - DSLOG_INF("DSWaylandPointerPrivate",""); -} - -void DSWaylandPointerPrivate::pointer_destroy_resource(Resource *resource) -{ - DSLOG_INF("DSWaylandPointerPrivate",""); -} - -void DSWaylandPointerPrivate::pointer_set_cursor(Resource *resource, uint32_t serial, struct ::wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y) -{ - DSLOG_INF("DSWaylandPointerPrivate",""); -} - -void DSWaylandPointerPrivate::pointer_release(Resource *resource) -{ - DSLOG_INF("DSWaylandPointerPrivate",""); - wl_resource_destroy(resource->handle); -} - -void DSWaylandPointerPrivate::sendEnter(struct ::wl_resource *wlResource, struct ::wl_resource *surface, int surface_x, int surface_y) -{ - if (!__wlPointerResource) - return; - - wl_fixed_t surface_x_fixed = wl_fixed_from_int(surface_x); - wl_fixed_t surface_y_fixed = wl_fixed_from_int(surface_y); - - send_enter(__wlPointerResource, __compositor->nextSerial(), surface, surface_x_fixed, surface_y_fixed); -} - -void DSWaylandPointerPrivate::sendLeave(struct ::wl_resource *wlResource, struct ::wl_resource *surface) -{ - if (!__wlPointerResource) - return; - - send_leave(__wlPointerResource, __compositor->nextSerial(), surface); -} - -void DSWaylandPointerPrivate::sendMotion(int surface_x, int surface_y) -{ - if (!__wlPointerResource) - return; - - wl_fixed_t surface_x_fixed = wl_fixed_from_int(surface_x); - wl_fixed_t surface_y_fixed = wl_fixed_from_int(surface_y); - - send_motion(__wlPointerResource, __seat->getCurrentEventTime(), surface_x_fixed, surface_y_fixed); -} - -void DSWaylandPointerPrivate::sendButton(uint32_t button, uint32_t state) -{ - if (!__wlPointerResource) - return; - - send_button(__wlPointerResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), button, state); -} -/*LCOV_EXCL_STOP*/ - -/* Begin Public Class Implementation */ -DSWaylandPointer::DSWaylandPointer(DSWaylandSeat *seat) - : DSObject(), _d_ptr(std::make_unique(seat, this)) -{ - //TODO : emit signal -} - -DSWaylandPointer::~DSWaylandPointer() -{ - //TODO : emit signal -} - -DSWaylandSeat *DSWaylandPointer::seat() -{ - DS_GET_PRIV(DSWaylandPointer); - - return priv->__seat; -} - -/*LCOV_EXCL_START*/ -void DSWaylandPointer::addClient(DSWaylandClient *client, uint32_t id, int version) -{ - DS_GET_PRIV(DSWaylandPointer); - - DSLOG_INF("DSWaylandPointer", "addClient(dswlClient=%p, id=%u, version=%d", client, id, version); - - priv->add(client->wlClient(), id, version); -} -/*LCOV_EXCL_STOP*/ - -void DSWaylandPointer::setFocus(DSWaylandSurface *waylandSurface) -{ - DS_GET_PRIV(DSWaylandPointer); - priv->setFocus(waylandSurface); -} - -void DSWaylandPointer::resetFocus() -{ - DS_GET_PRIV(DSWaylandPointer); - priv->__waylandSurface = nullptr; - priv->__wlPointerResource = nullptr; -} - -DSWaylandSurface *DSWaylandPointer::getFocus() -{ - DS_GET_PRIV(DSWaylandPointer); - return priv->getFocus(); -} - -/*LCOV_EXCL_START*/ -void DSWaylandPointer::sendEnter(int surface_x, int surface_y) -{ - DS_GET_PRIV(DSWaylandPointer); - priv->sendEnter(priv->__wlPointerResource, priv->__waylandSurface->getWlResource(), surface_x, surface_y); -} - -void DSWaylandPointer::sendLeave() -{ - DS_GET_PRIV(DSWaylandPointer); - priv->sendLeave(priv->__wlPointerResource, priv->__waylandSurface->getWlResource()); -} - -void DSWaylandPointer::sendMotion(int surface_x, int surface_y) -{ - DS_GET_PRIV(DSWaylandPointer); - priv->sendMotion(surface_x, surface_y); -} - -void DSWaylandPointer::sendButtonDown(uint32_t button) -{ - DS_GET_PRIV(DSWaylandPointer); - priv->sendButton(button, WL_POINTER_BUTTON_STATE_PRESSED); -} - -void DSWaylandPointer::sendButtonUp(uint32_t button) -{ - DS_GET_PRIV(DSWaylandPointer); - priv->sendButton(button, WL_POINTER_BUTTON_STATE_RELEASED); -} -/*LCOV_EXCL_STOP*/ - -} diff --git a/src/DSWaylandServer/DSWaylandPointer.h b/src/DSWaylandServer/DSWaylandPointer.h deleted file mode 100644 index 350ce60..0000000 --- a/src/DSWaylandServer/DSWaylandPointer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_POINTER_H__ -#define __DS_WAYLAND_POINTER_H__ - -#include "DSCore.h" -#include "DSObject.h" - -namespace display_server -{ - -class DSWaylandSeat; -class DSWaylandPointerPrivate; -class DSWaylandClient; -class DSWaylandSurface; - -class DS_DECL_EXPORT DSWaylandPointer : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWaylandPointer); -public: - DSWaylandPointer(DSWaylandSeat *seat); - ~DSWaylandPointer() override; - - DSWaylandSeat *seat(); - - void addClient(DSWaylandClient *client, uint32_t id, int version); - void resetFocus(); - void setFocus(DSWaylandSurface *waylandSurface); - DSWaylandSurface *getFocus(); - - void sendEnter(int surface_x, int surface_y); - void sendLeave(void); - void sendMotion(int surface_x, int surface_y); - void sendButtonDown(uint32_t button); - void sendButtonUp(uint32_t button); - -protected: - -private: - -}; - -} - -#endif //__DS_WAYLAND_POINTER_H__ diff --git a/src/DSWaylandServer/DSWaylandPointerPrivate.h b/src/DSWaylandServer/DSWaylandPointerPrivate.h deleted file mode 100644 index aa0809a..0000000 --- a/src/DSWaylandServer/DSWaylandPointerPrivate.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_POINTER_PRIVATE_H__ -#define __DS_WAYLAND_POINTER_PRIVATE_H__ - -#include "dswayland-server-wayland.h" - -#include "DSCore.h" -#include "DSObjectPrivate.h" - -struct wl_resource; - -namespace display_server -{ - -class DSWaylandSeat; -class DSWaylandCompositor; -class DSWaylandSurface; - -class DS_DECL_EXPORT DSWaylandPointerPrivate : public DSObjectPrivate, public DSWaylandServer::wl_pointer -{ - DS_PIMPL_USE_PUBLIC(DSWaylandPointer); -public: - DSWaylandPointerPrivate(DSWaylandSeat *seat, DSWaylandPointer *pointer); - ~DSWaylandPointerPrivate() override; - - void setFocus(DSWaylandSurface *waylandSurface); - DSWaylandSurface *getFocus(); - -protected: - //virtual Resource *pointer_allocate(); - void pointer_bind_resource(Resource *resource) override; - void pointer_destroy_resource(Resource *resource) override; - void pointer_set_cursor(Resource *resource, uint32_t serial, struct ::wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y) override; - void pointer_release(Resource *resource) override; - - /* APIs must be provided */ - void sendEnter(struct ::wl_resource *wlResource, struct ::wl_resource *surface, int surface_x, int surface_y); - void sendLeave(struct ::wl_resource *wlResource, struct ::wl_resource *surface); - void sendMotion(int surface_x, int surface_y); - void sendButton(uint32_t button, uint32_t state); - /* APIs don't need to provide */ - /* - void sendAxis(struct ::wl_resource *resource, uint32_t time, uint32_t axis, wl_fixed_t value); - void send_frame(struct ::wl_resource *resource); - void send_axis_source(struct ::wl_resource *resource, uint32_t axis_source); - void send_axis_stop(struct ::wl_resource *resource, uint32_t time, uint32_t axis); - void send_axis_discrete(struct ::wl_resource *resource, uint32_t axis, int32_t discrete); - */ - -private: - DSWaylandSeat *__seat; - DSWaylandCompositor *__compositor; - DSWaylandSurface *__waylandSurface; - struct ::wl_resource *__wlPointerResource; -}; - -} - -#endif //__DS_WAYLAND_POINTER_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp deleted file mode 100644 index b6575c8..0000000 --- a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp +++ /dev/null @@ -1,1494 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandProtocolTrace.h" -#include "DSWaylandProtocolTracePrivate.h" -#include "DSWaylandClient.h" -#include -#include - -namespace display_server -{ -/*LCOV_EXCL_START*/ -int DSWaylandProtocolTrace::__refCount { 0 }; -std::mutex DSWaylandProtocolTrace::__mutex; -DSWaylandProtocolTrace* DSWaylandProtocolTrace::__protocolTrace { nullptr }; - -static FILE *log_fp_ptrace = NULL; -static struct wl_protocol_logger *ds_wl_protocol_logger; -static ProtocolTrace_Rule_Checker *rc = nullptr; - -static struct -{ - const char *token_char; - const int token_length; - ProtocolTrace_Token token_name; -} token_table[] = -{ - {"\0", 1, PROTOCOLTRACE_TOKEN_EOS}, - {"\t", 1, PROTOCOLTRACE_TOKEN_SPACE}, - {" ", 1, PROTOCOLTRACE_TOKEN_SPACE}, - {"!=", 2, PROTOCOLTRACE_TOKEN_NOT_EQ}, - {"&", 1, PROTOCOLTRACE_TOKEN_AND}, - {"&&", 2, PROTOCOLTRACE_TOKEN_AND}, - {"(", 1, PROTOCOLTRACE_TOKEN_L_BR}, - {")", 1, PROTOCOLTRACE_TOKEN_R_BR}, - {"<", 1, PROTOCOLTRACE_TOKEN_LSS_THAN}, - {"<=", 2, PROTOCOLTRACE_TOKEN_LSS_EQ}, - {"<>", 2, PROTOCOLTRACE_TOKEN_NOT_EQ}, - {"=", 1, PROTOCOLTRACE_TOKEN_EQUAL}, - {"==", 2, PROTOCOLTRACE_TOKEN_EQUAL}, - {">", 1, PROTOCOLTRACE_TOKEN_GRT_THAN}, - {">=", 2, PROTOCOLTRACE_TOKEN_GRT_EQ}, - {"and", 3, PROTOCOLTRACE_TOKEN_AND}, - {"or", 2, PROTOCOLTRACE_TOKEN_OR}, - {"|", 1, PROTOCOLTRACE_TOKEN_OR}, - {"||", 2, PROTOCOLTRACE_TOKEN_OR}, -}; - -const char *get_next_argument(const char *signature, struct argument_details *details) -{ - details->nullable = 0; - for(; *signature; ++signature) - { - switch(*signature) - { - case 'i': - case 'u': - case 'f': - case 's': - case 'o': - case 'n': - case 'a': - case 'h': - details->type = *signature; - return signature +1; - case '?': - details->nullable = 1; - } - } - details->type = '\0'; - return signature; -} - -DSWaylandProtocolTrace::DSWaylandProtocolTrace(DSObject *parent) - : DS_INIT_PRIVATE_PTR(DSWaylandProtocolTrace) -{ -} - -DSWaylandProtocolTrace::~DSWaylandProtocolTrace() -{ - DSWaylandCompositor::releaseInstance(); -} - -DSWaylandProtocolTrace *DSWaylandProtocolTrace::getInstance() -{ - std::lock_guard tLock(__mutex); - - if(!__protocolTrace && (__refCount == 0)) - { - __protocolTrace = new DSWaylandProtocolTrace(new DSObject); - DSLOG_INF("DSWaylandProtocolTrace", "DSWaylandProtocolTrace instance has been created !"); - } - - ++__refCount; - return __protocolTrace; -} - -void DSWaylandProtocolTrace::releaseInstance() -{ - std::lock_guard tLock(__mutex); - - --__refCount; - if(__refCount < 0) - __refCount = 0; - - if((0==__refCount) && __protocolTrace) - { - delete __protocolTrace; - __protocolTrace = nullptr; - DSLOG_INF("DSWaylandProtocolTrace", "DSWaylandProtocolTrace instance has been removed !"); - } -} - -bool DSWaylandProtocolTrace::init(void) -{ - DS_GET_PRIV(DSWaylandProtocolTrace); - bool ret = false; - char *env_path = nullptr; - - rc = priv->rulechecker_init(); - - // set rule file path - env_path = getenv("E_INFO_RULE_FILE"); - DSLOG_DBG("DSWaylandProtocolTrace", "==================================================== rule file path = %s", env_path); - ret = priv->protocol_rule_init(env_path); - DSLOG_DBG("DSWaylandProtocolTrace", "result of protocol rule init = %d", ret); - - if(env_path) - { - char *tmp = strdup(env_path); - if(!tmp) return false; - free(tmp); - env_path = nullptr; - } - if(!ret) return ret; - - // set trace file path - DSLOG_DBG("DSWaylandProtocolTrace", "========================================================================================================"); - env_path = getenv("E_INFO_TRACE_FILE"); - DSLOG_DBG("DSWaylandProtocolTrace", "==================================================== trace file path = %s", env_path); - ret = priv->protocol_trace_init(env_path); - DSLOG_DBG("DSWaylandProtocolTrace", "result of protocol trace init = %d", ret); - - if(env_path) - { - char *tmp = strdup(env_path); - if(!tmp) return false; - free(tmp); - env_path = nullptr; - } - return ret; -} - -int DSWaylandProtocolTrace::enableProtocolTrace(bool state) -{ - DS_GET_PRIV(DSWaylandProtocolTrace); - //following state : enable, disable trace - DSLOG_DBG("DSWaylandProtocolTrace", "state = %d", state); - - if(log_fp_ptrace != nullptr) - { - fclose(log_fp_ptrace); - log_fp_ptrace = nullptr; - } - - if(state) - { - //TODO: can change trace file path by cmd - DSLOG_DBG("DSWaylandProtocolTrace", "state true == %d", state); - priv->protocol_trace_set(); - return 1; - } - else - { - DSLOG_DBG("DSWaylandProtocolTrace", "state false == %d", state); - priv->protocol_trace_unset(); - return 0; - } - - return -1; -} - - -bool DSWaylandProtocolTrace::updateProtocolRule(const int argc, const char **argv) -{ - DS_GET_PRIV(DSWaylandProtocolTrace); - DSLOG_DBG("DSWaylandProtocolTrace", "argc = %d, argv[0] = %s, argv[1] = %s", argc, argv[0], argv[1]); - - bool ret = false; - ret = priv->protocol_rule_set(argc, argv); - - return ret; -} - -DSWaylandProtocolTracePrivate::DSWaylandProtocolTracePrivate(DSWaylandProtocolTrace *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) -{ - __wlCompositor = DSWaylandCompositor::getInstance(); -} - -DSWaylandProtocolTracePrivate::~DSWaylandProtocolTracePrivate() -{ - -} - -bool DSWaylandProtocolTracePrivate::protocol_rule_init(char *rule_path) -{ - bool ret = false; - const char *argv[2]; - int argc = 2; - - if(!rule_path || strlen(rule_path) <= 0) - { - DSLOG_ERR("DSWaylandProtocolTracePrivate", "rule path is null"); - return false; - } - - argv[0] = "file"; - argv[1] = rule_path; - - DSLOG_DBG("DSWaylandProtocolTracePriv", "rule_path = %s", rule_path); - - ret = protocol_rule_set(argc, (const char**)&(argv[0])); - - return ret; -} - -bool DSWaylandProtocolTracePrivate::protocol_trace_init(char *trace_path) -{ - DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_trace_init"); - if(!trace_path || strlen(trace_path) <= 0) - { - DSLOG_ERR("DSWaylandProtocolTracePrivate", "trace path is null"); - return false; - } - - trace_env_path = trace_path; - DSLOG_DBG("DSWaylandProtocolTracePriv", "saved trace path = %s", trace_env_path); - - //enable - protocol_trace_unset(); - DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << protocol_trace_init"); - /* - log_fp_ptrace = fopen(trace_path, "a"); - - setvbuf(log_fp_ptrace, NULL, _IOLBF, 512); - - if(ds_wl_protocol_logger) - { - wl_protocol_logger_destroy(ds_wl_protocol_logger); - ds_wl_protocol_logger = NULL; - } - ::wl_display *display; - display = __wlCompositor->display(); - ds_wl_protocol_logger = wl_display_add_protocol_logger(display, protocol_trace_func, nullptr); - */ - return true; -} - -int DSWaylandProtocolTracePrivate::chk(const char *str) -{ - char *endptr; - int index = strtol(str, &endptr, 10); - if(errno == ERANGE) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : overflow"); - return -1; - } - if(errno != 0) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : other error"); - return -1; - } - if(endptr == 0) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : non-numeric"); - return -1; - } - if(*endptr != '\0') - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : non-numeric at end"); - return -1; - } - if(isspace(*str)) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Rule remove fail : space at beginning"); - return -1; - } - return index; -} - -bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char **argv) -{ - DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_rule_set"); - DSLOG_DBG("DSWaylandProtocolTracePriv", "(parameter) argc = %d, argv[0] = %s", argc, argv[0]); - const char * command; - - if(argc == 0) - { - rulechecker_rule_print(rc); - return true; - } - - command = argv[0]; - - if(!strcasecmp(command, "add")) - { - DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD"); - ProtocolTrace_Policy_Type policy_type; - ProtocolTrace_Rule_Set_Result result; - const char * policy = argv[1]; //allow, deny - char merge[8192] = {0,}, rule[8192] = {0,}; - int i, index=0, size_rule, apply = 0, size_merge; - - if(argc <3) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Error: Too few argumens."); - //REPLY("Error : Too few arguments."); - return false; - } - - if(!strcasecmp(policy, "ALLOW")) - policy_type = PROTOCOLTRACE_TYPE_ALLOW; - else if(!strcasecmp(policy, "DENY")) - policy_type = PROTOCOLTRACE_TYPE_DENY; - else - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Error : Unknown policy : [%s].\n Policy should be ALLOW or DENY.", policy); - //REPLY; - return false; - } - - // protocol arguments merge - protocol_arguments_merge(merge, sizeof(merge), argc -2, &(argv[2])); - - size_rule = sizeof(rule) -1; - size_merge = strlen(merge); - - for(i=0; i size_rule) - return false; - continue; - } - if(merge[i] == '+') - { - rule[index++] = ' '; - if(index > size_rule) - return false; - if(apply ==0) - { - const char * plus = "|| type=reply || type=error"; - int size_plus = strlen(plus); - int len = MIN(size_rule - index, size_plus); - snprintf(rule, sizeof(rule), "%s", plus); - index += len; - if(index >size_rule) - return false; - apply =1; - } - continue; - } - rule[index++] = merge[i]; - if(index >size_rule) - return false; - } - DSLOG_DBG("DSWaylandProtocolTracePriv", "ADD :: rule = %s", rule); - - result = rulechecker_rule_add(rc, policy_type, rule); - - if(result == PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Error: Too many rules were added."); - return false; - } - else if(result == PROTOCOLTRACE_RULE_SET_ERR_PARSE) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Error: An error occurred during parsing the rule [%s]", rule); - return false; - } - DSLOG_INF("DSWaylandProtocolTracePriv", "The rule was successfully added"); - rulechecker_rule_print(rc); - - return true; - } - else if(!strcasecmp(command, "remove")) - { - DSLOG_DBG("DSWaylandProtocolTracePriv", "REMOVE"); - const char * remove_idx; - int i; - - if(argc < 2) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Error: Too few arguments"); - return false; - } - - for(i =0; i> protocol_rule_file_set"); - int fd = -1, rule_len; - char fs[8096], *pfs; - - fd = open(filename, O_RDONLY); - if(fd<0) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "failed: open '%s'", filename); - return false; - } - - rule_len = read(fd, fs, sizeof(fs)); - pfs = fs; - - while(pfs -fs < rule_len) - { - int i, new_argc =3; - const char *new_argv[3] = {"add", }; - char policy[64] = {0,}; - char rule[1024] = {0,}; - - if(pfs[0] == ' ' || pfs[0] == '\n') - { - pfs++; - continue; - } - for(i=0; pfs[i] != ' '; i++) - policy[i] = pfs[i]; - - new_argv[1] = policy; - pfs += (strlen(new_argv[1])+1); - - memset(rule, 0, sizeof(rule)); - for(i=0; pfs[i]!='\n'; i++) - rule[i] = pfs[i]; - - new_argv[2] = rule; - - pfs += (strlen(new_argv[2]) +1); - - if(!protocol_rule_set((const int) new_argc, (const char**) new_argv)) - { - close(fd); - return false; - } - } - close(fd); - - DSLOG_DBG("DSWaylandProtocolTracePriv", "OUT << protocol_rule_file_set"); - return true; -} - -bool DSWaylandProtocolTracePrivate::protocol_rule_validate(ProtocolTrace_Protocol_Log *log) -{ - const char *cmd = ""; - - if(!rc) - return false; - - cmd = protocol_cmd_get(log->cmd); - - return rulechecker_rule_validate(rc, log->type, log->target_id, log->name, log->client_pid, cmd); -} - -void DSWaylandProtocolTracePrivate::wl_client_proc_name_get(pid_t pid, char *name, int size) - { - if(!name) return; - - FILE *h; - char proc[512], pname[512]; - size_t len; - - snprintf(proc, 512, "/proc/%d/cmdline", pid); - - h = fopen(proc, "r"); - if(!h) return; - - len = fread(pname, sizeof(char), 512, h); - if(len >0) - pname[len-1]='\0'; - else - { - strncpy(pname, "NO NAME", sizeof(pname)); - } - fclose(h); - - strncpy(name, pname, size); -} - -void DSWaylandProtocolTracePrivate::protocol_trace_set(void) -{ - DSLOG_DBG("DSWaylandProtocolTracePriv","IN >> protocol trace set"); - log_fp_ptrace = fopen(trace_env_path, "a"); - if(!log_fp_ptrace) - { - DSLOG_ERR("DSWaylandProtocolTracePriv","failed open file(%s)", trace_env_path); - return; - } - setvbuf(log_fp_ptrace, NULL, _IOLBF, 512); - DSLOG_DBG("DSWaylandProtocolTracePriv","has log_fp_ptrace"); - - if(ds_wl_protocol_logger) - { - DSLOG_DBG("DSWaylandProtocolTracePriv","if has ds_wl_protocol_logger -> destroy"); - wl_protocol_logger_destroy(ds_wl_protocol_logger); - ds_wl_protocol_logger = NULL; - } - ::wl_display *display; - display = __wlCompositor->display(); - DSLOG_DBG("DSWaylandProtocolTracePriv","get display "); - - //check working - ds_wl_protocol_logger = wl_display_add_protocol_logger(display, protocol_trace_func, __wlCompositor); - DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << protocol trace set"); -} - -void DSWaylandProtocolTracePrivate::protocol_trace_unset(void) -{ - DSLOG_DBG("DSWaylandProtocolTracePriv","IN >> protocol_trace_unset"); - if(ds_wl_protocol_logger) - { - wl_protocol_logger_destroy(ds_wl_protocol_logger); - ds_wl_protocol_logger = NULL; - } - DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << protocol_trace_unset"); -} - -void DSWaylandProtocolTracePrivate::wl_protocol_cb_client_destroy(struct wl_listener *listener, void *data) -{ - struct wl_client *wc = (struct wl_client *)data; - struct timespec tp; - unsigned int time; - pid_t client_pid =-1; - - - char strbuf[512], *str_buff = strbuf; - int str_r, str_l; - - str_buff[0] = '\0'; - str_r = sizeof(strbuf); - - wl_client_get_credentials(wc, &client_pid, nullptr, nullptr); - - clock_gettime(CLOCK_MONOTONIC, &tp); - time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); - - //TODO: get client name - BUF_SNPRINTF("[%10.3f] Server [PID:%d] client destroying", time/1000.0, client_pid); - - if(log_fp_ptrace) - fprintf(log_fp_ptrace, "%s\n", strbuf); - else - DSLOG_INF("DSWaylandProtocolTracePriv", "%s", strbuf); - - wl_list_remove(&listener->link); - free(listener); - listener = nullptr; -} - -void DSWaylandProtocolTracePrivate::protocol_client_destroy_listener_reg(struct wl_client *client) -{ - struct wl_listener *destroy_listener; - - destroy_listener = wl_client_get_destroy_listener(client, wl_protocol_cb_client_destroy); - if(destroy_listener) { - return; - } - - destroy_listener = (struct wl_listener *)calloc(1, sizeof(wl_listener)); - //EINA_SAFETY_ON_NULL_RETURN(destroy_listener); - if(!destroy_listener) - return; - - destroy_listener->notify = wl_protocol_cb_client_destroy; - wl_client_add_destroy_listener(client, destroy_listener); -} - -void DSWaylandProtocolTracePrivate::protocol_trace_func(void *user_data, enum wl_protocol_logger_type direction, const struct wl_protocol_logger_message *message) -{ - int i; - struct argument_details arg; - struct wl_client *wc = wl_resource_get_client(message->resource); - const char *signature = message->message->signature; - pid_t client_pid = -1; - struct timespec tp; - unsigned int time; - - char strbuf[512], *str_buff = strbuf; - int str_r, str_l; - - str_buff[0] = '\0'; - str_r = sizeof(strbuf); - - if(wc) - { - protocol_client_destroy_listener_reg(wc); - wl_client_get_credentials(wc, &client_pid, nullptr, nullptr); - } - - clock_gettime(CLOCK_MONOTONIC, &tp); - time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); - - ProtocolTrace_Protocol_Log elog = {PROTOCOL_TYPE_REQUEST,}; - elog.type = (direction == WL_PROTOCOL_LOGGER_EVENT)? PROTOCOL_TYPE_EVENT:PROTOCOL_TYPE_REQUEST; - elog.client_pid = client_pid; - elog.target_id = wl_resource_get_id(message->resource); - snprintf(elog.name, PATH_MAX,"%s:%s", wl_resource_get_class(message->resource), message->message->name); - - DSWaylandCompositor * comp = (DSWaylandCompositor * )user_data; - std::list clients = comp->clients(); - for(auto client : clients) - { - char name[512]; - wl_client_proc_name_get(client->pid(), name, sizeof(name)); - if(client->pid() == client_pid) - { - snprintf(elog.cmd, PATH_MAX, "%s", name); - } - } - - if(!protocol_rule_validate(&elog)) return; - - BUF_SNPRINTF("[%10.3f] %s%d%s%s@%u.%s(", - time / 1000.0, - elog.type ? "Server->Client [PID:" : "Server<-Client [PID:", - client_pid, "]", - wl_resource_get_class(message->resource), - wl_resource_get_id(message->resource), - message->message->name); - - for (i=0; iarguments_count; i++) - { - signature = get_next_argument(signature, &arg); - if(i>0) BUF_SNPRINTF(", "); - - switch(arg.type) - { - case 'u': - BUF_SNPRINTF("%u", message->arguments[i].u); - break; - case 'i': - BUF_SNPRINTF("%i", message->arguments[i].i); - break; - case 'f': - BUF_SNPRINTF("%f", wl_fixed_to_double(message->arguments[i].f)); - break; - case 's': - BUF_SNPRINTF("\"%s\"", message->arguments[i].s); - break; - case 'o': - if(message->arguments[i].o) - BUF_SNPRINTF("%s@%u", wl_resource_get_class((struct wl_resource*)message->arguments[i].o), - wl_resource_get_id((struct wl_resource*)message->arguments[i].o)); - else - BUF_SNPRINTF("nil"); - break; - case 'n': - BUF_SNPRINTF("new id %s@", (message->message->types[i]) ? message->message->types[i]->name : "[unknown]"); - if(message->arguments[i].n != 0) - BUF_SNPRINTF("%u", message->arguments[i].n); - else - BUF_SNPRINTF("nil"); - break; - case 'a': - BUF_SNPRINTF("array"); - break; - case 'h': - BUF_SNPRINTF("fd %d", message->arguments[i].h); - break; - } - } - - BUF_SNPRINTF("), cmd: %s", elog.cmd ? elog.cmd : "cmd is NULL"); - - if(log_fp_ptrace) - fprintf(log_fp_ptrace, "%s\n", strbuf); - else - DSLOG_INF("DSWaylandProtocolTracePriv","%s", strbuf); -} - -ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_create_node(ProtocolTrace_Tree *tree) -{ - ProtocolTrace_Tree_Node *node = (ProtocolTrace_Tree_Node*) calloc(1, sizeof(ProtocolTrace_Tree_Node) + tree->size); - // enia safety - if(!node) - return nullptr; - - node->left = nullptr; - node->right = nullptr; - - return node; -} - -ProtocolTrace_Tree *DSWaylandProtocolTracePrivate::bintree_create_tree(int size) -{ - ProtocolTrace_Tree *tree = (ProtocolTrace_Tree *)calloc(1, sizeof(ProtocolTrace_Tree) + size); - // eina safety - if(!tree) - return nullptr; - - tree->size = size; - tree->head = nullptr; - return tree; -} - -void DSWaylandProtocolTracePrivate::bintree_destroy_tree(ProtocolTrace_Tree *tree) -{ - if(tree->head) - bintree_remove_node_recursive(tree->head); - free(tree); -} - -ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_get_head(ProtocolTrace_Tree *tree) -{ - return tree->head; -} - -ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_get_left_child(ProtocolTrace_Tree_Node *node) -{ - return node->left; -} - -void *DSWaylandProtocolTracePrivate::bintree_get_node_data(ProtocolTrace_Tree_Node *node) -{ - return (void*)(node+1); -} - -ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::bintree_get_right_child(ProtocolTrace_Tree_Node *node) -{ - return node->right; -} - -void DSWaylandProtocolTracePrivate::bintree_inorder_traverse(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Traverse_Cb func, void *arg) -{ - if(tree->head) - bintree_inorder_traverse_recursive(tree, tree->head, tree->head, func, arg); -} - -int DSWaylandProtocolTracePrivate::bintree_inorder_traverse_recursive(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, ProtocolTrace_Tree_Traverse_Cb func, void *arg) -{ - if(node->left) - if(bintree_inorder_traverse_recursive(tree, node->left, node, func, arg)!=0) - return 1; - - if(func(tree, node, parent, arg)) - return 1; - - if(node->right) - if(bintree_inorder_traverse_recursive(tree,node->right, node, func, arg)!=0) - return 1; - return 0; -} - -void DSWaylandProtocolTracePrivate::bintree_postorder_traverse(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Traverse_Cb func, void *arg) -{ - if(tree->head) - bintree_postorder_traverse_recursive(tree, tree->head, tree->head, func, arg); -} - -int DSWaylandProtocolTracePrivate::bintree_postorder_traverse_recursive(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, ProtocolTrace_Tree_Traverse_Cb func, void *arg) -{ - if(node->left) - if(bintree_postorder_traverse_recursive(tree, node->left, node, func, arg)!=0) - return 1; - if(node->right) - if(bintree_postorder_traverse_recursive(tree, node->right, node, func, arg)!=0) - return 1; - - return func(tree, node,parent, arg); -} - -void DSWaylandProtocolTracePrivate::bintree_remove_node(ProtocolTrace_Tree_Node *node) -{ - free(node); -} - -void DSWaylandProtocolTracePrivate::bintree_remove_node_recursive(ProtocolTrace_Tree_Node *node) -{ - if(node->left) - bintree_remove_node_recursive(node->left); - if(node->right) - bintree_remove_node_recursive(node->right); - - bintree_remove_node(node); -} - -void DSWaylandProtocolTracePrivate::bintree_set_head(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *head) -{ - tree->head = head; -} - -void DSWaylandProtocolTracePrivate::bintree_set_left_child(ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *child) -{ - node->left = child; -} - -void DSWaylandProtocolTracePrivate::bintree_set_right_child(ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *child) -{ - node->right = child; -} - -ProtocolTrace_Token DSWaylandProtocolTracePrivate::parser_next_token_get(const char **string) -{ - static int token_cnt = sizeof(token_table) / sizeof(token_table[0]); - int i, compare_res, found =0, first, last; - - first = 0; - last = token_cnt -1; - - i = (first + last) /2; - while(1) - { - compare_res = strncmp(*string, token_table[i].token_char, token_table[i].token_length); - while(compare_res == 0) - { - found = 1; - i++; - if(i==token_cnt) - break; - compare_res = strncmp(*string, token_table[i].token_char, token_table[i].token_length); - } - - if(found) - { - i--; - *string += token_table[i].token_length; - return token_table[i].token_name; - } - - if(first >= last) - break; - - if(compare_res > 0) - first = i+1; - else - last = i-1; - - i = (first + last) /2; - - } - if(isalpha(**string)) - { - (*string)++; - while(isalpha(**string) || isdigit(**string) || **string == '_' || **string == '-') - { - (*string)++; - } - - return PROTOCOLTRACE_TOKEN_SYMBOL; - } - if(isdigit(**string)) - { - (*string)++; - while(isdigit(**string)) - (*string)++; - - return PROTOCOLTRACE_TOKEN_NUMBER; - } - return PROTOCOLTRACE_TOKEN_UNKNOWN; -} - -ProtocolTrace_Tree *DSWaylandProtocolTracePrivate::protocol_parser_rule_string_parse(const char *string) -{ - ProtocolTrace_Tree *tree; - ProtocolTrace_Tree_Node *node; - ProtocolTrace_Token_Data token; - - token.string = &string; - parser_token_process(&token); - - tree = bintree_create_tree(sizeof(ProtocolTrace_Rule_Node)); - if(!tree) return nullptr; - - node = parser_token_parse(tree, &token); - - if(!node) - { - bintree_destroy_tree(tree); - DSLOG_DBG("DSWaylandProtocolTracePriv", "finish destroy tree & return null"); - return nullptr; - } - - bintree_set_head(tree, node); - - return tree; -} - -ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::parser_statement_parse(ProtocolTrace_Tree *tree, ProtocolTrace_Token_Data *token) -{ - ProtocolTrace_Tree_Node *node = nullptr; - ProtocolTrace_Rule_Node *data; - - if(token->last_token == PROTOCOLTRACE_TOKEN_L_BR) - { - parser_token_process(token); - - node = parser_token_parse(tree, token); - if(!node) - return nullptr; - - if(token->last_token != PROTOCOLTRACE_TOKEN_R_BR) - goto fail; - - parser_token_process(token); - - return node; - } - - if(token->last_token != PROTOCOLTRACE_TOKEN_SYMBOL) - goto fail; - - node = bintree_create_node(tree); - //eina safety - - data = (ProtocolTrace_Rule_Node *) bintree_get_node_data(node); - - strncpy(data->variable_name, token->last_symbol, token->symbol_len); - data->variable_name[token->symbol_len] = '\0'; - - if(!strcasecmp(data->variable_name, "all")) - { - DSLOG_DBG("DSWaylandProtocolTracePriv", "data = all"); - data->node_type = PROTOCOLTRACE_NODE_TYPE_ALL; - parser_token_process(token); - - return node; - } - - data->node_type = PROTOCOLTRACE_NODE_TYPE_DATA; - - parser_token_process(token); - - switch(token->last_token) - { - case PROTOCOLTRACE_TOKEN_NOT_EQ: - data->comparer = PROTOCOLTRACE_COMPARER_NOT_EQ; - break; - case PROTOCOLTRACE_TOKEN_EQUAL: - data->comparer = PROTOCOLTRACE_COMPARER_EQUAL; - break; - case PROTOCOLTRACE_TOKEN_LSS_THAN: - data->comparer = PROTOCOLTRACE_COMPARER_LESS_EQ; - break; - case PROTOCOLTRACE_TOKEN_GRT_THAN: - data->comparer = PROTOCOLTRACE_COMPARER_GREATER; - break; - case PROTOCOLTRACE_TOKEN_GRT_EQ: - data->comparer = PROTOCOLTRACE_COMPARER_GREATE_EQ; - break; - default: - goto fail; - } - - parser_token_process(token); - - if(token->last_token == PROTOCOLTRACE_TOKEN_NUMBER) - { - data->value_type = PROTOCOLTRACE_DATA_TYPE_INTEGER; - data->value.integer = atoi(token->last_symbol); - } - else if (token->last_token == PROTOCOLTRACE_TOKEN_SYMBOL) - { - data->value_type = PROTOCOLTRACE_DATA_TYPE_STRING; - strncpy(data->value.string, token->last_symbol, token->symbol_len); - data->value.string[token->symbol_len] = '\0'; - } - else - { - goto fail; - } - - parser_token_process(token); - - return node; - - fail: - if(node) - bintree_remove_node_recursive(node); - return nullptr; -} - -ProtocolTrace_Tree_Node *DSWaylandProtocolTracePrivate::parser_token_parse(ProtocolTrace_Tree *tree, ProtocolTrace_Token_Data *token) -{ - - ProtocolTrace_Tree_Node *node, *left = nullptr, *right = nullptr; - ProtocolTrace_Rule_Node *data; - - node = parser_statement_parse(tree,token); - - if(!node) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "PARSE statement error\n"); - goto fail; - } - - while(token->last_token == PROTOCOLTRACE_TOKEN_AND) - { - left = node; - node = nullptr; - - parser_token_process(token); - - right = parser_statement_parse(tree, token); - if(!right) - goto fail; - - node = bintree_create_node(tree); - // eina safety - - data = (ProtocolTrace_Rule_Node *) bintree_get_node_data(node); - data->node_type = PROTOCOLTRACE_NODE_TYPE_AND; - bintree_set_left_child(node, left); - bintree_set_right_child(node, right); - } - - if(token->last_token == PROTOCOLTRACE_TOKEN_OR) - { - left = node; - node = nullptr; - - parser_token_process(token); - - right = parser_token_parse(tree, token); - if(!right) - goto fail; - - node = bintree_create_node(tree); - //eina safety - - data = (ProtocolTrace_Rule_Node *) bintree_get_node_data(node); - data->node_type = PROTOCOLTRACE_NODE_TYPE_OR; - bintree_set_left_child(node, left); - bintree_set_right_child(node, right); - } - return node; - - fail: - DSLOG_DBG("DSWaylandProtocolTracePriv", "[fail] recursive remove node"); - if(left) - bintree_remove_node_recursive(left); - return nullptr; -} - -void DSWaylandProtocolTracePrivate::parser_token_process(ProtocolTrace_Token_Data *token) -{ - do - { - token->last_symbol = *(token->string); - token->last_token = parser_next_token_get(token->string); - token->symbol_len = *(token->string) - token->last_symbol; - } while (token->last_token == PROTOCOLTRACE_TOKEN_SPACE); -} - -void DSWaylandProtocolTracePrivate::protocol_arguments_merge(char *target, int target_size, int argc, const char **argv) -{ - int i, len; - - for(i=0; icount-1; i>=0; i--) - rulechecker_rule_remove(rc,i); - - free(rc); -} - -ProtocolTrace_Rule_Checker *DSWaylandProtocolTracePrivate::rulechecker_init() -{ - ProtocolTrace_Rule_Checker *rc = (ProtocolTrace_Rule_Checker *) calloc(1, sizeof(ProtocolTrace_Rule_Checker)); - if (!rc) - return nullptr; - - rc->count = 0; - - return rc; -} - -int DSWaylandProtocolTracePrivate::rulechecker_int_compare(ProtocolTrace_Comparer comparer, int int2, int int1) -{ - switch (comparer) - { - case PROTOCOLTRACE_COMPARER_EQUAL: - return int1 == int2; - case PROTOCOLTRACE_COMPARER_LESS: - return int1 < int2; - case PROTOCOLTRACE_COMPARER_GREATER: - return int1 > int2; - case PROTOCOLTRACE_COMPARER_LESS_EQ: - return int1 <= int2; - case PROTOCOLTRACE_COMPARER_GREATE_EQ: - return int1 >= int2; - case PROTOCOLTRACE_COMPARER_NOT_EQ: - return int1 != int2; - } - return 0; -} - -ProtocolTrace_Rule_Set_Result DSWaylandProtocolTracePrivate::rulechecker_rule_add(ProtocolTrace_Rule_Checker *rc, ProtocolTrace_Policy_Type policy, const char *rule_string) -{ - if(rc->count == MAX_RULE) - return PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES; - - rc->rules[rc->count].tree = protocol_parser_rule_string_parse(rule_string); - if(!rc->rules[rc->count].tree) - { - DSLOG_DBG("DSWaylandProtocolTracePriv", "parse error"); - return PROTOCOLTRACE_RULE_SET_ERR_PARSE; - } - - rc->rules[rc->count].policy = policy; - rc->count++; - return PROTOCOLTRACE_RULE_SET_OK; -} - -void DSWaylandProtocolTracePrivate::rulechecker_rule_print(ProtocolTrace_Rule_Checker *rc) -{ - char tmpReply[4096]; - int tmpLen = sizeof(tmpReply); - char *reply = tmpReply; - int *len = &tmpLen; - ProtocolTrace_Reply_Buffer buffer = {&reply, len}; - int i; - - DSLOG_INF("DSWaylandProtocolTracePriv"," --------------------------[ Protocol Filter Rules ]--------------------------\n"); - DSLOG_INF("DSWaylandProtocolTracePriv"," No Policy Rule\n"); - DSLOG_INF("DSWaylandProtocolTracePriv"," -----------------------------------------------------------------------------\n"); - - for(i =0; i < rc->count; i++) - { - DSLOG_INF("DSWaylandProtocolTracePriv"," %3d %10s \"", i, rc->rules[i].policy == PROTOCOLTRACE_TYPE_ALLOW ? "ALLOW" : "DENY"); - bintree_inorder_traverse(rc->rules[i].tree, rule_print_func, (void*) & buffer); - DSLOG_INF("DSWaylandProtocolTracePriv","\"\n"); - - } -} - -ProtocolTrace_Rule_Set_Result DSWaylandProtocolTracePrivate::rulechecker_rule_remove(ProtocolTrace_Rule_Checker *rc, int index) -{ - if(index <0 || index >= rc->count) - return PROTOCOLTRACE_RULE_SET_ERR_NO_RULE; - - bintree_destroy_tree(rc->rules[index].tree); - rc->count--; - if(index!=rc->count) - memmove(&rc->rules[index], &rc->rules[index+1], sizeof(ProtocolTrace_Rule)*(rc->count - index)); - - return PROTOCOLTRACE_RULE_SET_OK; -} - -int DSWaylandProtocolTracePrivate::rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, const char *cmd) -{ - ProtocolTrace_Validate_Args args = {type, target_id, name, pid, cmd}; - ProtocolTrace_Tree_Node *node; - ProtocolTrace_Rule_Node *data; - ProtocolTrace_Policy_Type default_policy = PROTOCOLTRACE_TYPE_DENY; - int i; - - for(i=rc->count-1; i>=0; i--) - { - bintree_postorder_traverse(rc->rules[i].tree, rule_validate_func, &args); - node = (ProtocolTrace_Tree_Node *) bintree_get_head(rc->rules[i].tree); - data = (ProtocolTrace_Rule_Node *) bintree_get_node_data(node); - - if(data->result == PROTOCOLTRACE_RESULT_TRUE) - { - return rc->rules[i].policy == PROTOCOLTRACE_TYPE_ALLOW; - } - } - return default_policy == PROTOCOLTRACE_TYPE_ALLOW; -} - -int DSWaylandProtocolTracePrivate::rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, const char *str1) -{ - int result = strcasecmp(str2, str1); - - switch (comparer) - { - case PROTOCOLTRACE_COMPARER_EQUAL: - return result == 0; - case PROTOCOLTRACE_COMPARER_LESS: - return result < 0; - case PROTOCOLTRACE_COMPARER_GREATER: - return result > 0; - case PROTOCOLTRACE_COMPARER_LESS_EQ: - return result <= 0; - case PROTOCOLTRACE_COMPARER_GREATE_EQ: - return result >= 0; - case PROTOCOLTRACE_COMPARER_NOT_EQ: - return result != 0; - } - return 0; -} - -const char * DSWaylandProtocolTracePrivate::rulechecker_usage_print() -{ - return - "##########################################################\n" - "### Enlightenment Protocol Log filtering. ###\n" - "##########################################################\n" - "\n" - "-----------------------------------------------------------------\n" - "How to read enlightenment_info protocol messages :\n" - "[timestamp] Server --> Client [PID: [pid]] interface@id.message(arguments..) cmd: CMD\n" - " ex)\n" - "[1476930.145] Server --> Client [PID: 103] wl_touch@10.down(758, 6769315, wl_surface@23, 0, 408.000, 831.000) cmd: /usr/bin/launchpad-loader\n" - " ==> type = event && pid = 103 && cmd = launchpad-loader && iface = wl_touch && msg = up\n" - "[4234234.123] Server <-- Client [PID: 123] wl_seat@32.get_touch(new id wl_touch@22) cmd: /usr/bin/launchpad-loader\n" - " ==> type = request && pid = 123 && cmd = launchpad-loader && iface = wl_seat && msg = get_touch\n" - "-----------------------------------------------------------------\n" - "Usage : enlightenment_info -protocol_rule add [POLICY] [RULE]\n" - " enlightenment_info -protocol_rule remove [INDEX]\n" - " enlightenment_info -protocol_rule file [RULE_FILE]\n" - " enlightenment_info -protocol_rule print\n" - " enlightenment_info -protocol_rule help\n" - " [POLICY] : allow / deny \n" - " [RULE] : C Language-style boolean expression syntax. [VARIABLE] [COMPAROTOR] [VALUE]\n" - " [VARIABLE] : type / iface / msg / cmd(command) / pid\n" - " [COMPARATOR] : & / && / and / | / || / or / = / == / != / > / >= / < / <=\n" - " [VALUE] : string / number \n" - " ex)\n" - " enlightenment_info -protocol_rule add allow \"(type=request) && (iface == wl_pointer and (msg = down or msg = up))\"\n" - " enlightenment_info -protocol_rule add deny cmd!= launch-loader\n" - " enlightenment_info -protocol_rule remove all\n" - " enlightenment_info -protocol_rule remove 3\n" - "\n"; -} - -int DSWaylandProtocolTracePrivate::rule_print_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg) -{ - ProtocolTrace_Reply_Buffer *buffer = (ProtocolTrace_Reply_Buffer *)arg; - char *reply = *buffer->reply; - //int *len = buffer->len; - const char *operators[] = {"==", "<", ">", "<=", ">=", "!=" }; - ProtocolTrace_Rule_Node *data; - - data = (ProtocolTrace_Rule_Node *)bintree_get_node_data(node); - - if(data->node_type == PROTOCOLTRACE_NODE_TYPE_ALL) - DSLOG_INF("DSWaylandProtocolTracePriv", "------------------------------------------------- ALL"); - else if(data->node_type == PROTOCOLTRACE_NODE_TYPE_AND) - DSLOG_INF("DSWaylandProtocolTracePriv", "------------------------------------------------- AND"); - else if(data->node_type == PROTOCOLTRACE_NODE_TYPE_OR) - DSLOG_INF("DSWaylandProtocolTracePriv", "------------------------------------------------- OR"); - else // data->node_type == PROTOCOLTRACE_NODE_TYPE_DATA - { - if(node == bintree_get_left_child(parent)) - DSLOG_INF("DSWaylandProtocolTracePriv", "------------------------------------------------- ("); - DSLOG_INF("DSWaylandProtocolTracePriv", "------------------------------------------------- %s %s ", data->variable_name, operators[data->comparer]); - - if(data->value_type == PROTOCOLTRACE_DATA_TYPE_INTEGER) - DSLOG_INF("DSWaylandProtocolTracePriv", "------------------------------------------------- %d", data->value.integer); - else - DSLOG_INF("DSWaylandProtocolTracePriv", "------------------------------------------------- %s", data->value.string); - - if(node == bintree_get_right_child(parent)) - DSLOG_INF("DSWaylandProtocolTracePriv", "------------------------------------------------- )"); - } - - *buffer->reply = reply; - //DSLOG_DBG("DSWaylandProtocolTracePriv", "buffer->reply = %s", reply); - - return 0; -} - -int DSWaylandProtocolTracePrivate::rule_validate_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg) -{ - ProtocolTrace_Validate_Args *args = (ProtocolTrace_Validate_Args *)arg; - ProtocolTrace_Tree_Node *left, *right; - ProtocolTrace_Rule_Node *data, *left_data =nullptr, *right_data = nullptr; - - data = (ProtocolTrace_Rule_Node *)bintree_get_node_data(node); - data->result = PROTOCOLTRACE_RESULT_UNKNOWN; - - if(data->node_type == PROTOCOLTRACE_NODE_TYPE_AND || data->node_type == PROTOCOLTRACE_NODE_TYPE_OR) - { - left = bintree_get_left_child(node); - right = bintree_get_right_child(node); - if(!left || !right) - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Node error"); - return -1; - } - - left_data = (ProtocolTrace_Rule_Node *)bintree_get_node_data(left); - right_data = (ProtocolTrace_Rule_Node *)bintree_get_node_data(right); - } - - if(data->node_type == PROTOCOLTRACE_NODE_TYPE_ALL) - { - data->result = PROTOCOLTRACE_RESULT_TRUE; - } - else if(data->node_type == PROTOCOLTRACE_NODE_TYPE_DATA) - { - char iface[64] = {0,}; - char *msg = nullptr; - - if(args->name) - { - msg = (char *) strchr(args->name, ':'); - } - if(msg) - { - int size_iface = sizeof(iface) -1; - int min = MIN(size_iface, msg-args->name); - strncpy(iface, args->name, min); - iface[min] = '\0'; - msg++; - } - if(!strcasecmp(data->variable_name, "TYPE")) - { - const char *type_string; - if(args->type == 0) - type_string = "REQUEST"; - else if(args->type == 1) - type_string = "EVENT"; - else - { - DSLOG_ERR("DSWaylandProtocolTracePriv", "Invalid type %d", args->type); - return -1; - } - - if(rulechecker_string_compare(data->comparer, data->value.string, type_string)) - data->result = PROTOCOLTRACE_RESULT_TRUE; - else - data->result = PROTOCOLTRACE_RESULT_FALSE; - } - else if(!strcasecmp(data->variable_name, "IFACE")) - { - if(msg && iface[0] && rulechecker_string_compare(data->comparer, data->value.string, (const char *)iface)) - data->result = PROTOCOLTRACE_RESULT_TRUE; - else - data->result = PROTOCOLTRACE_RESULT_FALSE; - } - else if(!strcasecmp(data->variable_name, "MSG")) - { - if(msg && rulechecker_string_compare(data->comparer, data->value.string, msg)) - data->result = PROTOCOLTRACE_RESULT_TRUE; - else - data->result = PROTOCOLTRACE_RESULT_FALSE; - } - else if(!strcasecmp(data->variable_name, "PID")) - { - if(rulechecker_int_compare(data->comparer, data->value.integer, args->pid)) - data->result = PROTOCOLTRACE_RESULT_TRUE; - else - data->result = PROTOCOLTRACE_RESULT_FALSE; - } - else if(!strcasecmp(data->variable_name, "CMD") || !strcasecmp(data->variable_name, "COMMAND")) - { - if(msg && rulechecker_string_compare(data->comparer, data->value.string, args->cmd)) - data->result = PROTOCOLTRACE_RESULT_TRUE; - else - data->result = PROTOCOLTRACE_RESULT_FALSE; - } - } - else if(data->node_type == PROTOCOLTRACE_NODE_TYPE_AND) - { - if(left_data->result == PROTOCOLTRACE_RESULT_TRUE && right_data->result == PROTOCOLTRACE_RESULT_TRUE) - data->result = PROTOCOLTRACE_RESULT_TRUE; - else - data->result = PROTOCOLTRACE_RESULT_FALSE; - } - else if(data->node_type == PROTOCOLTRACE_NODE_TYPE_OR) - { - if(left_data->result == PROTOCOLTRACE_RESULT_TRUE || right_data->result == PROTOCOLTRACE_RESULT_TRUE) - data->result = PROTOCOLTRACE_RESULT_TRUE; - else - data->result = PROTOCOLTRACE_RESULT_FALSE; - } - else - { - return -1; - } - return 0; -} -/*LCOV_EXCL_STOP*/ -} // namespace display_server \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.h b/src/DSWaylandServer/DSWaylandProtocolTrace.h deleted file mode 100644 index 59cbbf0..0000000 --- a/src/DSWaylandServer/DSWaylandProtocolTrace.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_PROTOCOL_TRACE_H__ -#define __DS_WAYLAND_PROTOCOL_TRACE_H__ - -#include -#include -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -class DSWaylandProtocolTracePrivate; - -class DSWaylandProtocolTrace : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandProtocolTrace); - -public: - DSWaylandProtocolTrace(DSObject *parent); - virtual ~DSWaylandProtocolTrace(); - static DSWaylandProtocolTrace *getInstance(); - static void releaseInstance(); - - bool init(void); - int enableProtocolTrace(bool state); - bool updateProtocolRule(const int argc, const char **argv); - -private: - static std::mutex __mutex; - static DSWaylandProtocolTrace *__protocolTrace; - static int __refCount; -}; - -} - -#endif // __DS_WAYLAND_PROTOCOL_TRACE_H__ \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h deleted file mode 100644 index a64c0db..0000000 --- a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_PROTOCOL_TRACE_PRIVATE_H__ -#define __DS_WAYLAND_PROTOCOL_TRACE_PRIVATE_H__ - -#include "DSWaylandProtocolTrace.h" -#include "DSWaylandProtocolTraceStruct.h" -#include -#include -#include -#include - - -namespace display_server -{ -class DSWaylandProtocolTracePrivate : public DSObjectPrivate -{ -DS_PIMPL_USE_PUBLIC(DSWaylandProtocolTrace); - -public: - DSWaylandProtocolTracePrivate() = delete; - DSWaylandProtocolTracePrivate(DSWaylandProtocolTrace *p_ptr); - ~DSWaylandProtocolTracePrivate(); - - -protected: - - bool protocol_rule_init(char *rule_path); - bool protocol_trace_init(char *trace_path); - - bool protocol_rule_set(const int argc, const char **argv); - bool protocol_rule_file_set(const char *filename); - static bool protocol_rule_validate(ProtocolTrace_Protocol_Log *log); - - void protocol_trace_set(void); - void protocol_trace_unset(void); - -private: - DSWaylandCompositor *__wlCompositor; - char *trace_env_path = nullptr; - - static void wl_protocol_cb_client_destroy(struct wl_listener *listener, void *data); - static void protocol_client_destroy_listener_reg(struct wl_client *client); - static void protocol_trace_func(void *user_data, enum wl_protocol_logger_type direction, const struct wl_protocol_logger_message *message); - - ProtocolTrace_Tree_Node *bintree_create_node(ProtocolTrace_Tree *tree); - ProtocolTrace_Tree *bintree_create_tree(int size); - void bintree_destroy_tree(ProtocolTrace_Tree *tree); - static ProtocolTrace_Tree_Node *bintree_get_head(ProtocolTrace_Tree *tree); - static ProtocolTrace_Tree_Node *bintree_get_left_child(ProtocolTrace_Tree_Node *node); - static void * bintree_get_node_data(ProtocolTrace_Tree_Node *node); - static ProtocolTrace_Tree_Node *bintree_get_right_child(ProtocolTrace_Tree_Node *node); - void bintree_inorder_traverse(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Traverse_Cb func, void *arg); - int bintree_inorder_traverse_recursive(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, ProtocolTrace_Tree_Traverse_Cb func, void *arg); - static void bintree_postorder_traverse(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Traverse_Cb func, void *arg); - static int bintree_postorder_traverse_recursive(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, ProtocolTrace_Tree_Traverse_Cb func, void *arg); - void bintree_remove_node(ProtocolTrace_Tree_Node *node); - void bintree_remove_node_recursive(ProtocolTrace_Tree_Node *node); - void bintree_set_head(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *head); - void bintree_set_left_child(ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *child); - void bintree_set_right_child(ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *child); - ProtocolTrace_Token parser_next_token_get(const char **string); - ProtocolTrace_Tree *protocol_parser_rule_string_parse(const char *string); - ProtocolTrace_Tree_Node *parser_statement_parse(ProtocolTrace_Tree *tree, ProtocolTrace_Token_Data *token); - ProtocolTrace_Tree_Node *parser_token_parse(ProtocolTrace_Tree *tree, ProtocolTrace_Token_Data *token); - void parser_token_process(ProtocolTrace_Token_Data *token); - static void protocol_arguments_merge(char *target, int target_size, int argc, const char **argv); - static char * protocol_cmd_get(char *path); - void rulechecker_destroy(ProtocolTrace_Rule_Checker *rc); - ProtocolTrace_Rule_Checker *rulechecker_init(); - static int rulechecker_int_compare(ProtocolTrace_Comparer comparer, int int2, int int1); - ProtocolTrace_Rule_Set_Result rulechecker_rule_add(_ProtocolTrace_Rule_Checker *rc, ProtocolTrace_Policy_Type policy, const char *rule_string); - void rulechecker_rule_print(ProtocolTrace_Rule_Checker *rc); - ProtocolTrace_Rule_Set_Result rulechecker_rule_remove(ProtocolTrace_Rule_Checker *rc, int index); - static int rulechecker_rule_validate(ProtocolTrace_Rule_Checker *rc, int type, int target_id, const char *name, int pid, const char *cmd); - static int rulechecker_string_compare(ProtocolTrace_Comparer comparer, char *str2, const char *str1); - const char * rulechecker_usage_print(); - static int rule_print_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); - static int rule_validate_func(ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); - int chk(const char *str); - static void wl_client_proc_name_get(pid_t pid, char *name, int size); -}; - -} - - - -#endif // __DS_WAYLAND_PROTOCOL_TRACE_PRIVATE_H__ \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandProtocolTraceStruct.h b/src/DSWaylandServer/DSWaylandProtocolTraceStruct.h deleted file mode 100644 index a1129cd..0000000 --- a/src/DSWaylandServer/DSWaylandProtocolTraceStruct.h +++ /dev/null @@ -1,218 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__ -#define __DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__ - -#define PATH_MAX 512 -#define MAX_RULE 64 -#define STRING_MAX 64 - -#ifndef MAX -#define MAX(x, y) (((x) > (y)) ? (x) : (y)) -#endif - -#ifndef MIN -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#endif - -#define BUF_SNPRINTF(fmt, ARG...) do { \ - str_l = snprintf(str_buff, str_r, fmt, ##ARG); \ - str_buff += str_l; \ - str_r -= str_l; \ -} while(0) - -/* -#ifndef REPLY - #define REPLY(fmt, ARG...) \ - do { \ - if (reply && len && *len > 0) \ - { \ - int s = snprintf(reply, *len, fmt, ##ARG); \ - reply += s; \ - *len -= s; \ - } \ - } while (0) -#endif -*/ - -namespace display_server -{ - -typedef struct _ProtocolTrace_Tree_Node ProtocolTrace_Tree_Node; -typedef struct _ProtocolTrace_Tree ProtocolTrace_Tree; -typedef struct _ProtocolTrace_Token_Data ProtocolTrace_Token_Data; -typedef struct _ProtocolTrace_Rule_Node ProtocolTrace_Rule_Node; -typedef struct _ProtocolTrace_Rule ProtocolTrace_Rule; -typedef struct _ProtocolTrace_Rule_Checker ProtocolTrace_Rule_Checker; -typedef struct _ProtocolTrace_Protocol_Log ProtocolTrace_Protocol_Log; - -typedef int (*ProtocolTrace_Tree_Traverse_Cb) (ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg); - -struct _ProtocolTrace_Tree_Node -{ - ProtocolTrace_Tree_Node *left; - ProtocolTrace_Tree_Node *right; -}; - -struct _ProtocolTrace_Tree -{ - int size; - ProtocolTrace_Tree_Node *head; -}; - -typedef enum -{ - PROTOCOLTRACE_TOKEN_UNKNOWN = 0, - PROTOCOLTRACE_TOKEN_L_BR =1, - PROTOCOLTRACE_TOKEN_R_BR =2, - PROTOCOLTRACE_TOKEN_NOT_EQ=3, - PROTOCOLTRACE_TOKEN_EQUAL=4, - PROTOCOLTRACE_TOKEN_LSS_THAN=5, - PROTOCOLTRACE_TOKEN_LSS_EQ =6, - PROTOCOLTRACE_TOKEN_GRT_THAN=7, - PROTOCOLTRACE_TOKEN_GRT_EQ =8, - PROTOCOLTRACE_TOKEN_AND=9, - PROTOCOLTRACE_TOKEN_OR=10, - PROTOCOLTRACE_TOKEN_SPACE=11, - PROTOCOLTRACE_TOKEN_SYMBOL=12, - PROTOCOLTRACE_TOKEN_NUMBER=13, - PROTOCOLTRACE_TOKEN_EOS=14, -} ProtocolTrace_Token; - -struct _ProtocolTrace_Token_Data -{ - const char **string; - ProtocolTrace_Token last_token; - const char *last_symbol; - int symbol_len; -}; -typedef enum -{ - PROTOCOLTRACE_NODE_TYPE_NONE, - PROTOCOLTRACE_NODE_TYPE_AND, - PROTOCOLTRACE_NODE_TYPE_OR, - PROTOCOLTRACE_NODE_TYPE_DATA, - PROTOCOLTRACE_NODE_TYPE_ALL -} ProtocolTrace_Node_Type; - -typedef enum -{ - PROTOCOLTRACE_COMPARER_EQUAL, - PROTOCOLTRACE_COMPARER_LESS, - PROTOCOLTRACE_COMPARER_GREATER, - PROTOCOLTRACE_COMPARER_LESS_EQ, - PROTOCOLTRACE_COMPARER_GREATE_EQ, - PROTOCOLTRACE_COMPARER_NOT_EQ -} ProtocolTrace_Comparer; - -typedef enum -{ - PROTOCOLTRACE_DATA_TYPE_INTEGER, - PROTOCOLTRACE_DATA_TYPE_STRING -} ProtocolTrace_Data_Type; - -typedef enum -{ - PROTOCOLTRACE_RESULT_UNKNOWN, - PROTOCOLTRACE_RESULT_TRUE, - PROTOCOLTRACE_RESULT_FALSE -} ProtocolTrace_Result_Type; - -struct _ProtocolTrace_Rule_Node -{ - ProtocolTrace_Node_Type node_type; - char variable_name[STRING_MAX]; - ProtocolTrace_Comparer comparer; - ProtocolTrace_Data_Type value_type; - - union - { - char string[STRING_MAX]; - int integer; - }value; - - ProtocolTrace_Result_Type result; -}; - -typedef enum -{ - PROTOCOLTRACE_POLICY_TYPE_UNDEFINED, - PROTOCOLTRACE_TYPE_ALLOW, - PROTOCOLTRACE_TYPE_DENY -} ProtocolTrace_Policy_Type; - -struct _ProtocolTrace_Rule -{ - ProtocolTrace_Policy_Type policy; - ProtocolTrace_Tree *tree; -}; - -struct _ProtocolTrace_Rule_Checker -{ - ProtocolTrace_Rule rules[MAX_RULE]; - int count; -}; -typedef enum -{ - PROTOCOLTRACE_RULE_SET_OK, - PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES, - PROTOCOLTRACE_RULE_SET_ERR_PARSE, - PROTOCOLTRACE_RULE_SET_ERR_NO_RULE - } ProtocolTrace_Rule_Set_Result; -typedef enum{ - PROTOCOL_TYPE_REQUEST, - PROTOCOL_TYPE_EVENT -} ProtocolTrace_Protocol_Type; -struct _ProtocolTrace_Protocol_Log -{ - ProtocolTrace_Protocol_Type type; - int client_pid; - int target_id; - char name[PATH_MAX +1]; - char cmd[PATH_MAX +1]; -}; -struct argument_details { - char type; - int nullable; -}; - -typedef struct -{ - int type; - int target_id; - const char *name; - int pid; - const char *cmd; -} ProtocolTrace_Validate_Args; - -typedef struct -{ - char **reply; - int *len; -} ProtocolTrace_Reply_Buffer; - -} - - -#endif //__DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__ \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandRegion.cpp b/src/DSWaylandServer/DSWaylandRegion.cpp deleted file mode 100644 index 406da3c..0000000 --- a/src/DSWaylandServer/DSWaylandRegion.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandRegion.h" -#include "DSWaylandRegionPrivate.h" -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -/* DSWaylandRegionPrivate */ -DSWaylandRegionPrivate::DSWaylandRegionPrivate(DSWaylandRegion *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{} - -DSWaylandRegionPrivate::DSWaylandRegionPrivate(DSWaylandRegion *p_ptr, DSWaylandClient *waylandClient, uint32_t id) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ - if (id > 0) - { - init(waylandClient->wlClient(), (int)id, 1); - } -} - -DSWaylandRegionPrivate::~DSWaylandRegionPrivate() -{} - -void DSWaylandRegionPrivate::region_bind_resource(Resource *resource) -{ -} - -void DSWaylandRegionPrivate::region_destroy_resource(Resource *resource) -{ - DS_GET_PUB(DSWaylandRegion); - - DSWaylandCompositor *dswCompositor = DSWaylandCompositor::getInstance(); - if (dswCompositor) - { - dswCompositor->regionDestroy(pub); - } - DSWaylandCompositor::releaseInstance(); -} - -void DSWaylandRegionPrivate::region_destroy(Resource *resource) -{ -} - -void DSWaylandRegionPrivate::region_add(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ -} - -void DSWaylandRegionPrivate::region_subtract(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ -} - -DS_WAYLAND_IMPL_FROM_RESOURCE(DSWaylandRegion); - - -DSWaylandRegion::DSWaylandRegion() - : DS_INIT_PRIVATE_PTR(DSWaylandRegion) -{} - -DSWaylandRegion::DSWaylandRegion(DSWaylandClient *waylandClient, uint32_t id) - : _d_ptr(std::make_unique(this, waylandClient, id)) -{} - -DSWaylandRegion::~DSWaylandRegion() -{} - -struct ::wl_resource *DSWaylandRegion::getWlResource() -{ - DS_GET_PRIV(DSWaylandRegion); - - return priv->resource()->handle; -} - -bool DSWaylandRegion::hasResource() -{ - DS_GET_PRIV(DSWaylandRegion); - - if (priv->resource()) - return true; - return false; -} -/*LCOV_EXCL_STOP*/ - -} /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandRegion.h b/src/DSWaylandServer/DSWaylandRegion.h deleted file mode 100644 index c4bd950..0000000 --- a/src/DSWaylandServer/DSWaylandRegion.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_REGION_H__ -#define __DS_WAYLAND_REGION_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSStruct.h" -#include "DSWaylandClient.h" - -struct wl_resource; - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandRegionPrivate; - -class DSWaylandRegion : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWaylandRegion); - DS_WAYLAND_DEFINE_FROM_RESOURCE(DSWaylandRegion); -public: - DSWaylandRegion(); - DSWaylandRegion(DSWaylandClient *waylandClient, uint32_t id); - virtual ~DSWaylandRegion(); - - struct ::wl_resource *getWlResource(); - bool hasResource(); - -private: - -}; -/*LCOV_EXCL_STOP*/ - -} /* namespace display_server */ - -#endif /* _DS_WAYLAND_REGION_H_ */ diff --git a/src/DSWaylandServer/DSWaylandRegionPrivate.h b/src/DSWaylandServer/DSWaylandRegionPrivate.h deleted file mode 100644 index f5b6a22..0000000 --- a/src/DSWaylandServer/DSWaylandRegionPrivate.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_REGION_PRIVATE_H__ -#define __DS_WAYLAND_REGION_PRIVATE_H__ - -#include "dswayland-server-wayland.h" -#include "DSWaylandRegion.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandRegion; - -class DSWaylandRegionPrivate : public DSObjectPrivate, public DSWaylandServer::wl_region -{ -DS_PIMPL_USE_PUBLIC(DSWaylandRegion); -public: - DSWaylandRegionPrivate() = delete; - DSWaylandRegionPrivate(DSWaylandRegion *p_ptr); - DSWaylandRegionPrivate(DSWaylandRegion *p_ptr, DSWaylandClient *waylandClient, uint32_t id); - ~DSWaylandRegionPrivate() override; - -protected: - void region_bind_resource(Resource *resource); - void region_destroy_resource(Resource *resource); - - void region_destroy(Resource *resource); - void region_add(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - void region_subtract(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - -private: -}; -/*LCOV_EXCL_STOP*/ - -} /*namespace display_server */ - -#endif /* _DS_WAYLAND_REGION_PRIVATE_H_ */ diff --git a/src/DSWaylandServer/DSWaylandSeat.cpp b/src/DSWaylandServer/DSWaylandSeat.cpp deleted file mode 100644 index 34592dd..0000000 --- a/src/DSWaylandServer/DSWaylandSeat.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandSeat.h" -#include "DSWaylandSeatPrivate.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandClient.h" -#include "DSWaylandPointer.h" -#include "DSWaylandKeyboard.h" -#include "DSWaylandTouch.h" -#include "DSXkb.h" - -namespace display_server -{ - -/* Begin Private Class Implementation */ -DSWaylandSeatPrivate::DSWaylandSeatPrivate(DSWaylandCompositor *compositor, DSWaylandSeat *seat) - : DSObjectPrivate(seat), - __p_ptr(seat), - __cap(DSWaylandSeat::capNone), - __compositor(compositor), - __xkb(nullptr), - __pointer(nullptr), - __keyboard(nullptr), - __touch(nullptr), - __currentEventTime(0) -{ - if (!compositor) - return; - - wl_seat::init(compositor->display(), 4); -} - -DSWaylandSeatPrivate::~DSWaylandSeatPrivate() -{ -} - -void DSWaylandSeatPrivate::sendCapabilitiesToAllClients(uint32_t cap) -{ - auto func = [&](std::pair res) - { wl_seat::send_capabilities(res.second->handle, cap); }; - auto resMap = resourceMap(); - std::for_each(resMap.begin(), resMap.end(), func); -} - -void DSWaylandSeatPrivate::seat_bind_resource(Resource *resource) -{ - /* send capabilities */ - wl_seat::send_capabilities(resource->handle, (uint32_t)__cap); - - /* send seat name */ - if (!__seatName.empty()) - wl_seat::send_name(resource->handle, __seatName); -} - -void DSWaylandSeatPrivate::seat_destroy_resource(Resource *resource) -{ - //Nothing to do as wl_seat::destroy_func has removed the resource->handle from m_resource_map -} - -void DSWaylandSeatPrivate::seat_get_pointer(Resource *resource, uint32_t id) -{ - //TODO : add DSWaylandPointer here - //TODO : send pointer_enter here if this client equals to top-visible window's client - if (!__pointer) - return; - - __pointer->addClient(DSWaylandClient::fromWlClient(resource->client()), id, resource->version()); -} - -void DSWaylandSeatPrivate::seat_get_keyboard(Resource *resource, uint32_t id) -{ - //TODO : add DSWaylandKeyboard here - //TODO : send repeat info to the client - //TODO : send keyboard_enter here if this client equals to focus window's client - if (!__keyboard) - return; - - __keyboard->addClient(DSWaylandClient::fromWlClient(resource->client()), id, resource->version()); -} - -void DSWaylandSeatPrivate::seat_get_touch(Resource *resource, uint32_t id) -{ - //TODO : add DSWaylandTouch here - if (!__touch) - return; - - __touch->addClient(DSWaylandClient::fromWlClient(resource->client()), id, resource->version()); -} - -void DSWaylandSeatPrivate::seat_release(Resource *resource) -{ - //TODO : Check if we should destroy wl_resource here. -} - -/* Begin Public Class Implementation */ -DSWaylandSeat::DSWaylandSeat(DSWaylandCompositor *compositor, DSWaylandSeat::seatCapability cap) - : DSObject(), _d_ptr(std::make_unique(compositor, this)) -{ - setCapability(cap); -} - -DSWaylandSeat::~DSWaylandSeat() -{ -} - -void DSWaylandSeat::sendCapabilitiesToAllClients(uint32_t cap) -{ - DS_GET_PRIV(DSWaylandSeat); - - priv->sendCapabilitiesToAllClients(cap); -} - -void DSWaylandSeat::setCapability(DSWaylandSeat::seatCapability cap) -{ - DS_GET_PRIV(DSWaylandSeat); - - DSLOG_INF("DSWaylandSeat","cap=%d, priv->__cap=%d", cap, priv->__cap); - - if (cap == priv->__cap) - { - return; - } - - DSWaylandSeat::seatCapability diff = DSWaylandSeat::seatCapability((uint32_t)priv->__cap ^ cap); - - if (diff & DSWaylandSeat::capPointer) - { - if (!priv->__pointer) - { - priv->__pointer = new DSWaylandPointer(this); - DS_ASSERT(priv->__pointer); - DSLOG_INF("DSWaylandSeat", "DSWaylandPointer has been created."); - } - } - - if (diff & DSWaylandSeat::capKeyboard) - { - if (!priv->__keyboard) - { - priv->__keyboard = new DSWaylandKeyboard(this); - DS_ASSERT(priv->__keyboard); - DSLOG_INF("DSWaylandSeat", "DSWaylandKeyboard has been created."); - } - } - - if (diff & DSWaylandSeat::capTouch) - { - if (!priv->__touch) - { - priv->__touch = new DSWaylandTouch(this); - DS_ASSERT(priv->__touch); - DSLOG_INF("DSWaylandSeat", "DSWaylandTouch has been created."); - } - } - - /* send capabilities when it is updated */ - sendCapabilitiesToAllClients((uint32_t)cap); - - //TODO : check if we should set focus if the keyboard cap has been added newly. - - priv->__cap = cap; -} - -DSWaylandSeat::seatCapability DSWaylandSeat::getCapability(void) -{ - DS_GET_PRIV(DSWaylandSeat); - - return priv->__cap; -} - -void DSWaylandSeat::setName(std::string name) -{ - DS_GET_PRIV(DSWaylandSeat); - - //TODO : check if we should send name to client(s) when it has a name. - - priv->__seatName = name; -} - -std::string DSWaylandSeat::getName() -{ - DS_GET_PRIV(DSWaylandSeat); - - return priv->__seatName; -} - -void DSWaylandSeat::setCurrentEventTime(uint32_t timestamp) -{ - DS_GET_PRIV(DSWaylandSeat); - priv->__currentEventTime = timestamp; -} - -uint32_t DSWaylandSeat::getCurrentEventTime() -{ - DS_GET_PRIV(DSWaylandSeat); - return priv->__currentEventTime; -} - -void DSWaylandSeat::setXkb(DSXkb *xkb) -{ - DS_GET_PRIV(DSWaylandSeat); - priv->__xkb = xkb; -} - -DSXkb *DSWaylandSeat::getXkb() -{ - DS_GET_PRIV(DSWaylandSeat); - return priv->__xkb; -} - -DSWaylandPointer *DSWaylandSeat::getPointer() -{ - DS_GET_PRIV(DSWaylandSeat); - return priv->__pointer; -} - -DSWaylandKeyboard *DSWaylandSeat::getKeyboard() -{ - DS_GET_PRIV(DSWaylandSeat); - return priv->__keyboard; -} - -DSWaylandTouch *DSWaylandSeat::getTouch() -{ - DS_GET_PRIV(DSWaylandSeat); - return priv->__touch; -} - -DSWaylandCompositor *DSWaylandSeat::getCompositor() -{ - DS_GET_PRIV(DSWaylandSeat); - return priv->__compositor; -} - -} diff --git a/src/DSWaylandServer/DSWaylandSeat.h b/src/DSWaylandServer/DSWaylandSeat.h deleted file mode 100644 index 988f6ec..0000000 --- a/src/DSWaylandServer/DSWaylandSeat.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_SEAT_H__ -#define __DS_WAYLAND_SEAT_H__ - -#include "DSCore.h" -#include "DSObject.h" - -namespace display_server -{ - -class DSXkb; -class DSWaylandSeatPrivate; -class DSWaylandCompositor; -class DSWaylandPointer; -class DSWaylandKeyboard; -class DSWaylandTouch; - -class DS_DECL_EXPORT DSWaylandSeat : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWaylandSeat); -public: - enum seatCapability { - capNone = 0x0, - capPointer = 0x1, - capKeyboard = 0x2, - capPointerKeyboard = capPointer | capKeyboard, - capTouch = 0x4, - capPointerTouch = capPointer | capTouch, - capKeyboardTouch = capKeyboard | capTouch, - capAll = capPointer | capKeyboard | capTouch, - capDefault = capPointer | capKeyboard | capTouch, - }; - - DSWaylandSeat(DSWaylandCompositor *compositor, DSWaylandSeat::seatCapability cap); - ~DSWaylandSeat() override; - - void sendCapabilitiesToAllClients(uint32_t cap); - void setCapability(DSWaylandSeat::seatCapability cap); - DSWaylandSeat::seatCapability getCapability(void); - void setName(std::string name); - std::string getName(); - - void setCurrentEventTime(uint32_t timestamp); - uint32_t getCurrentEventTime(); - - void setXkb(DSXkb *xkb); - DSXkb *getXkb(); - - DSWaylandPointer *getPointer(); - DSWaylandKeyboard *getKeyboard(); - DSWaylandTouch *getTouch(); - DSWaylandCompositor *getCompositor(); - -protected: - -private: - -}; - -} - -#endif //__DS_WAYLAND_SEAT_H__ diff --git a/src/DSWaylandServer/DSWaylandSeatPrivate.h b/src/DSWaylandServer/DSWaylandSeatPrivate.h deleted file mode 100644 index 79722c3..0000000 --- a/src/DSWaylandServer/DSWaylandSeatPrivate.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_SEAT_PRIVATE_H__ -#define __DS_WAYLAND_SEAT_PRIVATE_H__ - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "dswayland-server-wayland.h" - -namespace display_server -{ - -class DSXkb; -class DSWaylandPointer; -class DSWaylandKeyboard; -class DSWaylandTouch; - -class DS_DECL_EXPORT DSWaylandSeatPrivate : public DSObjectPrivate, public DSWaylandServer::wl_seat -{ - DS_PIMPL_USE_PUBLIC(DSWaylandSeat); -public: - DSWaylandSeatPrivate(DSWaylandCompositor *compositor, DSWaylandSeat *seat); - ~DSWaylandSeatPrivate() override; - - void sendCapabilitiesToAllClients(uint32_t cap); - -protected: - void seat_bind_resource(Resource *resource) override; - void seat_destroy_resource(Resource *resource) override; - void seat_get_pointer(Resource *resource, uint32_t id) override; - void seat_get_keyboard(Resource *resource, uint32_t id) override; - void seat_get_touch(Resource *resource, uint32_t id) override; - void seat_release(Resource *resource) override; - -private: - DSWaylandSeat::seatCapability __cap; - DSWaylandCompositor *__compositor; - DSXkb *__xkb; - std::string __seatName; - - DSWaylandPointer *__pointer; - DSWaylandKeyboard *__keyboard; - DSWaylandTouch *__touch; - - uint32_t __currentEventTime; -}; - -} - -#endif //__DS_WAYLAND_SEAT_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandSurface.cpp b/src/DSWaylandServer/DSWaylandSurface.cpp deleted file mode 100644 index 5136242..0000000 --- a/src/DSWaylandServer/DSWaylandSurface.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandSurface.h" -#include "DSWaylandSurfacePrivate.h" -#include "DSWaylandClient.h" - -namespace display_server -{ - -/* DSWaylandSurfaceCommitInfoPrivate */ -DSWaylandSurfaceCommitInfoPrivate::DSWaylandSurfaceCommitInfoPrivate(DSWaylandSurfaceCommitInfo *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - bufferRef(nullptr), - attach({0, 0, nullptr}), - bufferChanged(false), - damageSurface({0, 0, 0, 0}), - transform(0), - scale(0), - damageBuffer({0,0,0,0}) -{ -} - -DSWaylandSurfaceCommitInfoPrivate::~DSWaylandSurfaceCommitInfoPrivate() -{} - -std::shared_ptr DSWaylandSurfaceCommitInfoPrivate::getBuffer() -{ - return bufferRef ? bufferRef->refDSBufferGet() : nullptr; -} - -/* DSWaylandSurfaceCommitInfo */ -DSWaylandSurfaceCommitInfo::DSWaylandSurfaceCommitInfo() - : DS_INIT_PRIVATE_PTR(DSWaylandSurfaceCommitInfo) -{} - -DSWaylandSurfaceCommitInfo::~DSWaylandSurfaceCommitInfo() -{} - -/*LCOV_EXCL_START*/ -std::shared_ptr DSWaylandSurfaceCommitInfo::getBuffer() -{ - DS_GET_PRIV(DSWaylandSurfaceCommitInfo); - - return priv->getBuffer(); -} - -bool DSWaylandSurfaceCommitInfo::bufferChanged() -{ - DS_GET_PRIV(DSWaylandSurfaceCommitInfo); - - return priv->bufferChanged; -} -/*LCOV_EXCL_STOP*/ - -/* DSWaylandSurfacePrivate */ -static uint32_t tizenResIdCnt = 0; - -DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __deleted(false), - __commitInfoPending{std::make_unique()}, - __commitInfo{std::make_shared()}, - __waylandClient(nullptr), - __bufferManager{DSBufferManager::getInstance()}, - __resId(0), - __tizenResId(++tizenResIdCnt) -{} - -DSWaylandSurfacePrivate::DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr, DSWaylandClient *waylandClient, uint32_t id) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __deleted(false), - __commitInfoPending{std::make_unique()}, - __commitInfo{std::make_shared()}, - __waylandClient(waylandClient), - __bufferManager{DSBufferManager::getInstance()}, - __resId(0), - __tizenResId(++tizenResIdCnt) -{ - if (id > 0) { - wl_surface::init(waylandClient->wlClient(), (int)id, 4); - __resId = id; - } -} - -DSWaylandSurfacePrivate::~DSWaylandSurfacePrivate() -{ - if (__bufferManager) - DSBufferManager::releaseInstance(); -} - -/*LCOV_EXCL_START*/ -uint32_t DSWaylandSurfacePrivate::getResourceId() -{ - return __resId; -} - -uint32_t DSWaylandSurfacePrivate::getTizenResourceId() -{ - return __tizenResId; -} - -void DSWaylandSurfacePrivate::surface_bind_resource(Resource *resource) -{ -} - -void DSWaylandSurfacePrivate::surface_destroy_resource(Resource *resource) -{ - __sendSurfaceDestroy(); -} - -void DSWaylandSurfacePrivate::surface_destroy(Resource *resource) -{ - __sendSurfaceDestroy(); -} -/*LCOV_EXCL_STOP*/ - -void DSWaylandSurfacePrivate::surface_attach(Resource *resource, struct ::wl_resource *buffer, int32_t x, int32_t y) -{ - DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); - std::shared_ptr dsBuffer; - - commitInfoPendingPriv->attach.x = x; - commitInfoPendingPriv->attach.y = y; - commitInfoPendingPriv->attach.buffer = buffer; - commitInfoPendingPriv->bufferRef.reset(nullptr); - - if (buffer) { - dsBuffer = __bufferManager->getDSBuffer(buffer); - commitInfoPendingPriv->bufferRef = std::make_unique(dsBuffer); - } else { - commitInfoPendingPriv->bufferRef = nullptr; - } - - commitInfoPendingPriv->bufferChanged = true; -} - -void DSWaylandSurfacePrivate::surface_damage(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ - DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); - - commitInfoPendingPriv->damageSurface.x = x; - commitInfoPendingPriv->damageSurface.y = y; - commitInfoPendingPriv->damageSurface.width = width; - commitInfoPendingPriv->damageSurface.height = height; -} - -/*LCOV_EXCL_START*/ -void DSWaylandSurfacePrivate::surface_frame(Resource *resource, uint32_t callback) -{ - //TODO: -} - -void DSWaylandSurfacePrivate::surface_set_opaque_region(Resource *resource, struct ::wl_resource *region) -{ - //TODO: -} - -void DSWaylandSurfacePrivate::surface_set_input_region(Resource *resource, struct ::wl_resource *region) -{ - //TODO: -} -/*LCOV_EXCL_STOP*/ - -void DSWaylandSurfacePrivate::surface_commit(Resource *resource) -{ - DS_GET_PUB(DSWaylandSurface); - - DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); - DSWaylandSurfaceCommitInfoPrivate *commitInfoPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfo.get()); - - //copy commit information from commitInfoPendingPriv to commitInfoPriv - commitInfoPriv->attach = commitInfoPendingPriv->attach; - commitInfoPriv->damageSurface = commitInfoPendingPriv->damageSurface; - commitInfoPriv->transform = commitInfoPendingPriv->transform; - commitInfoPriv->scale = commitInfoPendingPriv->scale; - commitInfoPriv->damageBuffer = commitInfoPendingPriv->damageBuffer; - commitInfoPriv->bufferRef = std::move(commitInfoPendingPriv->bufferRef); - commitInfoPriv->bufferChanged = commitInfoPendingPriv->bufferChanged; - commitInfoPendingPriv->bufferChanged = false; // reset value - - // emit a signal of the surface committed - pub->__surfaceCommittedSignal.emit(__commitInfo); -} - -/*LCOV_EXCL_START*/ -void DSWaylandSurfacePrivate::surface_set_buffer_transform(Resource *resource, int32_t transform) -{ - DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); - - commitInfoPendingPriv->transform = transform; -} - -void DSWaylandSurfacePrivate::surface_set_buffer_scale(Resource *resource, int32_t scale) -{ - DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); - - commitInfoPendingPriv->scale = scale; -} - -void DSWaylandSurfacePrivate::surface_damage_buffer(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ - DSWaylandSurfaceCommitInfoPrivate *commitInfoPendingPriv = DSWaylandSurfaceCommitInfoPrivate::getPrivate(__commitInfoPending.get()); - - commitInfoPendingPriv->damageBuffer.x = x; - commitInfoPendingPriv->damageBuffer.y = y; - commitInfoPendingPriv->damageBuffer.width = width; - commitInfoPendingPriv->damageBuffer.height = height; -} -/*LCOV_EXCL_STOP*/ - -void DSWaylandSurfacePrivate::__sendSurfaceDestroy(void) -{ - if (__deleted) return; - - DS_GET_PUB(DSWaylandSurface); - - DSWaylandCompositor *dswCompositor = DSWaylandCompositor::getInstance(); - if (dswCompositor) - { - dswCompositor->sendSurfaceDestroy(pub); - } - DSWaylandCompositor::releaseInstance(); - - __deleted = true; -} - - - -DS_WAYLAND_IMPL_FROM_RESOURCE(DSWaylandSurface); - -/* DSWaylandSurface */ -DSWaylandSurface::DSWaylandSurface() - : DS_INIT_PRIVATE_PTR(DSWaylandSurface) -{ -} - -DSWaylandSurface::DSWaylandSurface(DSWaylandClient *waylandClient, uint32_t id) - : _d_ptr(std::make_unique(this, waylandClient, id)) -{ -} - -DSWaylandSurface::~DSWaylandSurface() -{ -} - -void DSWaylandSurface::registerCallbackSurfaceCommitted(DSObject *slot, std::function commitInfo)> func) -{ - this->__surfaceCommittedSignal.connect(slot, func); -} - -struct ::wl_resource *DSWaylandSurface::getWlResource() -{ - DS_GET_PRIV(DSWaylandSurface); - - return priv->resource()->handle; -} - -DSWaylandClient *DSWaylandSurface::getClient() -{ - DS_GET_PRIV(DSWaylandSurface); - - return priv->__waylandClient; -} - -bool DSWaylandSurface::hasResource() -{ - DS_GET_PRIV(DSWaylandSurface); - - if (priv->resource()) - return true; - return false; -} - -/*LCOV_EXCL_START*/ -uint32_t DSWaylandSurface::getResourceId() -{ - DS_GET_PRIV(DSWaylandSurface); - - return priv->getResourceId(); -} - -uint32_t DSWaylandSurface::getTizenResourceId() -{ - DS_GET_PRIV(DSWaylandSurface); - - return priv->getTizenResourceId(); -} -/*LCOV_EXCL_STOP*/ - -} /* namespace display_server */ diff --git a/src/DSWaylandServer/DSWaylandSurface.h b/src/DSWaylandServer/DSWaylandSurface.h deleted file mode 100644 index e715fc7..0000000 --- a/src/DSWaylandServer/DSWaylandSurface.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_SURFACE_H__ -#define __DS_WAYLAND_SURFACE_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSSignal.h" -#include "DSStruct.h" -#include "DSWaylandClient.h" -#include "IDSBuffer.h" - -struct wl_resource; - -namespace display_server -{ - -class DSWaylandSurfaceCommitInfoPrivate; -class DSWaylandSurfacePrivate; - -class DSWaylandSurfaceCommitInfo : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandSurfaceCommitInfo); -public: - DSWaylandSurfaceCommitInfo(); - virtual ~DSWaylandSurfaceCommitInfo(); - - //TODO: add getter functions. - std::shared_ptr getBuffer(); - bool bufferChanged(); -}; - -class DSWaylandSurface : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWaylandSurface); - DS_WAYLAND_DEFINE_FROM_RESOURCE(DSWaylandSurface); -public: - DSWaylandSurface(); - DSWaylandSurface(DSWaylandClient *waylandClient, uint32_t id); - virtual ~DSWaylandSurface(); - - // Callback methods - void registerCallbackSurfaceCommitted(DSObject *slot, std::function commitInfo)> func); - - struct ::wl_resource *getWlResource(); - DSWaylandClient *getClient(); - bool hasResource(); - - uint32_t getResourceId(); - uint32_t getTizenResourceId(); - -private: - // signals - DSSignal> __surfaceCommittedSignal; -}; - -} /* namespace display_server */ - -#endif /* _DS_WAYLAND_SURFACE_H_ */ diff --git a/src/DSWaylandServer/DSWaylandSurfacePrivate.h b/src/DSWaylandServer/DSWaylandSurfacePrivate.h deleted file mode 100644 index 6e344de..0000000 --- a/src/DSWaylandServer/DSWaylandSurfacePrivate.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_SURFACE_PRIVATE_H__ -#define __DS_WAYLAND_SURFACE_PRIVATE_H__ - -#include "dswayland-server-wayland.h" -#include "DSWaylandSurface.h" -#include "DSBufferManager.h" -#include "DSBufferRef.h" - -namespace display_server -{ - -class DSWaylandSurfaceCommitInfo; -class DSWaylandSurface; - -class DSWaylandSurfaceCommitInfoPrivate : public DSObjectPrivate -{ -DS_PIMPL_USE_PUBLIC(DSWaylandSurfaceCommitInfo); -public: - DSWaylandSurfaceCommitInfoPrivate() = delete; - DSWaylandSurfaceCommitInfoPrivate(DSWaylandSurfaceCommitInfo *p_ptr); - ~DSWaylandSurfaceCommitInfoPrivate() override; - - static DSWaylandSurfaceCommitInfoPrivate *getPrivate(DSWaylandSurfaceCommitInfo *q) { return q->__d_func(); } - - //TODO: add getter functions. - std::shared_ptr getBuffer(); - -public: - struct _attach { - int32_t x; - int32_t y; - struct ::wl_resource *buffer; - }; - std::unique_ptr bufferRef; - struct _attach attach; - bool bufferChanged; - - struct damageSurface { - int32_t x; - int32_t y; - int32_t width; - int32_t height; - }; - struct damageSurface damageSurface; - - //TODO: opaque_region - //TODO: input region - int32_t transform; - int32_t scale; - - struct damageBuffer { - int32_t x; - int32_t y; - int32_t width; - int32_t height; - }; - struct damageBuffer damageBuffer; -}; - -struct wl_resource; - -class DSWaylandSurfacePrivate : public DSObjectPrivate, public DSWaylandServer::wl_surface -{ -DS_PIMPL_USE_PUBLIC(DSWaylandSurface); -public: - DSWaylandSurfacePrivate() = delete; - DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr); - DSWaylandSurfacePrivate(DSWaylandSurface *p_ptr, DSWaylandClient *waylandClient, uint32_t id); - ~DSWaylandSurfacePrivate() override; - - uint32_t getResourceId(); - uint32_t getTizenResourceId(); - -protected: - void surface_bind_resource(Resource *resource) override; - void surface_destroy_resource(Resource *resource) override; - - void surface_destroy(Resource *resource) override; - void surface_attach(Resource *resource, struct ::wl_resource *buffer, int32_t x, int32_t y) override; - void surface_damage(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; - void surface_frame(Resource *resource, uint32_t callback) override; - void surface_set_opaque_region(Resource *resource, struct ::wl_resource *region) override; - void surface_set_input_region(Resource *resource, struct ::wl_resource *region) override; - void surface_commit(Resource *resource) override; - void surface_set_buffer_transform(Resource *resource, int32_t transform) override; - void surface_set_buffer_scale(Resource *resource, int32_t scale) override; - void surface_damage_buffer(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; - -private: - void __sendSurfaceDestroy(void); - -private: - bool __deleted; - std::unique_ptr __commitInfoPending; - std::shared_ptr __commitInfo; - DSWaylandClient *__waylandClient; - DSBufferManager *__bufferManager; - uint32_t __resId; - uint32_t __tizenResId; -}; - -} /*namespace display_server */ - -#endif /* _DS_WAYLAND_SURFACE_PRIVATE_H_ */ diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp deleted file mode 100644 index d365121..0000000 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ /dev/null @@ -1,1126 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTextInputManager.h" -#include "DSWaylandTextInputManagerPrivate.h" -#include "DSWaylandTextInput.h" -#include "DSWaylandTextInputPrivate.h" -#include "DSWaylandSurface.h" - -namespace display_server { - -/*LCOV_EXCL_START*/ -DSWaylandTextInputManagerPrivate::DSWaylandTextInputManagerPrivate(DSWaylandTextInputManager *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __compositor(compositor) -{ - if (!compositor) - return; - - wl_text_input_manager::init(__compositor->display(), 1); -} - -DSWaylandTextInputManagerPrivate::~DSWaylandTextInputManagerPrivate() -{ -} - -void DSWaylandTextInputManagerPrivate::text_input_manager_create_text_input(Resource *resource, uint32_t id) -{ - DS_GET_PUB(DSWaylandTextInputManager); - - pub->createTextInput((void *)(resource->client()), id); -} - - -DSWaylandTextInputManager::DSWaylandTextInputManager(DSWaylandCompositor *compositor) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __dsTextInputPrivate(nullptr), - __compositor(compositor), - __textInputId(0) -{ - __textInput = new DSWaylandTextInput(compositor, this); -} - -DSWaylandTextInputManager::DSWaylandTextInputManager(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __dsTextInputPrivate(dsTextInputPrivate), - __compositor(compositor), - __textInputId(0) -{ - __textInput = new DSWaylandTextInput(compositor, this, __dsTextInputPrivate); -} - -DSWaylandTextInputManager::~DSWaylandTextInputManager() -{ -} - -void DSWaylandTextInputManager::createTextInput(void *client, unsigned int managerId) -{ - __textInput->createGlobal(client, managerId, allocTextInputId()); -} - -int DSWaylandTextInputManager::allocTextInputId() -{ - return __textInputId++; -} - -void DSWaylandTextInputManager::contextCommitString(unsigned int serial, std::string text) -{ - __textInput->sendCommitString(serial, text); -} - -void DSWaylandTextInputManager::contextPreeditString(unsigned int serial, std::string text, std::string commit) -{ - __textInput->sendPreeditString(serial, text, commit); -} - -void DSWaylandTextInputManager::contextPreeditStyling(int index, unsigned int length, unsigned int style) -{ - __textInput->sendPreeditStyling(index, length, style); -} - -void DSWaylandTextInputManager::contextPreeditCursor(int index) -{ - __textInput->sendPreeditCursor(index); -} - -void DSWaylandTextInputManager::contextDeleteSurroundingText(int index, unsigned int length) -{ - __textInput->sendDeleteSurroundingText(index, length); -} - -void DSWaylandTextInputManager::contextCursorPosition(int index, int anchor) -{ - __textInput->sendCursorPosition(index, anchor); -} - -void DSWaylandTextInputManager::contextModifiersMap(std::string map) -{ - __textInput->sendModifiersMap(map); -} - -void DSWaylandTextInputManager::contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) -{ - __textInput->sendKeysym(serial, time, sym, state, modifiers); -} - -void DSWaylandTextInputManager::contextLanguage(unsigned int serial, std::string language) -{ - __textInput->sendLanguage(serial, language); -} - -void DSWaylandTextInputManager::contextTextDirection(unsigned int serial, unsigned int direction) -{ - __textInput->sendTextDirection(serial, direction); -} - -void DSWaylandTextInputManager::contextSelectionRegion(unsigned int serial, int start, int end) -{ - __textInput->sendSelectionRegion(serial, start, end); -} - -void DSWaylandTextInputManager::contextPrivateCommand(unsigned int serial, std::string command) -{ - __textInput->sendPrivateCommand(serial, command); -} - -void DSWaylandTextInputManager::contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) -{ - __textInput->sendInputPanelData(serial, inputPanelData, inputPanelDataLength); -} - -void DSWaylandTextInputManager::contextShowInputPanel() -{ - __textInput->showInputPanel(); -} - -void DSWaylandTextInputManager::contextHideInputPanel() -{ - __textInput->hideInputPanel(); -} - -void DSWaylandTextInputManager::contextGetSelectionText(int fd) -{ - __textInput->sendGetSelectionText(fd); -} - -void DSWaylandTextInputManager::contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) -{ - __textInput->sendGetSurroundingText(maxlenBefore, maxlenAfter, fd); -} - -void DSWaylandTextInputManager::contextFilterKeyEventDone(unsigned int serial, unsigned int state) -{ - __textInput->sendFilterKeyEventDone(serial, state); -} - -void DSWaylandTextInputManager::contextUpdateIseGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height) -{ - __textInput->sendInputPanelGeometry(x, y, width, height); -} - -void DSWaylandTextInputManager::contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) -{ - __textInput->sendRecaptureString(serial, index, length, preedit, preeditCommit, commit); -} - -void DSWaylandTextInputManager::contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) -{ - __textInput->sendInputPanelEvent(serial, eventType, value); -} - -void DSWaylandTextInputManager::contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) -{ - __textInput->sendCommitContent(serial, content, description, mimeTypes); -} - -void DSWaylandTextInputManager::updateTextInputPanelState(bool state) -{ - __textInput->updatePanelState(state); -} - -void DSWaylandTextInputManager::setGeometryUpdated(bool updated) -{ - __textInput->setGeometryUpdated(updated); -} - -DSWaylandSurface* DSWaylandTextInputManager::getTextInputSurface() -{ - return __textInput->getClientSurface(); -} - - -DSWaylandTextInputPrivate::DSWaylandTextInputPrivate(DSWaylandTextInput *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __compositor(compositor), - __showClient(nullptr), - __activatedResource(nullptr), - __clientSurface(nullptr) -{ -} - -DSWaylandTextInputPrivate::~DSWaylandTextInputPrivate() -{ -} - -void DSWaylandTextInputPrivate::createGlobal(void *client, unsigned int managerId, int id) -{ - Resource *resource = add((struct ::wl_client *)client, managerId, 1); - __resourceIdMap.insert(std::pair(resource, id)); -} - -int DSWaylandTextInputPrivate::getResourceId(Resource *resource) -{ - DS_GET_PUB(DSWaylandTextInput); - - int id = -1; - - if (pub->__dsTextInputPrivate) - { - std::multimap::iterator it; - for (it = __resourceIdMap.begin(); it != __resourceIdMap.end(); it++) - { - if (resource == (*it).first) - { - id = (*it).second; - break; - } - } - } - - return id; -} - -void DSWaylandTextInputPrivate::showInputPanel(void *resource) -{ - DS_GET_PUB(DSWaylandTextInput); - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - Resource *privateResource = Resource::fromResource((struct ::wl_resource *)resource); - - /* NOTE: bug, sometimes in this time, input_method_context is not exist */ - int id = getResourceId(privateResource); - - if (id >= 0) - { - pub->__dsTextInputPrivate->showInputPanel(pub, id); - __showClient = privateResource->client(); - pub->__dsTextInputPrivate->updateInputPanelState(true); - } - - if (pub->__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateWillHide) - { - send_private_command(privateResource->handle, 0, "CONFORMANT_RESTORE"); - } - - pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillShow); - pub->__geometryUpdated = false; - pub->__dsTextInputPrivate->setInputPanelTransientFor(__clientSurface); -} - -void DSWaylandTextInputPrivate::text_input_destroy(Resource *resource) -{ - __resourceIdMap.erase(resource); -} - -void DSWaylandTextInputPrivate::text_input_activate(Resource *resource, struct ::wl_resource *seat, struct ::wl_resource *surface) -{ - DS_GET_PUB(DSWaylandTextInput); - - int id = getResourceId(resource); - - if (__activatedResource) - { - pub->__dsTextInputPrivate->deactivateTextInput(pub); - send_leave(__activatedResource->handle); - } - - if (id >= 0) - pub->__dsTextInputPrivate->activateTextInput(pub, id); - - __activatedResource = resource; - __clientSurface = DSWaylandSurface::fromWlResource(surface); -} - -void DSWaylandTextInputPrivate::text_input_deactivate(Resource *resource, struct ::wl_resource *seat) -{ - DS_GET_PUB(DSWaylandTextInput); - - /* NOTE: need to check __activatedResource and current resource? */ - - pub->__dsTextInputPrivate->deactivateTextInput(pub); - - send_leave(resource->handle); - - __activatedResource = nullptr; -} - -void DSWaylandTextInputPrivate::text_input_show_input_panel(Resource *resource) -{ - showInputPanel(resource->handle); -} - -void DSWaylandTextInputPrivate::hideInputPanel(Resource *resource, bool forceHide) -{ - DS_GET_PUB(DSWaylandTextInput); - - send_input_panel_geometry(resource->handle, 0, 0, 0, 0); - send_input_panel_state(resource->handle, WL_TEXT_INPUT_INPUT_PANEL_STATE_HIDE); - - if (forceHide) - { - pub->__dsTextInputPrivate->changeInputPanelVisibility(false); - pub->__dsTextInputPrivate->setInputPanelTransientFor(nullptr); - pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateDidHide); - } - else - { - pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillHide); - send_private_command(resource->handle, 0, "CONFORMANT_RESET"); - - /* TODO: temporary ignore timer */ - } - /* TODO: bug, sometimes in this time, input_method_context is not exist */ - int id = getResourceId(resource); - if (id >= 0) - pub->__dsTextInputPrivate->hideInputPanel(id); - /* TODO: inputpanel wait update set */ -} - -void DSWaylandTextInputPrivate::text_input_hide_input_panel(Resource *resource) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - if (__showClient == resource->client()) - { - hideInputPanel(resource, false); - __showClient = nullptr; - } -} - -void DSWaylandTextInputPrivate::text_input_reset(Resource *resource) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->resetTextInput(); -} - -void DSWaylandTextInputPrivate::text_input_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->setContentType(hint, purpose); -} - -void DSWaylandTextInputPrivate::text_input_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - /* NOTE: Nothing to do in this request */ -} - -void DSWaylandTextInputPrivate::text_input_set_preferred_language(Resource *resource, const std::string &language) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->setPreferredLanguage(language); -} - -void DSWaylandTextInputPrivate::text_input_commit_state(Resource *resource, uint32_t serial) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->commitState(serial); -} - -void DSWaylandTextInputPrivate::text_input_invoke_action(Resource *resource, uint32_t button, uint32_t index) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->invokeAction(button, index); -} - -void DSWaylandTextInputPrivate::text_input_set_return_key_type(Resource *resource, uint32_t return_key_type) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->setReturnKeyType(return_key_type); -} - -void DSWaylandTextInputPrivate::text_input_set_return_key_disabled(Resource *resource, uint32_t return_key_disabled) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->returnKeyDisabled(return_key_disabled); -} - -void DSWaylandTextInputPrivate::text_input_set_input_panel_data(Resource *resource, const std::string &input_panel_data, uint32_t input_panel_length) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->setInputPanelData(input_panel_data, input_panel_length); - - if (!input_panel_data.compare("WILL_HIDE_ACK")) - { - /* TODO: will hide timer control */ - if (pub->__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateWillHide) - { - pub->__dsTextInputPrivate->changeInputPanelVisibility(false); - pub->__dsTextInputPrivate->setInputPanelTransientFor(nullptr); - pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateDidShow); - } - } -} - -void DSWaylandTextInputPrivate::text_input_bidi_direction(Resource *resource, uint32_t direction) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->bidiDirection(direction); -} - -void DSWaylandTextInputPrivate::text_input_set_cursor_position(Resource *resource, uint32_t cursor_position) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->setCursorPosition(cursor_position); -} - -void DSWaylandTextInputPrivate::text_input_process_input_device_event(Resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->processInputDeviceEvent(event_type, event_data, event_length); -} - -void DSWaylandTextInputPrivate::text_input_filter_key_event(Resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - pub->__dsTextInputPrivate->filterKeyEvent(serial, time, keyname, state, modifiers, dev_name, dev_class, dev_subclass, keycode); - } - else - { - send_filter_key_event_done(resource->handle, serial, false); - } -} - -void DSWaylandTextInputPrivate::text_input_get_hide_permission(Resource *resource) -{ - unsigned int permission = 1; - - /* TODO: compare __clientSurface is focused */ - - send_hide_permission(resource->handle, permission); -} - -void DSWaylandTextInputPrivate::text_input_set_capital_mode(Resource *resource, uint32_t mode) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->setCapitalMode(mode); -} - -void DSWaylandTextInputPrivate::text_input_prediction_hint(Resource *resource, const std::string &text) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->predictionHint(text); -} - -void DSWaylandTextInputPrivate::text_input_set_mime_type(Resource *resource, const std::string &type) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->setMimeType(type); -} - -void DSWaylandTextInputPrivate::text_input_set_input_panel_position(Resource *resource, uint32_t x, uint32_t y) -{ - /* TODO: input panel position set */ -} - -void DSWaylandTextInputPrivate::text_input_finalize_content(Resource *resource, const std::string &text, uint32_t cursor_position) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->finalizeContent(text, cursor_position); -} - -void DSWaylandTextInputPrivate::text_input_prediction_hint_data(Resource *resource, const std::string &key, const std::string &value) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - pub->__dsTextInputPrivate->predictionHintData(key, value); -} - -void DSWaylandTextInputPrivate::text_input_input_panel_enabled(Resource *resource, uint32_t enabled) -{ -} - - -void DSWaylandTextInputPrivate::sendCommitString(unsigned int serial, std::string text) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_commit_string(__activatedResource->handle, serial, text); -} - -void DSWaylandTextInputPrivate::sendPreeditString(unsigned int serial, std::string text, std::string commit) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_preedit_string(__activatedResource->handle, serial, text, commit); -} - -void DSWaylandTextInputPrivate::sendPreeditStyling(int index, unsigned int length, unsigned int style) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_preedit_styling(__activatedResource->handle, index, length, style); -} - -void DSWaylandTextInputPrivate::sendPreeditCursor(int index) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_preedit_cursor(__activatedResource->handle, index); -} - -void DSWaylandTextInputPrivate::sendDeleteSurroundingText(int index, unsigned int length) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_delete_surrounding_text(__activatedResource->handle, index, length); -} - -void DSWaylandTextInputPrivate::sendCursorPosition(int index, int anchor) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_cursor_position(__activatedResource->handle, index, anchor); -} - -void DSWaylandTextInputPrivate::sendModifiersMap(std::string map) -{ - struct ::wl_array map_data; - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - wl_array_init(&map_data); - char *strptr = (char *)wl_array_add(&map_data, map.length()); - std::copy(map.c_str(), map.c_str() + map.length(), strptr); - - send_modifiers_map(__activatedResource->handle, &map_data); - - wl_array_release(&map_data); -} - -void DSWaylandTextInputPrivate::sendKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_keysym(__activatedResource->handle, serial, time, sym, state, modifiers); -} - -void DSWaylandTextInputPrivate::sendLanguage(unsigned int serial, std::string language) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_language(__activatedResource->handle, serial, language); -} - -void DSWaylandTextInputPrivate::sendTextDirection(unsigned int serial, unsigned int direction) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_text_direction(__activatedResource->handle, serial, direction); -} - -void DSWaylandTextInputPrivate::sendSelectionRegion(unsigned int serial, int start, int end) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_selection_region(__activatedResource->handle, serial, start, end); -} - -void DSWaylandTextInputPrivate::sendPrivateCommand(unsigned int serial, std::string command) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_private_command(__activatedResource->handle, serial, command); -} - -void DSWaylandTextInputPrivate::sendInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_input_panel_data(__activatedResource->handle, serial, inputPanelData, inputPanelDataLength); -} - -void DSWaylandTextInputPrivate::sendGetSelectionText(int fd) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_get_selection_text(__activatedResource->handle, fd); -} - -void DSWaylandTextInputPrivate::sendGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_get_surrounding_text(__activatedResource->handle, maxlenBefore, maxlenAfter, fd); -} - -void DSWaylandTextInputPrivate::sendFilterKeyEventDone(unsigned int serial, unsigned int state) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_filter_key_event_done(__activatedResource->handle, serial, state); -} - -void DSWaylandTextInputPrivate::sendInputPanelGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_input_panel_geometry(__activatedResource->handle, x, y, width, height); -} - -void DSWaylandTextInputPrivate::sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_recapture_string(__activatedResource->handle, serial, index, length, preedit, preeditCommit, commit); -} - -void DSWaylandTextInputPrivate::sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_input_panel_event(__activatedResource->handle, serial, eventType, value); -} - -void DSWaylandTextInputPrivate::sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) -{ - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - send_commit_content(__activatedResource->handle, serial, content, description, mimeTypes); -} - -void DSWaylandTextInputPrivate::updatePanelState(bool state) -{ - DS_GET_PUB(DSWaylandTextInput); - - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - if (!pub->__geometryUpdated) - { - stGeometry geo = pub->__dsTextInputPrivate->inputPanelGetGeometry(nullptr); - if (!(geo.w <= 1 || geo.h <= 1)) - pub->sendInputPanelGeometry(geo.x, geo.y, geo.w, geo.h); - pub->__geometryUpdated = true; - } - - unsigned int inputPanelState = WL_TEXT_INPUT_INPUT_PANEL_STATE_HIDE; - if (state) inputPanelState = WL_TEXT_INPUT_INPUT_PANEL_STATE_SHOW; - - send_input_panel_state(__activatedResource->handle, inputPanelState); -} - -void DSWaylandTextInputPrivate::updatePanelGeometry(DSWaylandSurface *wlSurface) -{ - DS_GET_PUB(DSWaylandTextInput); - if ((pub->__dsTextInputPrivate->getInputPanelState() != DSTextInputPrivate::InputPanelStateWillHide) && - (pub->__dsTextInputPrivate->getInputPanelState() != DSTextInputPrivate::InputPanelStateDidHide) && - (pub->__geometryUpdated)) - { - stGeometry geo = pub->__dsTextInputPrivate->inputPanelGetGeometry(nullptr); - if (!(geo.w <= 1 || geo.h <= 1)) - pub->sendInputPanelGeometry(geo.x, geo.y, geo.w, geo.h); - } -} - - -DSWaylandTextInput::DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylandTextInputManager *textInputManager) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __compositor(compositor), - __textInputManager(textInputManager), - __dsTextInputPrivate(nullptr), - __geometryUpdated(false) -{ -} - -DSWaylandTextInput::DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylandTextInputManager *textInputManager, DSTextInputPrivate *dsTextInputPrivate) - : DSObject(), _d_ptr(std::make_unique(this, compositor)), - __compositor(compositor), - __textInputManager(textInputManager), - __dsTextInputPrivate(dsTextInputPrivate), - __geometryUpdated(false) -{ -} - -DSWaylandTextInput::~DSWaylandTextInput() -{ -} - -void DSWaylandTextInput::createGlobal(void *client, unsigned int managerId, int id) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->createGlobal(client, managerId, id); -} - -void DSWaylandTextInput::showInputPanel() -{ - DS_GET_PRIV(DSWaylandTextInput); - - if (priv->__activatedResource) - priv->showInputPanel(priv->__activatedResource); -} - -void DSWaylandTextInput::hideInputPanel() -{ - DS_GET_PRIV(DSWaylandTextInput); - - if (priv->__activatedResource) - priv->hideInputPanel(priv->__activatedResource, false); -} - -void DSWaylandTextInput::sendCommitString(unsigned int serial, std::string text) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendCommitString(serial, text); -} - -void DSWaylandTextInput::sendPreeditString(unsigned int serial, std::string text, std::string commit) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendPreeditString(serial, text, commit); -} - -void DSWaylandTextInput::sendPreeditStyling(int index, unsigned int length, unsigned int style) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendPreeditStyling(index, length, style); -} - -void DSWaylandTextInput::sendPreeditCursor(int index) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendPreeditCursor(index); -} - -void DSWaylandTextInput::sendDeleteSurroundingText(int index, unsigned int length) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendDeleteSurroundingText(index, length); -} - -void DSWaylandTextInput::sendCursorPosition(int index, int anchor) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendCursorPosition(index, anchor); -} - -void DSWaylandTextInput::sendModifiersMap(std::string map) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendModifiersMap(map); -} - -void DSWaylandTextInput::sendKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendKeysym(serial, time, sym, state, modifiers); -} - -void DSWaylandTextInput::sendLanguage(unsigned int serial, std::string language) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendLanguage(serial, language); -} - -void DSWaylandTextInput::sendTextDirection(unsigned int serial, unsigned int direction) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendTextDirection(serial, direction); -} - -void DSWaylandTextInput::sendSelectionRegion(unsigned int serial, int start, int end) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendSelectionRegion(serial, start, end); -} - -void DSWaylandTextInput::sendPrivateCommand(unsigned int serial, std::string command) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendPrivateCommand(serial, command); -} - -void DSWaylandTextInput::sendInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendInputPanelData(serial, inputPanelData, inputPanelDataLength); -} - -void DSWaylandTextInput::sendGetSelectionText(int fd) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendGetSelectionText(fd); -} - -void DSWaylandTextInput::sendGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendGetSurroundingText(maxlenBefore, maxlenAfter, fd); -} - -void DSWaylandTextInput::sendFilterKeyEventDone(unsigned int serial, unsigned int state) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendFilterKeyEventDone(serial, state); -} - -void DSWaylandTextInput::sendInputPanelGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height) -{ - DS_GET_PRIV(DSWaylandTextInput); - - int angle = 0; - char geometry[128] = {0, }; - - if (priv->__clientSurface) - { - /* TODO: calculate angle and set this value to vconf */ - } - - snprintf(geometry, sizeof(geometry), "%d,%d,%d,%d", x, y, width, height); - - switch(angle) - { - case 90: - case 270: - //vconf_set_str(VCONFKEY_ISF_IME_RECENT_LAND_GEOMETRY, geometry); - break; - default: - //vconf_set_str(VCONFKEY_ISF_IME_RECENT_PORT_GEOMETRY, geometry); - break; - } - - priv->sendInputPanelGeometry(x, y, width, height); -} - -void DSWaylandTextInput::sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendRecaptureString(serial, index, length, preedit, preeditCommit, commit); -} - -void DSWaylandTextInput::sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendInputPanelEvent(serial, eventType, value); -} - -void DSWaylandTextInput::sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->sendCommitContent(serial, content, description, mimeTypes); -} - -void DSWaylandTextInput::updatePanelState(bool state) -{ - DS_GET_PRIV(DSWaylandTextInput); - - priv->updatePanelState(state); -} - -void DSWaylandTextInput::setGeometryUpdated(bool updated) -{ - __geometryUpdated = updated; -} - -DSWaylandSurface* DSWaylandTextInput::getClientSurface() -{ - DS_GET_PRIV(DSWaylandTextInput); - - return priv->__clientSurface; -} -/*LCOV_EXCL_STOP*/ - -} diff --git a/src/DSWaylandServer/DSWaylandTextInput.h b/src/DSWaylandServer/DSWaylandTextInput.h deleted file mode 100644 index c6b738b..0000000 --- a/src/DSWaylandServer/DSWaylandTextInput.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TEXT_INPUT_H__ -#define __DS_WAYLAND_TEXT_INPUT_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSWaylandTextInputManager.h" - -namespace display_server -{ - -class DSWaylandTextInputPrivate; -class DSTextInputPrivate; -class DSWaylandSurface; - -class DS_DECL_EXPORT DSWaylandTextInput : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTextInput); -public: - DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylandTextInputManager *textInputManager); - DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylandTextInputManager *textInputManager, DSTextInputPrivate *dsTextInputPrivate); - ~DSWaylandTextInput() override; - - void createGlobal(void *client, unsigned int managerId, int id); - void showInputPanel(); - void hideInputPanel(); - - void sendCommitString(unsigned int serial, std::string text); - void sendPreeditString(unsigned int serial, std::string text, std::string commit); - void sendPreeditStyling(int index, unsigned int length, unsigned int style); - void sendPreeditCursor(int index); - void sendDeleteSurroundingText(int index, unsigned int length); - void sendCursorPosition(int index, int anchor); - void sendModifiersMap(std::string map); - void sendKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); - void sendLanguage(unsigned int serial, std::string language); - void sendTextDirection(unsigned int serial, unsigned int direction); - void sendSelectionRegion(unsigned int serial, int start, int end); - void sendPrivateCommand(unsigned int serial, std::string command); - void sendInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); - void sendGetSelectionText(int fd); - void sendGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); - void sendFilterKeyEventDone(unsigned int serial, unsigned int state); - void sendInputPanelGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height); - void sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); - void sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); - void sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); - - void updatePanelState(bool state); - void setGeometryUpdated(bool updated); - DSWaylandSurface* getClientSurface(); - -protected: - -private: - DSWaylandCompositor *__compositor; - DSWaylandTextInputManager *__textInputManager; - DSTextInputPrivate *__dsTextInputPrivate; - bool __geometryUpdated; -}; - -} - -#endif //__DS_WAYLAND_TEXT_INPUT_H__ diff --git a/src/DSWaylandServer/DSWaylandTextInputManager.h b/src/DSWaylandServer/DSWaylandTextInputManager.h deleted file mode 100644 index c19519f..0000000 --- a/src/DSWaylandServer/DSWaylandTextInputManager.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TEXT_INPUT_MANAGER_H__ -#define __DS_WAYLAND_TEXT_INPUT_MANAGER_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSWaylandCompositor.h" -#include "DSTextInputPrivate.h" - -namespace display_server -{ - -class DSWaylandTextInputManagerPrivate; -class DSWaylandTextInput; -class DSWaylansSurface; - -class DS_DECL_EXPORT DSWaylandTextInputManager : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTextInputManager); -public: - DSWaylandTextInputManager(DSWaylandCompositor *compositor); - DSWaylandTextInputManager(DSWaylandCompositor *compositor, DSTextInputPrivate *dsTextInputPrivate); - ~DSWaylandTextInputManager() override; - - void createTextInput(void *client, unsigned int managerId); - int allocTextInputId(); - - void contextCommitString(unsigned int serial, std::string text); - void contextPreeditString(unsigned int serial, std::string text, std::string commit); - void contextPreeditStyling(int index, unsigned int length, unsigned int style); - void contextPreeditCursor(int index); - void contextDeleteSurroundingText(int index, unsigned int length); - void contextCursorPosition(int index, int anchor); - void contextModifiersMap(std::string map); - void contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); - void contextLanguage(unsigned int serial, std::string language); - void contextTextDirection(unsigned int serial, unsigned int direction); - void contextSelectionRegion(unsigned int serial, int start, int end); - void contextPrivateCommand(unsigned int serial, std::string command); - void contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); - void contextShowInputPanel(); - void contextHideInputPanel(); - void contextGetSelectionText(int fd); - void contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); - void contextFilterKeyEventDone(unsigned int serial, unsigned int state); - void contextUpdateIseGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height); - void contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); - void contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); - void contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); - - void updateTextInputPanelState(bool state); - void setGeometryUpdated(bool updated); - DSWaylandSurface* getTextInputSurface(); - -protected: - -private: - DSTextInputPrivate *__dsTextInputPrivate; - DSWaylandCompositor *__compositor; - DSWaylandTextInput *__textInput; - int __textInputId; -}; - -} - -#endif //__DS_WAYLAND_TEXT_INPUT_MANAGER_H__ diff --git a/src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h b/src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h deleted file mode 100644 index fa5d557..0000000 --- a/src/DSWaylandServer/DSWaylandTextInputManagerPrivate.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TEXT_INPUT_MANAGER_PRIVATE_H__ -#define __DS_WAYLAND_TEXT_INPUT_MANAGER_PRIVATE_H__ - -#include "dswayland-server-text.h" - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "DSWaylandTextInputManager.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DS_DECL_EXPORT DSWaylandTextInputManagerPrivate : public DSObjectPrivate, public DSWaylandServer::wl_text_input_manager -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTextInputManager); -public: - DSWaylandTextInputManagerPrivate(DSWaylandTextInputManager *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandTextInputManagerPrivate() override; - -protected: - void text_input_manager_create_text_input(Resource *resource, uint32_t id); - -private: - DSWaylandCompositor *__compositor; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_TEXT_INPUT_MANAGER_PRIVATE_H__ - diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h deleted file mode 100644 index 55fb499..0000000 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TEXT_INPUT_PRIVATE_H__ -#define __DS_WAYLAND_TEXT_INPUT_PRIVATE_H__ - -#include "dswayland-server-text.h" - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "DSWaylandTextInput.h" - -namespace display_server -{ - -class DSWaylandSurface; - -class DS_DECL_EXPORT DSWaylandTextInputPrivate : public DSObjectPrivate, public DSWaylandServer::wl_text_input -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTextInput); -public: - DSWaylandTextInputPrivate(DSWaylandTextInput *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandTextInputPrivate() override; - - void createGlobal(void *client, unsigned int managerId, int id); - int getResourceId(Resource *resource); - void showInputPanel(void *resource); - void hideInputPanel(Resource *resource, bool forceHide); - - void sendCommitString(unsigned int serial, std::string text); - void sendPreeditString(unsigned int serial, std::string text, std::string commit); - void sendPreeditStyling(int index, unsigned int length, unsigned int style); - void sendPreeditCursor(int index); - void sendDeleteSurroundingText(int index, unsigned int length); - void sendCursorPosition(int index, int anchor); - void sendModifiersMap(std::string map); - void sendKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); - void sendLanguage(unsigned int serial, std::string language); - void sendTextDirection(unsigned int serial, unsigned int direction); - void sendSelectionRegion(unsigned int serial, int start, int end); - void sendPrivateCommand(unsigned int serial, std::string command); - void sendInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); - void sendGetSelectionText(int fd); - void sendGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); - void sendFilterKeyEventDone(unsigned int serial, unsigned int state); - void sendInputPanelGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height); - void sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); - void sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); - void sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); - void updatePanelState(bool state); - void updatePanelGeometry(DSWaylandSurface *wlSurface); - -protected: - void text_input_destroy(Resource *resource); - void text_input_activate(Resource *resource, struct ::wl_resource *seat, struct ::wl_resource *surface); - void text_input_deactivate(Resource *resource, struct ::wl_resource *seat); - void text_input_show_input_panel(Resource *resource); - void text_input_hide_input_panel(Resource *resource); - void text_input_reset(Resource *resource); - void text_input_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose); - void text_input_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - void text_input_set_preferred_language(Resource *resource, const std::string &language); - void text_input_commit_state(Resource *resource, uint32_t serial); - void text_input_invoke_action(Resource *resource, uint32_t button, uint32_t index); - void text_input_set_return_key_type(Resource *resource, uint32_t return_key_type); - void text_input_set_return_key_disabled(Resource *resource, uint32_t return_key_disabled); - void text_input_set_input_panel_data(Resource *resource, const std::string &input_panel_data, uint32_t input_panel_length); - void text_input_bidi_direction(Resource *resource, uint32_t direction); - void text_input_set_cursor_position(Resource *resource, uint32_t cursor_position); - void text_input_process_input_device_event(Resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length); - void text_input_filter_key_event(Resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode); - void text_input_get_hide_permission(Resource *resource); - void text_input_set_capital_mode(Resource *resource, uint32_t mode); - void text_input_prediction_hint(Resource *resource, const std::string &text); - void text_input_set_mime_type(Resource *resource, const std::string &type); - void text_input_set_input_panel_position(Resource *resource, uint32_t x, uint32_t y); - void text_input_finalize_content(Resource *resource, const std::string &text, uint32_t cursor_position); - void text_input_prediction_hint_data(Resource *resource, const std::string &key, const std::string &value); - void text_input_input_panel_enabled(Resource *resource, uint32_t enabled); - -private: - DSWaylandCompositor *__compositor; - std::multimap __resourceIdMap; - struct ::wl_client *__showClient; - Resource *__activatedResource; - DSWaylandSurface *__clientSurface; -}; - -} - -#endif //__DS_WAYLAND_TEXT_INPUT_PRIVATE_H__ - diff --git a/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp b/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp deleted file mode 100644 index 8bfbd02..0000000 --- a/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenAppinfo.h" -#include "DSWaylandTizenAppinfoPrivate.h" -#include "DSTizenAppinfoMgr.h" - -const int TIZEN_APPINFO_VERSION = 1; - -namespace display_server -{ - -DSWaylandTizenAppinfoPrivate::DSWaylandTizenAppinfoPrivate(DSWaylandTizenAppinfo *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ -} - -DSWaylandTizenAppinfoPrivate::~DSWaylandTizenAppinfoPrivate() -{ -} - -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_initialize(DSWaylandCompositor *wlCompositor) -{ - ::wl_display *display; - display = wlCompositor->display(); - - init(display, TIZEN_APPINFO_VERSION); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_finalize(void) -{ -} - -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_bind_resource(Resource *resource) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_destroy_resource(Resource *resource) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); -} -/*LCOV_EXCL_START*/ -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_destroy(Resource *resource) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_register_pid(Resource *resource, uint32_t pid) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_deregister_pid(Resource *resource, uint32_t pid) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_set_appid(Resource *resource, uint32_t pid, const std::string &appid) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); -} - -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_get_base_output_resolution(Resource *resource, uint32_t pid) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); - DS_GET_PUB(DSWaylandTizenAppinfo); - bool result; - int res_w, res_h; - if (pub->__dsAppinfoMgr == nullptr) - return; - - result = pub->__dsAppinfoMgr->getBaseOutputResolution(pid, &res_w, &res_h); - if (!result) { - /* TODO: Read configured resolution values */ - /* FIXME : get base resolution from the correct way */ - res_w = 720; - res_h = 1280; - } - send_base_output_resolution_done(resource->handle, pid, res_w, res_h); - DSLOG_DBG("TizenAppinfoPriv", "SEND base_output_resolution_done event with width(%d), height(%d)", res_w, res_h); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_register_appid(Resource *resource, const std::string &appid) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); - DS_GET_PUB(DSWaylandTizenAppinfo); - if (pub->__dsAppinfoMgr) - pub->__dsAppinfoMgr->addTizenAppinfo(appid); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_deregister_appid(Resource *resource, const std::string &appid) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); - DS_GET_PUB(DSWaylandTizenAppinfo); - if (pub->__dsAppinfoMgr) - pub->__dsAppinfoMgr->removeTizenAppinfo(appid); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_set_pid(Resource *resource, const std::string &appid, uint32_t pid) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); - DS_GET_PUB(DSWaylandTizenAppinfo); - if (pub->__dsAppinfoMgr) - pub->__dsAppinfoMgr->updateTizenAppinfo(appid, pid); -} -void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_ready_metadata(Resource *resource, const std::string &appid, uint32_t pid) -{ - DSLOG_DBG("TizenAppinfoPriv", ""); -} -/*LCOV_EXCL_STOP*/ - -DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor) - : DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo), - __wlCompositor(wlCompositor), - __isCreated(false), - __isGetDSTizenAppinfoMgr(false) -{ - this->initialize(__wlCompositor); - __dsAppinfoMgr = DSTizenAppinfoMgr::getInstance(); - __isGetDSTizenAppinfoMgr = true; -} - -DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor, DSTizenAppinfoMgr *dsAppinfoMgr) - : DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo), - __wlCompositor(wlCompositor), - __isCreated(false), - __isGetDSTizenAppinfoMgr(false), - __dsAppinfoMgr(dsAppinfoMgr) -{ - this->initialize(__wlCompositor); -} - -DSWaylandTizenAppinfo::~DSWaylandTizenAppinfo() -{ - if (__isGetDSTizenAppinfoMgr) - DSTizenAppinfoMgr::releaseInstance(); - - if (isCreated()) - this->finalize(); -} - -bool DSWaylandTizenAppinfo::isCreated(void) -{ - return __isCreated; -} - -bool DSWaylandTizenAppinfo::initialize(DSWaylandCompositor *wlCompositor) -{ - if (!wlCompositor) return false; - if (isCreated()) - { - DSLOG_ERR("TizenAppinfo", "Already initialized"); - return true; - } - - DS_GET_PRIV(DSWaylandTizenAppinfo); - if (!priv) return false; - - __wlCompositor = wlCompositor; - __isCreated = true; - - priv->tizen_launch_appinfo_initialize(__wlCompositor); - - DSLOG_INF("TizenAppinfo", "TizenAppinfo initialized"); - return true; -} - -void DSWaylandTizenAppinfo::finalize(void) -{ - DS_GET_PRIV(DSWaylandTizenAppinfo); - priv->tizen_launch_appinfo_finalize(); - - DSLOG_INF("TizenAppinfo", "TizenAppinfo finalized"); - __isCreated = false; -} - -} diff --git a/src/DSWaylandServer/DSWaylandTizenAppinfo.h b/src/DSWaylandServer/DSWaylandTizenAppinfo.h deleted file mode 100644 index f11b122..0000000 --- a/src/DSWaylandServer/DSWaylandTizenAppinfo.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_APPINFO_H__ -#define __DS_WAYLAND_TIZEN_APPINFO_H__ - -#include -#include -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -class DSWaylandTizenAppinfoPrivate; -class DSTizenAppinfoMgr; - -class DSWaylandTizenAppinfo : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenAppinfo); - -public: - DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor); - DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor, DSTizenAppinfoMgr *dsAppinfoMgr); - virtual ~DSWaylandTizenAppinfo(); - - bool isCreated(void); - - bool initialize(DSWaylandCompositor *wlCompositor); - void finalize(void); - -private: - DSWaylandCompositor *__wlCompositor; - bool __isCreated; - bool __isGetDSTizenAppinfoMgr; - DSTizenAppinfoMgr *__dsAppinfoMgr; - -}; - -} - -#endif // __DS_WAYLAND_TIZEN_APPINFO_H__ - - diff --git a/src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h b/src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h deleted file mode 100644 index b32fc96..0000000 --- a/src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_APPINFO_PRIVATE_H__ -#define __DS_WAYLAND_TIZEN_APPINFO_PRIVATE_H__ - -#include "dswayland-server-tizen-launch.h" - -#include "DSWaylandTizenAppinfo.h" - -namespace display_server -{ - -class DS_DECL_EXPORT DSWaylandTizenAppinfoPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_launch_appinfo -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenAppinfo); - -public: - DSWaylandTizenAppinfoPrivate() = delete; - DSWaylandTizenAppinfoPrivate(DSWaylandTizenAppinfo *p_ptr); - ~DSWaylandTizenAppinfoPrivate() override; - - void tizen_launch_appinfo_initialize(DSWaylandCompositor *wlCompositor); - void tizen_launch_appinfo_finalize(void); - -protected: - void tizen_launch_appinfo_bind_resource(Resource *resource) override; - void tizen_launch_appinfo_destroy_resource(Resource *resource) override; - - void tizen_launch_appinfo_destroy(Resource *resource) override; - void tizen_launch_appinfo_register_pid(Resource *resource, uint32_t pid) override; - void tizen_launch_appinfo_deregister_pid(Resource *resource, uint32_t pid) override; - void tizen_launch_appinfo_set_appid(Resource *resource, uint32_t pid, const std::string &appid) override; - void tizen_launch_appinfo_get_base_output_resolution(Resource *resource, uint32_t pid) override; - void tizen_launch_appinfo_register_appid(Resource *resource, const std::string &appid) override; - void tizen_launch_appinfo_deregister_appid(Resource *resource, const std::string &appid) override; - void tizen_launch_appinfo_set_pid(Resource *resource, const std::string &appid, uint32_t pid) override; - void tizen_launch_appinfo_ready_metadata(Resource *resource, const std::string &appid, uint32_t pid) override; - -private: - -}; - -} - -#endif // __DS_WAYLAND_TIZEN_APPINFO_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandTizenIndicator.cpp b/src/DSWaylandServer/DSWaylandTizenIndicator.cpp deleted file mode 100644 index 6f2916c..0000000 --- a/src/DSWaylandServer/DSWaylandTizenIndicator.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenIndicator.h" -#include "DSWaylandTizenIndicatorPrivate.h" - -namespace display_server -{ - -DSWaylandTizenIndicator::DSWaylandTizenIndicator() - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenIndicator) -{ -} - -DSWaylandTizenIndicator::~DSWaylandTizenIndicator() -{ -} - -void DSWaylandTizenIndicator::setVisibleType(visible_type type) -{ - DS_GET_PRIV(DSWaylandTizenIndicator); - - priv->setVisibleType(type); -} -DSWaylandTizenIndicator::visible_type DSWaylandTizenIndicator::getVisibleType() -{ - DS_GET_PRIV(DSWaylandTizenIndicator); - - return priv->getVisibleType(); -} - - -DSWaylandTizenIndicatorPrivate::DSWaylandTizenIndicatorPrivate(DSWaylandTizenIndicator *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __vis_type(DSWaylandTizenIndicator::DS_INDICATOR_VISIBLE_TYPE_UNKNOWN) -{ -} - -DSWaylandTizenIndicatorPrivate::~DSWaylandTizenIndicatorPrivate() -{ -} - -/*LCOV_EXCL_START*/ -void DSWaylandTizenIndicatorPrivate::tizen_indicator_bind_resource(Resource *resource) -{ -} -void DSWaylandTizenIndicatorPrivate::tizen_indicator_destroy_resource(Resource *resource) -{ -} -void DSWaylandTizenIndicatorPrivate::tizen_indicator_destroy(Resource *resource) -{ -} -void DSWaylandTizenIndicatorPrivate::tizen_indicator_set_state(Resource *resource, struct ::wl_resource *surface, int32_t state) -{ -} -void DSWaylandTizenIndicatorPrivate::tizen_indicator_set_opacity_mode(Resource *resource, struct ::wl_resource *surface, int32_t mode) -{ -} -void DSWaylandTizenIndicatorPrivate::tizen_indicator_set_visible_type(Resource *resource, struct ::wl_resource *surface, int32_t type) -{ - DSWaylandTizenIndicator::visible_type vtype = DSWaylandTizenIndicator::DS_INDICATOR_VISIBLE_TYPE_UNKNOWN; - - if (type == DSWaylandServer::tizen_indicator::visible_type_hidden) - vtype = DSWaylandTizenIndicator::DS_INDICATOR_VISIBLE_TYPE_HIDDEN; - else - vtype = DSWaylandTizenIndicator::DS_INDICATOR_VISIBLE_TYPE_SHOWN; - - this->setVisibleType(vtype); -} -/*LCOV_EXCL_STOP*/ - -void DSWaylandTizenIndicatorPrivate::setVisibleType(DSWaylandTizenIndicator::visible_type type) -{ - this->__vis_type = type; -} - -DSWaylandTizenIndicator::visible_type DSWaylandTizenIndicatorPrivate::getVisibleType() -{ - return this->__vis_type; -} - - -} // namespace display_server - diff --git a/src/DSWaylandServer/DSWaylandTizenIndicator.h b/src/DSWaylandServer/DSWaylandTizenIndicator.h deleted file mode 100644 index 1d04c96..0000000 --- a/src/DSWaylandServer/DSWaylandTizenIndicator.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_INDICATOR_H__ -#define __DS_WAYLAND_TIZEN_INDICATOR_H__ - -#include -#include - -namespace display_server -{ - -class DSWaylandTizenIndicatorPrivate; - -class DSWaylandTizenIndicator : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenIndicator); - -public: - - enum visible_type { - DS_INDICATOR_VISIBLE_TYPE_UNKNOWN = -1, - DS_INDICATOR_VISIBLE_TYPE_SHOWN, - DS_INDICATOR_VISIBLE_TYPE_HIDDEN, - }; - - DSWaylandTizenIndicator(); - virtual ~DSWaylandTizenIndicator(); - - void setVisibleType(visible_type type); - visible_type getVisibleType(); -}; - -} - -#endif // __DS_WAYLAND_TIZEN_INDICATOR_H__ - diff --git a/src/DSWaylandServer/DSWaylandTizenIndicatorPrivate.h b/src/DSWaylandServer/DSWaylandTizenIndicatorPrivate.h deleted file mode 100644 index d7828ba..0000000 --- a/src/DSWaylandServer/DSWaylandTizenIndicatorPrivate.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_INDICATOR_PRIVATE_H__ -#define __DS_WAYLAND_TIZEN_INDICATOR_PRIVATE_H__ - -#include "dswayland-server-tizen-extension.h" -#include "DSWaylandTizenIndicator.h" - -namespace display_server -{ - -class DS_DECL_EXPORT DSWaylandTizenIndicatorPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_indicator -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenIndicator); - -public: - DSWaylandTizenIndicatorPrivate() = delete; - DSWaylandTizenIndicatorPrivate(DSWaylandTizenIndicator *p_ptr); - ~DSWaylandTizenIndicatorPrivate() override; - -protected: - void tizen_indicator_bind_resource(Resource *resource) override; - void tizen_indicator_destroy_resource(Resource *resource) override; - - void tizen_indicator_destroy(Resource *resource) override; - void tizen_indicator_set_state(Resource *resource, struct ::wl_resource *surface, int32_t state) override; - void tizen_indicator_set_opacity_mode(Resource *resource, struct ::wl_resource *surface, int32_t mode) override; - void tizen_indicator_set_visible_type(Resource *resource, struct ::wl_resource *surface, int32_t type) override; - - void setVisibleType(DSWaylandTizenIndicator::visible_type type); - DSWaylandTizenIndicator::visible_type getVisibleType(); - -private: - DSWaylandTizenIndicator::visible_type __vis_type; -}; - -} - -#endif // __DS_WAYLAND_TIZEN_INDICATOR_PRIVATE_H__ - diff --git a/src/DSWaylandServer/DSWaylandTizenInputDevice.h b/src/DSWaylandServer/DSWaylandTizenInputDevice.h deleted file mode 100644 index 1bbcc23..0000000 --- a/src/DSWaylandServer/DSWaylandTizenInputDevice.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_INPUT_DEVICE_H_ -#define _DS_WAYLAND_TIZEN_INPUT_DEVICE_H_ - -#include -#include -#include -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenInputDevicePrivate; - -class DSWaylandTizenInputDevice : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenInputDevice); -public: - DSWaylandTizenInputDevice(DSWaylandTizenInputDeviceManager *tzInputDeviceManager); - virtual ~DSWaylandTizenInputDevice(); - - void *addDevice(void *client, DSInputDevice *device); - void sendDeviceInfo(void *resource, DSInputDevice *device); - -private: - DSWaylandTizenInputDeviceManager *__tzInputDeviceManager; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif - diff --git a/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp b/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp deleted file mode 100644 index 0da0a99..0000000 --- a/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenInputDeviceManager.h" -#include "DSWaylandTizenInputDeviceManagerPrivate.h" -#include "DSWaylandTizenInputDevice.h" -#include "DSWaylandTizenInputDevicePrivate.h" - -namespace display_server -{ - -DSWaylandTizenInputDeviceManagerPrivate::DSWaylandTizenInputDeviceManagerPrivate(DSWaylandTizenInputDeviceManager *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __display(nullptr) -{ -} - -DSWaylandTizenInputDeviceManagerPrivate::~DSWaylandTizenInputDeviceManagerPrivate() -{ -} - -void DSWaylandTizenInputDeviceManagerPrivate::createGlobal(struct ::wl_display *display) -{ - __display = display; - - tizen_input_device_manager::init(__display, 3); -} - -/*LCOV_EXCL_START*/ -void DSWaylandTizenInputDeviceManagerPrivate::handleDeviceAdd(DSInputDevice *device) -{ - DS_GET_PUB(DSWaylandTizenInputDeviceManager); - std::multimap::iterator it; - std::multimap _resourceMap = resourceMap(); - DSWaylandTizenInputDevice *tzInputDevice = pub->getTizenInputDevice(); - for (it = _resourceMap.begin() ; it != _resourceMap.end() ; it++) - { - Resource *managerResource = (*it).second; - struct ::wl_resource *deviceResource = (struct ::wl_resource *)tzInputDevice->addDevice((void *)managerResource->client(), device); - send_device_add(managerResource->handle, pub->getCompositor()->nextSerial(), device->getIdentifier(), deviceResource, NULL); - tzInputDevice->sendDeviceInfo((void *)deviceResource, device); - } -} - -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_bind_resource(tizen_input_device_manager::Resource *resource) -{ -} - -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_destroy_resource(tizen_input_device_manager::Resource *resource) -{ -} - -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_block_events(tizen_input_device_manager::Resource *resource, uint32_t serial, uint32_t clas, uint32_t duration) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_unblock_events(tizen_input_device_manager::Resource *resource, uint32_t serial) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_init_generator(tizen_input_device_manager::Resource *resource, uint32_t clas) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_deinit_generator(tizen_input_device_manager::Resource *resource, uint32_t clas) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_generate_key(tizen_input_device_manager::Resource *resource, const std::string &keyname, uint32_t pressed) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_generate_pointer(tizen_input_device_manager::Resource *resource, uint32_t type, uint32_t x, uint32_t y, uint32_t button) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_generate_touch(tizen_input_device_manager::Resource *resource, uint32_t type, uint32_t x, uint32_t y, uint32_t finger) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_pointer_warp(tizen_input_device_manager::Resource *resource, struct ::wl_resource *surface, wl_fixed_t x, wl_fixed_t y) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_init_generator_with_name(tizen_input_device_manager::Resource *resource, uint32_t clas, const std::string &name) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_destroy(tizen_input_device_manager::Resource *resource) -{ -} -void DSWaylandTizenInputDeviceManagerPrivate::tizen_input_device_manager_generate_axis(tizen_input_device_manager::Resource *resource, uint32_t type, wl_fixed_t value) -{ -} -/*LCOV_EXCL_STOP*/ - - -DSWaylandTizenInputDeviceManager::DSWaylandTizenInputDeviceManager(DSWaylandCompositor *compositor) - : DS_INIT_PRIVATE_PTR(DSWaylandTizenInputDeviceManager) -{ - DS_GET_PRIV(DSWaylandTizenInputDeviceManager); - - __compositor = compositor; - priv->createGlobal(compositor->display()); - - __tzInputDevice = new DSWaylandTizenInputDevice(this); -} - -DSWaylandTizenInputDeviceManager::~DSWaylandTizenInputDeviceManager() -{ -} - -/*LCOV_EXCL_START*/ -void DSWaylandTizenInputDeviceManager::slotDeviceAdd(std::shared_ptr device) -{ - DS_GET_PRIV(DSWaylandTizenInputDeviceManager); - std::cout << "DSWaylandTizenInputDeviceManager slotDeviceAdd!" << std::endl; - device->print(); - - priv->handleDeviceAdd(device.get()); -} - -void DSWaylandTizenInputDeviceManager::slotDeviceRemove(std::shared_ptr device) -{ - std::cout << "DSWaylandTizenInputDeviceManager slotDeviceRemove!" << std::endl; - device->print(); -} -/*LCOV_EXCL_STOP*/ - -DSWaylandTizenInputDevicePrivate::DSWaylandTizenInputDevicePrivate(DSWaylandTizenInputDevice *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ -} - -DSWaylandTizenInputDevicePrivate::~DSWaylandTizenInputDevicePrivate() -{ -} - -/*LCOV_EXCL_START*/ -void DSWaylandTizenInputDevicePrivate::tizen_input_device_select_axes(Resource *resource, wl_array *axes) -{ -} - -void DSWaylandTizenInputDevicePrivate::tizen_input_device_release(Resource *resource) -{ -} - -void *DSWaylandTizenInputDevicePrivate::addDevice(void *client, DSInputDevice *device) -{ - Resource *resource; - - resource = add((struct ::wl_client *)client, 1); - - return (void *)resource->handle; -} - -void DSWaylandTizenInputDevicePrivate::sendDeviceInfo(void *resource, DSInputDevice *device) -{ - struct ::wl_array axes; - wl_array_init(&axes); - - send_device_info((struct ::wl_resource *)resource, device->getName(), (uint32_t)device->getClass(), (uint32_t)device->getSubclass(), &axes); - - wl_array_release(&axes); -} -/*LCOV_EXCL_STOP*/ - -DSWaylandTizenInputDevice::DSWaylandTizenInputDevice(DSWaylandTizenInputDeviceManager *tzInputDeviceManager) - : DS_INIT_PRIVATE_PTR(DSWaylandTizenInputDevice), - __tzInputDeviceManager(tzInputDeviceManager) -{ -} - -DSWaylandTizenInputDevice::~DSWaylandTizenInputDevice() -{ -} - -/*LCOV_EXCL_START*/ -void *DSWaylandTizenInputDevice::addDevice(void *client, DSInputDevice *device) -{ - DS_GET_PRIV(DSWaylandTizenInputDevice); - void *resource; - - resource = priv->addDevice(client, device); - return resource; -} - -void DSWaylandTizenInputDevice::sendDeviceInfo(void *resource, DSInputDevice *device) -{ - DS_GET_PRIV(DSWaylandTizenInputDevice); - - priv->sendDeviceInfo(resource, device); -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server - diff --git a/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.h b/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.h deleted file mode 100644 index cb2917a..0000000 --- a/src/DSWaylandServer/DSWaylandTizenInputDeviceManager.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_INPUT_DEVICE_MANAGER_H_ -#define _DS_WAYLAND_TIZEN_INPUT_DEVICE_MANAGER_H_ - -#include -#include -#include -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenInputDeviceManagerPrivate; -class DSWaylandTizenInputDevice; - -class DSWaylandTizenInputDeviceManager : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenInputDeviceManager); -public: - DSWaylandTizenInputDeviceManager(DSWaylandCompositor *compositor); - virtual ~DSWaylandTizenInputDeviceManager(); - - void slotDeviceAdd(std::shared_ptr device); - void slotDeviceRemove(std::shared_ptr device); - - DSWaylandCompositor *getCompositor() { return __compositor; } - DSWaylandTizenInputDevice *getTizenInputDevice() { return __tzInputDevice; } - -private: - DSWaylandCompositor *__compositor; - DSWaylandTizenInputDevice *__tzInputDevice; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif - diff --git a/src/DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h b/src/DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h deleted file mode 100644 index 7c5eeb8..0000000 --- a/src/DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_INPUT_DEVICE_MANAGER_PRIVATE_H_ -#define _DS_WAYLAND_TIZEN_INPUT_DEVICE_MANAGER_PRIVATE_H_ - -#include "dswayland-server-tizen-extension.h" -#include "DSWaylandTizenInputDeviceManager.h" -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenInputDeviceManagerPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_input_device_manager -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenInputDeviceManager); -public: - DSWaylandTizenInputDeviceManagerPrivate() = delete; - DSWaylandTizenInputDeviceManagerPrivate(DSWaylandTizenInputDeviceManager *p_ptr); - ~DSWaylandTizenInputDeviceManagerPrivate() override; - - void createGlobal(struct ::wl_display *display); - void handleDeviceAdd(DSInputDevice *device); - -protected: - void tizen_input_device_manager_bind_resource(Resource *resource) override; - void tizen_input_device_manager_destroy_resource(Resource *resource) override; - - void tizen_input_device_manager_block_events(Resource *resource, uint32_t serial, uint32_t clas, uint32_t duration) override; - void tizen_input_device_manager_unblock_events(Resource *resource, uint32_t serial) override; - void tizen_input_device_manager_init_generator(Resource *resource, uint32_t clas) override; - void tizen_input_device_manager_deinit_generator(Resource *resource, uint32_t clas) override; - void tizen_input_device_manager_generate_key(Resource *resource, const std::string &keyname, uint32_t pressed) override; - void tizen_input_device_manager_generate_pointer(Resource *resource, uint32_t type, uint32_t x, uint32_t y, uint32_t button) override; - void tizen_input_device_manager_generate_touch(Resource *resource, uint32_t type, uint32_t x, uint32_t y, uint32_t finger) override; - void tizen_input_device_manager_pointer_warp(Resource *resource, struct ::wl_resource *surface, wl_fixed_t x, wl_fixed_t y) override; - void tizen_input_device_manager_init_generator_with_name(Resource *resource, uint32_t clas, const std::string &name) override; - void tizen_input_device_manager_destroy(Resource *resource) override; - void tizen_input_device_manager_generate_axis(Resource *resource, uint32_t type, wl_fixed_t value) override; - -private: - struct ::wl_display *__display; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif - diff --git a/src/DSWaylandServer/DSWaylandTizenInputDevicePrivate.h b/src/DSWaylandServer/DSWaylandTizenInputDevicePrivate.h deleted file mode 100644 index e0ed628..0000000 --- a/src/DSWaylandServer/DSWaylandTizenInputDevicePrivate.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_INPUT_DEVICE_PRIVATE_H_ -#define _DS_WAYLAND_TIZEN_INPUT_DEVICE_PRIVATE_H_ - -#include "dswayland-server-tizen-extension.h" -#include "DSWaylandTizenInputDevice.h" - -namespace display_server -{ - -class DSWaylandTizenInputDevicePrivate : public DSObjectPrivate, public DSWaylandServer::tizen_input_device -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenInputDevice); -public: - DSWaylandTizenInputDevicePrivate() = delete; - DSWaylandTizenInputDevicePrivate(DSWaylandTizenInputDevice *p_ptr); - ~DSWaylandTizenInputDevicePrivate() override; - - void *addDevice(void *client, DSInputDevice *device); - void sendDeviceInfo(void *resource, DSInputDevice *device); - -protected: - void tizen_input_device_select_axes(Resource *resource, wl_array *axes) override; - void tizen_input_device_release(Resource *resource) override; - -private: - /* data */ -}; - -} - -#endif - diff --git a/src/DSWaylandServer/DSWaylandTizenLaunchEffect.cpp b/src/DSWaylandServer/DSWaylandTizenLaunchEffect.cpp deleted file mode 100644 index ae5b139..0000000 --- a/src/DSWaylandServer/DSWaylandTizenLaunchEffect.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenLaunchEffect.h" -#include "DSWaylandTizenLaunchEffectPrivate.h" -#include "DSWaylandTizenLaunchSplash.h" -#include "DSWaylandClient.h" - -const int TIZEN_LAUNCH_EFFECT_VERSION = 1; - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -DSWaylandTizenLaunchEffectPrivate::DSWaylandTizenLaunchEffectPrivate(DSWaylandTizenLaunchEffect *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ -} - -DSWaylandTizenLaunchEffectPrivate::~DSWaylandTizenLaunchEffectPrivate() -{ -} - -void DSWaylandTizenLaunchEffectPrivate::tizen_launch_effect_initialize(DSWaylandCompositor *wlCompositor) -{ - ::wl_display *display; - display = wlCompositor->display(); - - init(display, TIZEN_LAUNCH_EFFECT_VERSION); -} - -void DSWaylandTizenLaunchEffectPrivate::tizen_launch_effect_finalize(void) -{ - -} - -void DSWaylandTizenLaunchEffectPrivate::tizen_launch_effect_bind_resource(Resource *resource) -{ - DSLOG_DBG("TizenLaunchEffectPriv", ""); -} -void DSWaylandTizenLaunchEffectPrivate::tizen_launch_effect_destroy_resource(Resource *resource) -{ - DSLOG_DBG("TizenLaunchEffectPriv", ""); -} -void DSWaylandTizenLaunchEffectPrivate::tizen_launch_effect_create_splash_img(Resource *resource, uint32_t id) -{ - DSLOG_DBG("TizenLaunchEffectPriv", ""); - - DSWaylandClient *waylandClient = DSWaylandClient::fromWlClient(resource->client()); - std::shared_ptr tzSplash = std::make_shared(waylandClient, id, TIZEN_LAUNCH_EFFECT_VERSION); - __tzSplashList.push_front(tzSplash); -} -void DSWaylandTizenLaunchEffectPrivate::tizen_launch_effect_type_set(Resource *resource, const std::string &effect_type, uint32_t pid, struct ::wl_array *options) -{ - DSLOG_DBG("TizenLaunchEffectPriv", ""); -} -void DSWaylandTizenLaunchEffectPrivate::tizen_launch_effect_type_unset(Resource *resource, uint32_t pid) -{ - DSLOG_DBG("TizenLaunchEffectPriv", ""); -} -void DSWaylandTizenLaunchEffectPrivate::tizen_launch_effect_destroy(Resource *resource) -{ - DSLOG_DBG("TizenLaunchEffectPriv", ""); -} - -DSWaylandTizenLaunchEffect::DSWaylandTizenLaunchEffect(DSWaylandCompositor *wlCompositor) - : DS_INIT_PRIVATE_PTR(DSWaylandTizenLaunchEffect), - __wlCompositor(wlCompositor), - __isCreated(false) -{ - this->initialize(__wlCompositor); -} - -DSWaylandTizenLaunchEffect::~DSWaylandTizenLaunchEffect() -{ - if (isCreated()) - this->finalize(); -} - -bool DSWaylandTizenLaunchEffect::isCreated(void) -{ - return __isCreated; -} - -bool DSWaylandTizenLaunchEffect::initialize(DSWaylandCompositor *wlCompositor) -{ - if (!wlCompositor) return false; - if (isCreated()) - { - DSLOG_ERR("TizenLaunchEffect", "Already initialized"); - return true; - } - - DS_GET_PRIV(DSWaylandTizenLaunchEffect); - if (!priv) return false; - - __wlCompositor = wlCompositor; - __isCreated = true; - - priv->tizen_launch_effect_initialize(__wlCompositor); - - DSLOG_INF("TizenLaunchEffect", "TizenLaunchEffect initialized"); - return true; -} - -void DSWaylandTizenLaunchEffect::finalize(void) -{ - DS_GET_PRIV(DSWaylandTizenLaunchEffect); - priv->tizen_launch_effect_finalize(); - - DSLOG_INF("TizenLaunchEffect", "TizenLaunchEffect finalized"); - __isCreated = false; -} -/*LCOV_EXCL_STOP*/ - -} diff --git a/src/DSWaylandServer/DSWaylandTizenLaunchEffect.h b/src/DSWaylandServer/DSWaylandTizenLaunchEffect.h deleted file mode 100644 index e309ac6..0000000 --- a/src/DSWaylandServer/DSWaylandTizenLaunchEffect.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_LAUNCHEFFECT_H__ -#define __DS_WAYLAND_TIZEN_LAUNCHEFFECT_H__ - -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenLaunchEffectPrivate; - -class DSWaylandTizenLaunchEffect : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenLaunchEffect); - -public: - DSWaylandTizenLaunchEffect(DSWaylandCompositor *wlCompositor); - virtual ~DSWaylandTizenLaunchEffect(); - - bool isCreated(void); - - bool initialize(DSWaylandCompositor *wlCompositor); - void finalize(void); - -private: - DSWaylandCompositor *__wlCompositor; - bool __isCreated; - -}; -/*LCOV_EXCL_STOP*/ - -} -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenLaunchEffectPrivate.h b/src/DSWaylandServer/DSWaylandTizenLaunchEffectPrivate.h deleted file mode 100644 index 8ec0f59..0000000 --- a/src/DSWaylandServer/DSWaylandTizenLaunchEffectPrivate.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_LAUNCHEFFECT_PRIVATE_H__ -#define __DS_WAYLAND_TIZEN_LAUNCHEFFECT_PRIVATE_H__ - -#include "dswayland-server-tizen-launch.h" - -#include "DSWaylandTizenLaunchEffect.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenLaunchSplash; - -class DS_DECL_EXPORT DSWaylandTizenLaunchEffectPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_launch_effect -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenLaunchEffect); - -public: - DSWaylandTizenLaunchEffectPrivate() = delete; - DSWaylandTizenLaunchEffectPrivate(DSWaylandTizenLaunchEffect *p_ptr); - ~DSWaylandTizenLaunchEffectPrivate() override; - - void tizen_launch_effect_initialize(DSWaylandCompositor *wlCompositor); - void tizen_launch_effect_finalize(void); - -protected: - void tizen_launch_effect_bind_resource(Resource *resource); - void tizen_launch_effect_destroy_resource(Resource *resource); - - void tizen_launch_effect_create_splash_img(Resource *resource, uint32_t id); - void tizen_launch_effect_type_set(Resource *resource, const std::string &effect_type, uint32_t pid, struct ::wl_array *options); - void tizen_launch_effect_type_unset(Resource *resource, uint32_t pid); - void tizen_launch_effect_destroy(Resource *resource); - -private: - std::list> __tzSplashList; - -}; -/*LCOV_EXCL_STOP*/ - -} -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenLaunchSplash.cpp b/src/DSWaylandServer/DSWaylandTizenLaunchSplash.cpp deleted file mode 100644 index 737af3f..0000000 --- a/src/DSWaylandServer/DSWaylandTizenLaunchSplash.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenLaunchSplash.h" -#include "DSWaylandTizenLaunchSplashPrivate.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -DSWaylandTizenLaunchSplashPrivate::DSWaylandTizenLaunchSplashPrivate(DSWaylandTizenLaunchSplash *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{} - -DSWaylandTizenLaunchSplashPrivate::~DSWaylandTizenLaunchSplashPrivate() -{} - -void DSWaylandTizenLaunchSplashPrivate::init(DSWaylandClient *waylandClient, uint32_t id, int version) -{ - if (id > 0) { - tizen_launch_splash::init(waylandClient->wlClient(), (int)id, version); - } -} - -void DSWaylandTizenLaunchSplashPrivate::tizen_launch_splash_bind_resource(Resource *resource) -{} -void DSWaylandTizenLaunchSplashPrivate::tizen_launch_splash_destroy_resource(Resource *resource) -{} - -void DSWaylandTizenLaunchSplashPrivate::tizen_launch_splash_destroy(Resource *resource) -{} -void DSWaylandTizenLaunchSplashPrivate::tizen_launch_splash_launch(Resource *resource, const std::string &file, uint32_t file_type, uint32_t color_depth, uint32_t rotation, uint32_t indicator, const std::string &effect_type, const std::string &theme_type, struct ::wl_array *options) -{} -void DSWaylandTizenLaunchSplashPrivate::tizen_launch_splash_owner(Resource *resource, uint32_t pid) -{} -void DSWaylandTizenLaunchSplashPrivate::tizen_launch_splash_launch_v2(Resource *resource, const std::string &file, uint32_t file_type, uint32_t color_depth, uint32_t rotation, uint32_t indicator, const std::string &effect_type, const std::string &theme_type, struct ::wl_array *options, struct ::wl_array *extra_config) -{} - -DSWaylandTizenLaunchSplash::DSWaylandTizenLaunchSplash(DSWaylandClient *waylandClient, uint32_t id, int version) - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenLaunchSplash) -{ - DS_GET_PRIV(DSWaylandTizenLaunchSplash); - priv->init(waylandClient, id, version); -} - -DSWaylandTizenLaunchSplash::~DSWaylandTizenLaunchSplash() -{} -/*LCOV_EXCL_STOP*/ - -} diff --git a/src/DSWaylandServer/DSWaylandTizenLaunchSplash.h b/src/DSWaylandServer/DSWaylandTizenLaunchSplash.h deleted file mode 100644 index c04b995..0000000 --- a/src/DSWaylandServer/DSWaylandTizenLaunchSplash.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_LAUNCHSPLASH_H__ -#define __DS_WAYLAND_TIZEN_LAUNCHSPLASH_H__ - -#include "DSWaylandClient.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenLaunchSplashPrivate; - -class DSWaylandTizenLaunchSplash : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenLaunchSplash); - -public: - DSWaylandTizenLaunchSplash(DSWaylandClient *waylandClient, uint32_t id, int version); - ~DSWaylandTizenLaunchSplash() override; - -private: - -}; -/*LCOV_EXCL_STOP*/ - -} -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenLaunchSplashPrivate.h b/src/DSWaylandServer/DSWaylandTizenLaunchSplashPrivate.h deleted file mode 100644 index 72da257..0000000 --- a/src/DSWaylandServer/DSWaylandTizenLaunchSplashPrivate.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_LAUNCHSPLASH_PRIVATE_H__ -#define __DS_WAYLAND_TIZEN_LAUNCHSPLASH_PRIVATE_H__ - -#include "dswayland-server-tizen-launch.h" - -#include "DSWaylandTizenLaunchSplash.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenLaunchSplash; - -class DS_DECL_EXPORT DSWaylandTizenLaunchSplashPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_launch_splash -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenLaunchSplash); - -public: - DSWaylandTizenLaunchSplashPrivate() = delete; - DSWaylandTizenLaunchSplashPrivate(DSWaylandTizenLaunchSplash *p_ptr); - ~DSWaylandTizenLaunchSplashPrivate() override; - - void init(DSWaylandClient *waylandClient, uint32_t id, int version); - -protected: - void tizen_launch_splash_bind_resource(Resource *resource); - void tizen_launch_splash_destroy_resource(Resource *resource); - - void tizen_launch_splash_destroy(Resource *resource); - void tizen_launch_splash_launch(Resource *resource, const std::string &file, uint32_t file_type, uint32_t color_depth, uint32_t rotation, uint32_t indicator, const std::string &effect_type, const std::string &theme_type, struct ::wl_array *options); - void tizen_launch_splash_owner(Resource *resource, uint32_t pid); - void tizen_launch_splash_launch_v2(Resource *resource, const std::string &file, uint32_t file_type, uint32_t color_depth, uint32_t rotation, uint32_t indicator, const std::string &effect_type, const std::string &theme_type, struct ::wl_array *options, struct ::wl_array *extra_config); - -private: - -}; -/*LCOV_EXCL_STOP*/ - -} -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp deleted file mode 100644 index 5076ffb..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenPolicy.h" -#include "DSWaylandTizenPolicyPrivate.h" - -#include "DSWaylandTizenVisibility.h" -#include "DSWaylandTizenPosition.h" - -const int TIZEN_POLICY_VERSION = 7; - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -DSWaylandTizenPolicyPrivate::DSWaylandTizenPolicyPrivate(DSWaylandTizenPolicy *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ - DSLOG_DBG("TizenPolicyPriv", ""); - __wm = DSWindowManager::getInstance(); -} - -DSWaylandTizenPolicyPrivate::~DSWaylandTizenPolicyPrivate() -{ - DSLOG_DBG("TizenPolicyPriv", ""); - if (__wm) - DSWindowManager::releaseInstance(); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_initialize(DSWaylandCompositor *wlCompositor) -{ - ::wl_display *display; - display = wlCompositor->display(); - - init(display, TIZEN_POLICY_VERSION); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_finalize(void) -{ - -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_bind_resource(Resource *resource) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_destroy_resource(Resource *resource) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_get_visibility(Resource *resource, uint32_t id, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", "get_visibility... resource:%p, id:%d", resource, id); - - std::shared_ptr tzVis = std::make_shared(resource->client(), id, TIZEN_POLICY_VERSION, surface); - __tzVisList.push_front(tzVis); - - // TODO: we have to remove tzVis when it's resource is destroyed -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_get_position(Resource *resource, uint32_t id, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", "get_position... resource:%p, id:%d", resource, id); - - std::shared_ptr tzPos = std::make_shared(resource->client(), id, TIZEN_POLICY_VERSION, surface); - __tzPosList.push_front(tzPos); - - // TODO: we have to remove tzPos when it's resource is destroyed -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_activate(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", "Request to activate. resource:%p, wl_surface:%p", resource, surface); - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->activateWindow(dswlSurface); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_activate_below_by_res_id(Resource *resource, uint32_t res_id, uint32_t below_res_id) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_raise(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", "Request to raise. resource:%p, wl_surface:%p", resource, surface); - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->raiseWindow(dswlSurface); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_lower(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", "Request to lower. resource:%p, wl_surface:%p", resource, surface); - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->lowerWindow(dswlSurface); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_lower_by_res_id(Resource *resource, uint32_t res_id) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_focus_skip(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", "Request to skip focus. resource:%p, wl_surface:%p", resource, surface); - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->setWindowSkipFocus(dswlSurface, true); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_unset_focus_skip(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", "Request to unset skip_focus. resource:%p, wl_surface:%p", resource, surface); - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->setWindowSkipFocus(dswlSurface, false); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_role(Resource *resource, struct ::wl_resource *surface, const std::string &role) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_type(Resource *resource, struct ::wl_resource *surface, uint32_t win_type) -{ - DSLOG_DBG("TizenPolicyPriv", "tizen_policy_set_type, wl_surface:%p, type:%d", surface, win_type); - - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->setWindowType(dswlSurface, win_type); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_conformant(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_unset_conformant(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_get_conformant(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_notification_level(Resource *resource, struct ::wl_resource *surface, int32_t level) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_transient_for(Resource *resource, uint32_t child_id, uint32_t parent_id) -{ - DSLOG_DBG("TizenPolicyPriv", "Set Transient_for (parent_id:%d, child_id:%d)", parent_id, child_id); - DS_GET_PUB(DSWaylandTizenPolicy); - DSWaylandCompositor *wlComp = pub->getWlCompositor(); - if (!wlComp) return; - if (!__wm) return; - - DSWaylandSurface *childSurface = wlComp->getSurface(child_id); - DSWaylandSurface *parentSurface = wlComp->getSurface(parent_id); - - __wm->setWindowParent(childSurface, parentSurface); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_unset_transient_for(Resource *resource, uint32_t child_id) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_window_screen_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_place_subsurface_below_parent(Resource *resource, struct ::wl_resource *subsurface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_subsurface_stand_alone(Resource *resource, struct ::wl_resource *subsurface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_get_subsurface(Resource *resource, uint32_t id, struct ::wl_resource *surface, uint32_t parent_id) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_opaque_state(Resource *resource, struct ::wl_resource *surface, int32_t state) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_iconify(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_uniconify(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_add_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &name, const std::string &value) -{ - DSLOG_DBG("TizenPolicyPriv", "Add aux hint (id:%d, key:%s, value:%s)", id, name.c_str(), value.c_str()); - - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->addWindowAuxHint(dswlSurface, id, name, value); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_change_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &value) -{ - DSLOG_DBG("TizenPolicyPriv", "Change aux hint (id:%d, value:%s)", id, value.c_str()); - - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->changeWindowAuxHint(dswlSurface, id, value); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_del_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id) -{ - DSLOG_DBG("TizenPolicyPriv", "Delete aux hint (id:%d)", id); - - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - __wm->removeWindowAuxHint(dswlSurface, id); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_get_supported_aux_hints(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", "resource:%p, surface:%p", resource, surface); - - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (!dswlSurface) return; - if (!__wm) return; - - struct wl_array hints; - int len; - int numOfHints = 0; - char *p; - std::list hints_list; - - hints_list = __wm->getWindowSupportedAuxHints(dswlSurface); - numOfHints = hints_list.size(); - - wl_array_init(&hints); - for (std::string hintName : hints_list) - { - len = hintName.length() + 1; - p = (char*)wl_array_add(&hints, len); - - if (p == NULL) - break; - hintName.copy(p, len); - } - - send_supported_aux_hints(resource->handle, surface, &hints, numOfHints); - wl_array_release(&hints); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_background_state(Resource *resource, uint32_t pid) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_unset_background_state(Resource *resource, uint32_t pid) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_floating_mode(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_unset_floating_mode(Resource *resource, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_stack_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_activate_above_by_res_id(Resource *resource, uint32_t res_id, uint32_t above_res_id) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_get_subsurface_watcher(Resource *resource, uint32_t id, struct ::wl_resource *surface) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_parent(Resource *resource, struct ::wl_resource *child, struct ::wl_resource *parent) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_ack_conformant_region(Resource *resource, struct ::wl_resource *surface, uint32_t serial) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_destroy(Resource *resource) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_has_video(Resource *resource, struct ::wl_resource *surface, uint32_t has) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - -void DSWaylandTizenPolicyPrivate::tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid) -{ - DSLOG_DBG("TizenPolicyPriv", ""); -} - - -DSWaylandTizenPolicy::DSWaylandTizenPolicy(DSWaylandCompositor *wlCompositor) - : DS_INIT_PRIVATE_PTR(DSWaylandTizenPolicy), - __wlCompositor(wlCompositor), - __isCreated(false) -{ - this->initialize(__wlCompositor); -} - -DSWaylandTizenPolicy::~DSWaylandTizenPolicy() -{ - if (isCreated()) - this->finalize(); -} - -bool DSWaylandTizenPolicy::isCreated(void) -{ - return __isCreated; -} - -bool DSWaylandTizenPolicy::initialize(DSWaylandCompositor *wlCompositor) -{ - if (!wlCompositor) return false; - if (isCreated()) - { - DSLOG_ERR("TizenPolicy", "Already initialized"); - return true; - } - - DS_GET_PRIV(DSWaylandTizenPolicy); - if (!priv) return false; - - __wlCompositor = wlCompositor; - __isCreated = true; - - priv->tizen_policy_initialize(__wlCompositor); - - DSLOG_INF("TizenPolicy", "TizenPolicy initialized"); - return true; -} - -void DSWaylandTizenPolicy::finalize(void) -{ - DS_GET_PRIV(DSWaylandTizenPolicy); - priv->tizen_policy_finalize(); - - DSLOG_INF("TizenPolicy", "TizenPolicy finalized"); - __isCreated = false; -} - -DSWaylandCompositor *DSWaylandTizenPolicy::getWlCompositor() -{ - return __wlCompositor; -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server - diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.h b/src/DSWaylandServer/DSWaylandTizenPolicy.h deleted file mode 100644 index ddd6045..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_POLICY_H_ -#define _DS_WAYLAND_TIZEN_POLICY_H_ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSWaylandCompositor.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenPolicyPrivate; - -class DSWaylandTizenPolicy : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenPolicy) - -public: - DSWaylandTizenPolicy(DSWaylandCompositor *wlCompositor); - virtual ~DSWaylandTizenPolicy(); - - bool isCreated(void); - - bool initialize(DSWaylandCompositor *wlCompositor); - void finalize(void); - - DSWaylandCompositor *getWlCompositor(); - -private: - DSWaylandCompositor *__wlCompositor; - bool __isCreated; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyExt.cpp b/src/DSWaylandServer/DSWaylandTizenPolicyExt.cpp deleted file mode 100644 index 7e9c9f2..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPolicyExt.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenPolicyExt.h" -#include "DSWaylandTizenPolicyExtPrivate.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -/* DSWaylandTizenPolicyExt */ -DSWaylandTizenPolicyExtPrivate::DSWaylandTizenPolicyExtPrivate(DSWaylandTizenPolicyExt *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __resource_id_cnt(0) -{ - if (!compositor) - return; - - init(compositor->display(), 3); -} - -DSWaylandTizenPolicyExtPrivate::~DSWaylandTizenPolicyExtPrivate() -{ -} - -void DSWaylandTizenPolicyExtPrivate::tizen_policy_ext_bind_resource(Resource *resource) -{ -} - -void DSWaylandTizenPolicyExtPrivate::tizen_policy_ext_destroy_resource(Resource *resource) -{ -} - -void DSWaylandTizenPolicyExtPrivate::tizen_policy_ext_get_rotation(Resource *resource, uint32_t id, struct ::wl_resource *surface) -{ - DSWaylandTizenRotation *tizenRotation = nullptr; - - for (DSWaylandTizenRotation *temp : __rotationList) - if (temp->getRotationSurface() == surface) return; - - tizenRotation = new DSWaylandTizenRotation(resource->client(), id, surface); - if (tizenRotation == nullptr) - { - DSLOG_ERR("DSWaylandTizenPolicyExt", "fail get tizen resource"); - return; - } - - __rotationList.push_back(tizenRotation); -} - -DSWaylandTizenRotation *DSWaylandTizenPolicyExtPrivate::getTizenRotation(struct ::wl_resource *surface) -{ - DSWaylandTizenRotation *tizenRotation = nullptr; - - for (DSWaylandTizenRotation *temp : __rotationList) - { - if (temp->getRotationSurface() == surface) - { - tizenRotation = temp; - break; - } - } - - return tizenRotation; -} - -void DSWaylandTizenPolicyExtPrivate::delTizenRotation(DSWaylandTizenRotation *tizenRotation) -{ - __rotationList.remove(tizenRotation); -} - -DSWaylandTizenPolicyExt::DSWaylandTizenPolicyExt(DSWaylandCompositor *compositor) - : _d_ptr(std::make_unique(this, compositor)) -{ -} - -DSWaylandTizenPolicyExt::~DSWaylandTizenPolicyExt() -{ -} - -DSWaylandTizenRotation *DSWaylandTizenPolicyExt::getTizenRotation(struct ::wl_resource *surface) -{ - DS_GET_PRIV(DSWaylandTizenPolicyExt); - - return priv->getTizenRotation(surface); -} - -void DSWaylandTizenPolicyExt::delTizenRotation(DSWaylandTizenRotation *tizenRotation) -{ - DS_GET_PRIV(DSWaylandTizenPolicyExt); - - priv->delTizenRotation(tizenRotation); -} - -/* DSWaylandTizenRotation */ -DSWaylandTizenRotationPrivate::DSWaylandTizenRotationPrivate(DSWaylandTizenRotation *p_ptr, struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __surface(surface), - __resource_id(0) -{ - init(client, id, 3); -} - -DSWaylandTizenRotationPrivate::~DSWaylandTizenRotationPrivate() -{ -} - -void DSWaylandTizenRotationPrivate::tizen_rotation_bind_resource(Resource *resource) -{ -} - -void DSWaylandTizenRotationPrivate::tizen_rotation_destroy_resource(Resource *resource) -{ -} - -void DSWaylandTizenRotationPrivate::tizen_rotation_destroy(Resource *resource) -{ -} - -struct ::wl_resource *DSWaylandTizenRotationPrivate::getRotationSurface(void) -{ - return __surface; -} - -DSWaylandTizenRotation::DSWaylandTizenRotation(struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface) - : _d_ptr(std::make_unique(this, client, id, surface)) -{ -} - -DSWaylandTizenRotation::~DSWaylandTizenRotation() -{ -} - -struct ::wl_resource *DSWaylandTizenRotation::getRotationSurface(void) -{ - DS_GET_PRIV(DSWaylandTizenRotation); - - return priv->getRotationSurface(); -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyExt.h b/src/DSWaylandServer/DSWaylandTizenPolicyExt.h deleted file mode 100644 index 27b8119..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPolicyExt.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_POLICY_EXT_H_ -#define _DS_WAYLAND_TIZEN_POLICY_EXT_H_ - -#include -#include -#include -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenPolicyExtPrivate; -class DSWaylandTizenRotationPrivate; - -class DS_DECL_EXPORT DSWaylandTizenRotation : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenRotation); - -public: - DSWaylandTizenRotation(struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface); - virtual ~DSWaylandTizenRotation(); - - struct ::wl_resource *getRotationSurface(void); - void sendResourceId(void); - void setResourceId(uint32_t tizenResourceId); - uint32_t getResourceId(void); -}; - -class DS_DECL_EXPORT DSWaylandTizenPolicyExt : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenPolicyExt); - -public: - DSWaylandTizenPolicyExt(DSWaylandCompositor *compositor); - virtual ~DSWaylandTizenPolicyExt(); - - DSWaylandTizenRotation *getTizenRotation(struct ::wl_resource *surface); - void delTizenRotation(DSWaylandTizenRotation *resource); -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyExtPrivate.h b/src/DSWaylandServer/DSWaylandTizenPolicyExtPrivate.h deleted file mode 100644 index 74ce5f6..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPolicyExtPrivate.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_POLICY_EXT_PRIVATE_H_ -#define _DS_WAYLAND_TIZEN_POLICY_EXT_PRIVATE_H_ - -#include "dswayland-server-tizen-policy-ext.h" -#include "DSWaylandTizenPolicyExt.h" - -namespace display_server -{ - -class DS_DECL_EXPORT DSWaylandTizenRotationPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_rotation -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenRotation); - -public: - DSWaylandTizenRotationPrivate() = delete; - DSWaylandTizenRotationPrivate(DSWaylandTizenRotation *p_ptr, struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface); - ~DSWaylandTizenRotationPrivate() override; - - struct ::wl_resource *getRotationSurface(void); - -protected: - void tizen_rotation_bind_resource(Resource *resource) override; - void tizen_rotation_destroy_resource(Resource *resource) override; - void tizen_rotation_destroy(Resource *resource) override; -private: - struct ::wl_resource *__surface; - uint32_t __resource_id; -}; - -class DS_DECL_EXPORT DSWaylandTizenPolicyExtPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_policy_ext -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenPolicyExt); - -public: - DSWaylandTizenPolicyExtPrivate() = delete; - DSWaylandTizenPolicyExtPrivate(DSWaylandTizenPolicyExt *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandTizenPolicyExtPrivate() override; - - DSWaylandTizenRotation *getTizenRotation(struct ::wl_resource *surface); - void delTizenRotation(DSWaylandTizenRotation *resource); - -protected: - void tizen_policy_ext_bind_resource(Resource *resource) override; - void tizen_policy_ext_destroy_resource(Resource *resource) override; - void tizen_policy_ext_get_rotation(Resource *resource, uint32_t id, struct ::wl_resource *surface) override; - -private: - std::list __rotationList; - uint32_t __resource_id_cnt; //TO DO : have to manage more proper class -}; - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h deleted file mode 100644 index e917d2e..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_POLICY_PRIVATE_H_ -#define _DS_WAYLAND_TIZEN_POLICY_PRIVATE_H_ - -#include "dswayland-server-tizen-extension.h" -#include "DSWindowManager.h" -#include "DSWaylandTizenPolicy.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenVisibility; -class DSWaylandTizenPosition; - -class DSWaylandTizenPolicyPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_policy -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenPolicy) - -public: - DSWaylandTizenPolicyPrivate() = delete; - DSWaylandTizenPolicyPrivate(DSWaylandTizenPolicy *p_ptr); - ~DSWaylandTizenPolicyPrivate() override; - - void tizen_policy_initialize(DSWaylandCompositor *wlCompositor); - void tizen_policy_finalize(void); - -protected: - void tizen_policy_bind_resource(Resource *resource) override; - void tizen_policy_destroy_resource(Resource *resource) override; - - void tizen_policy_get_visibility(Resource *resource, uint32_t id, struct ::wl_resource *surface) override; - void tizen_policy_get_position(Resource *resource, uint32_t id, struct ::wl_resource *surface) override; - void tizen_policy_activate(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_activate_below_by_res_id(Resource *resource, uint32_t res_id, uint32_t below_res_id) override; - void tizen_policy_raise(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_lower(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_lower_by_res_id(Resource *resource, uint32_t res_id) override; - void tizen_policy_set_focus_skip(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_unset_focus_skip(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_set_role(Resource *resource, struct ::wl_resource *surface, const std::string &role) override; - void tizen_policy_set_type(Resource *resource, struct ::wl_resource *surface, uint32_t win_type) override; - void tizen_policy_set_conformant(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_unset_conformant(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_get_conformant(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_set_notification_level(Resource *resource, struct ::wl_resource *surface, int32_t level) override; - void tizen_policy_set_transient_for(Resource *resource, uint32_t child_id, uint32_t parent_id) override; - void tizen_policy_unset_transient_for(Resource *resource, uint32_t child_id) override; - void tizen_policy_set_window_screen_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode) override; - void tizen_policy_place_subsurface_below_parent(Resource *resource, struct ::wl_resource *subsurface) override; - void tizen_policy_set_subsurface_stand_alone(Resource *resource, struct ::wl_resource *subsurface) override; - void tizen_policy_get_subsurface(Resource *resource, uint32_t id, struct ::wl_resource *surface, uint32_t parent_id) override; - void tizen_policy_set_opaque_state(Resource *resource, struct ::wl_resource *surface, int32_t state) override; - void tizen_policy_iconify(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_uniconify(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_add_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &name, const std::string &value) override; - void tizen_policy_change_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &value) override; - void tizen_policy_del_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id) override; - void tizen_policy_get_supported_aux_hints(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_set_background_state(Resource *resource, uint32_t pid) override; - void tizen_policy_unset_background_state(Resource *resource, uint32_t pid) override; - void tizen_policy_set_floating_mode(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_unset_floating_mode(Resource *resource, struct ::wl_resource *surface) override; - void tizen_policy_set_stack_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode) override; - void tizen_policy_activate_above_by_res_id(Resource *resource, uint32_t res_id, uint32_t above_res_id) override; - void tizen_policy_get_subsurface_watcher(Resource *resource, uint32_t id, struct ::wl_resource *surface) override; - void tizen_policy_set_parent(Resource *resource, struct ::wl_resource *child, struct ::wl_resource *parent) override; - void tizen_policy_ack_conformant_region(Resource *resource, struct ::wl_resource *surface, uint32_t serial) override; - void tizen_policy_destroy(Resource *resource) override; - void tizen_policy_has_video(Resource *resource, struct ::wl_resource *surface, uint32_t has) override; - void tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid) override; - -private: - DSWindowManager *__wm; - std::list> __tzPosList; - std::list> __tzVisList; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif - diff --git a/src/DSWaylandServer/DSWaylandTizenPosition.cpp b/src/DSWaylandServer/DSWaylandTizenPosition.cpp deleted file mode 100644 index 34e4dbf..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPosition.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenPosition.h" -#include "DSWaylandTizenPositionPrivate.h" -#include "DSWindowManager.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -DSWaylandTizenPosition::DSWaylandTizenPosition(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenPosition) -{ - DSLOG_DBG("TIZEN_POSITION", "CREATOR... TizenPosition:%p", this); - init(client, id, version, surface); -} - -DSWaylandTizenPosition::~DSWaylandTizenPosition() -{ - DSLOG_DBG("TIZEN_POSITION", "DESTORYER... TizenPosition:%p", this); -} - -void DSWaylandTizenPosition::init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) -{ - DS_GET_PRIV(DSWaylandTizenPosition); - priv->init(client, id, version, surface); -} - -DSWaylandTizenPositionPrivate::DSWaylandTizenPositionPrivate(DSWaylandTizenPosition *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __wlSurface(nullptr), - __dswlSurface(nullptr) -{ -} - -DSWaylandTizenPositionPrivate::~DSWaylandTizenPositionPrivate() -{ -} - -void DSWaylandTizenPositionPrivate::init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) -{ - tizen_position::init(client, id, version); - __wlSurface = surface; - __dswlSurface = DSWaylandSurface::fromWlResource(surface); -} - -void DSWaylandTizenPositionPrivate::tizen_position_bind_resource(Resource *resource) -{ - -} - -void DSWaylandTizenPositionPrivate::tizen_position_destroy_resource(Resource *resource) -{ - -} - -void DSWaylandTizenPositionPrivate::tizen_position_destroy(Resource *resource) -{ - -} - -void DSWaylandTizenPositionPrivate::tizen_position_set(Resource *resource, int32_t x, int32_t y) -{ - DSLOG_DBG("TIZEN_POSITION", "Requested pos(%d,%d)", x, y); - - DSWindowManager *wm = DSWindowManager::getInstance(); - wm->setWindowPosition(__dswlSurface, x, y); - DSWindowManager::releaseInstance(); -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenPosition.h b/src/DSWaylandServer/DSWaylandTizenPosition.h deleted file mode 100644 index 084fe1e..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPosition.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_POSITION_H__ -#define __DS_WAYLAND_TIZEN_POSITION_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSWaylandSurface.h" -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenPositionPrivate; - -class DSWaylandTizenPosition : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenPosition); - -public: - DSWaylandTizenPosition(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); - ~DSWaylandTizenPosition() override; - - void init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); - -protected: - -private: -}; -/*LCOV_EXCL_STOP*/ - -} // namespace display_server - -#endif //__DS_WAYLAND_TIZEN_POSITION_H__ diff --git a/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h b/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h deleted file mode 100644 index fa3b5de..0000000 --- a/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_POLICY_PRIVATE__ -#define __DS_WAYLAND_TIZEN_POLICY_PRIVATE__ - -#include "dswayland-server-tizen-extension.h" -#include "DSWaylandTizenPosition.h" - -namespace display_server -{ - -class DSWaylandTizenPositionPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_position -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenPosition); - -public: - DSWaylandTizenPositionPrivate() = delete; - //DSWaylandTizenPositionPrivate(DSWaylandTizenPosition *p_ptr, struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); - DSWaylandTizenPositionPrivate(DSWaylandTizenPosition *p_ptr); - ~DSWaylandTizenPositionPrivate() override; - - void init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); - -protected: - void tizen_position_bind_resource(Resource *resource) override; - void tizen_position_destroy_resource(Resource *resource) override; - - void tizen_position_destroy(Resource *resource) override; - void tizen_position_set(Resource *resource, int32_t x, int32_t y) override; - -private: - struct ::wl_resource *__wlSurface; - DSWaylandSurface *__dswlSurface; - -}; - -} - -#endif //__DS_WAYLAND_TIZEN_POLICY_PRIVATE__ diff --git a/src/DSWaylandServer/DSWaylandTizenSurface.cpp b/src/DSWaylandServer/DSWaylandTizenSurface.cpp deleted file mode 100644 index d0f933d..0000000 --- a/src/DSWaylandServer/DSWaylandTizenSurface.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenSurface.h" -#include "DSWaylandTizenSurfacePrivate.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -/* DSWaylandTizenSurface */ -DSWaylandTizenSurfacePrivate::DSWaylandTizenSurfacePrivate(DSWaylandTizenSurface *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __wlCompositor(compositor) -{ - if (!compositor) - return; - - init(compositor->display(), 1); -} - -DSWaylandTizenSurfacePrivate::~DSWaylandTizenSurfacePrivate() -{ -} - -void DSWaylandTizenSurfacePrivate::tizen_surface_bind_resource(Resource *resource) -{ -} - -void DSWaylandTizenSurfacePrivate::tizen_surface_destroy_resource(Resource *resource) -{ -} - -void DSWaylandTizenSurfacePrivate::tizen_surface_get_tizen_resource(Resource *resource, uint32_t id, struct ::wl_resource *surface) -{ - DSWaylandTizenResource *tizenResource = nullptr; - DSWaylandSurface *waylandSurface = nullptr; - uint32_t tizenResourceId = 0; - - for (DSWaylandTizenResource *temp : __resourceList) - if (temp->getResourceSurface() == surface) return; - - tizenResource = new DSWaylandTizenResource(resource->client(), id, surface); - if (tizenResource == nullptr) - { - DSLOG_ERR("DSWaylandTizenSurface", "fail get tizen resource"); - return; - } - - waylandSurface = __wlCompositor->getSurface(surface); - if (waylandSurface) - { - tizenResourceId = waylandSurface->getTizenResourceId(); - tizenResource->setResourceId(tizenResourceId); - } - else - { - DSLOG_ERR("DSWaylandTizenSurface", "fail get tizen resource id"); - } - - __resourceList.push_back(tizenResource); - - tizenResource->sendResourceId(); -} - -void DSWaylandTizenSurfacePrivate::tizen_surface_destroy(Resource *resource) -{ -} - -DSWaylandTizenResource *DSWaylandTizenSurfacePrivate::getTizenResource(struct ::wl_resource *surface) -{ - DSWaylandTizenResource *tizenResource = nullptr; - - for (DSWaylandTizenResource *temp : __resourceList) - { - if (temp->getResourceSurface() == surface) - { - tizenResource = temp; - break; - } - } - - return tizenResource; -} - -void DSWaylandTizenSurfacePrivate::delTizenResource(DSWaylandTizenResource *tizenResource) -{ - __resourceList.remove(tizenResource); -} - -DSWaylandTizenSurface::DSWaylandTizenSurface(DSWaylandCompositor *compositor) - : _d_ptr(std::make_unique(this, compositor)) -{ -} - -DSWaylandTizenSurface::~DSWaylandTizenSurface() -{ -} - -DSWaylandTizenResource *DSWaylandTizenSurface::getTizenResource(struct ::wl_resource *surface) -{ - DS_GET_PRIV(DSWaylandTizenSurface); - - return priv->getTizenResource(surface); -} - -void DSWaylandTizenSurface::delTizenResource(DSWaylandTizenResource *tizenResource) -{ - DS_GET_PRIV(DSWaylandTizenSurface); - - priv->delTizenResource(tizenResource); -} - -/* DSWaylandTizenResource */ -DSWaylandTizenResourcePrivate::DSWaylandTizenResourcePrivate(DSWaylandTizenResource *p_ptr, struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __surface(surface), - __resource_id(0) -{ - init(client, id, 1); -} - -DSWaylandTizenResourcePrivate::~DSWaylandTizenResourcePrivate() -{ -} - -void DSWaylandTizenResourcePrivate::tizen_resource_bind_resource(Resource *resource) -{ -} - -void DSWaylandTizenResourcePrivate::tizen_resource_destroy_resource(Resource *resource) -{ -} - -void DSWaylandTizenResourcePrivate::tizen_resource_destroy(Resource *resource) -{ -} - -struct ::wl_resource *DSWaylandTizenResourcePrivate::getResourceSurface(void) -{ - return __surface; -} - -void DSWaylandTizenResourcePrivate::sendResourceId(void) -{ - send_resource_id(__resource_id); -} - -void DSWaylandTizenResourcePrivate::setResourceId(uint32_t tizenResourceId) -{ - __resource_id = tizenResourceId; -} - -uint32_t DSWaylandTizenResourcePrivate::getResourceId(void) -{ - return __resource_id; -} - -DSWaylandTizenResource::DSWaylandTizenResource(struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface) - : _d_ptr(std::make_unique(this, client, id, surface)) -{ -} - -DSWaylandTizenResource::~DSWaylandTizenResource() -{ -} - -struct ::wl_resource *DSWaylandTizenResource::getResourceSurface(void) -{ - DS_GET_PRIV(DSWaylandTizenResource); - - return priv->getResourceSurface(); -} - -void DSWaylandTizenResource::sendResourceId(void) -{ - DS_GET_PRIV(DSWaylandTizenResource); - - DSLOG_INF("DSWaylandTizenResource", "send Resource Id"); - - priv->sendResourceId(); -} - -void DSWaylandTizenResource::setResourceId(uint32_t tizenResourceId) -{ - DS_GET_PRIV(DSWaylandTizenResource); - - DSLOG_INF("DSWaylandTizenResource", "send Resource Id"); - - priv->setResourceId(tizenResourceId); -} - -uint32_t DSWaylandTizenResource::getResourceId(void) -{ - DS_GET_PRIV(DSWaylandTizenResource); - - DSLOG_INF("DSWaylandTizenResource", "send Resource Id"); - - return priv->getResourceId(); -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenSurface.h b/src/DSWaylandServer/DSWaylandTizenSurface.h deleted file mode 100644 index 3b56188..0000000 --- a/src/DSWaylandServer/DSWaylandTizenSurface.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_SURFACE_H_ -#define _DS_WAYLAND_TIZEN_SURFACE_H_ - -#include -#include -#include -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenSurfacePrivate; -class DSWaylandTizenResourcePrivate; - -class DS_DECL_EXPORT DSWaylandTizenResource : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenResource); - -public: - DSWaylandTizenResource(struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface); - virtual ~DSWaylandTizenResource(); - - struct ::wl_resource *getResourceSurface(void); - void sendResourceId(void); - void setResourceId(uint32_t tizenResourceId); - uint32_t getResourceId(void); -}; - -class DS_DECL_EXPORT DSWaylandTizenSurface : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenSurface); - -public: - DSWaylandTizenSurface(DSWaylandCompositor *compositor); - virtual ~DSWaylandTizenSurface(); - - DSWaylandTizenResource *getTizenResource(struct ::wl_resource *surface); - void delTizenResource(DSWaylandTizenResource *resource); -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenSurfacePrivate.h b/src/DSWaylandServer/DSWaylandTizenSurfacePrivate.h deleted file mode 100644 index 9c7229b..0000000 --- a/src/DSWaylandServer/DSWaylandTizenSurfacePrivate.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_SURFACE_PRIVATE_H_ -#define _DS_WAYLAND_TIZEN_SURFACE_PRIVATE_H_ - -#include "dswayland-server-tizen-extension.h" -#include "DSWaylandTizenSurface.h" -#include "DSWaylandSurface.h" - -namespace display_server -{ - -class DS_DECL_EXPORT DSWaylandTizenResourcePrivate : public DSObjectPrivate, public DSWaylandServer::tizen_resource -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenResource); - -public: - DSWaylandTizenResourcePrivate() = delete; - DSWaylandTizenResourcePrivate(DSWaylandTizenResource *p_ptr, struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface); - ~DSWaylandTizenResourcePrivate() override; - - struct ::wl_resource *getResourceSurface(void); - void sendResourceId(void); - void setResourceId(uint32_t tizenResourceId); - uint32_t getResourceId(void); - -protected: - void tizen_resource_bind_resource(Resource *resource) override; - void tizen_resource_destroy_resource(Resource *resource) override; - void tizen_resource_destroy(Resource *resource) override; -private: - struct ::wl_resource *__surface; - uint32_t __resource_id; -}; - -class DS_DECL_EXPORT DSWaylandTizenSurfacePrivate : public DSObjectPrivate, public DSWaylandServer::tizen_surface -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenSurface); - -public: - DSWaylandTizenSurfacePrivate() = delete; - DSWaylandTizenSurfacePrivate(DSWaylandTizenSurface *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandTizenSurfacePrivate() override; - - DSWaylandTizenResource *getTizenResource(struct ::wl_resource *surface); - void delTizenResource(DSWaylandTizenResource *resource); - -protected: - void tizen_surface_bind_resource(Resource *resource) override; - void tizen_surface_destroy_resource(Resource *resource) override; - void tizen_surface_get_tizen_resource(Resource *resource, uint32_t id, struct ::wl_resource *surface) override; - void tizen_surface_destroy(Resource *resource) override; - -private: - std::list __resourceList; - DSWaylandCompositor *__wlCompositor; -}; - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenSurfaceShm.cpp b/src/DSWaylandServer/DSWaylandTizenSurfaceShm.cpp deleted file mode 100644 index 4fd5917..0000000 --- a/src/DSWaylandServer/DSWaylandTizenSurfaceShm.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenSurfaceShm.h" -#include "DSWaylandTizenSurfaceShmPrivate.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -/* DSWaylandTizenSurfaceShm */ -DSWaylandTizenSurfaceShmPrivate::DSWaylandTizenSurfaceShmPrivate(DSWaylandTizenSurfaceShm *p_ptr, DSWaylandCompositor *compositor) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __shmFlusher(nullptr) -{ - if (!compositor) - return; - - tizen_surface_shm::init(compositor->display(), 2); -} - -DSWaylandTizenSurfaceShmPrivate::~DSWaylandTizenSurfaceShmPrivate() -{ - if (__shmFlusher != nullptr) - { - delete __shmFlusher; - __shmFlusher = nullptr; - } -} - -void DSWaylandTizenSurfaceShmPrivate::tizen_surface_shm_get_flusher(tizen_surface_shm::Resource *resource, uint32_t id, struct ::wl_resource *surface) -{ - if (__shmFlusher != nullptr) - { - if (__shmFlusher->getShmFlusherSurface() == surface) - { - DSLOG_ERR("DSWaylandShm", "cannot get shmflusher with same surface."); - return; - } - else - { - DSLOG_INF("DSWaylandShm", "delete previous shmflusher."); - delete __shmFlusher; - } - } - - __shmFlusher = new DSWaylandTizenSurfaceShmFlusher(resource->client(), id, surface); -} - -void DSWaylandTizenSurfaceShmPrivate::tizen_surface_shm_destroy(tizen_surface_shm::Resource *resource) -{ - if (__shmFlusher != nullptr) - { - delete __shmFlusher; - __shmFlusher = nullptr; - } -} - -DSWaylandTizenSurfaceShm::DSWaylandTizenSurfaceShm(DSWaylandCompositor *compositor) - : _d_ptr(std::make_unique(this, compositor)) -{ -} - -DSWaylandTizenSurfaceShm::~DSWaylandTizenSurfaceShm() -{ -} - -DSWaylandTizenSurfaceShmFlusher *DSWaylandTizenSurfaceShm::getShmFlusher(DSWaylandTizenSurfaceShm *TizenSurfaceShm) -{ - DS_GET_PRIV(DSWaylandTizenSurfaceShm); - - return priv->__shmFlusher; -} - - -/* DSWaylandTizenSurfaceShmFlusher */ -DSWaylandTizenSurfaceShmFlusherPrivate::DSWaylandTizenSurfaceShmFlusherPrivate(DSWaylandTizenSurfaceShmFlusher *p_ptr, struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __surface(nullptr) -{ - init(client, id, 2); - __surface = surface; -} - -DSWaylandTizenSurfaceShmFlusherPrivate::~DSWaylandTizenSurfaceShmFlusherPrivate() -{ -} - -void DSWaylandTizenSurfaceShmFlusherPrivate::tizen_surface_shm_flusher_bind_resource(Resource *resource) -{ -} - -void DSWaylandTizenSurfaceShmFlusherPrivate::tizen_surface_shm_flusher_destroy(Resource *resource) -{ -} - -void DSWaylandTizenSurfaceShmFlusherPrivate::sendShmFlusherFlush(void) -{ - send_flush(); -} - -void DSWaylandTizenSurfaceShmFlusherPrivate::sendShmFlusherFreeFlush(void) -{ - send_free_flush(); -} - -struct ::wl_resource *DSWaylandTizenSurfaceShmFlusherPrivate::getShmFlusherSurface(void) -{ - return __surface; -} - -DSWaylandTizenSurfaceShmFlusher::DSWaylandTizenSurfaceShmFlusher(struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface) - : _d_ptr(std::make_unique(this, client, id, surface)) -{ -} - -DSWaylandTizenSurfaceShmFlusher::~DSWaylandTizenSurfaceShmFlusher() -{ -} - -void DSWaylandTizenSurfaceShmFlusher::sendShmFlusherFlush(void) -{ - DS_GET_PRIV(DSWaylandTizenSurfaceShmFlusher); - - DSLOG_INF("DSWaylandShmFlusher", "sendShmFlusherFlush"); - - priv->sendShmFlusherFlush(); -} - -void DSWaylandTizenSurfaceShmFlusher::sendShmFlusherFreeFlush(void) -{ - DS_GET_PRIV(DSWaylandTizenSurfaceShmFlusher); - - DSLOG_INF("DSWaylandShmFlusher", "sendShmFlusherFreeFlush"); - - priv->sendShmFlusherFreeFlush(); -} - -struct ::wl_resource *DSWaylandTizenSurfaceShmFlusher::getShmFlusherSurface(void) -{ - DS_GET_PRIV(DSWaylandTizenSurfaceShmFlusher); - - return priv->getShmFlusherSurface(); -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenSurfaceShm.h b/src/DSWaylandServer/DSWaylandTizenSurfaceShm.h deleted file mode 100644 index 8adf4b2..0000000 --- a/src/DSWaylandServer/DSWaylandTizenSurfaceShm.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_SURFACE_SHM_H_ -#define _DS_WAYLAND_TIZEN_SURFACE_SHM_H_ - -#include -#include -#include -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenSurfaceShmPrivate; -class DSWaylandTizenSurfaceShmFlusherPrivate; - -class DS_DECL_EXPORT DSWaylandTizenSurfaceShmFlusher : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenSurfaceShmFlusher); - -public: - DSWaylandTizenSurfaceShmFlusher(struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface); - virtual ~DSWaylandTizenSurfaceShmFlusher(); - - void sendShmFlusherFlush(void); - void sendShmFlusherFreeFlush(void); - struct ::wl_resource *getShmFlusherSurface(void); -}; - -class DS_DECL_EXPORT DSWaylandTizenSurfaceShm : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenSurfaceShm); - -public: - DSWaylandTizenSurfaceShm(DSWaylandCompositor *compositor); - virtual ~DSWaylandTizenSurfaceShm(); - - DSWaylandTizenSurfaceShmFlusher *getShmFlusher(DSWaylandTizenSurfaceShm *TizenSurfaceShm); -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenSurfaceShmPrivate.h b/src/DSWaylandServer/DSWaylandTizenSurfaceShmPrivate.h deleted file mode 100644 index 5709e4d..0000000 --- a/src/DSWaylandServer/DSWaylandTizenSurfaceShmPrivate.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WAYLAND_TIZEN_SURFACE_SHM_PRIVATE_H_ -#define _DS_WAYLAND_TIZEN_SURFACE_SHM_PRIVATE_H_ - -#include "dswayland-server-tizen-surface.h" -#include "DSWaylandTizenSurfaceShm.h" - -namespace display_server -{ - -class DS_DECL_EXPORT DSWaylandTizenSurfaceShmFlusherPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_surface_shm_flusher -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenSurfaceShmFlusher); - -public: - DSWaylandTizenSurfaceShmFlusherPrivate() = delete; - DSWaylandTizenSurfaceShmFlusherPrivate(DSWaylandTizenSurfaceShmFlusher *p_ptr, struct ::wl_client *client, uint32_t id, struct ::wl_resource *surface); - ~DSWaylandTizenSurfaceShmFlusherPrivate() override; - - void sendShmFlusherFlush(void); - void sendShmFlusherFreeFlush(void); - - struct ::wl_resource *getShmFlusherSurface(void); -protected: - void tizen_surface_shm_flusher_bind_resource(Resource *resource) override; - void tizen_surface_shm_flusher_destroy(Resource *resource) override; -private: - struct ::wl_resource *__surface; -}; - -class DS_DECL_EXPORT DSWaylandTizenSurfaceShmPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_surface_shm -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenSurfaceShm); - -public: - DSWaylandTizenSurfaceShmPrivate() = delete; - DSWaylandTizenSurfaceShmPrivate(DSWaylandTizenSurfaceShm *p_ptr, DSWaylandCompositor *compositor); - ~DSWaylandTizenSurfaceShmPrivate() override; - -protected: - void tizen_surface_shm_get_flusher(Resource *resource, uint32_t id, struct ::wl_resource *surface) override; - void tizen_surface_shm_destroy(Resource *resource) override; -private: - DSWaylandTizenSurfaceShmFlusher *__shmFlusher; -}; - -} - -#endif diff --git a/src/DSWaylandServer/DSWaylandTizenVisibility.cpp b/src/DSWaylandServer/DSWaylandTizenVisibility.cpp deleted file mode 100644 index 77b7507..0000000 --- a/src/DSWaylandServer/DSWaylandTizenVisibility.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTizenVisibility.h" -#include "DSWaylandTizenVisibilityPrivate.h" -#include "DSWindowManager.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -DSWaylandTizenVisibilityPrivate::DSWaylandTizenVisibilityPrivate(DSWaylandTizenVisibility *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __wlSurface(nullptr), - __dswlSurface(nullptr) -{ -} - -DSWaylandTizenVisibilityPrivate::~DSWaylandTizenVisibilityPrivate() -{ -} - -void DSWaylandTizenVisibilityPrivate::init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) -{ - tizen_visibility::init(client, id, version); - __wlSurface = surface; - __dswlSurface = DSWaylandSurface::fromWlResource(surface); -} - -void DSWaylandTizenVisibilityPrivate::tizen_visibility_bind_resource(Resource *resource) -{ -} - -void DSWaylandTizenVisibilityPrivate::tizen_visibility_destroy_resource(Resource *resource) -{ -} - -void DSWaylandTizenVisibilityPrivate::tizen_visibility_destroy(Resource *resource) -{ -} - - - -DSWaylandTizenVisibility::DSWaylandTizenVisibility(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenVisibility) -{ - init(client, id, version, surface); -} - -DSWaylandTizenVisibility::~DSWaylandTizenVisibility() -{ -} - -void DSWaylandTizenVisibility::init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) -{ - DS_GET_PRIV(DSWaylandTizenVisibility); - priv->init(client, id, version, surface); -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenVisibility.h b/src/DSWaylandServer/DSWaylandTizenVisibility.h deleted file mode 100644 index da6dbf2..0000000 --- a/src/DSWaylandServer/DSWaylandTizenVisibility.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_VISIBILITY_H__ -#define __DS_WAYLAND_TIZEN_VISIBILITY_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSWaylandSurface.h" -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandTizenVisibilityPrivate; - -class DSWaylandTizenVisibility : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandTizenVisibility); - -public: - DSWaylandTizenVisibility(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); - ~DSWaylandTizenVisibility() override; - - void init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); -}; -/*LCOV_EXCL_STOP*/ - -} // namespace display_server - -#endif //__DS_WAYLAND_TIZEN_VISIBILITY_H__ diff --git a/src/DSWaylandServer/DSWaylandTizenVisibilityPrivate.h b/src/DSWaylandServer/DSWaylandTizenVisibilityPrivate.h deleted file mode 100644 index 9dfafab..0000000 --- a/src/DSWaylandServer/DSWaylandTizenVisibilityPrivate.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TIZEN_VISIBILITY_PRIVATE__ -#define __DS_WAYLAND_TIZEN_VISIBILITY_PRIVATE__ - -#include "dswayland-server-tizen-extension.h" -#include "DSWaylandTizenVisibility.h" - -namespace display_server -{ - -class DSWaylandTizenVisibilityPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_visibility -{ -DS_PIMPL_USE_PUBLIC(DSWaylandTizenVisibility); - -public: - DSWaylandTizenVisibilityPrivate() = delete; - DSWaylandTizenVisibilityPrivate(DSWaylandTizenVisibility *p_ptr); - ~DSWaylandTizenVisibilityPrivate() override; - - void init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); - -protected: - void tizen_visibility_bind_resource(Resource *resource) override; - void tizen_visibility_destroy_resource(Resource *resource) override; - - void tizen_visibility_destroy(Resource *resource) override; - -private: - struct ::wl_resource *__wlSurface; - DSWaylandSurface *__dswlSurface; - -}; - -} - -#endif //__DS_WAYLAND_TIZEN_VISIBILITY_PRIVATE__ diff --git a/src/DSWaylandServer/DSWaylandTouch.cpp b/src/DSWaylandServer/DSWaylandTouch.cpp deleted file mode 100644 index 248a198..0000000 --- a/src/DSWaylandServer/DSWaylandTouch.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWaylandTouch.h" -#include "DSWaylandTouchPrivate.h" -#include "DSWaylandClient.h" -#include "DSWaylandSeat.h" -#include "DSWaylandSurface.h" -#include "DSWaylandCompositor.h" - -namespace display_server { - -/* Begin Private Class Implementation */ -DSWaylandTouchPrivate::DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch *touch) - : DSObjectPrivate(touch), - __p_ptr(touch), - __seat(seat), - __compositor(seat ? (seat->getCompositor()) : nullptr), - __waylandSurface(nullptr), - __wlTouchResource(nullptr) -{ - wl_touch(); -} - -DSWaylandTouchPrivate::~DSWaylandTouchPrivate() -{ -} - -/*LCOV_EXCL_START*/ -void DSWaylandTouchPrivate::setFocus(DSWaylandSurface *waylandSurface) -{ - DSLOG_INF("DSWaylandTouchPrivate", "touch focus changed (%p -> %p)", __waylandSurface, waylandSurface); - - __waylandSurface = waylandSurface; - - if (!waylandSurface || !waylandSurface->hasResource()) - { - __wlTouchResource = nullptr; - DSLOG_INF("DSWaylandTouchPrivate", "wlTouchResource has been set to null."); - return; - } - - struct ::wl_resource *surface = waylandSurface->getWlResource(); - auto client = wl_resource_get_client(surface); - - std::multimap::iterator iter; - std::multimap resMap = resourceMap(); - - for (iter = resMap.begin(); iter != resMap.end(); iter++) - { - Resource *res = (*iter).second; - if (res->client() == client) - { - __wlTouchResource = res->handle; - break; - } - - } -} -/*LCOV_EXCL_STOP*/ - -DSWaylandSurface *DSWaylandTouchPrivate::getFocus() -{ - return __waylandSurface; -} - -/*LCOV_EXCL_START*/ -void DSWaylandTouchPrivate::touch_bind_resource(Resource *resource) -{ - DSLOG_INF("DSWaylandTouchPrivate",""); -} - -void DSWaylandTouchPrivate::touch_destroy_resource(Resource *resource) -{ - DSLOG_INF("DSWaylandTouchPrivate",""); -} - -void DSWaylandTouchPrivate::touch_release(Resource *resource) -{ - DSLOG_INF("DSWaylandTouchPrivate",""); - wl_resource_destroy(resource->handle); -} -/*LCOV_EXCL_STOP*/ - -/*LCOV_EXCL_START*/ -void DSWaylandTouchPrivate::sendDown(int32_t id, int x, int y) -{ - if (!__waylandSurface) - { - DSLOG_INF("DSWaylandTouchPrivate", "no waylandSurface available !"); - return; - } - - wl_fixed_t x_fixed = wl_fixed_from_int(x); - wl_fixed_t y_fixed = wl_fixed_from_int(y); - - struct ::wl_resource *surface = __waylandSurface->getWlResource(); - DS_ASSERT(surface != nullptr); - - send_down(__wlTouchResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), surface, id, x_fixed, y_fixed); -} - -void DSWaylandTouchPrivate::sendUp(int32_t id) -{ - send_up(__wlTouchResource, __compositor->nextSerial(), __seat->getCurrentEventTime(), id); -} - -void DSWaylandTouchPrivate::sendMotion(int32_t id, int x, int y) -{ - wl_fixed_t x_fixed = wl_fixed_from_int(x); - wl_fixed_t y_fixed = wl_fixed_from_int(y); - - send_motion(__wlTouchResource, __seat->getCurrentEventTime(), id, x_fixed, y_fixed); -} -/*LCOV_EXCL_STOP*/ - -/* Begin Public Class Implementation */ -DSWaylandTouch::DSWaylandTouch(DSWaylandSeat *seat) - : DSObject(), _d_ptr(std::make_unique(seat, this)) -{ - //TODO : emit signal -} - -DSWaylandTouch::~DSWaylandTouch() -{ - //TODO : emit signal -} - -DSWaylandSeat *DSWaylandTouch::seat() -{ - DS_GET_PRIV(DSWaylandTouch); - - return priv->__seat; -} - -/*LCOV_EXCL_START*/ -void DSWaylandTouch::addClient(DSWaylandClient *client, uint32_t id, int version) -{ - DS_GET_PRIV(DSWaylandTouch); - - DSLOG_INF("DSWaylandTouch", "addClient(dswlClient=%p, id=%u, version=%d", client, id, version); - - priv->add(client->wlClient(), id, version); -} -/*LCOV_EXCL_STOP*/ - -void DSWaylandTouch::setFocus(DSWaylandSurface *waylandSurface) -{ - DS_GET_PRIV(DSWaylandTouch); - priv->setFocus(waylandSurface); -} - -void DSWaylandTouch::resetFocus() -{ - DS_GET_PRIV(DSWaylandTouch); - priv->__waylandSurface = nullptr; - priv->__wlTouchResource = nullptr; -} - -DSWaylandSurface *DSWaylandTouch::getFocus() -{ - DS_GET_PRIV(DSWaylandTouch); - return priv->getFocus(); -} - -/*LCOV_EXCL_START*/ -void DSWaylandTouch::sendDown(int32_t id, int x, int y) -{ - DS_GET_PRIV(DSWaylandTouch); - priv->sendDown(id, x, y); -} - -void DSWaylandTouch::sendUp(int32_t id) -{ - DS_GET_PRIV(DSWaylandTouch); - priv->sendUp(id); -} - -void DSWaylandTouch::sendMotion(int32_t id, int x, int y) -{ - DS_GET_PRIV(DSWaylandTouch); - priv->sendMotion(id, x, y); -} -/*LCOV_EXCL_STOP*/ - -} diff --git a/src/DSWaylandServer/DSWaylandTouch.h b/src/DSWaylandServer/DSWaylandTouch.h deleted file mode 100644 index 203bbc6..0000000 --- a/src/DSWaylandServer/DSWaylandTouch.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TOUCH_H__ -#define __DS_WAYLAND_TOUCH_H__ - -#include "DSCore.h" -#include "DSObject.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandSeat; -class DSWaylandTouchPrivate; -class DSWaylandClient; -class DSWaylandSurface; - -class DS_DECL_EXPORT DSWaylandTouch : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWaylandTouch); -public: - DSWaylandTouch(DSWaylandSeat *seat); - ~DSWaylandTouch() override; - - DSWaylandSeat *seat(); - - void addClient(DSWaylandClient *client, uint32_t id, int version); - void setFocus(DSWaylandSurface *waylandSurface); - void resetFocus(); - DSWaylandSurface *getFocus(); - - void sendDown(int32_t id, int x, int y); - void sendUp(int32_t id); - void sendMotion(int32_t id, int x, int y); - -protected: - -private: - -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif //__DS_WAYLAND_TOUCH_H__ diff --git a/src/DSWaylandServer/DSWaylandTouchPrivate.h b/src/DSWaylandServer/DSWaylandTouchPrivate.h deleted file mode 100644 index 1556ce7..0000000 --- a/src/DSWaylandServer/DSWaylandTouchPrivate.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_TOUCH_PRIVATE_H__ -#define __DS_WAYLAND_TOUCH_PRIVATE_H__ - -#include "dswayland-server-wayland.h" - -#include "DSCore.h" -#include "DSObjectPrivate.h" - -struct wl_resource; - -namespace display_server -{ - -class DSWaylandSeat; -class DSWaylandCompositor; -class DSWaylandSurface; - -class DS_DECL_EXPORT DSWaylandTouchPrivate : public DSObjectPrivate, public DSWaylandServer::wl_touch -{ - DS_PIMPL_USE_PUBLIC(DSWaylandTouch); -public: - DSWaylandTouchPrivate(DSWaylandSeat *seat, DSWaylandTouch *touch); - ~DSWaylandTouchPrivate() override; - - void setFocus(DSWaylandSurface *waylandSurface); - DSWaylandSurface *getFocus(); - -protected: - //virtual Resource *touch_allocate(); - virtual void touch_bind_resource(Resource *resource); - virtual void touch_destroy_resource(Resource *resource); - virtual void touch_release(Resource *resource); - - /* APIs must be provided */ - void sendDown(int32_t id, int x, int y); - void sendUp(int32_t id); - void sendMotion(int32_t id, int x, int y); - /* - void sendFrame(struct ::wl_resource *surface); - void sendCancel(struct ::wl_resource *surface); - */ - /* APIs don't need to provide */ - /* - void send_shape(struct ::wl_resource *resource, int32_t id, wl_fixed_t major, wl_fixed_t minor); - void send_orientation(struct ::wl_resource *resource, int32_t id, wl_fixed_t orientation); - */ - -private: - DSWaylandSeat *__seat; - DSWaylandCompositor *__compositor; - DSWaylandSurface *__waylandSurface; - struct ::wl_resource *__wlTouchResource; -}; - -} - -#endif //__DS_WAYLAND_TOUCH_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp deleted file mode 100644 index e3e49bf..0000000 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp +++ /dev/null @@ -1,683 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWindowManager.h" -#include "DSWaylandZxdgShellV6.h" -#include "DSWaylandZxdgShellV6Private.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandSurface.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 -{ - -/*LCOV_EXCL_START*/ -/****************************************** - DSWaylandZxdgShellV6 - *****************************************/ - -DSWaylandZxdgShellV6::DSWaylandZxdgShellV6() - : IDSWaylandShell(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgShellV6) -{ -} - -DSWaylandZxdgShellV6::DSWaylandZxdgShellV6(DSWaylandCompositor *wlCompositor) - : IDSWaylandShell(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgShellV6) -{ - this->init(wlCompositor->display(), ZXDG_SHELL_V6_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 DSWaylandZxdgShellV6::getSurfaceList() -{ - DS_GET_PRIV(DSWaylandZxdgShellV6); - - return priv->getSurfaceList(); -} - -void DSWaylandZxdgShellV6::registerCallbackShellSurfaceCreated(DSObject *slot, std::function func) -{ - __zxdgSurfaceCreatedSignal.connect(slot, func); -} - -void DSWaylandZxdgShellV6::registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function func) -{ - __zxdgSurfaceDestroyedSignal.connect(slot, func); -} - -DSWaylandZxdgShellV6Private::DSWaylandZxdgShellV6Private(DSWaylandZxdgShellV6 *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) -{ -} - -DSWaylandZxdgShellV6Private::~DSWaylandZxdgShellV6Private() -{ -} - -void DSWaylandZxdgShellV6Private::zxdg_shell_v6_bind_resource(zxdg_shell_v6::Resource *resource) -{ -} -void DSWaylandZxdgShellV6Private::zxdg_shell_v6_destroy_resource(zxdg_shell_v6::Resource *resource) -{ -} - -void DSWaylandZxdgShellV6Private::zxdg_shell_v6_destroy(zxdg_shell_v6::Resource *resource) -{ -} -void DSWaylandZxdgShellV6Private::zxdg_shell_v6_create_positioner(zxdg_shell_v6::Resource *resource, uint32_t id) -{ -} -void DSWaylandZxdgShellV6Private::zxdg_shell_v6_get_xdg_surface(zxdg_shell_v6::Resource *resource, uint32_t id, struct ::wl_resource *surface) -{ - DSLOG_DBG("DSWaylandZxdgShell", ""); - DS_GET_PUB(DSWaylandZxdgShellV6); - - DSWaylandZxdgSurfaceV6 *zxdgSurf = new DSWaylandZxdgSurfaceV6(resource->client(), id, ZXDG_SURFACE_V6_VERSION, pub); - if (zxdgSurf) - { - zxdgSurf->setWlSurface(surface); - - DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface); - if (dswlSurface) - { - zxdgSurf->setSurface(dswlSurface); - } - - DSLOG_DBG("DSWaylandZxdgShell", "DSWaylandZxdgSurface:%p, DSWaylandSurface:%p, wl_surface:%p", zxdgSurf, dswlSurface, surface); - - 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; - - DS_GET_PUB(DSWaylandZxdgShellV6); - pub->__zxdgSurfaceCreatedSignal.emit(zxdgSurf); - - __surfList.push_back(zxdgSurf); -} - -void DSWaylandZxdgShellV6Private::delSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf) -{ - DS_GET_PUB(DSWaylandZxdgShellV6); - pub->__zxdgSurfaceDestroyedSignal.emit(zxdgSurf); - - __surfList.remove(zxdgSurf); -} - -std::list DSWaylandZxdgShellV6Private::getSurfaceList() -{ - return __surfList; -} - - -/****************************************** - DSWaylandZxdgPositionerV6 - *****************************************/ - -DSWaylandZxdgPositionerV6::DSWaylandZxdgPositionerV6() - : DSObject(), DS_INIT_PRIVATE_PTR(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) -{ -} - -DSWaylandZxdgPositionerV6Private::~DSWaylandZxdgPositionerV6Private() -{ -} - -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_bind_resource(zxdg_positioner_v6::Resource *resource) -{ -} -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_destroy_resource(zxdg_positioner_v6::Resource *resource) -{ -} - -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_destroy(zxdg_positioner_v6::Resource *resource) -{ -} -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_set_size(zxdg_positioner_v6::Resource *resurce, int32_t width, int32_t height) -{ -} -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_set_anchor_rect(zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) -{ -} -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_set_anchor(zxdg_positioner_v6::Resource *resource, uint32_t anchor) -{ -} -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_set_gravity(zxdg_positioner_v6::Resource *resource, uint32_t gravity) -{ -} -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_set_constraint_adjustment(zxdg_positioner_v6::Resource *resource, uint32_t constraint_adjustment) -{ -} -void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_set_offset(zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y) -{ -} - - -/****************************************** - DSWaylandZxdgSurfaceV6 - *****************************************/ - -DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6(DSWaylandZxdgShellV6 *xdgShell) - : IDSWaylandShellSurface(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6), - __xdgShell(xdgShell) -{ -} - -DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver, DSWaylandZxdgShellV6 *xdgShell) - : IDSWaylandShellSurface(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6), - __xdgShell(xdgShell) -{ - this->init(client, id, ver); -} - -DSWaylandZxdgSurfaceV6::~DSWaylandZxdgSurfaceV6() -{ - if (__xdgShell) - __xdgShell->delSurface(this); -} - -void DSWaylandZxdgSurfaceV6::init(struct ::wl_client *client, int id, int ver) -{ - DS_GET_PRIV(DSWaylandZxdgSurfaceV6); - - priv->init(client, id, ver); -} - -void DSWaylandZxdgSurfaceV6::setWlSurface(struct ::wl_resource *surface) -{ - DS_GET_PRIV(DSWaylandZxdgSurfaceV6); - - priv->setWlSurface(surface); -} - -struct ::wl_resource *DSWaylandZxdgSurfaceV6::getWlSurface(void) -{ - DS_GET_PRIV(DSWaylandZxdgSurfaceV6); - - return priv->getWlSurface(); -} - -void DSWaylandZxdgSurfaceV6::setSurface(DSWaylandSurface *surface) -{ - DS_GET_PRIV(DSWaylandZxdgSurfaceV6); - priv->setSurface(surface); -} - -DSWaylandSurface *DSWaylandZxdgSurfaceV6::getSurface(void) -{ - DS_GET_PRIV(DSWaylandZxdgSurfaceV6); - return priv->getSurface(); -} - -void DSWaylandZxdgSurfaceV6::sendConfigure(int x, int y, unsigned int w, unsigned int h) -{ - DS_GET_PRIV(DSWaylandZxdgSurfaceV6); - priv->sendConfigure(x, y, w, h); -} - -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), - __wlSurface(nullptr), __dsSurface(nullptr), - __toplevel(nullptr), __popup(nullptr), __role(DSWaylandZxdgSurfaceV6::DS_XDG_SURFACE_ROLE_NONE), - __x(0), __y(0), __w(0), __h(0), - __title(""), __appId("") -{ -} - -DSWaylandZxdgSurfaceV6Private::~DSWaylandZxdgSurfaceV6Private() -{ -} - -void DSWaylandZxdgSurfaceV6Private::setWlSurface(struct ::wl_resource *surface) -{ - __wlSurface = surface; -} - -struct ::wl_resource *DSWaylandZxdgSurfaceV6Private::getWlSurface(void) -{ - return __wlSurface; -} - -void DSWaylandZxdgSurfaceV6Private::setSurface(DSWaylandSurface *surface) -{ - __dsSurface = surface; -} - -DSWaylandSurface *DSWaylandZxdgSurfaceV6Private::getSurface(void) -{ - return __dsSurface; -} - -void DSWaylandZxdgSurfaceV6Private::sendConfigure(int x, int y, unsigned int w, unsigned int h) -{ - DSWaylandCompositor *wlCompositor = DSWaylandCompositor::getInstance(); - if (wlCompositor == nullptr) return; - - uint32_t serial = wlCompositor->nextSerial(); - - DSLOG_DBG("ZXDG_SURFACE", "Role:%d, Toplevel:%p, Popup:%p", __role, __toplevel, __popup); - - // TODO: Do we check role (toplevel or popup) - if (__toplevel) - __toplevel->sendConfigure(w, h); - - if (__popup) - __popup->sendConfigure(x, y, w, h); - - DSLOG_DBG("ZXDG_SURFACE", "Send configure... serial:%d", serial); - send_configure(serial); - - DSWaylandCompositor::releaseInstance(); -} - -void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_bind_resource(zxdg_surface_v6::Resource *resource) -{ -} -void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_destroy_resource(zxdg_surface_v6::Resource *resource) -{ -} - -void DSWaylandZxdgSurfaceV6Private::zxdg_surface_v6_destroy(zxdg_surface_v6::Resource *resource) -{ -} -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; - - DSLOG_DBG("ZXDG_SURFACE", "Get Toplevel. DSWaylandZxdgToplevel:%p", __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; - - DSLOG_DBG("ZXDG_SURFACE", "Get Popup. DSWaylandZxdgPopup:%p", __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 - - DSLOG_DBG("ZXDG_SURFACE", "Set Window geometry (%d,%d,%d,%d)", x, y, width, height); - - DSWindowManager *wm = DSWindowManager::getInstance(); - wm->setWindowGeometry(__dsSurface, __x, __y, __w, __h); - DSWindowManager::releaseInstance(); -} -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 - __title = title; - - DSWindowManager *wm = DSWindowManager::getInstance(); - wm->setWindowTitle(__dsSurface, __title); - DSWindowManager::releaseInstance(); -} - -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() - : DSObject(), DS_INIT_PRIVATE_PTR(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; -} - -void DSWaylandZxdgToplevelV6::sendConfigure(unsigned int w, unsigned int h) -{ - DS_GET_PRIV(DSWaylandZxdgToplevelV6); - priv->sendConfigure(w, h); -} - -DSWaylandZxdgToplevelV6Private::DSWaylandZxdgToplevelV6Private(DSWaylandZxdgToplevelV6 *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __zxdgSurface(nullptr) -{ -} - -DSWaylandZxdgToplevelV6Private::~DSWaylandZxdgToplevelV6Private() -{ -} - -void DSWaylandZxdgToplevelV6Private::sendConfigure(unsigned int w, unsigned int h) -{ - struct ::wl_array states; - wl_array_init(&states); - -/* - uint32_t *s; - - // if maximized - s = wl_array_add(&states, sizeof(uint32_t)); - if (s) - { - *s = ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED; - } - - // if fullscreen - s = wl_array_add(&states, sizeof(uint32_t)); - if (s) - { - *s = ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN; - } -*/ - - send_configure((int32_t)w, (int32_t)h, &states); - - wl_array_release(&states); -} - -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_bind_resource(zxdg_toplevel_v6::Resource *resource) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_destroy_resource(zxdg_toplevel_v6::Resource *resource) -{ -} - -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_destroy(zxdg_toplevel_v6::Resource *resource) -{ -} - -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_parent(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *parent) -{ - DSLOG_DBG("XDG_TopLevel", "Set Parent (parent:%p)", parent); - - DSWaylandSurface *surface = __zxdgSurface->getSurface(); - if (!surface) return; - - DSWaylandSurface *parentSurface = DSWaylandSurface::fromWlResource(parent); - - DSWindowManager *wm = DSWindowManager::getInstance(); - if (wm) - { - wm->setWindowParent(surface, parentSurface); - DSWindowManager::releaseInstance(); - } -} - -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) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_move(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_resize(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_max_size(zxdg_toplevel_v6::Resource *resource, int32_t width, int32_t height) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_min_size(zxdg_toplevel_v6::Resource *resource, int32_t width, int32_t height) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_maximized(zxdg_toplevel_v6::Resource *resource) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_unset_maximized(zxdg_toplevel_v6::Resource *resource) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_fullscreen(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *output) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_unset_fullscreen(zxdg_toplevel_v6::Resource *resource) -{ -} -void DSWaylandZxdgToplevelV6Private::zxdg_toplevel_v6_set_minimized(zxdg_toplevel_v6::Resource *resource) -{ -} - - -/****************************************** - DSWaylandZxdgPopupV6 - *****************************************/ - -DSWaylandZxdgPopupV6::DSWaylandZxdgPopupV6() - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgPopupV6) -{ -} - -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; -} - -void DSWaylandZxdgPopupV6::sendConfigure(int x, int y, unsigned int w, unsigned int h) -{ - DS_GET_PRIV(DSWaylandZxdgPopupV6); - priv->send_configure(x, y, w, h); -} - -DSWaylandZxdgPopupV6Private::DSWaylandZxdgPopupV6Private(DSWaylandZxdgPopupV6 *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __zxdgSurface(nullptr) -{ -} - -DSWaylandZxdgPopupV6Private::~DSWaylandZxdgPopupV6Private() -{ -} - -void DSWaylandZxdgPopupV6Private::sendConfigure(int x, int y, unsigned int w, unsigned int h) -{ - send_configure(x, y, w, h); -} - -void DSWaylandZxdgPopupV6Private::zxdg_popup_v6_bind_resource(zxdg_popup_v6::Resource *resource) -{ -} -void DSWaylandZxdgPopupV6Private::zxdg_popup_v6_destroy_resource(zxdg_popup_v6::Resource *resource) -{ -} - -void DSWaylandZxdgPopupV6Private::zxdg_popup_v6_destroy(zxdg_popup_v6::Resource *resource) -{ -} -void DSWaylandZxdgPopupV6Private::zxdg_popup_v6_grab(zxdg_popup_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial) -{ -} -/*LCOV_EXCL_STOP*/ - -} // namespace display_server - diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.h b/src/DSWaylandServer/DSWaylandZxdgShellV6.h deleted file mode 100644 index 8c539c2..0000000 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.h +++ /dev/null @@ -1,154 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_ZXDG_SHELL_V6_H__ -#define __DS_WAYLAND_ZXDG_SHELL_V6_H__ - -#include -#include -#include -#include "IDSWaylandShell.h" - -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandCompositor; -class DSWaylandZxdgShellV6; -class DSWaylandZxdgPositionerV6; -class DSWaylandZxdgSurfaceV6; -class DSWaylandZxdgToplevelV6; -class DSWaylandZxdgPopupV6; -class DSWaylandZxdgShellV6Private; -class DSWaylandZxdgPositionerV6Private; -class DSWaylandZxdgSurfaceV6Private; -class DSWaylandZxdgToplevelV6Private; -class DSWaylandZxdgPopupV6Private; - -class DSWaylandZxdgShellV6 : public IDSWaylandShell -{ -DS_PIMPL_USE_PRIVATE(DSWaylandZxdgShellV6); - -public: - DSWaylandZxdgShellV6(); - DSWaylandZxdgShellV6(DSWaylandCompositor *wlCompositor); - virtual ~DSWaylandZxdgShellV6(); - - void init(struct ::wl_display *display, int version); - void addSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf); - void delSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf); - std::list getSurfaceList(); - - void registerCallbackShellSurfaceCreated(DSObject *slot, std::function func); - void registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function func); - -public: - DSSignal __zxdgSurfaceCreatedSignal; - DSSignal __zxdgSurfaceDestroyedSignal; -}; - -class DSWaylandZxdgPositionerV6 : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandZxdgPositionerV6); - -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 IDSWaylandShellSurface -{ -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(DSWaylandZxdgShellV6 *xdgShell); - DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver, DSWaylandZxdgShellV6 *xdgShell); - virtual ~DSWaylandZxdgSurfaceV6(); - - void init(struct ::wl_client *client, int id, int ver); - - // TODO: Do we use ::wl_resource or DSWaylandSurface? - void setWlSurface(struct ::wl_resource *surface) override; - struct ::wl_resource *getWlSurface(void) override; - - void setSurface(DSWaylandSurface *surface) override; - DSWaylandSurface *getSurface(void) override; - - void sendConfigure(int x, int y, unsigned int w, unsigned int h) 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: - DSWaylandZxdgShellV6 *__xdgShell; -}; - -class DSWaylandZxdgToplevelV6 : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandZxdgToplevelV6); - -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); - void sendConfigure(unsigned int w, unsigned int h); -}; - -class DSWaylandZxdgPopupV6 : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWaylandZxdgPopupV6); - -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); - void sendConfigure(int x, int y, unsigned int w, unsigned int h); -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif // __DS_WAYLAND_ZXDG_SHELL_V6_H__ - diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6Private.h b/src/DSWaylandServer/DSWaylandZxdgShellV6Private.h deleted file mode 100644 index bd35be9..0000000 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6Private.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WAYLAND_ZXDG_SHELL_V6_PRIVATE_H__ -#define __DS_WAYLAND_ZXDG_SHELL_V6_PRIVATE_H__ - -#include - -#include "dswayland-server-xdg-shell-unstable-v6.h" -#include "DSWaylandZxdgShellV6.h" - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class DSWaylandZxdgShellV6Private : public DSObjectPrivate, public DSWaylandServer::zxdg_shell_v6 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandZxdgShellV6); - -public: - DSWaylandZxdgShellV6Private() = delete; - DSWaylandZxdgShellV6Private(DSWaylandZxdgShellV6 *p_ptr); - ~DSWaylandZxdgShellV6Private() override; - -protected: - void zxdg_shell_v6_bind_resource(Resource *resource) override; - void zxdg_shell_v6_destroy_resource(Resource *resource) override; - - void zxdg_shell_v6_destroy(Resource *resource) override; - void zxdg_shell_v6_create_positioner(Resource *resource, uint32_t id) override; - 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 getSurfaceList(); - -private: - std::list __surfList; -}; - -class DSWaylandZxdgPositionerV6Private : public DSObjectPrivate, public DSWaylandServer::zxdg_positioner_v6 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandZxdgPositionerV6); - -public: - DSWaylandZxdgPositionerV6Private() = delete; - DSWaylandZxdgPositionerV6Private(DSWaylandZxdgPositionerV6 *p_ptr); - ~DSWaylandZxdgPositionerV6Private() override; - -protected: - void zxdg_positioner_v6_bind_resource(zxdg_positioner_v6::Resource *resource) override; - void zxdg_positioner_v6_destroy_resource(zxdg_positioner_v6::Resource *resource) override; - - void zxdg_positioner_v6_destroy(zxdg_positioner_v6::Resource *resource) override; - void zxdg_positioner_v6_set_size(zxdg_positioner_v6::Resource *resource, int32_t width, int32_t height) override; - void zxdg_positioner_v6_set_anchor_rect(zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; - void zxdg_positioner_v6_set_anchor(zxdg_positioner_v6::Resource *resource, uint32_t anchor) override; - void zxdg_positioner_v6_set_gravity(zxdg_positioner_v6::Resource *resource, uint32_t gravity) override; - void zxdg_positioner_v6_set_constraint_adjustment(zxdg_positioner_v6::Resource *resource, uint32_t constraint_adjustment) override; - void zxdg_positioner_v6_set_offset(zxdg_positioner_v6::Resource *resource, int32_t x, int32_t y) override; -}; - -class DSWaylandZxdgSurfaceV6Private : public DSObjectPrivate, public DSWaylandServer::zxdg_surface_v6 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandZxdgSurfaceV6); - -public: - DSWaylandZxdgSurfaceV6Private() = delete; - DSWaylandZxdgSurfaceV6Private(DSWaylandZxdgSurfaceV6 *p_ptr); - ~DSWaylandZxdgSurfaceV6Private() override; - - void setWlSurface(struct ::wl_resource *surface); - struct ::wl_resource *getWlSurface(void); - - void setSurface(DSWaylandSurface *surface); - DSWaylandSurface *getSurface(void); - - void sendConfigure(int x, int y, unsigned int w, unsigned int h); - -protected: - void zxdg_surface_v6_bind_resource(zxdg_surface_v6::Resource *resource) override; - void zxdg_surface_v6_destroy_resource(zxdg_surface_v6::Resource *resource) override; - - void zxdg_surface_v6_destroy(zxdg_surface_v6::Resource *resource) override; - void zxdg_surface_v6_get_toplevel(zxdg_surface_v6::Resource *resource, uint32_t id) override; - void zxdg_surface_v6_get_popup(zxdg_surface_v6::Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner) override; - 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: - struct ::wl_resource *__wlSurface; - DSWaylandSurface *__dsSurface; - DSWaylandZxdgToplevelV6 *__toplevel; - DSWaylandZxdgPopupV6 *__popup; - DSWaylandZxdgSurfaceV6::Xdg_Surface_Role __role; - - int __x, __y; - unsigned int __w, __h; - std::string __title, __appId; -}; - -class DSWaylandZxdgToplevelV6Private : public DSObjectPrivate, public DSWaylandServer::zxdg_toplevel_v6 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandZxdgToplevelV6); - -public: - DSWaylandZxdgToplevelV6Private() = delete; - DSWaylandZxdgToplevelV6Private(DSWaylandZxdgToplevelV6 *p_ptr); - ~DSWaylandZxdgToplevelV6Private() override; - - void sendConfigure(unsigned int w, unsigned int h); - -protected: - void zxdg_toplevel_v6_bind_resource(zxdg_toplevel_v6::Resource *resource) override; - void zxdg_toplevel_v6_destroy_resource(zxdg_toplevel_v6::Resource *resource) override; - - void zxdg_toplevel_v6_destroy(zxdg_toplevel_v6::Resource *resource) override; - void zxdg_toplevel_v6_set_parent(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *parent) override; - void zxdg_toplevel_v6_set_title(zxdg_toplevel_v6::Resource *resource, const std::string &title) override; - void zxdg_toplevel_v6_set_app_id(zxdg_toplevel_v6::Resource *resource, const std::string &app_id) override; - void zxdg_toplevel_v6_show_window_menu(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y) override; - void zxdg_toplevel_v6_move(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial) override; - void zxdg_toplevel_v6_resize(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges) override; - void zxdg_toplevel_v6_set_max_size(zxdg_toplevel_v6::Resource *resource, int32_t width, int32_t height) override; - void zxdg_toplevel_v6_set_min_size(zxdg_toplevel_v6::Resource *resource, int32_t width, int32_t height) override; - void zxdg_toplevel_v6_set_maximized(zxdg_toplevel_v6::Resource *resource) override; - void zxdg_toplevel_v6_unset_maximized(zxdg_toplevel_v6::Resource *resource) override; - void zxdg_toplevel_v6_set_fullscreen(zxdg_toplevel_v6::Resource *resource, struct ::wl_resource *output) override; - void zxdg_toplevel_v6_unset_fullscreen(zxdg_toplevel_v6::Resource *resource) override; - void zxdg_toplevel_v6_set_minimized(zxdg_toplevel_v6::Resource *resource) override; - -private: - DSWaylandZxdgSurfaceV6 *__zxdgSurface; -}; - -class DSWaylandZxdgPopupV6Private : public DSObjectPrivate, public DSWaylandServer::zxdg_popup_v6 -{ -DS_PIMPL_USE_PUBLIC(DSWaylandZxdgPopupV6); - -public: - DSWaylandZxdgPopupV6Private() = delete; - DSWaylandZxdgPopupV6Private(DSWaylandZxdgPopupV6 *p_ptr); - ~DSWaylandZxdgPopupV6Private() override; - - void sendConfigure(int x, int y, unsigned int w, unsigned int h); - -protected: - void zxdg_popup_v6_bind_resource(zxdg_popup_v6::Resource *resource) override; - void zxdg_popup_v6_destroy_resource(zxdg_popup_v6::Resource *resource) override; - - void zxdg_popup_v6_destroy(zxdg_popup_v6::Resource *resource) override; - void zxdg_popup_v6_grab(zxdg_popup_v6::Resource *resource, struct ::wl_resource *seat, uint32_t serial) override; - -private: - DSWaylandZxdgSurfaceV6 *__zxdgSurface; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif // __DS_WAYLAND_ZXDG_SHELL_V6_PRIVATE_H__ - diff --git a/src/DSWaylandServer/IDSWaylandShell.h b/src/DSWaylandServer/IDSWaylandShell.h deleted file mode 100644 index 0de876a..0000000 --- a/src/DSWaylandServer/IDSWaylandShell.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __I_DS_WAYLAND_SHELL_H__ -#define __I_DS_WAYLAND_SHELL_H__ - -#include -#include -#include -#include "DSWaylandSurface.h" -#include - -namespace display_server -{ - -/*LCOV_EXCL_START*/ -class IDSWaylandShellSurface; - -class IDSWaylandShell : public DSObject -{ -public: - virtual ~IDSWaylandShell() = default; - - virtual void registerCallbackShellSurfaceCreated(DSObject *slot, std::function func) = 0; - virtual void registerCallbackShellSurfaceDestroyed(DSObject *slot, std::function func) = 0; -}; - - -class IDSWaylandShellSurface : public DSObject -{ -public: - virtual ~IDSWaylandShellSurface() = default; - - // TODO: we need change ::wl_resource to DSWaylandSurface - virtual void setWlSurface(struct ::wl_resource *surface) = 0; - virtual struct ::wl_resource *getWlSurface(void) = 0; - - virtual void setSurface(DSWaylandSurface *surface) = 0; - virtual DSWaylandSurface *getSurface(void) = 0; - - virtual void sendConfigure(int x, int y, unsigned int w, unsigned int h) = 0; -}; -/*LCOV_EXCL_STOP*/ - -} - -#endif // __I_DS_WAYLAND_SHELL_H__ - diff --git a/src/DSWaylandServer/README.md b/src/DSWaylandServer/README.md deleted file mode 100644 index 10eb855..0000000 --- a/src/DSWaylandServer/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# DSWaylandServer -A collection of classes and headers of wayland server side objects diff --git a/src/DSWaylandServer/dswayland-server-eom.cpp b/src/DSWaylandServer/dswayland-server-eom.cpp deleted file mode 100644 index c1805da..0000000 --- a/src/DSWaylandServer/dswayland-server-eom.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/eom.xml */ - -#include "dswayland-server-wl-eom.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - wl_eom::wl_eom(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_eom::wl_eom(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_eom::wl_eom(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_eom::wl_eom() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_eom::~wl_eom() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_eom::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_eom::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_eom::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_eom::Resource *wl_eom::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_eom::Resource *wl_eom::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_eom::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_eom_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_eom::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_eom::interface() - { - return &::wl_eom_interface; - } - - wl_eom::Resource *wl_eom::eom_allocate() - { - return new Resource; - } - - void wl_eom::eom_bind_resource(Resource *) - { - } - - void wl_eom::eom_destroy_resource(Resource *) - { - } - - void wl_eom::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_eom *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_eom::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_eom *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_eom::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_eom *that = resource->eom_object; - that->m_resource_map.erase(resource->client()); - that->eom_destroy_resource(resource); - delete resource; - } - - wl_eom::Resource *wl_eom::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_eom_interface, version, id); - return bind(handle); - } - - wl_eom::Resource *wl_eom::bind(struct ::wl_resource *handle) - { - Resource *resource = eom_allocate(); - resource->eom_object = this; - - wl_resource_set_implementation(handle, &m_wl_eom_interface, resource, destroy_func); - resource->handle = handle; - eom_bind_resource(resource); - return resource; - } - wl_eom::Resource *wl_eom::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_eom_interface, &m_wl_eom_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_eom_interface wl_eom::m_wl_eom_interface = { - wl_eom::handle_set_attribute, - wl_eom::handle_set_shell_window, - wl_eom::handle_get_output_info - }; - - void wl_eom::eom_set_attribute(Resource *, uint32_t , uint32_t ) - { - } - - void wl_eom::eom_set_shell_window(Resource *, uint32_t , struct ::wl_resource *) - { - } - - void wl_eom::eom_get_output_info(Resource *, uint32_t ) - { - } - - - void wl_eom::handle_set_attribute( - ::wl_client *client, - struct wl_resource *resource, - uint32_t output_id, - uint32_t attribute) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->eom_object)->eom_set_attribute( - r, - output_id, - attribute); - } - - void wl_eom::handle_set_shell_window( - ::wl_client *client, - struct wl_resource *resource, - uint32_t output_id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->eom_object)->eom_set_shell_window( - r, - output_id, - surface); - } - - void wl_eom::handle_get_output_info( - ::wl_client *client, - struct wl_resource *resource, - uint32_t output_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->eom_object)->eom_get_output_info( - r, - output_id); - } - - void wl_eom::send_output_count(uint32_t count) - { - DS_ASSERT_X(m_resource, "wl_eom::output_count", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_eom::output_count as it's not initialised"); - return; - } - send_output_count( - m_resource->handle, - count); - } - - void wl_eom::send_output_count(struct ::wl_resource *resource, uint32_t count) - { - wl_eom_send_output_count( - resource, - count); - } - - - void wl_eom::send_output_info(uint32_t output_id, uint32_t type, uint32_t mode, uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection, uint32_t skip, uint32_t attribute, uint32_t attribute_state, uint32_t error) - { - DS_ASSERT_X(m_resource, "wl_eom::output_info", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_eom::output_info as it's not initialised"); - return; - } - send_output_info( - m_resource->handle, - output_id, - type, - mode, - w, - h, - w_mm, - h_mm, - connection, - skip, - attribute, - attribute_state, - error); - } - - void wl_eom::send_output_info(struct ::wl_resource *resource, uint32_t output_id, uint32_t type, uint32_t mode, uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection, uint32_t skip, uint32_t attribute, uint32_t attribute_state, uint32_t error) - { - wl_eom_send_output_info( - resource, - output_id, - type, - mode, - w, - h, - w_mm, - h_mm, - connection, - skip, - attribute, - attribute_state, - error); - } - - - void wl_eom::send_output_type(uint32_t output_id, uint32_t type, uint32_t status) - { - DS_ASSERT_X(m_resource, "wl_eom::output_type", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_eom::output_type as it's not initialised"); - return; - } - send_output_type( - m_resource->handle, - output_id, - type, - status); - } - - void wl_eom::send_output_type(struct ::wl_resource *resource, uint32_t output_id, uint32_t type, uint32_t status) - { - wl_eom_send_output_type( - resource, - output_id, - type, - status); - } - - - void wl_eom::send_output_mode(uint32_t output_id, uint32_t mode) - { - DS_ASSERT_X(m_resource, "wl_eom::output_mode", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_eom::output_mode as it's not initialised"); - return; - } - send_output_mode( - m_resource->handle, - output_id, - mode); - } - - void wl_eom::send_output_mode(struct ::wl_resource *resource, uint32_t output_id, uint32_t mode) - { - wl_eom_send_output_mode( - resource, - output_id, - mode); - } - - - void wl_eom::send_output_attribute(uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error) - { - DS_ASSERT_X(m_resource, "wl_eom::output_attribute", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_eom::output_attribute as it's not initialised"); - return; - } - send_output_attribute( - m_resource->handle, - output_id, - attribute, - attribute_state, - error); - } - - void wl_eom::send_output_attribute(struct ::wl_resource *resource, uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error) - { - wl_eom_send_output_attribute( - resource, - output_id, - attribute, - attribute_state, - error); - } - - - void wl_eom::send_output_set_window(uint32_t output_id, uint32_t error) - { - DS_ASSERT_X(m_resource, "wl_eom::output_set_window", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_eom::output_set_window as it's not initialised"); - return; - } - send_output_set_window( - m_resource->handle, - output_id, - error); - } - - void wl_eom::send_output_set_window(struct ::wl_resource *resource, uint32_t output_id, uint32_t error) - { - wl_eom_send_output_set_window( - resource, - output_id, - error); - } - - - void wl_eom::send_output_add(uint32_t output_id) - { - DS_ASSERT_X(m_resource, "wl_eom::output_add", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_eom::output_add as it's not initialised"); - return; - } - send_output_add( - m_resource->handle, - output_id); - } - - void wl_eom::send_output_add(struct ::wl_resource *resource, uint32_t output_id) - { - wl_eom_send_output_add( - resource, - output_id); - } - - - void wl_eom::send_output_remove(uint32_t output_id) - { - DS_ASSERT_X(m_resource, "wl_eom::output_remove", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_eom::output_remove as it's not initialised"); - return; - } - send_output_remove( - m_resource->handle, - output_id); - } - - void wl_eom::send_output_remove(struct ::wl_resource *resource, uint32_t output_id) - { - wl_eom_send_output_remove( - resource, - output_id); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-eom.h b/src/DSWaylandServer/dswayland-server-eom.h deleted file mode 100644 index 7c3edb3..0000000 --- a/src/DSWaylandServer/dswayland-server-eom.h +++ /dev/null @@ -1,190 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/eom.xml */ - -#ifndef __DS_WL_EOM_PROTOCOL_H__ -#define __DS_WL_EOM_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "wl-eom-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class wl_eom - { - public: - wl_eom(struct ::wl_client *client, uint32_t id, int version); - wl_eom(struct ::wl_display *display, int version); - wl_eom(struct ::wl_resource *resource); - wl_eom(); - - virtual ~wl_eom(); - - class Resource - { - public: - Resource() : eom_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_eom *eom_object; - wl_eom *object() { return eom_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_none = 0, // no error - error_no_output = 1, // Given output is invalid. - error_no_attribute = 2, // Given attribute is invalid. - error_output_occupied = 3, // The key has been grabbed already. - }; - - enum type { - type_none = 0, // none - type_vga = 1, // VGA output connector type - type_dvii = 2, // DVI-I output connector type - type_dvid = 3, // DVI-D output connector type - type_dvia = 4, // DVI-A output connector type - type_composite = 5, // Composite output connector type - type_svideo = 6, // S-Video output connector type - type_lvds = 7, // LVDS output connector type - type_component = 8, // Component output connector type - type_9pindin = 9, // 9 pin DIN output connector type - type_displayport = 10, // DisplayPort output connector type - type_hdmia = 11, // HDMI type A output connector type - type_hdmib = 12, // HDMI type B output connector type - type_tv = 13, // TV output connector type - type_edp = 14, // eDP output connector type - type_virtual = 15, // Virtual output connector type - type_dsi = 16, // DSI output connector type - }; - - enum status { - status_none = 0, // none - status_connection = 1, // output connected - status_disconnection = 2, // output disconnected - }; - - enum mode { - mode_none = 0, // none - mode_mirror = 1, // mirror mode - mode_presentation = 2, // presentation mode - }; - - enum attribute { - attribute_none = 0, // none - attribute_normal = 1, // nomal attribute - attribute_exclusive_share = 2, // exclusive share attribute - attribute_exclusive = 3, // exclusive attribute - }; - - enum attribute_state { - attribute_state_none = 0, // none - attribute_state_active = 1, // attribute is active on the output - attribute_state_inactive = 2, // attribute is inactive on the output - attribute_state_lost = 3, // the connection of output is lost - }; - - void send_output_count(uint32_t count); - void send_output_count(struct ::wl_resource *resource, uint32_t count); - void send_output_info(uint32_t output_id, uint32_t type, uint32_t mode, uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection, uint32_t skip, uint32_t attribute, uint32_t attribute_state, uint32_t error); - void send_output_info(struct ::wl_resource *resource, uint32_t output_id, uint32_t type, uint32_t mode, uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection, uint32_t skip, uint32_t attribute, uint32_t attribute_state, uint32_t error); - void send_output_type(uint32_t output_id, uint32_t type, uint32_t status); - void send_output_type(struct ::wl_resource *resource, uint32_t output_id, uint32_t type, uint32_t status); - void send_output_mode(uint32_t output_id, uint32_t mode); - void send_output_mode(struct ::wl_resource *resource, uint32_t output_id, uint32_t mode); - void send_output_attribute(uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error); - void send_output_attribute(struct ::wl_resource *resource, uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error); - void send_output_set_window(uint32_t output_id, uint32_t error); - void send_output_set_window(struct ::wl_resource *resource, uint32_t output_id, uint32_t error); - void send_output_add(uint32_t output_id); - void send_output_add(struct ::wl_resource *resource, uint32_t output_id); - void send_output_remove(uint32_t output_id); - void send_output_remove(struct ::wl_resource *resource, uint32_t output_id); - - protected: - virtual Resource *eom_allocate(); - - virtual void eom_bind_resource(Resource *resource); - virtual void eom_destroy_resource(Resource *resource); - - virtual void eom_set_attribute(Resource *resource, uint32_t output_id, uint32_t attribute); - virtual void eom_set_shell_window(Resource *resource, uint32_t output_id, struct ::wl_resource *surface); - virtual void eom_get_output_info(Resource *resource, uint32_t output_id); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_eom_interface m_wl_eom_interface; - - static void handle_set_attribute( - ::wl_client *client, - struct wl_resource *resource, - uint32_t output_id, - uint32_t attribute); - static void handle_set_shell_window( - ::wl_client *client, - struct wl_resource *resource, - uint32_t output_id, - struct ::wl_resource *surface); - static void handle_get_output_info( - ::wl_client *client, - struct wl_resource *resource, - uint32_t output_id); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_eom *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-fullscreen-shell.cpp b/src/DSWaylandServer/dswayland-server-fullscreen-shell.cpp deleted file mode 100644 index e728f47..0000000 --- a/src/DSWaylandServer/dswayland-server-fullscreen-shell.cpp +++ /dev/null @@ -1,474 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/fullscreen-shell.xml */ - -#include "dswayland-server-fullscreen-shell.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - _wl_fullscreen_shell::_wl_fullscreen_shell(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - _wl_fullscreen_shell::_wl_fullscreen_shell(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - _wl_fullscreen_shell::_wl_fullscreen_shell(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - _wl_fullscreen_shell::_wl_fullscreen_shell() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - _wl_fullscreen_shell::~_wl_fullscreen_shell() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - _wl_fullscreen_shell::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void _wl_fullscreen_shell::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void _wl_fullscreen_shell::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - _wl_fullscreen_shell::Resource *_wl_fullscreen_shell::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - _wl_fullscreen_shell::Resource *_wl_fullscreen_shell::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void _wl_fullscreen_shell::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::_wl_fullscreen_shell_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = _wl_fullscreen_shell::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *_wl_fullscreen_shell::interface() - { - return &::_wl_fullscreen_shell_interface; - } - - _wl_fullscreen_shell::Resource *_wl_fullscreen_shell::_wl_fullscreen_shell_allocate() - { - return new Resource; - } - - void _wl_fullscreen_shell::_wl_fullscreen_shell_bind_resource(Resource *) - { - } - - void _wl_fullscreen_shell::_wl_fullscreen_shell_destroy_resource(Resource *) - { - } - - void _wl_fullscreen_shell::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - _wl_fullscreen_shell *that = static_cast<_wl_fullscreen_shell *>(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void _wl_fullscreen_shell::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - _wl_fullscreen_shell *that = static_cast<_wl_fullscreen_shell::DisplayDestroyedListener *>(listener)->parent; - that->m_global = NULL; - } - - void _wl_fullscreen_shell::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - _wl_fullscreen_shell *that = resource->_wl_fullscreen_shell_object; - that->m_resource_map.erase(resource->client()); - that->_wl_fullscreen_shell_destroy_resource(resource); - delete resource; - } - - _wl_fullscreen_shell::Resource *_wl_fullscreen_shell::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::_wl_fullscreen_shell_interface, version, id); - return bind(handle); - } - - _wl_fullscreen_shell::Resource *_wl_fullscreen_shell::bind(struct ::wl_resource *handle) - { - Resource *resource = _wl_fullscreen_shell_allocate(); - resource->_wl_fullscreen_shell_object = this; - - wl_resource_set_implementation(handle, &m__wl_fullscreen_shell_interface, resource, destroy_func); - resource->handle = handle; - _wl_fullscreen_shell_bind_resource(resource); - return resource; - } - _wl_fullscreen_shell::Resource *_wl_fullscreen_shell::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::_wl_fullscreen_shell_interface, &m__wl_fullscreen_shell_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::_wl_fullscreen_shell_interface _wl_fullscreen_shell::m__wl_fullscreen_shell_interface = { - _wl_fullscreen_shell::handle_release, - _wl_fullscreen_shell::handle_present_surface, - _wl_fullscreen_shell::handle_present_surface_for_mode - }; - - void _wl_fullscreen_shell::_wl_fullscreen_shell_release(Resource *) - { - } - - void _wl_fullscreen_shell::_wl_fullscreen_shell_present_surface(Resource *, struct ::wl_resource *, uint32_t , struct ::wl_resource *) - { - } - - void _wl_fullscreen_shell::_wl_fullscreen_shell_present_surface_for_mode(Resource *, struct ::wl_resource *, struct ::wl_resource *, int32_t , uint32_t) - { - } - - - void _wl_fullscreen_shell::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<_wl_fullscreen_shell *>(r->_wl_fullscreen_shell_object)->_wl_fullscreen_shell_release( - r); - } - - void _wl_fullscreen_shell::handle_present_surface( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t method, - struct ::wl_resource *output) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<_wl_fullscreen_shell *>(r->_wl_fullscreen_shell_object)->_wl_fullscreen_shell_present_surface( - r, - surface, - method, - output); - } - - void _wl_fullscreen_shell::handle_present_surface_for_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - struct ::wl_resource *output, - int32_t framerate, - uint32_t feedback) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast<_wl_fullscreen_shell *>(r->_wl_fullscreen_shell_object)->_wl_fullscreen_shell_present_surface_for_mode( - r, - surface, - output, - framerate, - feedback); - } - - void _wl_fullscreen_shell::send_capability(uint32_t capability) - { - DS_ASSERT_X(m_resource, "_wl_fullscreen_shell::capability", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call _wl_fullscreen_shell::capability as it's not initialised"); - return; - } - send_capability( - m_resource->handle, - capability); - } - - void _wl_fullscreen_shell::send_capability(struct ::wl_resource *resource, uint32_t capability) - { - _wl_fullscreen_shell_send_capability( - resource, - capability); - } - - - _wl_fullscreen_shell_mode_feedback::_wl_fullscreen_shell_mode_feedback(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - _wl_fullscreen_shell_mode_feedback::_wl_fullscreen_shell_mode_feedback(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - _wl_fullscreen_shell_mode_feedback::_wl_fullscreen_shell_mode_feedback(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - _wl_fullscreen_shell_mode_feedback::_wl_fullscreen_shell_mode_feedback() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - _wl_fullscreen_shell_mode_feedback::~_wl_fullscreen_shell_mode_feedback() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - _wl_fullscreen_shell_mode_feedback::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void _wl_fullscreen_shell_mode_feedback::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void _wl_fullscreen_shell_mode_feedback::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - _wl_fullscreen_shell_mode_feedback::Resource *_wl_fullscreen_shell_mode_feedback::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - _wl_fullscreen_shell_mode_feedback::Resource *_wl_fullscreen_shell_mode_feedback::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void _wl_fullscreen_shell_mode_feedback::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::_wl_fullscreen_shell_mode_feedback_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = _wl_fullscreen_shell_mode_feedback::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *_wl_fullscreen_shell_mode_feedback::interface() - { - return &::_wl_fullscreen_shell_mode_feedback_interface; - } - - _wl_fullscreen_shell_mode_feedback::Resource *_wl_fullscreen_shell_mode_feedback::_wl_fullscreen_shell_mode_feedback_allocate() - { - return new Resource; - } - - void _wl_fullscreen_shell_mode_feedback::_wl_fullscreen_shell_mode_feedback_bind_resource(Resource *) - { - } - - void _wl_fullscreen_shell_mode_feedback::_wl_fullscreen_shell_mode_feedback_destroy_resource(Resource *) - { - } - - void _wl_fullscreen_shell_mode_feedback::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - _wl_fullscreen_shell_mode_feedback *that = static_cast<_wl_fullscreen_shell_mode_feedback *>(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void _wl_fullscreen_shell_mode_feedback::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - _wl_fullscreen_shell_mode_feedback *that = static_cast<_wl_fullscreen_shell_mode_feedback::DisplayDestroyedListener *>(listener)->parent; - that->m_global = NULL; - } - - void _wl_fullscreen_shell_mode_feedback::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - _wl_fullscreen_shell_mode_feedback *that = resource->_wl_fullscreen_shell_mode_feedback_object; - that->m_resource_map.erase(resource->client()); - that->_wl_fullscreen_shell_mode_feedback_destroy_resource(resource); - delete resource; - } - - _wl_fullscreen_shell_mode_feedback::Resource *_wl_fullscreen_shell_mode_feedback::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::_wl_fullscreen_shell_mode_feedback_interface, version, id); - return bind(handle); - } - - _wl_fullscreen_shell_mode_feedback::Resource *_wl_fullscreen_shell_mode_feedback::bind(struct ::wl_resource *handle) - { - Resource *resource = _wl_fullscreen_shell_mode_feedback_allocate(); - resource->_wl_fullscreen_shell_mode_feedback_object = this; - - wl_resource_set_implementation(handle, NULL, resource, destroy_func); - resource->handle = handle; - _wl_fullscreen_shell_mode_feedback_bind_resource(resource); - return resource; - } - _wl_fullscreen_shell_mode_feedback::Resource *_wl_fullscreen_shell_mode_feedback::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::_wl_fullscreen_shell_mode_feedback_interface, NULL)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - void _wl_fullscreen_shell_mode_feedback::send_mode_successful() - { - DS_ASSERT_X(m_resource, "_wl_fullscreen_shell_mode_feedback::mode_successful", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call _wl_fullscreen_shell_mode_feedback::mode_successful as it's not initialised"); - return; - } - send_mode_successful( - m_resource->handle); - } - - void _wl_fullscreen_shell_mode_feedback::send_mode_successful(struct ::wl_resource *resource) - { - _wl_fullscreen_shell_mode_feedback_send_mode_successful( - resource); - } - - - void _wl_fullscreen_shell_mode_feedback::send_mode_failed() - { - DS_ASSERT_X(m_resource, "_wl_fullscreen_shell_mode_feedback::mode_failed", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call _wl_fullscreen_shell_mode_feedback::mode_failed as it's not initialised"); - return; - } - send_mode_failed( - m_resource->handle); - } - - void _wl_fullscreen_shell_mode_feedback::send_mode_failed(struct ::wl_resource *resource) - { - _wl_fullscreen_shell_mode_feedback_send_mode_failed( - resource); - } - - - void _wl_fullscreen_shell_mode_feedback::send_present_cancelled() - { - DS_ASSERT_X(m_resource, "_wl_fullscreen_shell_mode_feedback::present_cancelled", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call _wl_fullscreen_shell_mode_feedback::present_cancelled as it's not initialised"); - return; - } - send_present_cancelled( - m_resource->handle); - } - - void _wl_fullscreen_shell_mode_feedback::send_present_cancelled(struct ::wl_resource *resource) - { - _wl_fullscreen_shell_mode_feedback_send_present_cancelled( - resource); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-fullscreen-shell.h b/src/DSWaylandServer/dswayland-server-fullscreen-shell.h deleted file mode 100644 index 4e59050..0000000 --- a/src/DSWaylandServer/dswayland-server-fullscreen-shell.h +++ /dev/null @@ -1,222 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/fullscreen-shell.xml */ - -#ifndef __DS_FULLSCREEN_SHELL_PROTOCOL_H__ -#define __DS_FULLSCREEN_SHELL_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "fullscreen-shell-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class _wl_fullscreen_shell - { - public: - _wl_fullscreen_shell(struct ::wl_client *client, uint32_t id, int version); - _wl_fullscreen_shell(struct ::wl_display *display, int version); - _wl_fullscreen_shell(struct ::wl_resource *resource); - _wl_fullscreen_shell(); - - virtual ~_wl_fullscreen_shell(); - - class Resource - { - public: - Resource() : _wl_fullscreen_shell_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - _wl_fullscreen_shell *_wl_fullscreen_shell_object; - _wl_fullscreen_shell *object() { return _wl_fullscreen_shell_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum capability { - capability_arbitrary_modes = 1, // compositor is capable of almost any output mode - capability_cursor_plane = 2, // compositor has a separate cursor plane - }; - - enum present_method { - present_method_default = 0, // no preference, apply default policy - present_method_center = 1, // center the surface on the output - present_method_zoom = 2, // scale the surface, preserving aspect ratio, to the largest size that will fit on the output - present_method_zoom_crop = 3, // scale the surface, preserving aspect ratio, to fully fill the output cropping if needed - present_method_stretch = 4, // scale the surface to the size of the output ignoring aspect ratio - }; - - enum error { - error_invalid_method = 0, // present_method is not known - }; - - void send_capability(uint32_t capability); - void send_capability(struct ::wl_resource *resource, uint32_t capability); - - protected: - virtual Resource *_wl_fullscreen_shell_allocate(); - - virtual void _wl_fullscreen_shell_bind_resource(Resource *resource); - virtual void _wl_fullscreen_shell_destroy_resource(Resource *resource); - - virtual void _wl_fullscreen_shell_release(Resource *resource); - virtual void _wl_fullscreen_shell_present_surface(Resource *resource, struct ::wl_resource *surface, uint32_t method, struct ::wl_resource *output); - virtual void _wl_fullscreen_shell_present_surface_for_mode(Resource *resource, struct ::wl_resource *surface, struct ::wl_resource *output, int32_t framerate, uint32_t feedback); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::_wl_fullscreen_shell_interface m__wl_fullscreen_shell_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - static void handle_present_surface( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t method, - struct ::wl_resource *output); - static void handle_present_surface_for_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - struct ::wl_resource *output, - int32_t framerate, - uint32_t feedback); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - _wl_fullscreen_shell *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class _wl_fullscreen_shell_mode_feedback - { - public: - _wl_fullscreen_shell_mode_feedback(struct ::wl_client *client, uint32_t id, int version); - _wl_fullscreen_shell_mode_feedback(struct ::wl_display *display, int version); - _wl_fullscreen_shell_mode_feedback(struct ::wl_resource *resource); - _wl_fullscreen_shell_mode_feedback(); - - virtual ~_wl_fullscreen_shell_mode_feedback(); - - class Resource - { - public: - Resource() : _wl_fullscreen_shell_mode_feedback_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - _wl_fullscreen_shell_mode_feedback *_wl_fullscreen_shell_mode_feedback_object; - _wl_fullscreen_shell_mode_feedback *object() { return _wl_fullscreen_shell_mode_feedback_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_mode_successful(); - void send_mode_successful(struct ::wl_resource *resource); - void send_mode_failed(); - void send_mode_failed(struct ::wl_resource *resource); - void send_present_cancelled(); - void send_present_cancelled(struct ::wl_resource *resource); - - protected: - virtual Resource *_wl_fullscreen_shell_mode_feedback_allocate(); - - virtual void _wl_fullscreen_shell_mode_feedback_bind_resource(Resource *resource); - virtual void _wl_fullscreen_shell_mode_feedback_destroy_resource(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - _wl_fullscreen_shell_mode_feedback *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp b/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp deleted file mode 100644 index dd60486..0000000 --- a/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp +++ /dev/null @@ -1,2050 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/input-method.xml */ - -#include "dswayland-server-input-method-unstable-v1.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - zwp_input_method_context_v1::zwp_input_method_context_v1(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zwp_input_method_context_v1::zwp_input_method_context_v1(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zwp_input_method_context_v1::zwp_input_method_context_v1(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zwp_input_method_context_v1::zwp_input_method_context_v1() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zwp_input_method_context_v1::~zwp_input_method_context_v1() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zwp_input_method_context_v1::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zwp_input_method_context_v1::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zwp_input_method_context_v1::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zwp_input_method_context_v1::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zwp_input_method_context_v1_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zwp_input_method_context_v1::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zwp_input_method_context_v1::interface() - { - return &::zwp_input_method_context_v1_interface; - } - - zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::zwp_input_method_context_v1_allocate() - { - return new Resource; - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_bind_resource(Resource *) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_destroy_resource(Resource *) - { - } - - void zwp_input_method_context_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zwp_input_method_context_v1 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zwp_input_method_context_v1::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zwp_input_method_context_v1 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zwp_input_method_context_v1::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zwp_input_method_context_v1 *that = resource->zwp_input_method_context_v1_object; - that->m_resource_map.erase(resource->client()); - that->zwp_input_method_context_v1_destroy_resource(resource); - delete resource; - } - - zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_method_context_v1_interface, version, id); - return bind(handle); - } - - zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::bind(struct ::wl_resource *handle) - { - Resource *resource = zwp_input_method_context_v1_allocate(); - resource->zwp_input_method_context_v1_object = this; - - wl_resource_set_implementation(handle, &m_zwp_input_method_context_v1_interface, resource, destroy_func); - resource->handle = handle; - zwp_input_method_context_v1_bind_resource(resource); - return resource; - } - zwp_input_method_context_v1::Resource *zwp_input_method_context_v1::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zwp_input_method_context_v1_interface, &m_zwp_input_method_context_v1_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zwp_input_method_context_v1_interface zwp_input_method_context_v1::m_zwp_input_method_context_v1_interface = { - zwp_input_method_context_v1::handle_destroy, - zwp_input_method_context_v1::handle_commit_string, - zwp_input_method_context_v1::handle_preedit_string, - zwp_input_method_context_v1::handle_preedit_styling, - zwp_input_method_context_v1::handle_preedit_cursor, - zwp_input_method_context_v1::handle_delete_surrounding_text, - zwp_input_method_context_v1::handle_cursor_position, - zwp_input_method_context_v1::handle_modifiers_map, - zwp_input_method_context_v1::handle_keysym, - zwp_input_method_context_v1::handle_grab_keyboard, - zwp_input_method_context_v1::handle_key, - zwp_input_method_context_v1::handle_modifiers, - zwp_input_method_context_v1::handle_language, - zwp_input_method_context_v1::handle_text_direction, - zwp_input_method_context_v1::handle_selection_region, - zwp_input_method_context_v1::handle_private_command, - zwp_input_method_context_v1::handle_update_input_panel_data, - zwp_input_method_context_v1::handle_hide_input_panel, - zwp_input_method_context_v1::handle_get_selection_text, - zwp_input_method_context_v1::handle_get_surrounding_text, - zwp_input_method_context_v1::handle_filter_key_event_done, - zwp_input_method_context_v1::handle_update_ise_geometry, - zwp_input_method_context_v1::handle_recapture_string, - zwp_input_method_context_v1::handle_input_panel_event, - zwp_input_method_context_v1::handle_commit_content, - zwp_input_method_context_v1::handle_update_candidate_state, - zwp_input_method_context_v1::handle_reshow_input_panel, - zwp_input_method_context_v1::handle_set_floating_panel, - zwp_input_method_context_v1::handle_set_floating_drag_enabled - }; - - void zwp_input_method_context_v1::zwp_input_method_context_v1_destroy(Resource *) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_commit_string(Resource *, uint32_t , const std::string &) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_string(Resource *, uint32_t , const std::string &, const std::string &) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_styling(Resource *, uint32_t , uint32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_preedit_cursor(Resource *, int32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_delete_surrounding_text(Resource *, int32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_cursor_position(Resource *, int32_t , int32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_modifiers_map(Resource *, struct ::wl_array *) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_keysym(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_grab_keyboard(Resource *, uint32_t) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_key(Resource *, uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_modifiers(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_language(Resource *, uint32_t , const std::string &) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_text_direction(Resource *, uint32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_selection_region(Resource *, uint32_t , int32_t , int32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_private_command(Resource *, uint32_t , const std::string &) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_update_input_panel_data(Resource *, uint32_t , const std::string &, uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_hide_input_panel(Resource *, uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_get_selection_text(Resource *, int32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_get_surrounding_text(Resource *, uint32_t , uint32_t , int32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_filter_key_event_done(Resource *, uint32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_update_ise_geometry(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_recapture_string(Resource *, uint32_t , int32_t , uint32_t , const std::string &, const std::string &, const std::string &) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_input_panel_event(Resource *, uint32_t , uint32_t , uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_commit_content(Resource *, uint32_t , const std::string &, const std::string &, const std::string &) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_update_candidate_state(Resource *, uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_reshow_input_panel(Resource *) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_set_floating_panel(Resource *, uint32_t ) - { - } - - void zwp_input_method_context_v1::zwp_input_method_context_v1_set_floating_drag_enabled(Resource *, uint32_t ) - { - } - - - void zwp_input_method_context_v1::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_destroy( - r); - } - - void zwp_input_method_context_v1::handle_commit_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *text) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_commit_string( - r, - serial, - std::string(text)); - } - - void zwp_input_method_context_v1::handle_preedit_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *text, - const char *commit) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_string( - r, - serial, - std::string(text), - std::string(commit)); - } - - void zwp_input_method_context_v1::handle_preedit_styling( - ::wl_client *client, - struct wl_resource *resource, - uint32_t index, - uint32_t length, - uint32_t style) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_styling( - r, - index, - length, - style); - } - - void zwp_input_method_context_v1::handle_preedit_cursor( - ::wl_client *client, - struct wl_resource *resource, - int32_t index) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_preedit_cursor( - r, - index); - } - - void zwp_input_method_context_v1::handle_delete_surrounding_text( - ::wl_client *client, - struct wl_resource *resource, - int32_t index, - uint32_t length) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_delete_surrounding_text( - r, - index, - length); - } - - void zwp_input_method_context_v1::handle_cursor_position( - ::wl_client *client, - struct wl_resource *resource, - int32_t index, - int32_t anchor) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_cursor_position( - r, - index, - anchor); - } - - void zwp_input_method_context_v1::handle_modifiers_map( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_array *map) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_modifiers_map( - r, - map); - } - - void zwp_input_method_context_v1::handle_keysym( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t time, - uint32_t sym, - uint32_t state, - uint32_t modifiers) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_keysym( - r, - serial, - time, - sym, - state, - modifiers); - } - - void zwp_input_method_context_v1::handle_grab_keyboard( - ::wl_client *client, - struct wl_resource *resource, - uint32_t keyboard) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_grab_keyboard( - r, - keyboard); - } - - void zwp_input_method_context_v1::handle_key( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t time, - uint32_t key, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_key( - r, - serial, - time, - key, - state); - } - - void zwp_input_method_context_v1::handle_modifiers( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t mods_depressed, - uint32_t mods_latched, - uint32_t mods_locked, - uint32_t group) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_modifiers( - r, - serial, - mods_depressed, - mods_latched, - mods_locked, - group); - } - - void zwp_input_method_context_v1::handle_language( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *language) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_language( - r, - serial, - std::string(language)); - } - - void zwp_input_method_context_v1::handle_text_direction( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t direction) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_text_direction( - r, - serial, - direction); - } - - void zwp_input_method_context_v1::handle_selection_region( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - int32_t start, - int32_t end) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_selection_region( - r, - serial, - start, - end); - } - - void zwp_input_method_context_v1::handle_private_command( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *command) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_private_command( - r, - serial, - std::string(command)); - } - - void zwp_input_method_context_v1::handle_update_input_panel_data( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *input_panel_data, - uint32_t input_panel_data_length) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_update_input_panel_data( - r, - serial, - std::string(input_panel_data), - input_panel_data_length); - } - - void zwp_input_method_context_v1::handle_hide_input_panel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_hide_input_panel( - r, - serial); - } - - void zwp_input_method_context_v1::handle_get_selection_text( - ::wl_client *client, - struct wl_resource *resource, - int32_t fd) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_get_selection_text( - r, - fd); - } - - void zwp_input_method_context_v1::handle_get_surrounding_text( - ::wl_client *client, - struct wl_resource *resource, - uint32_t maxlen_before, - uint32_t maxlen_after, - int32_t fd) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_get_surrounding_text( - r, - maxlen_before, - maxlen_after, - fd); - } - - void zwp_input_method_context_v1::handle_filter_key_event_done( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_filter_key_event_done( - r, - serial, - state); - } - - void zwp_input_method_context_v1::handle_update_ise_geometry( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_update_ise_geometry( - r, - serial, - x, - y, - width, - height); - } - - void zwp_input_method_context_v1::handle_recapture_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - int32_t index, - uint32_t length, - const char *preedit, - const char *preedit_commit, - const char *commit) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_recapture_string( - r, - serial, - index, - length, - std::string(preedit), - std::string(preedit_commit), - std::string(commit)); - } - - void zwp_input_method_context_v1::handle_input_panel_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t event_type, - uint32_t value) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_input_panel_event( - r, - serial, - event_type, - value); - } - - void zwp_input_method_context_v1::handle_commit_content( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *content, - const char *description, - const char *mime_types) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_commit_content( - r, - serial, - std::string(content), - std::string(description), - std::string(mime_types)); - } - - void zwp_input_method_context_v1::handle_update_candidate_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_update_candidate_state( - r, - state); - } - - void zwp_input_method_context_v1::handle_reshow_input_panel( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_reshow_input_panel( - r); - } - - void zwp_input_method_context_v1::handle_set_floating_panel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_set_floating_panel( - r, - state); - } - - void zwp_input_method_context_v1::handle_set_floating_drag_enabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t enabled) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_context_v1_object)->zwp_input_method_context_v1_set_floating_drag_enabled( - r, - enabled); - } - - void zwp_input_method_context_v1::send_surrounding_text(const std::string &text, uint32_t cursor, uint32_t anchor) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::surrounding_text", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::surrounding_text as it's not initialised"); - return; - } - send_surrounding_text( - m_resource->handle, - text, - cursor, - anchor); - } - - void zwp_input_method_context_v1::send_surrounding_text(struct ::wl_resource *resource, const std::string &text, uint32_t cursor, uint32_t anchor) - { - zwp_input_method_context_v1_send_surrounding_text( - resource, - text.c_str(), - cursor, - anchor); - } - - - void zwp_input_method_context_v1::send_reset() - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::reset", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::reset as it's not initialised"); - return; - } - send_reset( - m_resource->handle); - } - - void zwp_input_method_context_v1::send_reset(struct ::wl_resource *resource) - { - zwp_input_method_context_v1_send_reset( - resource); - } - - - void zwp_input_method_context_v1::send_content_type(uint32_t hint, uint32_t purpose) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::content_type", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::content_type as it's not initialised"); - return; - } - send_content_type( - m_resource->handle, - hint, - purpose); - } - - void zwp_input_method_context_v1::send_content_type(struct ::wl_resource *resource, uint32_t hint, uint32_t purpose) - { - zwp_input_method_context_v1_send_content_type( - resource, - hint, - purpose); - } - - - void zwp_input_method_context_v1::send_invoke_action(uint32_t button, uint32_t index) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::invoke_action", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::invoke_action as it's not initialised"); - return; - } - send_invoke_action( - m_resource->handle, - button, - index); - } - - void zwp_input_method_context_v1::send_invoke_action(struct ::wl_resource *resource, uint32_t button, uint32_t index) - { - zwp_input_method_context_v1_send_invoke_action( - resource, - button, - index); - } - - - void zwp_input_method_context_v1::send_commit_state(uint32_t serial) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::commit_state", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::commit_state as it's not initialised"); - return; - } - send_commit_state( - m_resource->handle, - serial); - } - - void zwp_input_method_context_v1::send_commit_state(struct ::wl_resource *resource, uint32_t serial) - { - zwp_input_method_context_v1_send_commit_state( - resource, - serial); - } - - - void zwp_input_method_context_v1::send_preferred_language(const std::string &language) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::preferred_language", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::preferred_language as it's not initialised"); - return; - } - send_preferred_language( - m_resource->handle, - language); - } - - void zwp_input_method_context_v1::send_preferred_language(struct ::wl_resource *resource, const std::string &language) - { - zwp_input_method_context_v1_send_preferred_language( - resource, - language.c_str()); - } - - - void zwp_input_method_context_v1::send_return_key_type(uint32_t return_key_type) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::return_key_type", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::return_key_type as it's not initialised"); - return; - } - send_return_key_type( - m_resource->handle, - return_key_type); - } - - void zwp_input_method_context_v1::send_return_key_type(struct ::wl_resource *resource, uint32_t return_key_type) - { - zwp_input_method_context_v1_send_return_key_type( - resource, - return_key_type); - } - - - void zwp_input_method_context_v1::send_return_key_disabled(uint32_t return_key_disabled) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::return_key_disabled", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::return_key_disabled as it's not initialised"); - return; - } - send_return_key_disabled( - m_resource->handle, - return_key_disabled); - } - - void zwp_input_method_context_v1::send_return_key_disabled(struct ::wl_resource *resource, uint32_t return_key_disabled) - { - zwp_input_method_context_v1_send_return_key_disabled( - resource, - return_key_disabled); - } - - - void zwp_input_method_context_v1::send_input_panel_data(const std::string &input_panel_data, uint32_t input_panel_data_length) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::input_panel_data", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::input_panel_data as it's not initialised"); - return; - } - send_input_panel_data( - m_resource->handle, - input_panel_data, - input_panel_data_length); - } - - void zwp_input_method_context_v1::send_input_panel_data(struct ::wl_resource *resource, const std::string &input_panel_data, uint32_t input_panel_data_length) - { - zwp_input_method_context_v1_send_input_panel_data( - resource, - input_panel_data.c_str(), - input_panel_data_length); - } - - - void zwp_input_method_context_v1::send_bidi_direction(uint32_t direction) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::bidi_direction", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::bidi_direction as it's not initialised"); - return; - } - send_bidi_direction( - m_resource->handle, - direction); - } - - void zwp_input_method_context_v1::send_bidi_direction(struct ::wl_resource *resource, uint32_t direction) - { - zwp_input_method_context_v1_send_bidi_direction( - resource, - direction); - } - - - void zwp_input_method_context_v1::send_cursor_position(uint32_t cursor_position) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::cursor_position", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::cursor_position as it's not initialised"); - return; - } - send_cursor_position( - m_resource->handle, - cursor_position); - } - - void zwp_input_method_context_v1::send_cursor_position(struct ::wl_resource *resource, uint32_t cursor_position) - { - zwp_input_method_context_v1_send_cursor_position( - resource, - cursor_position); - } - - - void zwp_input_method_context_v1::send_process_input_device_event(uint32_t event_type, const std::string &event_data, uint32_t event_length) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::process_input_device_event", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::process_input_device_event as it's not initialised"); - return; - } - send_process_input_device_event( - m_resource->handle, - event_type, - event_data, - event_length); - } - - void zwp_input_method_context_v1::send_process_input_device_event(struct ::wl_resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length) - { - zwp_input_method_context_v1_send_process_input_device_event( - resource, - event_type, - event_data.c_str(), - event_length); - } - - - void zwp_input_method_context_v1::send_filter_key_event(uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::filter_key_event", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::filter_key_event as it's not initialised"); - return; - } - send_filter_key_event( - m_resource->handle, - serial, - time, - keyname, - state, - modifiers, - dev_name, - dev_class, - dev_subclass, - keycode); - } - - void zwp_input_method_context_v1::send_filter_key_event(struct ::wl_resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode) - { - zwp_input_method_context_v1_send_filter_key_event( - resource, - serial, - time, - keyname.c_str(), - state, - modifiers, - dev_name.c_str(), - dev_class, - dev_subclass, - keycode); - } - - - void zwp_input_method_context_v1::send_capital_mode(uint32_t mode) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::capital_mode", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::capital_mode as it's not initialised"); - return; - } - send_capital_mode( - m_resource->handle, - mode); - } - - void zwp_input_method_context_v1::send_capital_mode(struct ::wl_resource *resource, uint32_t mode) - { - zwp_input_method_context_v1_send_capital_mode( - resource, - mode); - } - - - void zwp_input_method_context_v1::send_prediction_hint(const std::string &text) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::prediction_hint", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::prediction_hint as it's not initialised"); - return; - } - send_prediction_hint( - m_resource->handle, - text); - } - - void zwp_input_method_context_v1::send_prediction_hint(struct ::wl_resource *resource, const std::string &text) - { - zwp_input_method_context_v1_send_prediction_hint( - resource, - text.c_str()); - } - - - void zwp_input_method_context_v1::send_mime_type(const std::string &type) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::mime_type", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::mime_type as it's not initialised"); - return; - } - send_mime_type( - m_resource->handle, - type); - } - - void zwp_input_method_context_v1::send_mime_type(struct ::wl_resource *resource, const std::string &type) - { - zwp_input_method_context_v1_send_mime_type( - resource, - type.c_str()); - } - - - void zwp_input_method_context_v1::send_finalized_content(const std::string &text, uint32_t cursor_position) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::finalized_content", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::finalized_content as it's not initialised"); - return; - } - send_finalized_content( - m_resource->handle, - text, - cursor_position); - } - - void zwp_input_method_context_v1::send_finalized_content(struct ::wl_resource *resource, const std::string &text, uint32_t cursor_position) - { - zwp_input_method_context_v1_send_finalized_content( - resource, - text.c_str(), - cursor_position); - } - - - void zwp_input_method_context_v1::send_prediction_hint_data(const std::string &key, const std::string &value) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::prediction_hint_data", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::prediction_hint_data as it's not initialised"); - return; - } - send_prediction_hint_data( - m_resource->handle, - key, - value); - } - - void zwp_input_method_context_v1::send_prediction_hint_data(struct ::wl_resource *resource, const std::string &key, const std::string &value) - { - zwp_input_method_context_v1_send_prediction_hint_data( - resource, - key.c_str(), - value.c_str()); - } - - - void zwp_input_method_context_v1::send_input_panel_enabled(uint32_t enabled) - { - DS_ASSERT_X(m_resource, "zwp_input_method_context_v1::input_panel_enabled", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_context_v1::input_panel_enabled as it's not initialised"); - return; - } - send_input_panel_enabled( - m_resource->handle, - enabled); - } - - void zwp_input_method_context_v1::send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled) - { - zwp_input_method_context_v1_send_input_panel_enabled( - resource, - enabled); - } - - - zwp_input_method_v1::zwp_input_method_v1(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zwp_input_method_v1::zwp_input_method_v1(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zwp_input_method_v1::zwp_input_method_v1(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zwp_input_method_v1::zwp_input_method_v1() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zwp_input_method_v1::~zwp_input_method_v1() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zwp_input_method_v1::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zwp_input_method_v1::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zwp_input_method_v1::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zwp_input_method_v1::Resource *zwp_input_method_v1::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zwp_input_method_v1::Resource *zwp_input_method_v1::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zwp_input_method_v1::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zwp_input_method_v1_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zwp_input_method_v1::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zwp_input_method_v1::interface() - { - return &::zwp_input_method_v1_interface; - } - - zwp_input_method_v1::Resource *zwp_input_method_v1::zwp_input_method_v1_allocate() - { - return new Resource; - } - - void zwp_input_method_v1::zwp_input_method_v1_bind_resource(Resource *) - { - } - - void zwp_input_method_v1::zwp_input_method_v1_destroy_resource(Resource *) - { - } - - void zwp_input_method_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zwp_input_method_v1 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zwp_input_method_v1::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zwp_input_method_v1 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zwp_input_method_v1::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zwp_input_method_v1 *that = resource->zwp_input_method_v1_object; - that->m_resource_map.erase(resource->client()); - that->zwp_input_method_v1_destroy_resource(resource); - delete resource; - } - - zwp_input_method_v1::Resource *zwp_input_method_v1::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_method_v1_interface, version, id); - return bind(handle); - } - - zwp_input_method_v1::Resource *zwp_input_method_v1::bind(struct ::wl_resource *handle) - { - Resource *resource = zwp_input_method_v1_allocate(); - resource->zwp_input_method_v1_object = this; - - wl_resource_set_implementation(handle, NULL, resource, destroy_func); - resource->handle = handle; - zwp_input_method_v1_bind_resource(resource); - return resource; - } - zwp_input_method_v1::Resource *zwp_input_method_v1::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zwp_input_method_v1_interface, NULL)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - void zwp_input_method_v1::send_activate(struct ::wl_resource *id) - { - DS_ASSERT_X(m_resource, "zwp_input_method_v1::activate", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_v1::activate as it's not initialised"); - return; - } - send_activate( - m_resource->handle, - id); - } - - void zwp_input_method_v1::send_activate(struct ::wl_resource *resource, struct ::wl_resource *id) - { - zwp_input_method_v1_send_activate( - resource, - id); - } - - - void zwp_input_method_v1::send_deactivate(struct ::wl_resource *context) - { - DS_ASSERT_X(m_resource, "zwp_input_method_v1::deactivate", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_v1::deactivate as it's not initialised"); - return; - } - send_deactivate( - m_resource->handle, - context); - } - - void zwp_input_method_v1::send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context) - { - zwp_input_method_v1_send_deactivate( - resource, - context); - } - - - void zwp_input_method_v1::send_destroy(struct ::wl_resource *context) - { - DS_ASSERT_X(m_resource, "zwp_input_method_v1::destroy", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_v1::destroy as it's not initialised"); - return; - } - send_destroy( - m_resource->handle, - context); - } - - void zwp_input_method_v1::send_destroy(struct ::wl_resource *resource, struct ::wl_resource *context) - { - zwp_input_method_v1_send_destroy( - resource, - context); - } - - - void zwp_input_method_v1::send_show_input_panel(struct ::wl_resource *context, uint32_t degree) - { - DS_ASSERT_X(m_resource, "zwp_input_method_v1::show_input_panel", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_v1::show_input_panel as it's not initialised"); - return; - } - send_show_input_panel( - m_resource->handle, - context, - degree); - } - - void zwp_input_method_v1::send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t degree) - { - zwp_input_method_v1_send_show_input_panel( - resource, - context, - degree); - } - - - void zwp_input_method_v1::send_hide_input_panel(struct ::wl_resource *context) - { - DS_ASSERT_X(m_resource, "zwp_input_method_v1::hide_input_panel", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_v1::hide_input_panel as it's not initialised"); - return; - } - send_hide_input_panel( - m_resource->handle, - context); - } - - void zwp_input_method_v1::send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context) - { - zwp_input_method_v1_send_hide_input_panel( - resource, - context); - } - - - void zwp_input_method_v1::send_open_connection(struct ::wl_resource *context) - { - DS_ASSERT_X(m_resource, "zwp_input_method_v1::open_connection", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_v1::open_connection as it's not initialised"); - return; - } - send_open_connection( - m_resource->handle, - context); - } - - void zwp_input_method_v1::send_open_connection(struct ::wl_resource *resource, struct ::wl_resource *context) - { - zwp_input_method_v1_send_open_connection( - resource, - context); - } - - - void zwp_input_method_v1::send_close_connection(struct ::wl_resource *context) - { - DS_ASSERT_X(m_resource, "zwp_input_method_v1::close_connection", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_v1::close_connection as it's not initialised"); - return; - } - send_close_connection( - m_resource->handle, - context); - } - - void zwp_input_method_v1::send_close_connection(struct ::wl_resource *resource, struct ::wl_resource *context) - { - zwp_input_method_v1_send_close_connection( - resource, - context); - } - - - void zwp_input_method_v1::send_set_text_input_id(struct ::wl_resource *context, uint32_t text_input_id) - { - DS_ASSERT_X(m_resource, "zwp_input_method_v1::set_text_input_id", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zwp_input_method_v1::set_text_input_id as it's not initialised"); - return; - } - send_set_text_input_id( - m_resource->handle, - context, - text_input_id); - } - - void zwp_input_method_v1::send_set_text_input_id(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t text_input_id) - { - zwp_input_method_v1_send_set_text_input_id( - resource, - context, - text_input_id); - } - - - zwp_input_panel_v1::zwp_input_panel_v1(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zwp_input_panel_v1::zwp_input_panel_v1(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zwp_input_panel_v1::zwp_input_panel_v1(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zwp_input_panel_v1::zwp_input_panel_v1() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zwp_input_panel_v1::~zwp_input_panel_v1() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zwp_input_panel_v1::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zwp_input_panel_v1::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zwp_input_panel_v1::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zwp_input_panel_v1::Resource *zwp_input_panel_v1::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zwp_input_panel_v1::Resource *zwp_input_panel_v1::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zwp_input_panel_v1::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zwp_input_panel_v1_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zwp_input_panel_v1::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zwp_input_panel_v1::interface() - { - return &::zwp_input_panel_v1_interface; - } - - zwp_input_panel_v1::Resource *zwp_input_panel_v1::zwp_input_panel_v1_allocate() - { - return new Resource; - } - - void zwp_input_panel_v1::zwp_input_panel_v1_bind_resource(Resource *) - { - } - - void zwp_input_panel_v1::zwp_input_panel_v1_destroy_resource(Resource *) - { - } - - void zwp_input_panel_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zwp_input_panel_v1 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zwp_input_panel_v1::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zwp_input_panel_v1 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zwp_input_panel_v1::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zwp_input_panel_v1 *that = resource->zwp_input_panel_v1_object; - that->m_resource_map.erase(resource->client()); - that->zwp_input_panel_v1_destroy_resource(resource); - delete resource; - } - - zwp_input_panel_v1::Resource *zwp_input_panel_v1::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_panel_v1_interface, version, id); - return bind(handle); - } - - zwp_input_panel_v1::Resource *zwp_input_panel_v1::bind(struct ::wl_resource *handle) - { - Resource *resource = zwp_input_panel_v1_allocate(); - resource->zwp_input_panel_v1_object = this; - - wl_resource_set_implementation(handle, &m_zwp_input_panel_v1_interface, resource, destroy_func); - resource->handle = handle; - zwp_input_panel_v1_bind_resource(resource); - return resource; - } - zwp_input_panel_v1::Resource *zwp_input_panel_v1::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zwp_input_panel_v1_interface, &m_zwp_input_panel_v1_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zwp_input_panel_v1_interface zwp_input_panel_v1::m_zwp_input_panel_v1_interface = { - zwp_input_panel_v1::handle_get_input_panel_surface - }; - - void zwp_input_panel_v1::zwp_input_panel_v1_get_input_panel_surface(Resource *, uint32_t, struct ::wl_resource *) - { - } - - - void zwp_input_panel_v1::handle_get_input_panel_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_panel_v1_object)->zwp_input_panel_v1_get_input_panel_surface( - r, - id, - surface); - } - - zwp_input_panel_surface_v1::zwp_input_panel_surface_v1(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zwp_input_panel_surface_v1::zwp_input_panel_surface_v1(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zwp_input_panel_surface_v1::zwp_input_panel_surface_v1(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zwp_input_panel_surface_v1::zwp_input_panel_surface_v1() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zwp_input_panel_surface_v1::~zwp_input_panel_surface_v1() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zwp_input_panel_surface_v1::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zwp_input_panel_surface_v1::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zwp_input_panel_surface_v1::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zwp_input_panel_surface_v1::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zwp_input_panel_surface_v1_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zwp_input_panel_surface_v1::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zwp_input_panel_surface_v1::interface() - { - return &::zwp_input_panel_surface_v1_interface; - } - - zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_allocate() - { - return new Resource; - } - - void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_bind_resource(Resource *) - { - } - - void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_destroy_resource(Resource *) - { - } - - void zwp_input_panel_surface_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zwp_input_panel_surface_v1 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zwp_input_panel_surface_v1::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zwp_input_panel_surface_v1 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zwp_input_panel_surface_v1::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zwp_input_panel_surface_v1 *that = resource->zwp_input_panel_surface_v1_object; - that->m_resource_map.erase(resource->client()); - that->zwp_input_panel_surface_v1_destroy_resource(resource); - delete resource; - } - - zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_panel_surface_v1_interface, version, id); - return bind(handle); - } - - zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::bind(struct ::wl_resource *handle) - { - Resource *resource = zwp_input_panel_surface_v1_allocate(); - resource->zwp_input_panel_surface_v1_object = this; - - wl_resource_set_implementation(handle, &m_zwp_input_panel_surface_v1_interface, resource, destroy_func); - resource->handle = handle; - zwp_input_panel_surface_v1_bind_resource(resource); - return resource; - } - zwp_input_panel_surface_v1::Resource *zwp_input_panel_surface_v1::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zwp_input_panel_surface_v1_interface, &m_zwp_input_panel_surface_v1_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zwp_input_panel_surface_v1_interface zwp_input_panel_surface_v1::m_zwp_input_panel_surface_v1_interface = { - zwp_input_panel_surface_v1::handle_set_toplevel, - zwp_input_panel_surface_v1::handle_set_overlay_panel, - zwp_input_panel_surface_v1::handle_set_ready - }; - - void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_set_toplevel(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_set_overlay_panel(Resource *) - { - } - - void zwp_input_panel_surface_v1::zwp_input_panel_surface_v1_set_ready(Resource *, uint32_t ) - { - } - - - void zwp_input_panel_surface_v1::handle_set_toplevel( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output, - uint32_t position) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_panel_surface_v1_object)->zwp_input_panel_surface_v1_set_toplevel( - r, - output, - position); - } - - void zwp_input_panel_surface_v1::handle_set_overlay_panel( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_panel_surface_v1_object)->zwp_input_panel_surface_v1_set_overlay_panel( - r); - } - - void zwp_input_panel_surface_v1::handle_set_ready( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_panel_surface_v1_object)->zwp_input_panel_surface_v1_set_ready( - r, - state); - } - - zwp_input_method_manager_v1::zwp_input_method_manager_v1(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zwp_input_method_manager_v1::zwp_input_method_manager_v1(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zwp_input_method_manager_v1::zwp_input_method_manager_v1(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zwp_input_method_manager_v1::zwp_input_method_manager_v1() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zwp_input_method_manager_v1::~zwp_input_method_manager_v1() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zwp_input_method_manager_v1::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zwp_input_method_manager_v1::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zwp_input_method_manager_v1::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zwp_input_method_manager_v1::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zwp_input_method_manager_v1_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zwp_input_method_manager_v1::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zwp_input_method_manager_v1::interface() - { - return &::zwp_input_method_manager_v1_interface; - } - - zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::zwp_input_method_manager_v1_allocate() - { - return new Resource; - } - - void zwp_input_method_manager_v1::zwp_input_method_manager_v1_bind_resource(Resource *) - { - } - - void zwp_input_method_manager_v1::zwp_input_method_manager_v1_destroy_resource(Resource *) - { - } - - void zwp_input_method_manager_v1::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zwp_input_method_manager_v1 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zwp_input_method_manager_v1::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zwp_input_method_manager_v1 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zwp_input_method_manager_v1::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zwp_input_method_manager_v1 *that = resource->zwp_input_method_manager_v1_object; - that->m_resource_map.erase(resource->client()); - that->zwp_input_method_manager_v1_destroy_resource(resource); - delete resource; - } - - zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zwp_input_method_manager_v1_interface, version, id); - return bind(handle); - } - - zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::bind(struct ::wl_resource *handle) - { - Resource *resource = zwp_input_method_manager_v1_allocate(); - resource->zwp_input_method_manager_v1_object = this; - - wl_resource_set_implementation(handle, &m_zwp_input_method_manager_v1_interface, resource, destroy_func); - resource->handle = handle; - zwp_input_method_manager_v1_bind_resource(resource); - return resource; - } - zwp_input_method_manager_v1::Resource *zwp_input_method_manager_v1::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zwp_input_method_manager_v1_interface, &m_zwp_input_method_manager_v1_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zwp_input_method_manager_v1_interface zwp_input_method_manager_v1::m_zwp_input_method_manager_v1_interface = { - zwp_input_method_manager_v1::handle_set_transient_for - }; - - void zwp_input_method_manager_v1::zwp_input_method_manager_v1_set_transient_for(Resource *, uint32_t , uint32_t ) - { - } - - - void zwp_input_method_manager_v1::handle_set_transient_for( - ::wl_client *client, - struct wl_resource *resource, - uint32_t parent_pid, - uint32_t child_pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zwp_input_method_manager_v1_object)->zwp_input_method_manager_v1_set_transient_for( - r, - parent_pid, - child_pid); - } -} - -/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.h b/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.h deleted file mode 100644 index 42ae0b2..0000000 --- a/src/DSWaylandServer/dswayland-server-input-method-unstable-v1.h +++ /dev/null @@ -1,679 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/input-method.xml */ - -#ifndef __DS_INPUT_METHOD_UNSTABLE_V1_PROTOCOL_H__ -#define __DS_INPUT_METHOD_UNSTABLE_V1_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "input-method-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class zwp_input_method_context_v1 - { - public: - zwp_input_method_context_v1(struct ::wl_client *client, uint32_t id, int version); - zwp_input_method_context_v1(struct ::wl_display *display, int version); - zwp_input_method_context_v1(struct ::wl_resource *resource); - zwp_input_method_context_v1(); - - virtual ~zwp_input_method_context_v1(); - - class Resource - { - public: - Resource() : zwp_input_method_context_v1_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zwp_input_method_context_v1 *zwp_input_method_context_v1_object; - zwp_input_method_context_v1 *object() { return zwp_input_method_context_v1_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_surrounding_text(const std::string &text, uint32_t cursor, uint32_t anchor); - void send_surrounding_text(struct ::wl_resource *resource, const std::string &text, uint32_t cursor, uint32_t anchor); - void send_reset(); - void send_reset(struct ::wl_resource *resource); - void send_content_type(uint32_t hint, uint32_t purpose); - void send_content_type(struct ::wl_resource *resource, uint32_t hint, uint32_t purpose); - void send_invoke_action(uint32_t button, uint32_t index); - void send_invoke_action(struct ::wl_resource *resource, uint32_t button, uint32_t index); - void send_commit_state(uint32_t serial); - void send_commit_state(struct ::wl_resource *resource, uint32_t serial); - void send_preferred_language(const std::string &language); - void send_preferred_language(struct ::wl_resource *resource, const std::string &language); - void send_return_key_type(uint32_t return_key_type); - void send_return_key_type(struct ::wl_resource *resource, uint32_t return_key_type); - void send_return_key_disabled(uint32_t return_key_disabled); - void send_return_key_disabled(struct ::wl_resource *resource, uint32_t return_key_disabled); - void send_input_panel_data(const std::string &input_panel_data, uint32_t input_panel_data_length); - void send_input_panel_data(struct ::wl_resource *resource, const std::string &input_panel_data, uint32_t input_panel_data_length); - void send_bidi_direction(uint32_t direction); - void send_bidi_direction(struct ::wl_resource *resource, uint32_t direction); - void send_cursor_position(uint32_t cursor_position); - void send_cursor_position(struct ::wl_resource *resource, uint32_t cursor_position); - void send_process_input_device_event(uint32_t event_type, const std::string &event_data, uint32_t event_length); - void send_process_input_device_event(struct ::wl_resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length); - void send_filter_key_event(uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode); - void send_filter_key_event(struct ::wl_resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode); - void send_capital_mode(uint32_t mode); - void send_capital_mode(struct ::wl_resource *resource, uint32_t mode); - void send_prediction_hint(const std::string &text); - void send_prediction_hint(struct ::wl_resource *resource, const std::string &text); - void send_mime_type(const std::string &type); - void send_mime_type(struct ::wl_resource *resource, const std::string &type); - void send_finalized_content(const std::string &text, uint32_t cursor_position); - void send_finalized_content(struct ::wl_resource *resource, const std::string &text, uint32_t cursor_position); - void send_prediction_hint_data(const std::string &key, const std::string &value); - void send_prediction_hint_data(struct ::wl_resource *resource, const std::string &key, const std::string &value); - void send_input_panel_enabled(uint32_t enabled); - void send_input_panel_enabled(struct ::wl_resource *resource, uint32_t enabled); - - protected: - virtual Resource *zwp_input_method_context_v1_allocate(); - - virtual void zwp_input_method_context_v1_bind_resource(Resource *resource); - virtual void zwp_input_method_context_v1_destroy_resource(Resource *resource); - - virtual void zwp_input_method_context_v1_destroy(Resource *resource); - virtual void zwp_input_method_context_v1_commit_string(Resource *resource, uint32_t serial, const std::string &text); - virtual void zwp_input_method_context_v1_preedit_string(Resource *resource, uint32_t serial, const std::string &text, const std::string &commit); - virtual void zwp_input_method_context_v1_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style); - virtual void zwp_input_method_context_v1_preedit_cursor(Resource *resource, int32_t index); - virtual void zwp_input_method_context_v1_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length); - virtual void zwp_input_method_context_v1_cursor_position(Resource *resource, int32_t index, int32_t anchor); - virtual void zwp_input_method_context_v1_modifiers_map(Resource *resource, struct ::wl_array *map); - virtual void zwp_input_method_context_v1_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers); - virtual void zwp_input_method_context_v1_grab_keyboard(Resource *resource, uint32_t keyboard); - virtual void zwp_input_method_context_v1_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); - virtual void zwp_input_method_context_v1_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); - virtual void zwp_input_method_context_v1_language(Resource *resource, uint32_t serial, const std::string &language); - virtual void zwp_input_method_context_v1_text_direction(Resource *resource, uint32_t serial, uint32_t direction); - virtual void zwp_input_method_context_v1_selection_region(Resource *resource, uint32_t serial, int32_t start, int32_t end); - virtual void zwp_input_method_context_v1_private_command(Resource *resource, uint32_t serial, const std::string &command); - virtual void zwp_input_method_context_v1_update_input_panel_data(Resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length); - virtual void zwp_input_method_context_v1_hide_input_panel(Resource *resource, uint32_t serial); - virtual void zwp_input_method_context_v1_get_selection_text(Resource *resource, int32_t fd); - virtual void zwp_input_method_context_v1_get_surrounding_text(Resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd); - virtual void zwp_input_method_context_v1_filter_key_event_done(Resource *resource, uint32_t serial, uint32_t state); - virtual void zwp_input_method_context_v1_update_ise_geometry(Resource *resource, uint32_t serial, uint32_t x, uint32_t y, uint32_t width, uint32_t height); - virtual void zwp_input_method_context_v1_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit); - virtual void zwp_input_method_context_v1_input_panel_event(Resource *resource, uint32_t serial, uint32_t event_type, uint32_t value); - virtual void zwp_input_method_context_v1_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types); - virtual void zwp_input_method_context_v1_update_candidate_state(Resource *resource, uint32_t state); - virtual void zwp_input_method_context_v1_reshow_input_panel(Resource *resource); - virtual void zwp_input_method_context_v1_set_floating_panel(Resource *resource, uint32_t state); - virtual void zwp_input_method_context_v1_set_floating_drag_enabled(Resource *resource, uint32_t enabled); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zwp_input_method_context_v1_interface m_zwp_input_method_context_v1_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_commit_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *text); - static void handle_preedit_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *text, - const char *commit); - static void handle_preedit_styling( - ::wl_client *client, - struct wl_resource *resource, - uint32_t index, - uint32_t length, - uint32_t style); - static void handle_preedit_cursor( - ::wl_client *client, - struct wl_resource *resource, - int32_t index); - static void handle_delete_surrounding_text( - ::wl_client *client, - struct wl_resource *resource, - int32_t index, - uint32_t length); - static void handle_cursor_position( - ::wl_client *client, - struct wl_resource *resource, - int32_t index, - int32_t anchor); - static void handle_modifiers_map( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_array *map); - static void handle_keysym( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t time, - uint32_t sym, - uint32_t state, - uint32_t modifiers); - static void handle_grab_keyboard( - ::wl_client *client, - struct wl_resource *resource, - uint32_t keyboard); - static void handle_key( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t time, - uint32_t key, - uint32_t state); - static void handle_modifiers( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t mods_depressed, - uint32_t mods_latched, - uint32_t mods_locked, - uint32_t group); - static void handle_language( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *language); - static void handle_text_direction( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t direction); - static void handle_selection_region( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - int32_t start, - int32_t end); - static void handle_private_command( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *command); - static void handle_update_input_panel_data( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *input_panel_data, - uint32_t input_panel_data_length); - static void handle_hide_input_panel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_get_selection_text( - ::wl_client *client, - struct wl_resource *resource, - int32_t fd); - static void handle_get_surrounding_text( - ::wl_client *client, - struct wl_resource *resource, - uint32_t maxlen_before, - uint32_t maxlen_after, - int32_t fd); - static void handle_filter_key_event_done( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t state); - static void handle_update_ise_geometry( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height); - static void handle_recapture_string( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - int32_t index, - uint32_t length, - const char *preedit, - const char *preedit_commit, - const char *commit); - static void handle_input_panel_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t event_type, - uint32_t value); - static void handle_commit_content( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *content, - const char *description, - const char *mime_types); - static void handle_update_candidate_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state); - static void handle_reshow_input_panel( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_floating_panel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state); - static void handle_set_floating_drag_enabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t enabled); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zwp_input_method_context_v1 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class zwp_input_method_v1 - { - public: - zwp_input_method_v1(struct ::wl_client *client, uint32_t id, int version); - zwp_input_method_v1(struct ::wl_display *display, int version); - zwp_input_method_v1(struct ::wl_resource *resource); - zwp_input_method_v1(); - - virtual ~zwp_input_method_v1(); - - class Resource - { - public: - Resource() : zwp_input_method_v1_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zwp_input_method_v1 *zwp_input_method_v1_object; - zwp_input_method_v1 *object() { return zwp_input_method_v1_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_activate(struct ::wl_resource *id); - void send_activate(struct ::wl_resource *resource, struct ::wl_resource *id); - void send_deactivate(struct ::wl_resource *context); - void send_deactivate(struct ::wl_resource *resource, struct ::wl_resource *context); - void send_destroy(struct ::wl_resource *context); - void send_destroy(struct ::wl_resource *resource, struct ::wl_resource *context); - void send_show_input_panel(struct ::wl_resource *context, uint32_t degree); - void send_show_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t degree); - void send_hide_input_panel(struct ::wl_resource *context); - void send_hide_input_panel(struct ::wl_resource *resource, struct ::wl_resource *context); - void send_open_connection(struct ::wl_resource *context); - void send_open_connection(struct ::wl_resource *resource, struct ::wl_resource *context); - void send_close_connection(struct ::wl_resource *context); - void send_close_connection(struct ::wl_resource *resource, struct ::wl_resource *context); - void send_set_text_input_id(struct ::wl_resource *context, uint32_t text_input_id); - void send_set_text_input_id(struct ::wl_resource *resource, struct ::wl_resource *context, uint32_t text_input_id); - - protected: - virtual Resource *zwp_input_method_v1_allocate(); - - virtual void zwp_input_method_v1_bind_resource(Resource *resource); - virtual void zwp_input_method_v1_destroy_resource(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zwp_input_method_v1 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class zwp_input_panel_v1 - { - public: - zwp_input_panel_v1(struct ::wl_client *client, uint32_t id, int version); - zwp_input_panel_v1(struct ::wl_display *display, int version); - zwp_input_panel_v1(struct ::wl_resource *resource); - zwp_input_panel_v1(); - - virtual ~zwp_input_panel_v1(); - - class Resource - { - public: - Resource() : zwp_input_panel_v1_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zwp_input_panel_v1 *zwp_input_panel_v1_object; - zwp_input_panel_v1 *object() { return zwp_input_panel_v1_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *zwp_input_panel_v1_allocate(); - - virtual void zwp_input_panel_v1_bind_resource(Resource *resource); - virtual void zwp_input_panel_v1_destroy_resource(Resource *resource); - - virtual void zwp_input_panel_v1_get_input_panel_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zwp_input_panel_v1_interface m_zwp_input_panel_v1_interface; - - static void handle_get_input_panel_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zwp_input_panel_v1 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class zwp_input_panel_surface_v1 - { - public: - zwp_input_panel_surface_v1(struct ::wl_client *client, uint32_t id, int version); - zwp_input_panel_surface_v1(struct ::wl_display *display, int version); - zwp_input_panel_surface_v1(struct ::wl_resource *resource); - zwp_input_panel_surface_v1(); - - virtual ~zwp_input_panel_surface_v1(); - - class Resource - { - public: - Resource() : zwp_input_panel_surface_v1_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zwp_input_panel_surface_v1 *zwp_input_panel_surface_v1_object; - zwp_input_panel_surface_v1 *object() { return zwp_input_panel_surface_v1_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum position { - position_center_bottom = 0, - }; - - protected: - virtual Resource *zwp_input_panel_surface_v1_allocate(); - - virtual void zwp_input_panel_surface_v1_bind_resource(Resource *resource); - virtual void zwp_input_panel_surface_v1_destroy_resource(Resource *resource); - - virtual void zwp_input_panel_surface_v1_set_toplevel(Resource *resource, struct ::wl_resource *output, uint32_t position); - virtual void zwp_input_panel_surface_v1_set_overlay_panel(Resource *resource); - virtual void zwp_input_panel_surface_v1_set_ready(Resource *resource, uint32_t state); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zwp_input_panel_surface_v1_interface m_zwp_input_panel_surface_v1_interface; - - static void handle_set_toplevel( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output, - uint32_t position); - static void handle_set_overlay_panel( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_ready( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zwp_input_panel_surface_v1 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class zwp_input_method_manager_v1 - { - public: - zwp_input_method_manager_v1(struct ::wl_client *client, uint32_t id, int version); - zwp_input_method_manager_v1(struct ::wl_display *display, int version); - zwp_input_method_manager_v1(struct ::wl_resource *resource); - zwp_input_method_manager_v1(); - - virtual ~zwp_input_method_manager_v1(); - - class Resource - { - public: - Resource() : zwp_input_method_manager_v1_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zwp_input_method_manager_v1 *zwp_input_method_manager_v1_object; - zwp_input_method_manager_v1 *object() { return zwp_input_method_manager_v1_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *zwp_input_method_manager_v1_allocate(); - - virtual void zwp_input_method_manager_v1_bind_resource(Resource *resource); - virtual void zwp_input_method_manager_v1_destroy_resource(Resource *resource); - - virtual void zwp_input_method_manager_v1_set_transient_for(Resource *resource, uint32_t parent_pid, uint32_t child_pid); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zwp_input_method_manager_v1_interface m_zwp_input_method_manager_v1_interface; - - static void handle_set_transient_for( - ::wl_client *client, - struct wl_resource *resource, - uint32_t parent_pid, - uint32_t child_pid); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zwp_input_method_manager_v1 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-presentation-time.cpp b/src/DSWaylandServer/dswayland-server-presentation-time.cpp deleted file mode 100644 index 75af141..0000000 --- a/src/DSWaylandServer/dswayland-server-presentation-time.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/presentation-time.xml */ - -#include "dswayland-server-presentation-time.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - wp_presentation::wp_presentation(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wp_presentation::wp_presentation(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wp_presentation::wp_presentation(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wp_presentation::wp_presentation() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wp_presentation::~wp_presentation() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wp_presentation::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wp_presentation::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wp_presentation::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wp_presentation::Resource *wp_presentation::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wp_presentation::Resource *wp_presentation::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wp_presentation::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wp_presentation_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wp_presentation::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wp_presentation::interface() - { - return &::wp_presentation_interface; - } - - wp_presentation::Resource *wp_presentation::wp_presentation_allocate() - { - return new Resource; - } - - void wp_presentation::wp_presentation_bind_resource(Resource *) - { - } - - void wp_presentation::wp_presentation_destroy_resource(Resource *) - { - } - - void wp_presentation::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wp_presentation *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wp_presentation::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wp_presentation *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wp_presentation::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wp_presentation *that = resource->wp_presentation_object; - that->m_resource_map.erase(resource->client()); - that->wp_presentation_destroy_resource(resource); - delete resource; - } - - wp_presentation::Resource *wp_presentation::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wp_presentation_interface, version, id); - return bind(handle); - } - - wp_presentation::Resource *wp_presentation::bind(struct ::wl_resource *handle) - { - Resource *resource = wp_presentation_allocate(); - resource->wp_presentation_object = this; - - wl_resource_set_implementation(handle, &m_wp_presentation_interface, resource, destroy_func); - resource->handle = handle; - wp_presentation_bind_resource(resource); - return resource; - } - wp_presentation::Resource *wp_presentation::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wp_presentation_interface, &m_wp_presentation_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wp_presentation_interface wp_presentation::m_wp_presentation_interface = { - wp_presentation::handle_destroy, - wp_presentation::handle_feedback - }; - - void wp_presentation::wp_presentation_destroy(Resource *) - { - } - - void wp_presentation::wp_presentation_feedback(Resource *, struct ::wl_resource *, uint32_t) - { - } - - - void wp_presentation::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->wp_presentation_object)->wp_presentation_destroy( - r); - } - - void wp_presentation::handle_feedback( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t callback) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->wp_presentation_object)->wp_presentation_feedback( - r, - surface, - callback); - } - - void wp_presentation::send_clock_id(uint32_t clk_id) - { - DS_ASSERT_X(m_resource, "wp_presentation::clock_id", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wp_presentation::clock_id as it's not initialised"); - return; - } - send_clock_id( - m_resource->handle, - clk_id); - } - - void wp_presentation::send_clock_id(struct ::wl_resource *resource, uint32_t clk_id) - { - wp_presentation_send_clock_id( - resource, - clk_id); - } - - - wp_presentation_feedback::wp_presentation_feedback(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wp_presentation_feedback::wp_presentation_feedback(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wp_presentation_feedback::wp_presentation_feedback(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wp_presentation_feedback::wp_presentation_feedback() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wp_presentation_feedback::~wp_presentation_feedback() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wp_presentation_feedback::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wp_presentation_feedback::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wp_presentation_feedback::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wp_presentation_feedback::Resource *wp_presentation_feedback::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wp_presentation_feedback::Resource *wp_presentation_feedback::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wp_presentation_feedback::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wp_presentation_feedback_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wp_presentation_feedback::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wp_presentation_feedback::interface() - { - return &::wp_presentation_feedback_interface; - } - - wp_presentation_feedback::Resource *wp_presentation_feedback::wp_presentation_feedback_allocate() - { - return new Resource; - } - - void wp_presentation_feedback::wp_presentation_feedback_bind_resource(Resource *) - { - } - - void wp_presentation_feedback::wp_presentation_feedback_destroy_resource(Resource *) - { - } - - void wp_presentation_feedback::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wp_presentation_feedback *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wp_presentation_feedback::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wp_presentation_feedback *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wp_presentation_feedback::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wp_presentation_feedback *that = resource->wp_presentation_feedback_object; - that->m_resource_map.erase(resource->client()); - that->wp_presentation_feedback_destroy_resource(resource); - delete resource; - } - - wp_presentation_feedback::Resource *wp_presentation_feedback::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wp_presentation_feedback_interface, version, id); - return bind(handle); - } - - wp_presentation_feedback::Resource *wp_presentation_feedback::bind(struct ::wl_resource *handle) - { - Resource *resource = wp_presentation_feedback_allocate(); - resource->wp_presentation_feedback_object = this; - - wl_resource_set_implementation(handle, NULL, resource, destroy_func); - resource->handle = handle; - wp_presentation_feedback_bind_resource(resource); - return resource; - } - wp_presentation_feedback::Resource *wp_presentation_feedback::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wp_presentation_feedback_interface, NULL)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - void wp_presentation_feedback::send_sync_output(struct ::wl_resource *output) - { - DS_ASSERT_X(m_resource, "wp_presentation_feedback::sync_output", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wp_presentation_feedback::sync_output as it's not initialised"); - return; - } - send_sync_output( - m_resource->handle, - output); - } - - void wp_presentation_feedback::send_sync_output(struct ::wl_resource *resource, struct ::wl_resource *output) - { - wp_presentation_feedback_send_sync_output( - resource, - output); - } - - - void wp_presentation_feedback::send_presented(uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags) - { - DS_ASSERT_X(m_resource, "wp_presentation_feedback::presented", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wp_presentation_feedback::presented as it's not initialised"); - return; - } - send_presented( - m_resource->handle, - tv_sec_hi, - tv_sec_lo, - tv_nsec, - refresh, - seq_hi, - seq_lo, - flags); - } - - void wp_presentation_feedback::send_presented(struct ::wl_resource *resource, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags) - { - wp_presentation_feedback_send_presented( - resource, - tv_sec_hi, - tv_sec_lo, - tv_nsec, - refresh, - seq_hi, - seq_lo, - flags); - } - - - void wp_presentation_feedback::send_discarded() - { - DS_ASSERT_X(m_resource, "wp_presentation_feedback::discarded", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wp_presentation_feedback::discarded as it's not initialised"); - return; - } - send_discarded( - m_resource->handle); - } - - void wp_presentation_feedback::send_discarded(struct ::wl_resource *resource) - { - wp_presentation_feedback_send_discarded( - resource); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-presentation-time.h b/src/DSWaylandServer/dswayland-server-presentation-time.h deleted file mode 100644 index d377ffd..0000000 --- a/src/DSWaylandServer/dswayland-server-presentation-time.h +++ /dev/null @@ -1,208 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/presentation-time.xml */ - -#ifndef __DS_PRESENTATION_TIME_PROTOCOL_H__ -#define __DS_PRESENTATION_TIME_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "presentation-time-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class wp_presentation - { - public: - wp_presentation(struct ::wl_client *client, uint32_t id, int version); - wp_presentation(struct ::wl_display *display, int version); - wp_presentation(struct ::wl_resource *resource); - wp_presentation(); - - virtual ~wp_presentation(); - - class Resource - { - public: - Resource() : wp_presentation_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wp_presentation *wp_presentation_object; - wp_presentation *object() { return wp_presentation_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_timestamp = 0, // invalid value in tv_nsec - error_invalid_flag = 1, // invalid flag - }; - - void send_clock_id(uint32_t clk_id); - void send_clock_id(struct ::wl_resource *resource, uint32_t clk_id); - - protected: - virtual Resource *wp_presentation_allocate(); - - virtual void wp_presentation_bind_resource(Resource *resource); - virtual void wp_presentation_destroy_resource(Resource *resource); - - virtual void wp_presentation_destroy(Resource *resource); - virtual void wp_presentation_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t callback); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wp_presentation_interface m_wp_presentation_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_feedback( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t callback); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wp_presentation *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wp_presentation_feedback - { - public: - wp_presentation_feedback(struct ::wl_client *client, uint32_t id, int version); - wp_presentation_feedback(struct ::wl_display *display, int version); - wp_presentation_feedback(struct ::wl_resource *resource); - wp_presentation_feedback(); - - virtual ~wp_presentation_feedback(); - - class Resource - { - public: - Resource() : wp_presentation_feedback_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wp_presentation_feedback *wp_presentation_feedback_object; - wp_presentation_feedback *object() { return wp_presentation_feedback_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum kind { - kind_vsync = 0x1, // presentation was vsync'd - kind_hw_clock = 0x2, // hardware provided the presentation timestamp - kind_hw_completion = 0x4, // hardware signalled the start of the presentation - kind_zero_copy = 0x8, // presentation was done zero-copy - }; - - void send_sync_output(struct ::wl_resource *output); - void send_sync_output(struct ::wl_resource *resource, struct ::wl_resource *output); - void send_presented(uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags); - void send_presented(struct ::wl_resource *resource, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec, uint32_t refresh, uint32_t seq_hi, uint32_t seq_lo, uint32_t flags); - void send_discarded(); - void send_discarded(struct ::wl_resource *resource); - - protected: - virtual Resource *wp_presentation_feedback_allocate(); - - virtual void wp_presentation_feedback_bind_resource(Resource *resource); - virtual void wp_presentation_feedback_destroy_resource(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wp_presentation_feedback *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-scaler.cpp b/src/DSWaylandServer/dswayland-server-scaler.cpp deleted file mode 100644 index 12e10d0..0000000 --- a/src/DSWaylandServer/dswayland-server-scaler.cpp +++ /dev/null @@ -1,463 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/scaler.xml */ - -#include "dswayland-server-scaler.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - wl_scaler::wl_scaler(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_scaler::wl_scaler(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_scaler::wl_scaler(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_scaler::wl_scaler() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_scaler::~wl_scaler() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_scaler::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_scaler::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_scaler::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_scaler::Resource *wl_scaler::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_scaler::Resource *wl_scaler::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_scaler::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_scaler_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_scaler::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_scaler::interface() - { - return &::wl_scaler_interface; - } - - wl_scaler::Resource *wl_scaler::scaler_allocate() - { - return new Resource; - } - - void wl_scaler::scaler_bind_resource(Resource *) - { - } - - void wl_scaler::scaler_destroy_resource(Resource *) - { - } - - void wl_scaler::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_scaler *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_scaler::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_scaler *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_scaler::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_scaler *that = resource->scaler_object; - that->m_resource_map.erase(resource->client()); - that->scaler_destroy_resource(resource); - delete resource; - } - - wl_scaler::Resource *wl_scaler::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_scaler_interface, version, id); - return bind(handle); - } - - wl_scaler::Resource *wl_scaler::bind(struct ::wl_resource *handle) - { - Resource *resource = scaler_allocate(); - resource->scaler_object = this; - - wl_resource_set_implementation(handle, &m_wl_scaler_interface, resource, destroy_func); - resource->handle = handle; - scaler_bind_resource(resource); - return resource; - } - wl_scaler::Resource *wl_scaler::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_scaler_interface, &m_wl_scaler_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_scaler_interface wl_scaler::m_wl_scaler_interface = { - wl_scaler::handle_destroy, - wl_scaler::handle_get_viewport - }; - - void wl_scaler::scaler_destroy(Resource *) - { - } - - void wl_scaler::scaler_get_viewport(Resource *, uint32_t, struct ::wl_resource *) - { - } - - - void wl_scaler::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->scaler_object)->scaler_destroy( - r); - } - - void wl_scaler::handle_get_viewport( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->scaler_object)->scaler_get_viewport( - r, - id, - surface); - } - - wl_viewport::wl_viewport(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_viewport::wl_viewport(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_viewport::wl_viewport(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_viewport::wl_viewport() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_viewport::~wl_viewport() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_viewport::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_viewport::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_viewport::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_viewport::Resource *wl_viewport::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_viewport::Resource *wl_viewport::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_viewport::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_viewport_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_viewport::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_viewport::interface() - { - return &::wl_viewport_interface; - } - - wl_viewport::Resource *wl_viewport::viewport_allocate() - { - return new Resource; - } - - void wl_viewport::viewport_bind_resource(Resource *) - { - } - - void wl_viewport::viewport_destroy_resource(Resource *) - { - } - - void wl_viewport::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_viewport *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_viewport::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_viewport *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_viewport::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_viewport *that = resource->viewport_object; - that->m_resource_map.erase(resource->client()); - that->viewport_destroy_resource(resource); - delete resource; - } - - wl_viewport::Resource *wl_viewport::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_viewport_interface, version, id); - return bind(handle); - } - - wl_viewport::Resource *wl_viewport::bind(struct ::wl_resource *handle) - { - Resource *resource = viewport_allocate(); - resource->viewport_object = this; - - wl_resource_set_implementation(handle, &m_wl_viewport_interface, resource, destroy_func); - resource->handle = handle; - viewport_bind_resource(resource); - return resource; - } - wl_viewport::Resource *wl_viewport::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_viewport_interface, &m_wl_viewport_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_viewport_interface wl_viewport::m_wl_viewport_interface = { - wl_viewport::handle_destroy, - wl_viewport::handle_set, - wl_viewport::handle_set_source, - wl_viewport::handle_set_destination - }; - - void wl_viewport::viewport_destroy(Resource *) - { - } - - void wl_viewport::viewport_set(Resource *, wl_fixed_t , wl_fixed_t , wl_fixed_t , wl_fixed_t , int32_t , int32_t ) - { - } - - void wl_viewport::viewport_set_source(Resource *, wl_fixed_t , wl_fixed_t , wl_fixed_t , wl_fixed_t ) - { - } - - void wl_viewport::viewport_set_destination(Resource *, int32_t , int32_t ) - { - } - - - void wl_viewport::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->viewport_object)->viewport_destroy( - r); - } - - void wl_viewport::handle_set( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t src_x, - wl_fixed_t src_y, - wl_fixed_t src_width, - wl_fixed_t src_height, - int32_t dst_width, - int32_t dst_height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->viewport_object)->viewport_set( - r, - src_x, - src_y, - src_width, - src_height, - dst_width, - dst_height); - } - - void wl_viewport::handle_set_source( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t x, - wl_fixed_t y, - wl_fixed_t width, - wl_fixed_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->viewport_object)->viewport_set_source( - r, - x, - y, - width, - height); - } - - void wl_viewport::handle_set_destination( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->viewport_object)->viewport_set_destination( - r, - width, - height); - } -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-scaler.h b/src/DSWaylandServer/dswayland-server-scaler.h deleted file mode 100644 index dd197a3..0000000 --- a/src/DSWaylandServer/dswayland-server-scaler.h +++ /dev/null @@ -1,226 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/scaler.xml */ - -#ifndef __DS_SCALER_PROTOCOL_H__ -#define __DS_SCALER_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "scaler-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class wl_scaler - { - public: - wl_scaler(struct ::wl_client *client, uint32_t id, int version); - wl_scaler(struct ::wl_display *display, int version); - wl_scaler(struct ::wl_resource *resource); - wl_scaler(); - - virtual ~wl_scaler(); - - class Resource - { - public: - Resource() : scaler_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_scaler *scaler_object; - wl_scaler *object() { return scaler_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_viewport_exists = 0, // the surface already has a viewport object associated - }; - - protected: - virtual Resource *scaler_allocate(); - - virtual void scaler_bind_resource(Resource *resource); - virtual void scaler_destroy_resource(Resource *resource); - - virtual void scaler_destroy(Resource *resource); - virtual void scaler_get_viewport(Resource *resource, uint32_t id, struct ::wl_resource *surface); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_scaler_interface m_wl_scaler_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_get_viewport( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_scaler *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_viewport - { - public: - wl_viewport(struct ::wl_client *client, uint32_t id, int version); - wl_viewport(struct ::wl_display *display, int version); - wl_viewport(struct ::wl_resource *resource); - wl_viewport(); - - virtual ~wl_viewport(); - - class Resource - { - public: - Resource() : viewport_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_viewport *viewport_object; - wl_viewport *object() { return viewport_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_bad_value = 0, // negative or zero values in width or height - }; - - protected: - virtual Resource *viewport_allocate(); - - virtual void viewport_bind_resource(Resource *resource); - virtual void viewport_destroy_resource(Resource *resource); - - virtual void viewport_destroy(Resource *resource); - virtual void viewport_set(Resource *resource, wl_fixed_t src_x, wl_fixed_t src_y, wl_fixed_t src_width, wl_fixed_t src_height, int32_t dst_width, int32_t dst_height); - virtual void viewport_set_source(Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height); - virtual void viewport_set_destination(Resource *resource, int32_t width, int32_t height); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_viewport_interface m_wl_viewport_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t src_x, - wl_fixed_t src_y, - wl_fixed_t src_width, - wl_fixed_t src_height, - int32_t dst_width, - int32_t dst_height); - static void handle_set_source( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t x, - wl_fixed_t y, - wl_fixed_t width, - wl_fixed_t height); - static void handle_set_destination( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_viewport *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-screenshooter.cpp b/src/DSWaylandServer/dswayland-server-screenshooter.cpp deleted file mode 100644 index 75c0457..0000000 --- a/src/DSWaylandServer/dswayland-server-screenshooter.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/screenshooter.xml */ - -#include "dswayland-server-screenshooter.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - screenshooter::screenshooter(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - screenshooter::screenshooter(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - screenshooter::screenshooter(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - screenshooter::screenshooter() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - screenshooter::~screenshooter() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - screenshooter::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void screenshooter::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void screenshooter::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - screenshooter::Resource *screenshooter::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - screenshooter::Resource *screenshooter::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void screenshooter::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::screenshooter_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = screenshooter::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *screenshooter::interface() - { - return &::screenshooter_interface; - } - - screenshooter::Resource *screenshooter::screenshooter_allocate() - { - return new Resource; - } - - void screenshooter::screenshooter_bind_resource(Resource *) - { - } - - void screenshooter::screenshooter_destroy_resource(Resource *) - { - } - - void screenshooter::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - screenshooter *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void screenshooter::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - screenshooter *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void screenshooter::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - screenshooter *that = resource->screenshooter_object; - that->m_resource_map.erase(resource->client()); - that->screenshooter_destroy_resource(resource); - delete resource; - } - - screenshooter::Resource *screenshooter::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::screenshooter_interface, version, id); - return bind(handle); - } - - screenshooter::Resource *screenshooter::bind(struct ::wl_resource *handle) - { - Resource *resource = screenshooter_allocate(); - resource->screenshooter_object = this; - - wl_resource_set_implementation(handle, &m_screenshooter_interface, resource, destroy_func); - resource->handle = handle; - screenshooter_bind_resource(resource); - return resource; - } - screenshooter::Resource *screenshooter::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::screenshooter_interface, &m_screenshooter_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::screenshooter_interface screenshooter::m_screenshooter_interface = { - screenshooter::handle_shoot - }; - - void screenshooter::screenshooter_shoot(Resource *, struct ::wl_resource *, struct ::wl_resource *) - { - } - - - void screenshooter::handle_shoot( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output, - struct ::wl_resource *buffer) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->screenshooter_object)->screenshooter_shoot( - r, - output, - buffer); - } - - void screenshooter::send_done() - { - DS_ASSERT_X(m_resource, "screenshooter::done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call screenshooter::done as it's not initialised"); - return; - } - send_done( - m_resource->handle); - } - - void screenshooter::send_done(struct ::wl_resource *resource) - { - screenshooter_send_done( - resource); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-screenshooter.h b/src/DSWaylandServer/dswayland-server-screenshooter.h deleted file mode 100644 index fb66535..0000000 --- a/src/DSWaylandServer/dswayland-server-screenshooter.h +++ /dev/null @@ -1,112 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/screenshooter.xml */ - -#ifndef __DS_SCREENSHOOTER_PROTOCOL_H__ -#define __DS_SCREENSHOOTER_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "screenshooter-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class screenshooter - { - public: - screenshooter(struct ::wl_client *client, uint32_t id, int version); - screenshooter(struct ::wl_display *display, int version); - screenshooter(struct ::wl_resource *resource); - screenshooter(); - - virtual ~screenshooter(); - - class Resource - { - public: - Resource() : screenshooter_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - screenshooter *screenshooter_object; - screenshooter *object() { return screenshooter_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_done(); - void send_done(struct ::wl_resource *resource); - - protected: - virtual Resource *screenshooter_allocate(); - - virtual void screenshooter_bind_resource(Resource *resource); - virtual void screenshooter_destroy_resource(Resource *resource); - - virtual void screenshooter_shoot(Resource *resource, struct ::wl_resource *output, struct ::wl_resource *buffer); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::screenshooter_interface m_screenshooter_interface; - - static void handle_shoot( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output, - struct ::wl_resource *buffer); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - screenshooter *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-text-cursor-position.cpp b/src/DSWaylandServer/dswayland-server-text-cursor-position.cpp deleted file mode 100644 index 82ac43a..0000000 --- a/src/DSWaylandServer/dswayland-server-text-cursor-position.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/text-cursor-position.xml */ - -#include "dswayland-server-text-cursor-position.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - text_cursor_position::text_cursor_position(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - text_cursor_position::text_cursor_position(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - text_cursor_position::text_cursor_position(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - text_cursor_position::text_cursor_position() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - text_cursor_position::~text_cursor_position() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - text_cursor_position::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void text_cursor_position::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void text_cursor_position::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - text_cursor_position::Resource *text_cursor_position::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - text_cursor_position::Resource *text_cursor_position::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void text_cursor_position::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::text_cursor_position_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = text_cursor_position::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *text_cursor_position::interface() - { - return &::text_cursor_position_interface; - } - - text_cursor_position::Resource *text_cursor_position::text_cursor_position_allocate() - { - return new Resource; - } - - void text_cursor_position::text_cursor_position_bind_resource(Resource *) - { - } - - void text_cursor_position::text_cursor_position_destroy_resource(Resource *) - { - } - - void text_cursor_position::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - text_cursor_position *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void text_cursor_position::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - text_cursor_position *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void text_cursor_position::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - text_cursor_position *that = resource->text_cursor_position_object; - that->m_resource_map.erase(resource->client()); - that->text_cursor_position_destroy_resource(resource); - delete resource; - } - - text_cursor_position::Resource *text_cursor_position::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::text_cursor_position_interface, version, id); - return bind(handle); - } - - text_cursor_position::Resource *text_cursor_position::bind(struct ::wl_resource *handle) - { - Resource *resource = text_cursor_position_allocate(); - resource->text_cursor_position_object = this; - - wl_resource_set_implementation(handle, &m_text_cursor_position_interface, resource, destroy_func); - resource->handle = handle; - text_cursor_position_bind_resource(resource); - return resource; - } - text_cursor_position::Resource *text_cursor_position::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::text_cursor_position_interface, &m_text_cursor_position_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::text_cursor_position_interface text_cursor_position::m_text_cursor_position_interface = { - text_cursor_position::handle_notify - }; - - void text_cursor_position::text_cursor_position_notify(Resource *, struct ::wl_resource *, wl_fixed_t , wl_fixed_t ) - { - } - - - void text_cursor_position::handle_notify( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - wl_fixed_t x, - wl_fixed_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_cursor_position_object)->text_cursor_position_notify( - r, - surface, - x, - y); - } -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-text-cursor-position.h b/src/DSWaylandServer/dswayland-server-text-cursor-position.h deleted file mode 100644 index c148170..0000000 --- a/src/DSWaylandServer/dswayland-server-text-cursor-position.h +++ /dev/null @@ -1,110 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/text-cursor-position.xml */ - -#ifndef __DS_TEXT_CURSOR_POSITION_PROTOCOL_H__ -#define __DS_TEXT_CURSOR_POSITION_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "text-cursor-position-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class text_cursor_position - { - public: - text_cursor_position(struct ::wl_client *client, uint32_t id, int version); - text_cursor_position(struct ::wl_display *display, int version); - text_cursor_position(struct ::wl_resource *resource); - text_cursor_position(); - - virtual ~text_cursor_position(); - - class Resource - { - public: - Resource() : text_cursor_position_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - text_cursor_position *text_cursor_position_object; - text_cursor_position *object() { return text_cursor_position_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *text_cursor_position_allocate(); - - virtual void text_cursor_position_bind_resource(Resource *resource); - virtual void text_cursor_position_destroy_resource(Resource *resource); - - virtual void text_cursor_position_notify(Resource *resource, struct ::wl_resource *surface, wl_fixed_t x, wl_fixed_t y); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::text_cursor_position_interface m_text_cursor_position_interface; - - static void handle_notify( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - wl_fixed_t x, - wl_fixed_t y); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - text_cursor_position *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-text.cpp b/src/DSWaylandServer/dswayland-server-text.cpp deleted file mode 100644 index 30cc051..0000000 --- a/src/DSWaylandServer/dswayland-server-text.cpp +++ /dev/null @@ -1,1380 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/text.xml */ - -#include "dswayland-server-text.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - wl_text_input::wl_text_input(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_text_input::wl_text_input(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_text_input::wl_text_input(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_text_input::wl_text_input() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_text_input::~wl_text_input() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_text_input::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_text_input::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_text_input::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_text_input::Resource *wl_text_input::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_text_input::Resource *wl_text_input::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_text_input::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_text_input_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_text_input::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_text_input::interface() - { - return &::wl_text_input_interface; - } - - wl_text_input::Resource *wl_text_input::text_input_allocate() - { - return new Resource; - } - - void wl_text_input::text_input_bind_resource(Resource *) - { - } - - void wl_text_input::text_input_destroy_resource(Resource *) - { - } - - void wl_text_input::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_text_input *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_text_input::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_text_input *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_text_input::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_text_input *that = resource->text_input_object; - that->m_resource_map.erase(resource->client()); - that->text_input_destroy_resource(resource); - delete resource; - } - - wl_text_input::Resource *wl_text_input::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_text_input_interface, version, id); - return bind(handle); - } - - wl_text_input::Resource *wl_text_input::bind(struct ::wl_resource *handle) - { - Resource *resource = text_input_allocate(); - resource->text_input_object = this; - - wl_resource_set_implementation(handle, &m_wl_text_input_interface, resource, destroy_func); - resource->handle = handle; - text_input_bind_resource(resource); - return resource; - } - wl_text_input::Resource *wl_text_input::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_text_input_interface, &m_wl_text_input_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_text_input_interface wl_text_input::m_wl_text_input_interface = { - wl_text_input::handle_destroy, - wl_text_input::handle_activate, - wl_text_input::handle_deactivate, - wl_text_input::handle_show_input_panel, - wl_text_input::handle_hide_input_panel, - wl_text_input::handle_reset, - wl_text_input::handle_set_content_type, - wl_text_input::handle_set_cursor_rectangle, - wl_text_input::handle_set_preferred_language, - wl_text_input::handle_commit_state, - wl_text_input::handle_invoke_action, - wl_text_input::handle_set_return_key_type, - wl_text_input::handle_set_return_key_disabled, - wl_text_input::handle_set_input_panel_data, - wl_text_input::handle_bidi_direction, - wl_text_input::handle_set_cursor_position, - wl_text_input::handle_process_input_device_event, - wl_text_input::handle_filter_key_event, - wl_text_input::handle_get_hide_permission, - wl_text_input::handle_set_capital_mode, - wl_text_input::handle_prediction_hint, - wl_text_input::handle_set_mime_type, - wl_text_input::handle_set_input_panel_position, - wl_text_input::handle_finalize_content, - wl_text_input::handle_prediction_hint_data, - wl_text_input::handle_input_panel_enabled - }; - - void wl_text_input::text_input_destroy(Resource *) - { - } - - void wl_text_input::text_input_activate(Resource *, struct ::wl_resource *, struct ::wl_resource *) - { - } - - void wl_text_input::text_input_deactivate(Resource *, struct ::wl_resource *) - { - } - - void wl_text_input::text_input_show_input_panel(Resource *) - { - } - - void wl_text_input::text_input_hide_input_panel(Resource *) - { - } - - void wl_text_input::text_input_reset(Resource *) - { - } - - void wl_text_input::text_input_set_content_type(Resource *, uint32_t , uint32_t ) - { - } - - void wl_text_input::text_input_set_cursor_rectangle(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void wl_text_input::text_input_set_preferred_language(Resource *, const std::string &) - { - } - - void wl_text_input::text_input_commit_state(Resource *, uint32_t ) - { - } - - void wl_text_input::text_input_invoke_action(Resource *, uint32_t , uint32_t ) - { - } - - void wl_text_input::text_input_set_return_key_type(Resource *, uint32_t ) - { - } - - void wl_text_input::text_input_set_return_key_disabled(Resource *, uint32_t ) - { - } - - void wl_text_input::text_input_set_input_panel_data(Resource *, const std::string &, uint32_t ) - { - } - - void wl_text_input::text_input_bidi_direction(Resource *, uint32_t ) - { - } - - void wl_text_input::text_input_set_cursor_position(Resource *, uint32_t ) - { - } - - void wl_text_input::text_input_process_input_device_event(Resource *, uint32_t , const std::string &, uint32_t ) - { - } - - void wl_text_input::text_input_filter_key_event(Resource *, uint32_t , uint32_t , const std::string &, uint32_t , uint32_t , const std::string &, uint32_t , uint32_t , uint32_t ) - { - } - - void wl_text_input::text_input_get_hide_permission(Resource *) - { - } - - void wl_text_input::text_input_set_capital_mode(Resource *, uint32_t ) - { - } - - void wl_text_input::text_input_prediction_hint(Resource *, const std::string &) - { - } - - void wl_text_input::text_input_set_mime_type(Resource *, const std::string &) - { - } - - void wl_text_input::text_input_set_input_panel_position(Resource *, uint32_t , uint32_t ) - { - } - - void wl_text_input::text_input_finalize_content(Resource *, const std::string &, uint32_t ) - { - } - - void wl_text_input::text_input_prediction_hint_data(Resource *, const std::string &, const std::string &) - { - } - - void wl_text_input::text_input_input_panel_enabled(Resource *, uint32_t ) - { - } - - - void wl_text_input::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_destroy( - r); - } - - void wl_text_input::handle_activate( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_activate( - r, - seat, - surface); - } - - void wl_text_input::handle_deactivate( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_deactivate( - r, - seat); - } - - void wl_text_input::handle_show_input_panel( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_show_input_panel( - r); - } - - void wl_text_input::handle_hide_input_panel( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_hide_input_panel( - r); - } - - void wl_text_input::handle_reset( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_reset( - r); - } - - void wl_text_input::handle_set_content_type( - ::wl_client *client, - struct wl_resource *resource, - uint32_t hint, - uint32_t purpose) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_content_type( - r, - hint, - purpose); - } - - void wl_text_input::handle_set_cursor_rectangle( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_cursor_rectangle( - r, - x, - y, - width, - height); - } - - void wl_text_input::handle_set_preferred_language( - ::wl_client *client, - struct wl_resource *resource, - const char *language) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_preferred_language( - r, - std::string(language)); - } - - void wl_text_input::handle_commit_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_commit_state( - r, - serial); - } - - void wl_text_input::handle_invoke_action( - ::wl_client *client, - struct wl_resource *resource, - uint32_t button, - uint32_t index) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_invoke_action( - r, - button, - index); - } - - void wl_text_input::handle_set_return_key_type( - ::wl_client *client, - struct wl_resource *resource, - uint32_t return_key_type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_return_key_type( - r, - return_key_type); - } - - void wl_text_input::handle_set_return_key_disabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t return_key_disabled) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_return_key_disabled( - r, - return_key_disabled); - } - - void wl_text_input::handle_set_input_panel_data( - ::wl_client *client, - struct wl_resource *resource, - const char *input_panel_data, - uint32_t input_panel_length) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_input_panel_data( - r, - std::string(input_panel_data), - input_panel_length); - } - - void wl_text_input::handle_bidi_direction( - ::wl_client *client, - struct wl_resource *resource, - uint32_t direction) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_bidi_direction( - r, - direction); - } - - void wl_text_input::handle_set_cursor_position( - ::wl_client *client, - struct wl_resource *resource, - uint32_t cursor_position) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_cursor_position( - r, - cursor_position); - } - - void wl_text_input::handle_process_input_device_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_type, - const char *event_data, - uint32_t event_length) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_process_input_device_event( - r, - event_type, - std::string(event_data), - event_length); - } - - void wl_text_input::handle_filter_key_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t time, - const char *keyname, - uint32_t state, - uint32_t modifiers, - const char *dev_name, - uint32_t dev_class, - uint32_t dev_subclass, - uint32_t keycode) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_filter_key_event( - r, - serial, - time, - std::string(keyname), - state, - modifiers, - std::string(dev_name), - dev_class, - dev_subclass, - keycode); - } - - void wl_text_input::handle_get_hide_permission( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_get_hide_permission( - r); - } - - void wl_text_input::handle_set_capital_mode( - ::wl_client *client, - struct wl_resource *resource, - uint32_t mode) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_capital_mode( - r, - mode); - } - - void wl_text_input::handle_prediction_hint( - ::wl_client *client, - struct wl_resource *resource, - const char *text) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_prediction_hint( - r, - std::string(text)); - } - - void wl_text_input::handle_set_mime_type( - ::wl_client *client, - struct wl_resource *resource, - const char *type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_mime_type( - r, - std::string(type)); - } - - void wl_text_input::handle_set_input_panel_position( - ::wl_client *client, - struct wl_resource *resource, - uint32_t x, - uint32_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_set_input_panel_position( - r, - x, - y); - } - - void wl_text_input::handle_finalize_content( - ::wl_client *client, - struct wl_resource *resource, - const char *text, - uint32_t cursor_position) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_finalize_content( - r, - std::string(text), - cursor_position); - } - - void wl_text_input::handle_prediction_hint_data( - ::wl_client *client, - struct wl_resource *resource, - const char *key, - const char *value) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_prediction_hint_data( - r, - std::string(key), - std::string(value)); - } - - void wl_text_input::handle_input_panel_enabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t enabled) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_object)->text_input_input_panel_enabled( - r, - enabled); - } - - void wl_text_input::send_enter(struct ::wl_resource *surface) - { - DS_ASSERT_X(m_resource, "wl_text_input::enter", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::enter as it's not initialised"); - return; - } - send_enter( - m_resource->handle, - surface); - } - - void wl_text_input::send_enter(struct ::wl_resource *resource, struct ::wl_resource *surface) - { - wl_text_input_send_enter( - resource, - surface); - } - - - void wl_text_input::send_leave() - { - DS_ASSERT_X(m_resource, "wl_text_input::leave", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::leave as it's not initialised"); - return; - } - send_leave( - m_resource->handle); - } - - void wl_text_input::send_leave(struct ::wl_resource *resource) - { - wl_text_input_send_leave( - resource); - } - - - void wl_text_input::send_modifiers_map(struct ::wl_array *map) - { - DS_ASSERT_X(m_resource, "wl_text_input::modifiers_map", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::modifiers_map as it's not initialised"); - return; - } - send_modifiers_map( - m_resource->handle, - map); - } - - void wl_text_input::send_modifiers_map(struct ::wl_resource *resource, struct ::wl_array *map) - { - wl_text_input_send_modifiers_map( - resource, - map); - } - - - void wl_text_input::send_input_panel_state(uint32_t state) - { - DS_ASSERT_X(m_resource, "wl_text_input::input_panel_state", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::input_panel_state as it's not initialised"); - return; - } - send_input_panel_state( - m_resource->handle, - state); - } - - void wl_text_input::send_input_panel_state(struct ::wl_resource *resource, uint32_t state) - { - wl_text_input_send_input_panel_state( - resource, - state); - } - - - void wl_text_input::send_preedit_string(uint32_t serial, const std::string &text, const std::string &commit) - { - DS_ASSERT_X(m_resource, "wl_text_input::preedit_string", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::preedit_string as it's not initialised"); - return; - } - send_preedit_string( - m_resource->handle, - serial, - text, - commit); - } - - void wl_text_input::send_preedit_string(struct ::wl_resource *resource, uint32_t serial, const std::string &text, const std::string &commit) - { - wl_text_input_send_preedit_string( - resource, - serial, - text.c_str(), - commit.c_str()); - } - - - void wl_text_input::send_preedit_styling(uint32_t index, uint32_t length, uint32_t style) - { - DS_ASSERT_X(m_resource, "wl_text_input::preedit_styling", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::preedit_styling as it's not initialised"); - return; - } - send_preedit_styling( - m_resource->handle, - index, - length, - style); - } - - void wl_text_input::send_preedit_styling(struct ::wl_resource *resource, uint32_t index, uint32_t length, uint32_t style) - { - wl_text_input_send_preedit_styling( - resource, - index, - length, - style); - } - - - void wl_text_input::send_preedit_cursor(int32_t index) - { - DS_ASSERT_X(m_resource, "wl_text_input::preedit_cursor", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::preedit_cursor as it's not initialised"); - return; - } - send_preedit_cursor( - m_resource->handle, - index); - } - - void wl_text_input::send_preedit_cursor(struct ::wl_resource *resource, int32_t index) - { - wl_text_input_send_preedit_cursor( - resource, - index); - } - - - void wl_text_input::send_commit_string(uint32_t serial, const std::string &text) - { - DS_ASSERT_X(m_resource, "wl_text_input::commit_string", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::commit_string as it's not initialised"); - return; - } - send_commit_string( - m_resource->handle, - serial, - text); - } - - void wl_text_input::send_commit_string(struct ::wl_resource *resource, uint32_t serial, const std::string &text) - { - wl_text_input_send_commit_string( - resource, - serial, - text.c_str()); - } - - - void wl_text_input::send_cursor_position(int32_t index, int32_t anchor) - { - DS_ASSERT_X(m_resource, "wl_text_input::cursor_position", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::cursor_position as it's not initialised"); - return; - } - send_cursor_position( - m_resource->handle, - index, - anchor); - } - - void wl_text_input::send_cursor_position(struct ::wl_resource *resource, int32_t index, int32_t anchor) - { - wl_text_input_send_cursor_position( - resource, - index, - anchor); - } - - - void wl_text_input::send_delete_surrounding_text(int32_t index, uint32_t length) - { - DS_ASSERT_X(m_resource, "wl_text_input::delete_surrounding_text", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::delete_surrounding_text as it's not initialised"); - return; - } - send_delete_surrounding_text( - m_resource->handle, - index, - length); - } - - void wl_text_input::send_delete_surrounding_text(struct ::wl_resource *resource, int32_t index, uint32_t length) - { - wl_text_input_send_delete_surrounding_text( - resource, - index, - length); - } - - - void wl_text_input::send_keysym(uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) - { - DS_ASSERT_X(m_resource, "wl_text_input::keysym", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::keysym as it's not initialised"); - return; - } - send_keysym( - m_resource->handle, - serial, - time, - sym, - state, - modifiers); - } - - void wl_text_input::send_keysym(struct ::wl_resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) - { - wl_text_input_send_keysym( - resource, - serial, - time, - sym, - state, - modifiers); - } - - - void wl_text_input::send_language(uint32_t serial, const std::string &language) - { - DS_ASSERT_X(m_resource, "wl_text_input::language", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::language as it's not initialised"); - return; - } - send_language( - m_resource->handle, - serial, - language); - } - - void wl_text_input::send_language(struct ::wl_resource *resource, uint32_t serial, const std::string &language) - { - wl_text_input_send_language( - resource, - serial, - language.c_str()); - } - - - void wl_text_input::send_text_direction(uint32_t serial, uint32_t direction) - { - DS_ASSERT_X(m_resource, "wl_text_input::text_direction", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::text_direction as it's not initialised"); - return; - } - send_text_direction( - m_resource->handle, - serial, - direction); - } - - void wl_text_input::send_text_direction(struct ::wl_resource *resource, uint32_t serial, uint32_t direction) - { - wl_text_input_send_text_direction( - resource, - serial, - direction); - } - - - void wl_text_input::send_selection_region(uint32_t serial, int32_t start, int32_t end) - { - DS_ASSERT_X(m_resource, "wl_text_input::selection_region", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::selection_region as it's not initialised"); - return; - } - send_selection_region( - m_resource->handle, - serial, - start, - end); - } - - void wl_text_input::send_selection_region(struct ::wl_resource *resource, uint32_t serial, int32_t start, int32_t end) - { - wl_text_input_send_selection_region( - resource, - serial, - start, - end); - } - - - void wl_text_input::send_private_command(uint32_t serial, const std::string &command) - { - DS_ASSERT_X(m_resource, "wl_text_input::private_command", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::private_command as it's not initialised"); - return; - } - send_private_command( - m_resource->handle, - serial, - command); - } - - void wl_text_input::send_private_command(struct ::wl_resource *resource, uint32_t serial, const std::string &command) - { - wl_text_input_send_private_command( - resource, - serial, - command.c_str()); - } - - - void wl_text_input::send_input_panel_geometry(uint32_t x, uint32_t y, uint32_t width, uint32_t height) - { - DS_ASSERT_X(m_resource, "wl_text_input::input_panel_geometry", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::input_panel_geometry as it's not initialised"); - return; - } - send_input_panel_geometry( - m_resource->handle, - x, - y, - width, - height); - } - - void wl_text_input::send_input_panel_geometry(struct ::wl_resource *resource, uint32_t x, uint32_t y, uint32_t width, uint32_t height) - { - wl_text_input_send_input_panel_geometry( - resource, - x, - y, - width, - height); - } - - - void wl_text_input::send_input_panel_data(uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length) - { - DS_ASSERT_X(m_resource, "wl_text_input::input_panel_data", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::input_panel_data as it's not initialised"); - return; - } - send_input_panel_data( - m_resource->handle, - serial, - input_panel_data, - input_panel_data_length); - } - - void wl_text_input::send_input_panel_data(struct ::wl_resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length) - { - wl_text_input_send_input_panel_data( - resource, - serial, - input_panel_data.c_str(), - input_panel_data_length); - } - - - void wl_text_input::send_get_selection_text(int32_t fd) - { - DS_ASSERT_X(m_resource, "wl_text_input::get_selection_text", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::get_selection_text as it's not initialised"); - return; - } - send_get_selection_text( - m_resource->handle, - fd); - } - - void wl_text_input::send_get_selection_text(struct ::wl_resource *resource, int32_t fd) - { - wl_text_input_send_get_selection_text( - resource, - fd); - } - - - void wl_text_input::send_get_surrounding_text(uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd) - { - DS_ASSERT_X(m_resource, "wl_text_input::get_surrounding_text", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::get_surrounding_text as it's not initialised"); - return; - } - send_get_surrounding_text( - m_resource->handle, - maxlen_before, - maxlen_after, - fd); - } - - void wl_text_input::send_get_surrounding_text(struct ::wl_resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd) - { - wl_text_input_send_get_surrounding_text( - resource, - maxlen_before, - maxlen_after, - fd); - } - - - void wl_text_input::send_filter_key_event_done(uint32_t serial, uint32_t state) - { - DS_ASSERT_X(m_resource, "wl_text_input::filter_key_event_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::filter_key_event_done as it's not initialised"); - return; - } - send_filter_key_event_done( - m_resource->handle, - serial, - state); - } - - void wl_text_input::send_filter_key_event_done(struct ::wl_resource *resource, uint32_t serial, uint32_t state) - { - wl_text_input_send_filter_key_event_done( - resource, - serial, - state); - } - - - void wl_text_input::send_hide_permission(uint32_t response) - { - DS_ASSERT_X(m_resource, "wl_text_input::hide_permission", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::hide_permission as it's not initialised"); - return; - } - send_hide_permission( - m_resource->handle, - response); - } - - void wl_text_input::send_hide_permission(struct ::wl_resource *resource, uint32_t response) - { - wl_text_input_send_hide_permission( - resource, - response); - } - - - void wl_text_input::send_recapture_string(uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit) - { - DS_ASSERT_X(m_resource, "wl_text_input::recapture_string", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::recapture_string as it's not initialised"); - return; - } - send_recapture_string( - m_resource->handle, - serial, - index, - length, - preedit, - preedit_commit, - commit); - } - - void wl_text_input::send_recapture_string(struct ::wl_resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit) - { - wl_text_input_send_recapture_string( - resource, - serial, - index, - length, - preedit.c_str(), - preedit_commit.c_str(), - commit.c_str()); - } - - - void wl_text_input::send_input_panel_event(uint32_t serial, uint32_t event_type, uint32_t value) - { - DS_ASSERT_X(m_resource, "wl_text_input::input_panel_event", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::input_panel_event as it's not initialised"); - return; - } - send_input_panel_event( - m_resource->handle, - serial, - event_type, - value); - } - - void wl_text_input::send_input_panel_event(struct ::wl_resource *resource, uint32_t serial, uint32_t event_type, uint32_t value) - { - wl_text_input_send_input_panel_event( - resource, - serial, - event_type, - value); - } - - - void wl_text_input::send_commit_content(uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types) - { - DS_ASSERT_X(m_resource, "wl_text_input::commit_content", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_text_input::commit_content as it's not initialised"); - return; - } - send_commit_content( - m_resource->handle, - serial, - content, - description, - mime_types); - } - - void wl_text_input::send_commit_content(struct ::wl_resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types) - { - wl_text_input_send_commit_content( - resource, - serial, - content.c_str(), - description.c_str(), - mime_types.c_str()); - } - - - wl_text_input_manager::wl_text_input_manager(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_text_input_manager::wl_text_input_manager(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_text_input_manager::wl_text_input_manager(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_text_input_manager::wl_text_input_manager() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_text_input_manager::~wl_text_input_manager() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_text_input_manager::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_text_input_manager::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_text_input_manager::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_text_input_manager::Resource *wl_text_input_manager::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_text_input_manager::Resource *wl_text_input_manager::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_text_input_manager::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_text_input_manager_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_text_input_manager::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_text_input_manager::interface() - { - return &::wl_text_input_manager_interface; - } - - wl_text_input_manager::Resource *wl_text_input_manager::text_input_manager_allocate() - { - return new Resource; - } - - void wl_text_input_manager::text_input_manager_bind_resource(Resource *) - { - } - - void wl_text_input_manager::text_input_manager_destroy_resource(Resource *) - { - } - - void wl_text_input_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_text_input_manager *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_text_input_manager::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_text_input_manager *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_text_input_manager::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_text_input_manager *that = resource->text_input_manager_object; - that->m_resource_map.erase(resource->client()); - that->text_input_manager_destroy_resource(resource); - delete resource; - } - - wl_text_input_manager::Resource *wl_text_input_manager::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_text_input_manager_interface, version, id); - return bind(handle); - } - - wl_text_input_manager::Resource *wl_text_input_manager::bind(struct ::wl_resource *handle) - { - Resource *resource = text_input_manager_allocate(); - resource->text_input_manager_object = this; - - wl_resource_set_implementation(handle, &m_wl_text_input_manager_interface, resource, destroy_func); - resource->handle = handle; - text_input_manager_bind_resource(resource); - return resource; - } - wl_text_input_manager::Resource *wl_text_input_manager::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_text_input_manager_interface, &m_wl_text_input_manager_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_text_input_manager_interface wl_text_input_manager::m_wl_text_input_manager_interface = { - wl_text_input_manager::handle_create_text_input - }; - - void wl_text_input_manager::text_input_manager_create_text_input(Resource *, uint32_t) - { - } - - - void wl_text_input_manager::handle_create_text_input( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->text_input_manager_object)->text_input_manager_create_text_input( - r, - id); - } -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-text.h b/src/DSWaylandServer/dswayland-server-text.h deleted file mode 100644 index 8f91aeb..0000000 --- a/src/DSWaylandServer/dswayland-server-text.h +++ /dev/null @@ -1,475 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/text.xml */ - -#ifndef __DS_TEXT_PROTOCOL_H__ -#define __DS_TEXT_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "text-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class wl_text_input - { - public: - wl_text_input(struct ::wl_client *client, uint32_t id, int version); - wl_text_input(struct ::wl_display *display, int version); - wl_text_input(struct ::wl_resource *resource); - wl_text_input(); - - virtual ~wl_text_input(); - - class Resource - { - public: - Resource() : text_input_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_text_input *text_input_object; - wl_text_input *object() { return text_input_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum content_hint { - content_hint_none = 0x0, // no special behaviour - content_hint_default = 0x7, // auto completion, correction and capitalization - content_hint_password = 0xc0, // hidden and sensitive text - content_hint_auto_completion = 0x1, // suggest word completions - content_hint_auto_correction = 0x2, // suggest word corrections - content_hint_auto_capitalization = 0x4, // switch to uppercase letters at the start of a sentence - content_hint_lowercase = 0x8, // prefer lowercase letters - content_hint_uppercase = 0x10, // prefer uppercase letters - content_hint_titlecase = 0x20, // prefer casing for titles and headings (can be language dependent) - content_hint_hidden_text = 0x40, // characters should be hidden - content_hint_sensitive_data = 0x80, // typed text should not be stored - content_hint_latin = 0x100, // just latin characters should be entered - content_hint_multiline = 0x200, // the text input is multiline - content_hint_word_capitalization = 0x400, // switch to uppercase letters at the start of a word - content_hint_autofill_credit_card_expiration_date = 0x10000, // autofilled with credit card expiration date - content_hint_autofill_credit_card_expiration_day = 0x20000, // autofilled with credit card expiration day - content_hint_autofill_credit_card_expiration_month = 0x30000, // autofilled with credit card expiration month - content_hint_autofill_credit_card_expiration_year = 0x40000, // autofilled with credit card expiration year - content_hint_autofill_credit_card_number = 0x50000, // autofilled with credit card number - content_hint_autofill_email_address = 0x60000, // autofilled with email address - content_hint_autofill_phone = 0x70000, // autofilled with phone number - content_hint_autofill_postal_address = 0x80000, // autofilled with postal address - content_hint_autofill_postal_code = 0x90000, // autofilled with postal code - content_hint_autofill_id = 0xA0000, // autofilled with id - content_hint_autofill_name = 0xB0000, // autofilled with name - }; - - enum content_purpose { - content_purpose_normal = 0, // default input, allowing all characters - content_purpose_alpha = 1, // allow only alphabetic characters - content_purpose_digits = 2, // allow only digits - content_purpose_number = 3, // input a number (including decimal separator and sign) - content_purpose_phone = 4, // input a phone number - content_purpose_url = 5, // input an URL - content_purpose_email = 6, // input an email address - content_purpose_name = 7, // input a name of a person - content_purpose_password = 8, // input a password (combine with password or sensitive_data hint) - content_purpose_date = 9, // input a date - content_purpose_time = 10, // input a time - content_purpose_datetime = 11, // input a date and time - content_purpose_terminal = 12, // input for a terminal - content_purpose_ip = 13, // input for a IP (number and a-f for Ipv6) - content_purpose_emoticon = 14, // input for an emoticon - content_purpose_digits_signed = 15, // allow digits and negative sign - content_purpose_digits_decimal = 16, // allow digits and decimal point - content_purpose_digits_signeddecimal = 17, // allow digits, negative sign and decimal point - content_purpose_password_digits = 18, // input a password with only digits - content_purpose_filename = 19, // default input for the name of a file (symbols such as '/' should be disabled) - content_purpose_hex = 20, // input for a hexadecimal - content_purpose_voice = 21, // input for a voice - }; - - enum return_key_type { - return_key_type_default = 0, // default - return_key_type_done = 1, // done - return_key_type_go = 2, // go - return_key_type_join = 3, // join - return_key_type_login = 4, // login - return_key_type_next = 5, // next - return_key_type_search = 6, // search - return_key_type_send = 7, // send - }; - - enum capital_mode { - capital_mode_uppercase = 0, // uppercase - capital_mode_lowercase = 1, // lowercase - }; - - enum input_panel_state { - input_panel_state_hide = 0, // Notification prior to the dismissal of the input panel - input_panel_state_show = 1, // Notification after the display of the input panel - }; - - enum preedit_style { - preedit_style_default = 0, // default style for composing text - preedit_style_none = 1, // style should be the same as in non-composing text - preedit_style_active = 2, - preedit_style_inactive = 3, - preedit_style_highlight = 4, - preedit_style_underline = 5, - preedit_style_selection = 6, - preedit_style_incorrect = 7, - preedit_style_reverse = 8, // Draw the text in reverse color mode - preedit_style_bgcolor1 = 9, // Draw the text in underline background 1 mode - preedit_style_bgcolor2 = 10, // Draw the text in underline background 2 mode - preedit_style_bgcolor3 = 11, // Draw the text in underline background 3 mode - preedit_style_bgcolor4 = 12, // Draw the text in underline background 4 mode - }; - - enum text_direction { - text_direction_auto = 0, // automatic text direction based on text and language - text_direction_ltr = 1, // left-to-right - text_direction_rtl = 2, // right-to-left - }; - - void send_enter(struct ::wl_resource *surface); - void send_enter(struct ::wl_resource *resource, struct ::wl_resource *surface); - void send_leave(); - void send_leave(struct ::wl_resource *resource); - void send_modifiers_map(struct ::wl_array *map); - void send_modifiers_map(struct ::wl_resource *resource, struct ::wl_array *map); - void send_input_panel_state(uint32_t state); - void send_input_panel_state(struct ::wl_resource *resource, uint32_t state); - void send_preedit_string(uint32_t serial, const std::string &text, const std::string &commit); - void send_preedit_string(struct ::wl_resource *resource, uint32_t serial, const std::string &text, const std::string &commit); - void send_preedit_styling(uint32_t index, uint32_t length, uint32_t style); - void send_preedit_styling(struct ::wl_resource *resource, uint32_t index, uint32_t length, uint32_t style); - void send_preedit_cursor(int32_t index); - void send_preedit_cursor(struct ::wl_resource *resource, int32_t index); - void send_commit_string(uint32_t serial, const std::string &text); - void send_commit_string(struct ::wl_resource *resource, uint32_t serial, const std::string &text); - void send_cursor_position(int32_t index, int32_t anchor); - void send_cursor_position(struct ::wl_resource *resource, int32_t index, int32_t anchor); - void send_delete_surrounding_text(int32_t index, uint32_t length); - void send_delete_surrounding_text(struct ::wl_resource *resource, int32_t index, uint32_t length); - void send_keysym(uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers); - void send_keysym(struct ::wl_resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers); - void send_language(uint32_t serial, const std::string &language); - void send_language(struct ::wl_resource *resource, uint32_t serial, const std::string &language); - void send_text_direction(uint32_t serial, uint32_t direction); - void send_text_direction(struct ::wl_resource *resource, uint32_t serial, uint32_t direction); - void send_selection_region(uint32_t serial, int32_t start, int32_t end); - void send_selection_region(struct ::wl_resource *resource, uint32_t serial, int32_t start, int32_t end); - void send_private_command(uint32_t serial, const std::string &command); - void send_private_command(struct ::wl_resource *resource, uint32_t serial, const std::string &command); - void send_input_panel_geometry(uint32_t x, uint32_t y, uint32_t width, uint32_t height); - void send_input_panel_geometry(struct ::wl_resource *resource, uint32_t x, uint32_t y, uint32_t width, uint32_t height); - void send_input_panel_data(uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length); - void send_input_panel_data(struct ::wl_resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length); - void send_get_selection_text(int32_t fd); - void send_get_selection_text(struct ::wl_resource *resource, int32_t fd); - void send_get_surrounding_text(uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd); - void send_get_surrounding_text(struct ::wl_resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd); - void send_filter_key_event_done(uint32_t serial, uint32_t state); - void send_filter_key_event_done(struct ::wl_resource *resource, uint32_t serial, uint32_t state); - void send_hide_permission(uint32_t response); - void send_hide_permission(struct ::wl_resource *resource, uint32_t response); - void send_recapture_string(uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit); - void send_recapture_string(struct ::wl_resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit); - void send_input_panel_event(uint32_t serial, uint32_t event_type, uint32_t value); - void send_input_panel_event(struct ::wl_resource *resource, uint32_t serial, uint32_t event_type, uint32_t value); - void send_commit_content(uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types); - void send_commit_content(struct ::wl_resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types); - - protected: - virtual Resource *text_input_allocate(); - - virtual void text_input_bind_resource(Resource *resource); - virtual void text_input_destroy_resource(Resource *resource); - - virtual void text_input_destroy(Resource *resource); - virtual void text_input_activate(Resource *resource, struct ::wl_resource *seat, struct ::wl_resource *surface); - virtual void text_input_deactivate(Resource *resource, struct ::wl_resource *seat); - virtual void text_input_show_input_panel(Resource *resource); - virtual void text_input_hide_input_panel(Resource *resource); - virtual void text_input_reset(Resource *resource); - virtual void text_input_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose); - virtual void text_input_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void text_input_set_preferred_language(Resource *resource, const std::string &language); - virtual void text_input_commit_state(Resource *resource, uint32_t serial); - virtual void text_input_invoke_action(Resource *resource, uint32_t button, uint32_t index); - virtual void text_input_set_return_key_type(Resource *resource, uint32_t return_key_type); - virtual void text_input_set_return_key_disabled(Resource *resource, uint32_t return_key_disabled); - virtual void text_input_set_input_panel_data(Resource *resource, const std::string &input_panel_data, uint32_t input_panel_length); - virtual void text_input_bidi_direction(Resource *resource, uint32_t direction); - virtual void text_input_set_cursor_position(Resource *resource, uint32_t cursor_position); - virtual void text_input_process_input_device_event(Resource *resource, uint32_t event_type, const std::string &event_data, uint32_t event_length); - virtual void text_input_filter_key_event(Resource *resource, uint32_t serial, uint32_t time, const std::string &keyname, uint32_t state, uint32_t modifiers, const std::string &dev_name, uint32_t dev_class, uint32_t dev_subclass, uint32_t keycode); - virtual void text_input_get_hide_permission(Resource *resource); - virtual void text_input_set_capital_mode(Resource *resource, uint32_t mode); - virtual void text_input_prediction_hint(Resource *resource, const std::string &text); - virtual void text_input_set_mime_type(Resource *resource, const std::string &type); - virtual void text_input_set_input_panel_position(Resource *resource, uint32_t x, uint32_t y); - virtual void text_input_finalize_content(Resource *resource, const std::string &text, uint32_t cursor_position); - virtual void text_input_prediction_hint_data(Resource *resource, const std::string &key, const std::string &value); - virtual void text_input_input_panel_enabled(Resource *resource, uint32_t enabled); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_text_input_interface m_wl_text_input_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_activate( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - struct ::wl_resource *surface); - static void handle_deactivate( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat); - static void handle_show_input_panel( - ::wl_client *client, - struct wl_resource *resource); - static void handle_hide_input_panel( - ::wl_client *client, - struct wl_resource *resource); - static void handle_reset( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_content_type( - ::wl_client *client, - struct wl_resource *resource, - uint32_t hint, - uint32_t purpose); - static void handle_set_cursor_rectangle( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_set_preferred_language( - ::wl_client *client, - struct wl_resource *resource, - const char *language); - static void handle_commit_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_invoke_action( - ::wl_client *client, - struct wl_resource *resource, - uint32_t button, - uint32_t index); - static void handle_set_return_key_type( - ::wl_client *client, - struct wl_resource *resource, - uint32_t return_key_type); - static void handle_set_return_key_disabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t return_key_disabled); - static void handle_set_input_panel_data( - ::wl_client *client, - struct wl_resource *resource, - const char *input_panel_data, - uint32_t input_panel_length); - static void handle_bidi_direction( - ::wl_client *client, - struct wl_resource *resource, - uint32_t direction); - static void handle_set_cursor_position( - ::wl_client *client, - struct wl_resource *resource, - uint32_t cursor_position); - static void handle_process_input_device_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_type, - const char *event_data, - uint32_t event_length); - static void handle_filter_key_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t time, - const char *keyname, - uint32_t state, - uint32_t modifiers, - const char *dev_name, - uint32_t dev_class, - uint32_t dev_subclass, - uint32_t keycode); - static void handle_get_hide_permission( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_capital_mode( - ::wl_client *client, - struct wl_resource *resource, - uint32_t mode); - static void handle_prediction_hint( - ::wl_client *client, - struct wl_resource *resource, - const char *text); - static void handle_set_mime_type( - ::wl_client *client, - struct wl_resource *resource, - const char *type); - static void handle_set_input_panel_position( - ::wl_client *client, - struct wl_resource *resource, - uint32_t x, - uint32_t y); - static void handle_finalize_content( - ::wl_client *client, - struct wl_resource *resource, - const char *text, - uint32_t cursor_position); - static void handle_prediction_hint_data( - ::wl_client *client, - struct wl_resource *resource, - const char *key, - const char *value); - static void handle_input_panel_enabled( - ::wl_client *client, - struct wl_resource *resource, - uint32_t enabled); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_text_input *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_text_input_manager - { - public: - wl_text_input_manager(struct ::wl_client *client, uint32_t id, int version); - wl_text_input_manager(struct ::wl_display *display, int version); - wl_text_input_manager(struct ::wl_resource *resource); - wl_text_input_manager(); - - virtual ~wl_text_input_manager(); - - class Resource - { - public: - Resource() : text_input_manager_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_text_input_manager *text_input_manager_object; - wl_text_input_manager *object() { return text_input_manager_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *text_input_manager_allocate(); - - virtual void text_input_manager_bind_resource(Resource *resource); - virtual void text_input_manager_destroy_resource(Resource *resource); - - virtual void text_input_manager_create_text_input(Resource *resource, uint32_t id); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_text_input_manager_interface m_wl_text_input_manager_interface; - - static void handle_create_text_input( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_text_input_manager *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-dpms.cpp b/src/DSWaylandServer/dswayland-server-tizen-dpms.cpp deleted file mode 100644 index b9ff7e0..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-dpms.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-dpms.xml */ - -#include "dswayland-server-tizen-dpms.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - tizen_dpms_manager::tizen_dpms_manager(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_dpms_manager::tizen_dpms_manager(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_dpms_manager::tizen_dpms_manager(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_dpms_manager::tizen_dpms_manager() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_dpms_manager::~tizen_dpms_manager() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_dpms_manager::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_dpms_manager::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_dpms_manager::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_dpms_manager::Resource *tizen_dpms_manager::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_dpms_manager::Resource *tizen_dpms_manager::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_dpms_manager::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_dpms_manager_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_dpms_manager::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_dpms_manager::interface() - { - return &::tizen_dpms_manager_interface; - } - - tizen_dpms_manager::Resource *tizen_dpms_manager::tizen_dpms_manager_allocate() - { - return new Resource; - } - - void tizen_dpms_manager::tizen_dpms_manager_bind_resource(Resource *) - { - } - - void tizen_dpms_manager::tizen_dpms_manager_destroy_resource(Resource *) - { - } - - void tizen_dpms_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_dpms_manager *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_dpms_manager::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_dpms_manager *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_dpms_manager::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_dpms_manager *that = resource->tizen_dpms_manager_object; - that->m_resource_map.erase(resource->client()); - that->tizen_dpms_manager_destroy_resource(resource); - delete resource; - } - - tizen_dpms_manager::Resource *tizen_dpms_manager::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_dpms_manager_interface, version, id); - return bind(handle); - } - - tizen_dpms_manager::Resource *tizen_dpms_manager::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_dpms_manager_allocate(); - resource->tizen_dpms_manager_object = this; - - wl_resource_set_implementation(handle, &m_tizen_dpms_manager_interface, resource, destroy_func); - resource->handle = handle; - tizen_dpms_manager_bind_resource(resource); - return resource; - } - tizen_dpms_manager::Resource *tizen_dpms_manager::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_dpms_manager_interface, &m_tizen_dpms_manager_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_dpms_manager_interface tizen_dpms_manager::m_tizen_dpms_manager_interface = { - tizen_dpms_manager::handle_destroy, - tizen_dpms_manager::handle_set_dpms, - tizen_dpms_manager::handle_get_dpms - }; - - void tizen_dpms_manager::tizen_dpms_manager_destroy(Resource *) - { - } - - void tizen_dpms_manager::tizen_dpms_manager_set_dpms(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_dpms_manager::tizen_dpms_manager_get_dpms(Resource *, struct ::wl_resource *) - { - } - - - void tizen_dpms_manager::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_dpms_manager_object)->tizen_dpms_manager_destroy( - r); - } - - void tizen_dpms_manager::handle_set_dpms( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output, - uint32_t mode) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_dpms_manager_object)->tizen_dpms_manager_set_dpms( - r, - output, - mode); - } - - void tizen_dpms_manager::handle_get_dpms( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_dpms_manager_object)->tizen_dpms_manager_get_dpms( - r, - output); - } - - void tizen_dpms_manager::send_set_state(uint32_t mode, uint32_t error) - { - DS_ASSERT_X(m_resource, "tizen_dpms_manager::set_state", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_dpms_manager::set_state as it's not initialised"); - return; - } - send_set_state( - m_resource->handle, - mode, - error); - } - - void tizen_dpms_manager::send_set_state(struct ::wl_resource *resource, uint32_t mode, uint32_t error) - { - tizen_dpms_manager_send_set_state( - resource, - mode, - error); - } - - - void tizen_dpms_manager::send_get_state(uint32_t mode, uint32_t error) - { - DS_ASSERT_X(m_resource, "tizen_dpms_manager::get_state", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_dpms_manager::get_state as it's not initialised"); - return; - } - send_get_state( - m_resource->handle, - mode, - error); - } - - void tizen_dpms_manager::send_get_state(struct ::wl_resource *resource, uint32_t mode, uint32_t error) - { - tizen_dpms_manager_send_get_state( - resource, - mode, - error); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-dpms.h b/src/DSWaylandServer/dswayland-server-tizen-dpms.h deleted file mode 100644 index 04894c6..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-dpms.h +++ /dev/null @@ -1,138 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-dpms.xml */ - -#ifndef __DS_TIZEN_DPMS_PROTOCOL_H__ -#define __DS_TIZEN_DPMS_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "tizen-dpms-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class tizen_dpms_manager - { - public: - tizen_dpms_manager(struct ::wl_client *client, uint32_t id, int version); - tizen_dpms_manager(struct ::wl_display *display, int version); - tizen_dpms_manager(struct ::wl_resource *resource); - tizen_dpms_manager(); - - virtual ~tizen_dpms_manager(); - - class Resource - { - public: - Resource() : tizen_dpms_manager_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_dpms_manager *tizen_dpms_manager_object; - tizen_dpms_manager *object() { return tizen_dpms_manager_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_none = 0, // no error - error_invalid_permission = 1, // Permission deny - error_invalid_parameter = 2, // Given parameter is invalid - error_not_supported = 3, // Given service is not supported. - error_already_done = 4, // Given request is already done. - }; - - enum mode { - mode_on = 0, // DPMS ON - mode_standby = 1, // DPMS STANDBY - mode_suspend = 2, // DPMS SUSPEND - mode_off = 3, // DPMS OFF - }; - - void send_set_state(uint32_t mode, uint32_t error); - void send_set_state(struct ::wl_resource *resource, uint32_t mode, uint32_t error); - void send_get_state(uint32_t mode, uint32_t error); - void send_get_state(struct ::wl_resource *resource, uint32_t mode, uint32_t error); - - protected: - virtual Resource *tizen_dpms_manager_allocate(); - - virtual void tizen_dpms_manager_bind_resource(Resource *resource); - virtual void tizen_dpms_manager_destroy_resource(Resource *resource); - - virtual void tizen_dpms_manager_destroy(Resource *resource); - virtual void tizen_dpms_manager_set_dpms(Resource *resource, struct ::wl_resource *output, uint32_t mode); - virtual void tizen_dpms_manager_get_dpms(Resource *resource, struct ::wl_resource *output); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_dpms_manager_interface m_tizen_dpms_manager_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_dpms( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output, - uint32_t mode); - static void handle_get_dpms( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_dpms_manager *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-extension.cpp b/src/DSWaylandServer/dswayland-server-tizen-extension.cpp deleted file mode 100644 index 499087a..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-extension.cpp +++ /dev/null @@ -1,8399 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-extension.xml */ - -#include "dswayland-server-tizen-extension.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - tizen_surface::tizen_surface(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_surface::tizen_surface(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_surface::tizen_surface(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_surface::tizen_surface() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_surface::~tizen_surface() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_surface::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_surface::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_surface::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_surface::Resource *tizen_surface::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_surface::Resource *tizen_surface::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_surface::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_surface_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_surface::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_surface::interface() - { - return &::tizen_surface_interface; - } - - tizen_surface::Resource *tizen_surface::tizen_surface_allocate() - { - return new Resource; - } - - void tizen_surface::tizen_surface_bind_resource(Resource *) - { - } - - void tizen_surface::tizen_surface_destroy_resource(Resource *) - { - } - - void tizen_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_surface *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_surface::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_surface *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_surface::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_surface *that = resource->tizen_surface_object; - that->m_resource_map.erase(resource->client()); - that->tizen_surface_destroy_resource(resource); - delete resource; - } - - tizen_surface::Resource *tizen_surface::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_surface_interface, version, id); - return bind(handle); - } - - tizen_surface::Resource *tizen_surface::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_surface_allocate(); - resource->tizen_surface_object = this; - - wl_resource_set_implementation(handle, &m_tizen_surface_interface, resource, destroy_func); - resource->handle = handle; - tizen_surface_bind_resource(resource); - return resource; - } - tizen_surface::Resource *tizen_surface::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_surface_interface, &m_tizen_surface_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_surface_interface tizen_surface::m_tizen_surface_interface = { - tizen_surface::handle_get_tizen_resource, - tizen_surface::handle_destroy - }; - - void tizen_surface::tizen_surface_get_tizen_resource(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_surface::tizen_surface_destroy(Resource *) - { - } - - - void tizen_surface::handle_get_tizen_resource( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_surface_object)->tizen_surface_get_tizen_resource( - r, - id, - surface); - } - - void tizen_surface::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_surface_object)->tizen_surface_destroy( - r); - } - - tizen_resource::tizen_resource(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_resource::tizen_resource(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_resource::tizen_resource(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_resource::tizen_resource() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_resource::~tizen_resource() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_resource::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_resource::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_resource::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_resource::Resource *tizen_resource::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_resource::Resource *tizen_resource::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_resource::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_resource_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_resource::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_resource::interface() - { - return &::tizen_resource_interface; - } - - tizen_resource::Resource *tizen_resource::tizen_resource_allocate() - { - return new Resource; - } - - void tizen_resource::tizen_resource_bind_resource(Resource *) - { - } - - void tizen_resource::tizen_resource_destroy_resource(Resource *) - { - } - - void tizen_resource::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_resource *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_resource::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_resource *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_resource::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_resource *that = resource->tizen_resource_object; - that->m_resource_map.erase(resource->client()); - that->tizen_resource_destroy_resource(resource); - delete resource; - } - - tizen_resource::Resource *tizen_resource::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_resource_interface, version, id); - return bind(handle); - } - - tizen_resource::Resource *tizen_resource::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_resource_allocate(); - resource->tizen_resource_object = this; - - wl_resource_set_implementation(handle, &m_tizen_resource_interface, resource, destroy_func); - resource->handle = handle; - tizen_resource_bind_resource(resource); - return resource; - } - tizen_resource::Resource *tizen_resource::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_resource_interface, &m_tizen_resource_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_resource_interface tizen_resource::m_tizen_resource_interface = { - tizen_resource::handle_destroy - }; - - void tizen_resource::tizen_resource_destroy(Resource *) - { - } - - - void tizen_resource::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_resource_object)->tizen_resource_destroy( - r); - } - - void tizen_resource::send_resource_id(uint32_t id) - { - DS_ASSERT_X(m_resource, "tizen_resource::resource_id", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_resource::resource_id as it's not initialised"); - return; - } - send_resource_id( - m_resource->handle, - id); - } - - void tizen_resource::send_resource_id(struct ::wl_resource *resource, uint32_t id) - { - tizen_resource_send_resource_id( - resource, - id); - } - - - tizen_policy::tizen_policy(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_policy::tizen_policy(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_policy::tizen_policy(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_policy::tizen_policy() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_policy::~tizen_policy() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_policy::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_policy::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_policy::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_policy::Resource *tizen_policy::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_policy::Resource *tizen_policy::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_policy::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_policy_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_policy::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_policy::interface() - { - return &::tizen_policy_interface; - } - - tizen_policy::Resource *tizen_policy::tizen_policy_allocate() - { - return new Resource; - } - - void tizen_policy::tizen_policy_bind_resource(Resource *) - { - } - - void tizen_policy::tizen_policy_destroy_resource(Resource *) - { - } - - void tizen_policy::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_policy *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_policy::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_policy *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_policy::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_policy *that = resource->tizen_policy_object; - that->m_resource_map.erase(resource->client()); - that->tizen_policy_destroy_resource(resource); - delete resource; - } - - tizen_policy::Resource *tizen_policy::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_policy_interface, version, id); - return bind(handle); - } - - tizen_policy::Resource *tizen_policy::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_policy_allocate(); - resource->tizen_policy_object = this; - - wl_resource_set_implementation(handle, &m_tizen_policy_interface, resource, destroy_func); - resource->handle = handle; - tizen_policy_bind_resource(resource); - return resource; - } - tizen_policy::Resource *tizen_policy::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_policy_interface, &m_tizen_policy_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_policy_interface tizen_policy::m_tizen_policy_interface = { - tizen_policy::handle_get_visibility, - tizen_policy::handle_get_position, - tizen_policy::handle_activate, - tizen_policy::handle_activate_below_by_res_id, - tizen_policy::handle_raise, - tizen_policy::handle_lower, - tizen_policy::handle_lower_by_res_id, - tizen_policy::handle_set_focus_skip, - tizen_policy::handle_unset_focus_skip, - tizen_policy::handle_set_role, - tizen_policy::handle_set_type, - tizen_policy::handle_set_conformant, - tizen_policy::handle_unset_conformant, - tizen_policy::handle_get_conformant, - tizen_policy::handle_set_notification_level, - tizen_policy::handle_set_transient_for, - tizen_policy::handle_unset_transient_for, - tizen_policy::handle_set_window_screen_mode, - tizen_policy::handle_place_subsurface_below_parent, - tizen_policy::handle_set_subsurface_stand_alone, - tizen_policy::handle_get_subsurface, - tizen_policy::handle_set_opaque_state, - tizen_policy::handle_iconify, - tizen_policy::handle_uniconify, - tizen_policy::handle_add_aux_hint, - tizen_policy::handle_change_aux_hint, - tizen_policy::handle_del_aux_hint, - tizen_policy::handle_get_supported_aux_hints, - tizen_policy::handle_set_background_state, - tizen_policy::handle_unset_background_state, - tizen_policy::handle_set_floating_mode, - tizen_policy::handle_unset_floating_mode, - tizen_policy::handle_set_stack_mode, - tizen_policy::handle_activate_above_by_res_id, - tizen_policy::handle_get_subsurface_watcher, - tizen_policy::handle_set_parent, - tizen_policy::handle_ack_conformant_region, - tizen_policy::handle_destroy, - tizen_policy::handle_has_video, - tizen_policy::handle_set_appid, - tizen_policy::handle_show, - tizen_policy::handle_hide, - tizen_policy::handle_set_transient_for_below, - tizen_policy::handle_set_parent_with_below - }; - - void tizen_policy::tizen_policy_get_visibility(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_get_position(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_activate(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_activate_below_by_res_id(Resource *, uint32_t , uint32_t ) - { - } - - void tizen_policy::tizen_policy_raise(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_lower(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_lower_by_res_id(Resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_set_focus_skip(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_unset_focus_skip(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_set_role(Resource *, struct ::wl_resource *, const std::string &) - { - } - - void tizen_policy::tizen_policy_set_type(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_set_conformant(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_unset_conformant(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_get_conformant(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_set_notification_level(Resource *, struct ::wl_resource *, int32_t ) - { - } - - void tizen_policy::tizen_policy_set_transient_for(Resource *, uint32_t , uint32_t ) - { - } - - void tizen_policy::tizen_policy_unset_transient_for(Resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_set_window_screen_mode(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_place_subsurface_below_parent(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_set_subsurface_stand_alone(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_get_subsurface(Resource *, uint32_t, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_set_opaque_state(Resource *, struct ::wl_resource *, int32_t ) - { - } - - void tizen_policy::tizen_policy_iconify(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_uniconify(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_add_aux_hint(Resource *, struct ::wl_resource *, int32_t , const std::string &, const std::string &) - { - } - - void tizen_policy::tizen_policy_change_aux_hint(Resource *, struct ::wl_resource *, int32_t , const std::string &) - { - } - - void tizen_policy::tizen_policy_del_aux_hint(Resource *, struct ::wl_resource *, int32_t ) - { - } - - void tizen_policy::tizen_policy_get_supported_aux_hints(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_set_background_state(Resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_unset_background_state(Resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_set_floating_mode(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_unset_floating_mode(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_set_stack_mode(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_activate_above_by_res_id(Resource *, uint32_t , uint32_t ) - { - } - - void tizen_policy::tizen_policy_get_subsurface_watcher(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_set_parent(Resource *, struct ::wl_resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_ack_conformant_region(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_destroy(Resource *) - { - } - - void tizen_policy::tizen_policy_has_video(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_policy::tizen_policy_set_appid(Resource *, int32_t , const std::string &) - { - } - - void tizen_policy::tizen_policy_show(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_hide(Resource *, struct ::wl_resource *) - { - } - - void tizen_policy::tizen_policy_set_transient_for_below(Resource *, uint32_t , uint32_t ) - { - } - - void tizen_policy::tizen_policy_set_parent_with_below(Resource *, struct ::wl_resource *, struct ::wl_resource *) - { - } - - - void tizen_policy::handle_get_visibility( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_get_visibility( - r, - id, - surface); - } - - void tizen_policy::handle_get_position( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_get_position( - r, - id, - surface); - } - - void tizen_policy::handle_activate( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_activate( - r, - surface); - } - - void tizen_policy::handle_activate_below_by_res_id( - ::wl_client *client, - struct wl_resource *resource, - uint32_t res_id, - uint32_t below_res_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_activate_below_by_res_id( - r, - res_id, - below_res_id); - } - - void tizen_policy::handle_raise( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_raise( - r, - surface); - } - - void tizen_policy::handle_lower( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_lower( - r, - surface); - } - - void tizen_policy::handle_lower_by_res_id( - ::wl_client *client, - struct wl_resource *resource, - uint32_t res_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_lower_by_res_id( - r, - res_id); - } - - void tizen_policy::handle_set_focus_skip( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_focus_skip( - r, - surface); - } - - void tizen_policy::handle_unset_focus_skip( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_unset_focus_skip( - r, - surface); - } - - void tizen_policy::handle_set_role( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - const char *role) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_role( - r, - surface, - std::string(role)); - } - - void tizen_policy::handle_set_type( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t win_type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_type( - r, - surface, - win_type); - } - - void tizen_policy::handle_set_conformant( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_conformant( - r, - surface); - } - - void tizen_policy::handle_unset_conformant( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_unset_conformant( - r, - surface); - } - - void tizen_policy::handle_get_conformant( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_get_conformant( - r, - surface); - } - - void tizen_policy::handle_set_notification_level( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t level) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_notification_level( - r, - surface, - level); - } - - void tizen_policy::handle_set_transient_for( - ::wl_client *client, - struct wl_resource *resource, - uint32_t child_id, - uint32_t parent_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_transient_for( - r, - child_id, - parent_id); - } - - void tizen_policy::handle_unset_transient_for( - ::wl_client *client, - struct wl_resource *resource, - uint32_t child_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_unset_transient_for( - r, - child_id); - } - - void tizen_policy::handle_set_window_screen_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t mode) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_window_screen_mode( - r, - surface, - mode); - } - - void tizen_policy::handle_place_subsurface_below_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *subsurface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_place_subsurface_below_parent( - r, - subsurface); - } - - void tizen_policy::handle_set_subsurface_stand_alone( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *subsurface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_subsurface_stand_alone( - r, - subsurface); - } - - void tizen_policy::handle_get_subsurface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface, - uint32_t parent_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_get_subsurface( - r, - id, - surface, - parent_id); - } - - void tizen_policy::handle_set_opaque_state( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_opaque_state( - r, - surface, - state); - } - - void tizen_policy::handle_iconify( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_iconify( - r, - surface); - } - - void tizen_policy::handle_uniconify( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_uniconify( - r, - surface); - } - - void tizen_policy::handle_add_aux_hint( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t id, - const char *name, - const char *value) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_add_aux_hint( - r, - surface, - id, - std::string(name), - std::string(value)); - } - - void tizen_policy::handle_change_aux_hint( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t id, - const char *value) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_change_aux_hint( - r, - surface, - id, - std::string(value)); - } - - void tizen_policy::handle_del_aux_hint( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_del_aux_hint( - r, - surface, - id); - } - - void tizen_policy::handle_get_supported_aux_hints( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_get_supported_aux_hints( - r, - surface); - } - - void tizen_policy::handle_set_background_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_background_state( - r, - pid); - } - - void tizen_policy::handle_unset_background_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_unset_background_state( - r, - pid); - } - - void tizen_policy::handle_set_floating_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_floating_mode( - r, - surface); - } - - void tizen_policy::handle_unset_floating_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_unset_floating_mode( - r, - surface); - } - - void tizen_policy::handle_set_stack_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t mode) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_stack_mode( - r, - surface, - mode); - } - - void tizen_policy::handle_activate_above_by_res_id( - ::wl_client *client, - struct wl_resource *resource, - uint32_t res_id, - uint32_t above_res_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_activate_above_by_res_id( - r, - res_id, - above_res_id); - } - - void tizen_policy::handle_get_subsurface_watcher( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_get_subsurface_watcher( - r, - id, - surface); - } - - void tizen_policy::handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *child, - struct ::wl_resource *parent) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_parent( - r, - child, - parent); - } - - void tizen_policy::handle_ack_conformant_region( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_ack_conformant_region( - r, - surface, - serial); - } - - void tizen_policy::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_destroy( - r); - } - - void tizen_policy::handle_has_video( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t has) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_has_video( - r, - surface, - has); - } - - void tizen_policy::handle_set_appid( - ::wl_client *client, - struct wl_resource *resource, - int32_t pid, - const char *appid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_appid( - r, - pid, - std::string(appid)); - } - - void tizen_policy::handle_show( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_show( - r, - surface); - } - - void tizen_policy::handle_hide( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_hide( - r, - surface); - } - - void tizen_policy::handle_set_transient_for_below( - ::wl_client *client, - struct wl_resource *resource, - uint32_t child_id, - uint32_t parent_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_transient_for_below( - r, - child_id, - parent_id); - } - - void tizen_policy::handle_set_parent_with_below( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *child, - struct ::wl_resource *parent) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_object)->tizen_policy_set_parent_with_below( - r, - child, - parent); - } - - void tizen_policy::send_conformant(struct ::wl_resource *surface, uint32_t is_conformant) - { - DS_ASSERT_X(m_resource, "tizen_policy::conformant", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::conformant as it's not initialised"); - return; - } - send_conformant( - m_resource->handle, - surface, - is_conformant); - } - - void tizen_policy::send_conformant(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t is_conformant) - { - tizen_policy_send_conformant( - resource, - surface, - is_conformant); - } - - - void tizen_policy::send_conformant_area(struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h) - { - DS_ASSERT_X(m_resource, "tizen_policy::conformant_area", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::conformant_area as it's not initialised"); - return; - } - send_conformant_area( - m_resource->handle, - surface, - conformant_part, - state, - x, - y, - w, - h); - } - - void tizen_policy::send_conformant_area(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h) - { - tizen_policy_send_conformant_area( - resource, - surface, - conformant_part, - state, - x, - y, - w, - h); - } - - - void tizen_policy::send_notification_done(struct ::wl_resource *surface, int32_t level, uint32_t error_state) - { - DS_ASSERT_X(m_resource, "tizen_policy::notification_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::notification_done as it's not initialised"); - return; - } - send_notification_done( - m_resource->handle, - surface, - level, - error_state); - } - - void tizen_policy::send_notification_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t level, uint32_t error_state) - { - tizen_policy_send_notification_done( - resource, - surface, - level, - error_state); - } - - - void tizen_policy::send_transient_for_done(uint32_t child_id) - { - DS_ASSERT_X(m_resource, "tizen_policy::transient_for_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::transient_for_done as it's not initialised"); - return; - } - send_transient_for_done( - m_resource->handle, - child_id); - } - - void tizen_policy::send_transient_for_done(struct ::wl_resource *resource, uint32_t child_id) - { - tizen_policy_send_transient_for_done( - resource, - child_id); - } - - - void tizen_policy::send_window_screen_mode_done(struct ::wl_resource *surface, uint32_t mode, uint32_t error_state) - { - DS_ASSERT_X(m_resource, "tizen_policy::window_screen_mode_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::window_screen_mode_done as it's not initialised"); - return; - } - send_window_screen_mode_done( - m_resource->handle, - surface, - mode, - error_state); - } - - void tizen_policy::send_window_screen_mode_done(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t mode, uint32_t error_state) - { - tizen_policy_send_window_screen_mode_done( - resource, - surface, - mode, - error_state); - } - - - void tizen_policy::send_iconify_state_changed(struct ::wl_resource *surface, uint32_t iconified, uint32_t force) - { - DS_ASSERT_X(m_resource, "tizen_policy::iconify_state_changed", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::iconify_state_changed as it's not initialised"); - return; - } - send_iconify_state_changed( - m_resource->handle, - surface, - iconified, - force); - } - - void tizen_policy::send_iconify_state_changed(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t iconified, uint32_t force) - { - tizen_policy_send_iconify_state_changed( - resource, - surface, - iconified, - force); - } - - - void tizen_policy::send_supported_aux_hints(struct ::wl_resource *surface, struct ::wl_array *hints, uint32_t num_hints) - { - DS_ASSERT_X(m_resource, "tizen_policy::supported_aux_hints", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::supported_aux_hints as it's not initialised"); - return; - } - send_supported_aux_hints( - m_resource->handle, - surface, - hints, - num_hints); - } - - void tizen_policy::send_supported_aux_hints(struct ::wl_resource *resource, struct ::wl_resource *surface, struct ::wl_array *hints, uint32_t num_hints) - { - tizen_policy_send_supported_aux_hints( - resource, - surface, - hints, - num_hints); - } - - - void tizen_policy::send_allowed_aux_hint(struct ::wl_resource *surface, int32_t id) - { - DS_ASSERT_X(m_resource, "tizen_policy::allowed_aux_hint", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::allowed_aux_hint as it's not initialised"); - return; - } - send_allowed_aux_hint( - m_resource->handle, - surface, - id); - } - - void tizen_policy::send_allowed_aux_hint(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t id) - { - tizen_policy_send_allowed_aux_hint( - resource, - surface, - id); - } - - - void tizen_policy::send_aux_message(struct ::wl_resource *surface, const std::string &key, const std::string &value, struct ::wl_array *options) - { - DS_ASSERT_X(m_resource, "tizen_policy::aux_message", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::aux_message as it's not initialised"); - return; - } - send_aux_message( - m_resource->handle, - surface, - key, - value, - options); - } - - void tizen_policy::send_aux_message(struct ::wl_resource *resource, struct ::wl_resource *surface, const std::string &key, const std::string &value, struct ::wl_array *options) - { - tizen_policy_send_aux_message( - resource, - surface, - key.c_str(), - value.c_str(), - options); - } - - - void tizen_policy::send_conformant_region(struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial) - { - DS_ASSERT_X(m_resource, "tizen_policy::conformant_region", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::conformant_region as it's not initialised"); - return; - } - send_conformant_region( - m_resource->handle, - surface, - conformant_part, - state, - x, - y, - w, - h, - serial); - } - - void tizen_policy::send_conformant_region(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial) - { - tizen_policy_send_conformant_region( - resource, - surface, - conformant_part, - state, - x, - y, - w, - h, - serial); - } - - - void tizen_policy::send_interactive_move_done(struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h) - { - DS_ASSERT_X(m_resource, "tizen_policy::interactive_move_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::interactive_move_done as it's not initialised"); - return; - } - send_interactive_move_done( - m_resource->handle, - surface, - x, - y, - w, - h); - } - - void tizen_policy::send_interactive_move_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h) - { - tizen_policy_send_interactive_move_done( - resource, - surface, - x, - y, - w, - h); - } - - - void tizen_policy::send_interactive_resize_done(struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h) - { - DS_ASSERT_X(m_resource, "tizen_policy::interactive_resize_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy::interactive_resize_done as it's not initialised"); - return; - } - send_interactive_resize_done( - m_resource->handle, - surface, - x, - y, - w, - h); - } - - void tizen_policy::send_interactive_resize_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h) - { - tizen_policy_send_interactive_resize_done( - resource, - surface, - x, - y, - w, - h); - } - - - tizen_visibility::tizen_visibility(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_visibility::tizen_visibility(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_visibility::tizen_visibility(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_visibility::tizen_visibility() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_visibility::~tizen_visibility() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_visibility::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_visibility::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_visibility::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_visibility::Resource *tizen_visibility::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_visibility::Resource *tizen_visibility::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_visibility::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_visibility_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_visibility::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_visibility::interface() - { - return &::tizen_visibility_interface; - } - - tizen_visibility::Resource *tizen_visibility::tizen_visibility_allocate() - { - return new Resource; - } - - void tizen_visibility::tizen_visibility_bind_resource(Resource *) - { - } - - void tizen_visibility::tizen_visibility_destroy_resource(Resource *) - { - } - - void tizen_visibility::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_visibility *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_visibility::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_visibility *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_visibility::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_visibility *that = resource->tizen_visibility_object; - that->m_resource_map.erase(resource->client()); - that->tizen_visibility_destroy_resource(resource); - delete resource; - } - - tizen_visibility::Resource *tizen_visibility::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_visibility_interface, version, id); - return bind(handle); - } - - tizen_visibility::Resource *tizen_visibility::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_visibility_allocate(); - resource->tizen_visibility_object = this; - - wl_resource_set_implementation(handle, &m_tizen_visibility_interface, resource, destroy_func); - resource->handle = handle; - tizen_visibility_bind_resource(resource); - return resource; - } - tizen_visibility::Resource *tizen_visibility::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_visibility_interface, &m_tizen_visibility_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_visibility_interface tizen_visibility::m_tizen_visibility_interface = { - tizen_visibility::handle_destroy - }; - - void tizen_visibility::tizen_visibility_destroy(Resource *) - { - } - - - void tizen_visibility::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_visibility_object)->tizen_visibility_destroy( - r); - } - - void tizen_visibility::send_notify(uint32_t visibility) - { - DS_ASSERT_X(m_resource, "tizen_visibility::notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_visibility::notify as it's not initialised"); - return; - } - send_notify( - m_resource->handle, - visibility); - } - - void tizen_visibility::send_notify(struct ::wl_resource *resource, uint32_t visibility) - { - tizen_visibility_send_notify( - resource, - visibility); - } - - - void tizen_visibility::send_changed(uint32_t type, uint32_t option) - { - DS_ASSERT_X(m_resource, "tizen_visibility::changed", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_visibility::changed as it's not initialised"); - return; - } - send_changed( - m_resource->handle, - type, - option); - } - - void tizen_visibility::send_changed(struct ::wl_resource *resource, uint32_t type, uint32_t option) - { - tizen_visibility_send_changed( - resource, - type, - option); - } - - - tizen_position::tizen_position(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_position::tizen_position(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_position::tizen_position(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_position::tizen_position() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_position::~tizen_position() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_position::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_position::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_position::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_position::Resource *tizen_position::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_position::Resource *tizen_position::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_position::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_position_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_position::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_position::interface() - { - return &::tizen_position_interface; - } - - tizen_position::Resource *tizen_position::tizen_position_allocate() - { - return new Resource; - } - - void tizen_position::tizen_position_bind_resource(Resource *) - { - } - - void tizen_position::tizen_position_destroy_resource(Resource *) - { - } - - void tizen_position::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_position *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_position::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_position *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_position::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_position *that = resource->tizen_position_object; - that->m_resource_map.erase(resource->client()); - that->tizen_position_destroy_resource(resource); - delete resource; - } - - tizen_position::Resource *tizen_position::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_position_interface, version, id); - return bind(handle); - } - - tizen_position::Resource *tizen_position::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_position_allocate(); - resource->tizen_position_object = this; - - wl_resource_set_implementation(handle, &m_tizen_position_interface, resource, destroy_func); - resource->handle = handle; - tizen_position_bind_resource(resource); - return resource; - } - tizen_position::Resource *tizen_position::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_position_interface, &m_tizen_position_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_position_interface tizen_position::m_tizen_position_interface = { - tizen_position::handle_destroy, - tizen_position::handle_set - }; - - void tizen_position::tizen_position_destroy(Resource *) - { - } - - void tizen_position::tizen_position_set(Resource *, int32_t , int32_t ) - { - } - - - void tizen_position::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_position_object)->tizen_position_destroy( - r); - } - - void tizen_position::handle_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_position_object)->tizen_position_set( - r, - x, - y); - } - - void tizen_position::send_changed(int32_t x, int32_t y) - { - DS_ASSERT_X(m_resource, "tizen_position::changed", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_position::changed as it's not initialised"); - return; - } - send_changed( - m_resource->handle, - x, - y); - } - - void tizen_position::send_changed(struct ::wl_resource *resource, int32_t x, int32_t y) - { - tizen_position_send_changed( - resource, - x, - y); - } - - - tizen_move_resize::tizen_move_resize(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_move_resize::tizen_move_resize(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_move_resize::tizen_move_resize(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_move_resize::tizen_move_resize() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_move_resize::~tizen_move_resize() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_move_resize::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_move_resize::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_move_resize::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_move_resize::Resource *tizen_move_resize::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_move_resize::Resource *tizen_move_resize::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_move_resize::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_move_resize_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_move_resize::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_move_resize::interface() - { - return &::tizen_move_resize_interface; - } - - tizen_move_resize::Resource *tizen_move_resize::tizen_move_resize_allocate() - { - return new Resource; - } - - void tizen_move_resize::tizen_move_resize_bind_resource(Resource *) - { - } - - void tizen_move_resize::tizen_move_resize_destroy_resource(Resource *) - { - } - - void tizen_move_resize::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_move_resize *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_move_resize::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_move_resize *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_move_resize::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_move_resize *that = resource->tizen_move_resize_object; - that->m_resource_map.erase(resource->client()); - that->tizen_move_resize_destroy_resource(resource); - delete resource; - } - - tizen_move_resize::Resource *tizen_move_resize::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_move_resize_interface, version, id); - return bind(handle); - } - - tizen_move_resize::Resource *tizen_move_resize::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_move_resize_allocate(); - resource->tizen_move_resize_object = this; - - wl_resource_set_implementation(handle, &m_tizen_move_resize_interface, resource, destroy_func); - resource->handle = handle; - tizen_move_resize_bind_resource(resource); - return resource; - } - tizen_move_resize::Resource *tizen_move_resize::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_move_resize_interface, &m_tizen_move_resize_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_move_resize_interface tizen_move_resize::m_tizen_move_resize_interface = { - tizen_move_resize::handle_destroy, - tizen_move_resize::handle_set_geometry - }; - - void tizen_move_resize::tizen_move_resize_destroy(Resource *) - { - } - - void tizen_move_resize::tizen_move_resize_set_geometry(Resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t , int32_t , int32_t ) - { - } - - - void tizen_move_resize::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_move_resize_object)->tizen_move_resize_destroy( - r); - } - - void tizen_move_resize::handle_set_geometry( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t serial, - int32_t x, - int32_t y, - int32_t w, - int32_t h) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_move_resize_object)->tizen_move_resize_set_geometry( - r, - surface, - serial, - x, - y, - w, - h); - } - - void tizen_move_resize::send_geometry_done(struct ::wl_resource *surface, uint32_t serial, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t error_state) - { - DS_ASSERT_X(m_resource, "tizen_move_resize::geometry_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_move_resize::geometry_done as it's not initialised"); - return; - } - send_geometry_done( - m_resource->handle, - surface, - serial, - x, - y, - w, - h, - error_state); - } - - void tizen_move_resize::send_geometry_done(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t serial, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t error_state) - { - tizen_move_resize_send_geometry_done( - resource, - surface, - serial, - x, - y, - w, - h, - error_state); - } - - - tizen_gesture::tizen_gesture(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_gesture::tizen_gesture(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_gesture::tizen_gesture(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_gesture::tizen_gesture() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_gesture::~tizen_gesture() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_gesture::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_gesture::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_gesture::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_gesture::Resource *tizen_gesture::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_gesture::Resource *tizen_gesture::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_gesture::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_gesture_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_gesture::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_gesture::interface() - { - return &::tizen_gesture_interface; - } - - tizen_gesture::Resource *tizen_gesture::tizen_gesture_allocate() - { - return new Resource; - } - - void tizen_gesture::tizen_gesture_bind_resource(Resource *) - { - } - - void tizen_gesture::tizen_gesture_destroy_resource(Resource *) - { - } - - void tizen_gesture::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_gesture *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_gesture::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_gesture *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_gesture::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_gesture *that = resource->tizen_gesture_object; - that->m_resource_map.erase(resource->client()); - that->tizen_gesture_destroy_resource(resource); - delete resource; - } - - tizen_gesture::Resource *tizen_gesture::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_gesture_interface, version, id); - return bind(handle); - } - - tizen_gesture::Resource *tizen_gesture::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_gesture_allocate(); - resource->tizen_gesture_object = this; - - wl_resource_set_implementation(handle, &m_tizen_gesture_interface, resource, destroy_func); - resource->handle = handle; - tizen_gesture_bind_resource(resource); - return resource; - } - tizen_gesture::Resource *tizen_gesture::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_gesture_interface, &m_tizen_gesture_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_gesture_interface tizen_gesture::m_tizen_gesture_interface = { - tizen_gesture::handle_grab_edge_swipe, - tizen_gesture::handle_ungrab_edge_swipe, - tizen_gesture::handle_grab_edge_drag, - tizen_gesture::handle_ungrab_edge_drag, - tizen_gesture::handle_grab_tap, - tizen_gesture::handle_ungrab_tap, - tizen_gesture::handle_grab_palm_cover, - tizen_gesture::handle_ungrab_palm_cover, - tizen_gesture::handle_select_palm_cover, - tizen_gesture::handle_deselect_palm_cover, - tizen_gesture::handle_activate_set, - tizen_gesture::handle_destroy - }; - - void tizen_gesture::tizen_gesture_grab_edge_swipe(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void tizen_gesture::tizen_gesture_ungrab_edge_swipe(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void tizen_gesture::tizen_gesture_grab_edge_drag(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void tizen_gesture::tizen_gesture_ungrab_edge_drag(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void tizen_gesture::tizen_gesture_grab_tap(Resource *, uint32_t , uint32_t ) - { - } - - void tizen_gesture::tizen_gesture_ungrab_tap(Resource *, uint32_t , uint32_t ) - { - } - - void tizen_gesture::tizen_gesture_grab_palm_cover(Resource *) - { - } - - void tizen_gesture::tizen_gesture_ungrab_palm_cover(Resource *) - { - } - - void tizen_gesture::tizen_gesture_select_palm_cover(Resource *, struct ::wl_resource *) - { - } - - void tizen_gesture::tizen_gesture_deselect_palm_cover(Resource *, struct ::wl_resource *) - { - } - - void tizen_gesture::tizen_gesture_activate_set(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) - { - } - - void tizen_gesture::tizen_gesture_destroy(Resource *) - { - } - - - void tizen_gesture::handle_grab_edge_swipe( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t edge, - uint32_t edge_size, - uint32_t start_point, - uint32_t end_point) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_grab_edge_swipe( - r, - fingers, - edge, - edge_size, - start_point, - end_point); - } - - void tizen_gesture::handle_ungrab_edge_swipe( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t edge, - uint32_t edge_size, - uint32_t start_point, - uint32_t end_point) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_ungrab_edge_swipe( - r, - fingers, - edge, - edge_size, - start_point, - end_point); - } - - void tizen_gesture::handle_grab_edge_drag( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t edge, - uint32_t edge_size, - uint32_t start_point, - uint32_t end_point) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_grab_edge_drag( - r, - fingers, - edge, - edge_size, - start_point, - end_point); - } - - void tizen_gesture::handle_ungrab_edge_drag( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t edge, - uint32_t edge_size, - uint32_t start_point, - uint32_t end_point) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_ungrab_edge_drag( - r, - fingers, - edge, - edge_size, - start_point, - end_point); - } - - void tizen_gesture::handle_grab_tap( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t repeats) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_grab_tap( - r, - fingers, - repeats); - } - - void tizen_gesture::handle_ungrab_tap( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t repeats) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_ungrab_tap( - r, - fingers, - repeats); - } - - void tizen_gesture::handle_grab_palm_cover( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_grab_palm_cover( - r); - } - - void tizen_gesture::handle_ungrab_palm_cover( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_ungrab_palm_cover( - r); - } - - void tizen_gesture::handle_select_palm_cover( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_select_palm_cover( - r, - surface); - } - - void tizen_gesture::handle_deselect_palm_cover( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_deselect_palm_cover( - r, - surface); - } - - void tizen_gesture::handle_activate_set( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t type, - uint32_t active) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_activate_set( - r, - surface, - type, - active); - } - - void tizen_gesture::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_gesture_object)->tizen_gesture_destroy( - r); - } - - void tizen_gesture::send_grab_edge_swipe_notify(uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point, uint32_t error) - { - DS_ASSERT_X(m_resource, "tizen_gesture::grab_edge_swipe_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::grab_edge_swipe_notify as it's not initialised"); - return; - } - send_grab_edge_swipe_notify( - m_resource->handle, - fingers, - edge, - edge_size, - start_point, - end_point, - error); - } - - void tizen_gesture::send_grab_edge_swipe_notify(struct ::wl_resource *resource, uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point, uint32_t error) - { - tizen_gesture_send_grab_edge_swipe_notify( - resource, - fingers, - edge, - edge_size, - start_point, - end_point, - error); - } - - - void tizen_gesture::send_edge_swipe(uint32_t mode, uint32_t fingers, int32_t sx, int32_t sy, uint32_t edge) - { - DS_ASSERT_X(m_resource, "tizen_gesture::edge_swipe", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::edge_swipe as it's not initialised"); - return; - } - send_edge_swipe( - m_resource->handle, - mode, - fingers, - sx, - sy, - edge); - } - - void tizen_gesture::send_edge_swipe(struct ::wl_resource *resource, uint32_t mode, uint32_t fingers, int32_t sx, int32_t sy, uint32_t edge) - { - tizen_gesture_send_edge_swipe( - resource, - mode, - fingers, - sx, - sy, - edge); - } - - - void tizen_gesture::send_edge_drag_notify(uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point, uint32_t error) - { - DS_ASSERT_X(m_resource, "tizen_gesture::edge_drag_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::edge_drag_notify as it's not initialised"); - return; - } - send_edge_drag_notify( - m_resource->handle, - fingers, - edge, - edge_size, - start_point, - end_point, - error); - } - - void tizen_gesture::send_edge_drag_notify(struct ::wl_resource *resource, uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point, uint32_t error) - { - tizen_gesture_send_edge_drag_notify( - resource, - fingers, - edge, - edge_size, - start_point, - end_point, - error); - } - - - void tizen_gesture::send_edge_drag(uint32_t mode, uint32_t fingers, int32_t cx, int32_t cy, uint32_t edge) - { - DS_ASSERT_X(m_resource, "tizen_gesture::edge_drag", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::edge_drag as it's not initialised"); - return; - } - send_edge_drag( - m_resource->handle, - mode, - fingers, - cx, - cy, - edge); - } - - void tizen_gesture::send_edge_drag(struct ::wl_resource *resource, uint32_t mode, uint32_t fingers, int32_t cx, int32_t cy, uint32_t edge) - { - tizen_gesture_send_edge_drag( - resource, - mode, - fingers, - cx, - cy, - edge); - } - - - void tizen_gesture::send_tap_notify(uint32_t fingers, uint32_t repeats, uint32_t error) - { - DS_ASSERT_X(m_resource, "tizen_gesture::tap_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::tap_notify as it's not initialised"); - return; - } - send_tap_notify( - m_resource->handle, - fingers, - repeats, - error); - } - - void tizen_gesture::send_tap_notify(struct ::wl_resource *resource, uint32_t fingers, uint32_t repeats, uint32_t error) - { - tizen_gesture_send_tap_notify( - resource, - fingers, - repeats, - error); - } - - - void tizen_gesture::send_tap(uint32_t mode, uint32_t fingers, uint32_t repeats) - { - DS_ASSERT_X(m_resource, "tizen_gesture::tap", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::tap as it's not initialised"); - return; - } - send_tap( - m_resource->handle, - mode, - fingers, - repeats); - } - - void tizen_gesture::send_tap(struct ::wl_resource *resource, uint32_t mode, uint32_t fingers, uint32_t repeats) - { - tizen_gesture_send_tap( - resource, - mode, - fingers, - repeats); - } - - - void tizen_gesture::send_palm_cover_notify(struct ::wl_resource *surface, uint32_t error) - { - DS_ASSERT_X(m_resource, "tizen_gesture::palm_cover_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::palm_cover_notify as it's not initialised"); - return; - } - send_palm_cover_notify( - m_resource->handle, - surface, - error); - } - - void tizen_gesture::send_palm_cover_notify(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t error) - { - tizen_gesture_send_palm_cover_notify( - resource, - surface, - error); - } - - - void tizen_gesture::send_palm_cover(struct ::wl_resource *surface, uint32_t mode, uint32_t duration, int32_t cx, int32_t cy, uint32_t size, wl_fixed_t pressure) - { - DS_ASSERT_X(m_resource, "tizen_gesture::palm_cover", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::palm_cover as it's not initialised"); - return; - } - send_palm_cover( - m_resource->handle, - surface, - mode, - duration, - cx, - cy, - size, - pressure); - } - - void tizen_gesture::send_palm_cover(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t mode, uint32_t duration, int32_t cx, int32_t cy, uint32_t size, wl_fixed_t pressure) - { - tizen_gesture_send_palm_cover( - resource, - surface, - mode, - duration, - cx, - cy, - size, - pressure); - } - - - void tizen_gesture::send_activate_notify(struct ::wl_resource *surface, uint32_t type, uint32_t active, uint32_t error) - { - DS_ASSERT_X(m_resource, "tizen_gesture::activate_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_gesture::activate_notify as it's not initialised"); - return; - } - send_activate_notify( - m_resource->handle, - surface, - type, - active, - error); - } - - void tizen_gesture::send_activate_notify(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t type, uint32_t active, uint32_t error) - { - tizen_gesture_send_activate_notify( - resource, - surface, - type, - active, - error); - } - - - tizen_keyrouter::tizen_keyrouter(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_keyrouter::tizen_keyrouter(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_keyrouter::tizen_keyrouter(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_keyrouter::tizen_keyrouter() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_keyrouter::~tizen_keyrouter() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_keyrouter::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_keyrouter::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_keyrouter::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_keyrouter::Resource *tizen_keyrouter::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_keyrouter::Resource *tizen_keyrouter::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_keyrouter::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_keyrouter_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_keyrouter::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_keyrouter::interface() - { - return &::tizen_keyrouter_interface; - } - - tizen_keyrouter::Resource *tizen_keyrouter::tizen_keyrouter_allocate() - { - return new Resource; - } - - void tizen_keyrouter::tizen_keyrouter_bind_resource(Resource *) - { - } - - void tizen_keyrouter::tizen_keyrouter_destroy_resource(Resource *) - { - } - - void tizen_keyrouter::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_keyrouter *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_keyrouter::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_keyrouter *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_keyrouter::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_keyrouter *that = resource->tizen_keyrouter_object; - that->m_resource_map.erase(resource->client()); - that->tizen_keyrouter_destroy_resource(resource); - delete resource; - } - - tizen_keyrouter::Resource *tizen_keyrouter::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_keyrouter_interface, version, id); - return bind(handle); - } - - tizen_keyrouter::Resource *tizen_keyrouter::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_keyrouter_allocate(); - resource->tizen_keyrouter_object = this; - - wl_resource_set_implementation(handle, &m_tizen_keyrouter_interface, resource, destroy_func); - resource->handle = handle; - tizen_keyrouter_bind_resource(resource); - return resource; - } - tizen_keyrouter::Resource *tizen_keyrouter::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_keyrouter_interface, &m_tizen_keyrouter_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_keyrouter_interface tizen_keyrouter::m_tizen_keyrouter_interface = { - tizen_keyrouter::handle_set_keygrab, - tizen_keyrouter::handle_unset_keygrab, - tizen_keyrouter::handle_get_keygrab_status, - tizen_keyrouter::handle_set_keygrab_list, - tizen_keyrouter::handle_unset_keygrab_list, - tizen_keyrouter::handle_get_keygrab_list, - tizen_keyrouter::handle_set_register_none_key, - tizen_keyrouter::handle_get_keyregister_status, - tizen_keyrouter::handle_set_input_config, - tizen_keyrouter::handle_destroy - }; - - void tizen_keyrouter::tizen_keyrouter_set_keygrab(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) - { - } - - void tizen_keyrouter::tizen_keyrouter_unset_keygrab(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_keyrouter::tizen_keyrouter_get_keygrab_status(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_keyrouter::tizen_keyrouter_set_keygrab_list(Resource *, struct ::wl_resource *, struct ::wl_array *) - { - } - - void tizen_keyrouter::tizen_keyrouter_unset_keygrab_list(Resource *, struct ::wl_resource *, struct ::wl_array *) - { - } - - void tizen_keyrouter::tizen_keyrouter_get_keygrab_list(Resource *, struct ::wl_resource *) - { - } - - void tizen_keyrouter::tizen_keyrouter_set_register_none_key(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void tizen_keyrouter::tizen_keyrouter_get_keyregister_status(Resource *, uint32_t ) - { - } - - void tizen_keyrouter::tizen_keyrouter_set_input_config(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) - { - } - - void tizen_keyrouter::tizen_keyrouter_destroy(Resource *) - { - } - - - void tizen_keyrouter::handle_set_keygrab( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t key, - uint32_t mode) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_set_keygrab( - r, - surface, - key, - mode); - } - - void tizen_keyrouter::handle_unset_keygrab( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t key) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_unset_keygrab( - r, - surface, - key); - } - - void tizen_keyrouter::handle_get_keygrab_status( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t key) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_get_keygrab_status( - r, - surface, - key); - } - - void tizen_keyrouter::handle_set_keygrab_list( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - struct ::wl_array *grab_list) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_set_keygrab_list( - r, - surface, - grab_list); - } - - void tizen_keyrouter::handle_unset_keygrab_list( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - struct ::wl_array *ungrab_list) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_unset_keygrab_list( - r, - surface, - ungrab_list); - } - - void tizen_keyrouter::handle_get_keygrab_list( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_get_keygrab_list( - r, - surface); - } - - void tizen_keyrouter::handle_set_register_none_key( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t data) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_set_register_none_key( - r, - surface, - data); - } - - void tizen_keyrouter::handle_get_keyregister_status( - ::wl_client *client, - struct wl_resource *resource, - uint32_t data) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_get_keyregister_status( - r, - data); - } - - void tizen_keyrouter::handle_set_input_config( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t config_mode, - uint32_t value) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_set_input_config( - r, - surface, - config_mode, - value); - } - - void tizen_keyrouter::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_keyrouter_object)->tizen_keyrouter_destroy( - r); - } - - void tizen_keyrouter::send_keygrab_notify(struct ::wl_resource *surface, uint32_t key, uint32_t mode, uint32_t error) - { - DS_ASSERT_X(m_resource, "tizen_keyrouter::keygrab_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_keyrouter::keygrab_notify as it's not initialised"); - return; - } - send_keygrab_notify( - m_resource->handle, - surface, - key, - mode, - error); - } - - void tizen_keyrouter::send_keygrab_notify(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t key, uint32_t mode, uint32_t error) - { - tizen_keyrouter_send_keygrab_notify( - resource, - surface, - key, - mode, - error); - } - - - void tizen_keyrouter::send_keygrab_notify_list(struct ::wl_resource *surface, struct ::wl_array *grab_result) - { - DS_ASSERT_X(m_resource, "tizen_keyrouter::keygrab_notify_list", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_keyrouter::keygrab_notify_list as it's not initialised"); - return; - } - send_keygrab_notify_list( - m_resource->handle, - surface, - grab_result); - } - - void tizen_keyrouter::send_keygrab_notify_list(struct ::wl_resource *resource, struct ::wl_resource *surface, struct ::wl_array *grab_result) - { - tizen_keyrouter_send_keygrab_notify_list( - resource, - surface, - grab_result); - } - - - void tizen_keyrouter::send_getgrab_notify_list(struct ::wl_resource *surface, struct ::wl_array *grab_result) - { - DS_ASSERT_X(m_resource, "tizen_keyrouter::getgrab_notify_list", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_keyrouter::getgrab_notify_list as it's not initialised"); - return; - } - send_getgrab_notify_list( - m_resource->handle, - surface, - grab_result); - } - - void tizen_keyrouter::send_getgrab_notify_list(struct ::wl_resource *resource, struct ::wl_resource *surface, struct ::wl_array *grab_result) - { - tizen_keyrouter_send_getgrab_notify_list( - resource, - surface, - grab_result); - } - - - void tizen_keyrouter::send_set_register_none_key_notify(struct ::wl_resource *surface, uint32_t mode) - { - DS_ASSERT_X(m_resource, "tizen_keyrouter::set_register_none_key_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_keyrouter::set_register_none_key_notify as it's not initialised"); - return; - } - send_set_register_none_key_notify( - m_resource->handle, - surface, - mode); - } - - void tizen_keyrouter::send_set_register_none_key_notify(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t mode) - { - tizen_keyrouter_send_set_register_none_key_notify( - resource, - surface, - mode); - } - - - void tizen_keyrouter::send_keyregister_notify(uint32_t status) - { - DS_ASSERT_X(m_resource, "tizen_keyrouter::keyregister_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_keyrouter::keyregister_notify as it's not initialised"); - return; - } - send_keyregister_notify( - m_resource->handle, - status); - } - - void tizen_keyrouter::send_keyregister_notify(struct ::wl_resource *resource, uint32_t status) - { - tizen_keyrouter_send_keyregister_notify( - resource, - status); - } - - - void tizen_keyrouter::send_set_input_config_notify(uint32_t status) - { - DS_ASSERT_X(m_resource, "tizen_keyrouter::set_input_config_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_keyrouter::set_input_config_notify as it's not initialised"); - return; - } - send_set_input_config_notify( - m_resource->handle, - status); - } - - void tizen_keyrouter::send_set_input_config_notify(struct ::wl_resource *resource, uint32_t status) - { - tizen_keyrouter_send_set_input_config_notify( - resource, - status); - } - - - void tizen_keyrouter::send_key_cancel(uint32_t key) - { - DS_ASSERT_X(m_resource, "tizen_keyrouter::key_cancel", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_keyrouter::key_cancel as it's not initialised"); - return; - } - send_key_cancel( - m_resource->handle, - key); - } - - void tizen_keyrouter::send_key_cancel(struct ::wl_resource *resource, uint32_t key) - { - tizen_keyrouter_send_key_cancel( - resource, - key); - } - - - void tizen_keyrouter::send_event_surface(struct ::wl_resource *surface, uint32_t key, uint32_t mode) - { - DS_ASSERT_X(m_resource, "tizen_keyrouter::event_surface", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_keyrouter::event_surface as it's not initialised"); - return; - } - send_event_surface( - m_resource->handle, - surface, - key, - mode); - } - - void tizen_keyrouter::send_event_surface(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t key, uint32_t mode) - { - tizen_keyrouter_send_event_surface( - resource, - surface, - key, - mode); - } - - - tizen_screenshooter::tizen_screenshooter(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_screenshooter::tizen_screenshooter(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_screenshooter::tizen_screenshooter(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_screenshooter::tizen_screenshooter() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_screenshooter::~tizen_screenshooter() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_screenshooter::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_screenshooter::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_screenshooter::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_screenshooter::Resource *tizen_screenshooter::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_screenshooter::Resource *tizen_screenshooter::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_screenshooter::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_screenshooter_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_screenshooter::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_screenshooter::interface() - { - return &::tizen_screenshooter_interface; - } - - tizen_screenshooter::Resource *tizen_screenshooter::tizen_screenshooter_allocate() - { - return new Resource; - } - - void tizen_screenshooter::tizen_screenshooter_bind_resource(Resource *) - { - } - - void tizen_screenshooter::tizen_screenshooter_destroy_resource(Resource *) - { - } - - void tizen_screenshooter::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_screenshooter *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_screenshooter::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_screenshooter *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_screenshooter::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_screenshooter *that = resource->tizen_screenshooter_object; - that->m_resource_map.erase(resource->client()); - that->tizen_screenshooter_destroy_resource(resource); - delete resource; - } - - tizen_screenshooter::Resource *tizen_screenshooter::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_screenshooter_interface, version, id); - return bind(handle); - } - - tizen_screenshooter::Resource *tizen_screenshooter::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_screenshooter_allocate(); - resource->tizen_screenshooter_object = this; - - wl_resource_set_implementation(handle, &m_tizen_screenshooter_interface, resource, destroy_func); - resource->handle = handle; - tizen_screenshooter_bind_resource(resource); - return resource; - } - tizen_screenshooter::Resource *tizen_screenshooter::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_screenshooter_interface, &m_tizen_screenshooter_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_screenshooter_interface tizen_screenshooter::m_tizen_screenshooter_interface = { - tizen_screenshooter::handle_get_screenmirror, - tizen_screenshooter::handle_set_oneshot_auto_rotation, - tizen_screenshooter::handle_destroy - }; - - void tizen_screenshooter::tizen_screenshooter_get_screenmirror(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_screenshooter::tizen_screenshooter_set_oneshot_auto_rotation(Resource *, uint32_t ) - { - } - - void tizen_screenshooter::tizen_screenshooter_destroy(Resource *) - { - } - - - void tizen_screenshooter::handle_get_screenmirror( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *output) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenshooter_object)->tizen_screenshooter_get_screenmirror( - r, - id, - output); - } - - void tizen_screenshooter::handle_set_oneshot_auto_rotation( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenshooter_object)->tizen_screenshooter_set_oneshot_auto_rotation( - r, - set); - } - - void tizen_screenshooter::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenshooter_object)->tizen_screenshooter_destroy( - r); - } - - void tizen_screenshooter::send_format(uint32_t format) - { - DS_ASSERT_X(m_resource, "tizen_screenshooter::format", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_screenshooter::format as it's not initialised"); - return; - } - send_format( - m_resource->handle, - format); - } - - void tizen_screenshooter::send_format(struct ::wl_resource *resource, uint32_t format) - { - tizen_screenshooter_send_format( - resource, - format); - } - - - void tizen_screenshooter::send_screenshooter_notify(uint32_t noti) - { - DS_ASSERT_X(m_resource, "tizen_screenshooter::screenshooter_notify", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_screenshooter::screenshooter_notify as it's not initialised"); - return; - } - send_screenshooter_notify( - m_resource->handle, - noti); - } - - void tizen_screenshooter::send_screenshooter_notify(struct ::wl_resource *resource, uint32_t noti) - { - tizen_screenshooter_send_screenshooter_notify( - resource, - noti); - } - - - tizen_screenmirror::tizen_screenmirror(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_screenmirror::tizen_screenmirror(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_screenmirror::tizen_screenmirror(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_screenmirror::tizen_screenmirror() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_screenmirror::~tizen_screenmirror() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_screenmirror::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_screenmirror::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_screenmirror::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_screenmirror::Resource *tizen_screenmirror::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_screenmirror::Resource *tizen_screenmirror::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_screenmirror::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_screenmirror_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_screenmirror::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_screenmirror::interface() - { - return &::tizen_screenmirror_interface; - } - - tizen_screenmirror::Resource *tizen_screenmirror::tizen_screenmirror_allocate() - { - return new Resource; - } - - void tizen_screenmirror::tizen_screenmirror_bind_resource(Resource *) - { - } - - void tizen_screenmirror::tizen_screenmirror_destroy_resource(Resource *) - { - } - - void tizen_screenmirror::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_screenmirror *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_screenmirror::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_screenmirror *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_screenmirror::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_screenmirror *that = resource->tizen_screenmirror_object; - that->m_resource_map.erase(resource->client()); - that->tizen_screenmirror_destroy_resource(resource); - delete resource; - } - - tizen_screenmirror::Resource *tizen_screenmirror::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_screenmirror_interface, version, id); - return bind(handle); - } - - tizen_screenmirror::Resource *tizen_screenmirror::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_screenmirror_allocate(); - resource->tizen_screenmirror_object = this; - - wl_resource_set_implementation(handle, &m_tizen_screenmirror_interface, resource, destroy_func); - resource->handle = handle; - tizen_screenmirror_bind_resource(resource); - return resource; - } - tizen_screenmirror::Resource *tizen_screenmirror::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_screenmirror_interface, &m_tizen_screenmirror_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_screenmirror_interface tizen_screenmirror::m_tizen_screenmirror_interface = { - tizen_screenmirror::handle_destroy, - tizen_screenmirror::handle_set_stretch, - tizen_screenmirror::handle_queue, - tizen_screenmirror::handle_dequeue, - tizen_screenmirror::handle_start, - tizen_screenmirror::handle_stop, - tizen_screenmirror::handle_set_auto_rotation - }; - - void tizen_screenmirror::tizen_screenmirror_destroy(Resource *) - { - } - - void tizen_screenmirror::tizen_screenmirror_set_stretch(Resource *, uint32_t ) - { - } - - void tizen_screenmirror::tizen_screenmirror_queue(Resource *, struct ::wl_resource *) - { - } - - void tizen_screenmirror::tizen_screenmirror_dequeue(Resource *, struct ::wl_resource *) - { - } - - void tizen_screenmirror::tizen_screenmirror_start(Resource *) - { - } - - void tizen_screenmirror::tizen_screenmirror_stop(Resource *) - { - } - - void tizen_screenmirror::tizen_screenmirror_set_auto_rotation(Resource *, uint32_t ) - { - } - - - void tizen_screenmirror::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenmirror_object)->tizen_screenmirror_destroy( - r); - } - - void tizen_screenmirror::handle_set_stretch( - ::wl_client *client, - struct wl_resource *resource, - uint32_t stretch) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenmirror_object)->tizen_screenmirror_set_stretch( - r, - stretch); - } - - void tizen_screenmirror::handle_queue( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *buffer) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenmirror_object)->tizen_screenmirror_queue( - r, - buffer); - } - - void tizen_screenmirror::handle_dequeue( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *buffer) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenmirror_object)->tizen_screenmirror_dequeue( - r, - buffer); - } - - void tizen_screenmirror::handle_start( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenmirror_object)->tizen_screenmirror_start( - r); - } - - void tizen_screenmirror::handle_stop( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenmirror_object)->tizen_screenmirror_stop( - r); - } - - void tizen_screenmirror::handle_set_auto_rotation( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screenmirror_object)->tizen_screenmirror_set_auto_rotation( - r, - set); - } - - void tizen_screenmirror::send_dequeued(struct ::wl_resource *buffer) - { - DS_ASSERT_X(m_resource, "tizen_screenmirror::dequeued", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_screenmirror::dequeued as it's not initialised"); - return; - } - send_dequeued( - m_resource->handle, - buffer); - } - - void tizen_screenmirror::send_dequeued(struct ::wl_resource *resource, struct ::wl_resource *buffer) - { - tizen_screenmirror_send_dequeued( - resource, - buffer); - } - - - void tizen_screenmirror::send_content(uint32_t content) - { - DS_ASSERT_X(m_resource, "tizen_screenmirror::content", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_screenmirror::content as it's not initialised"); - return; - } - send_content( - m_resource->handle, - content); - } - - void tizen_screenmirror::send_content(struct ::wl_resource *resource, uint32_t content) - { - tizen_screenmirror_send_content( - resource, - content); - } - - - void tizen_screenmirror::send_stop() - { - DS_ASSERT_X(m_resource, "tizen_screenmirror::stop", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_screenmirror::stop as it's not initialised"); - return; - } - send_stop( - m_resource->handle); - } - - void tizen_screenmirror::send_stop(struct ::wl_resource *resource) - { - tizen_screenmirror_send_stop( - resource); - } - - - tizen_video::tizen_video(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_video::tizen_video(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_video::tizen_video(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_video::tizen_video() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_video::~tizen_video() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_video::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_video::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_video::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_video::Resource *tizen_video::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_video::Resource *tizen_video::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_video::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_video_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_video::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_video::interface() - { - return &::tizen_video_interface; - } - - tizen_video::Resource *tizen_video::tizen_video_allocate() - { - return new Resource; - } - - void tizen_video::tizen_video_bind_resource(Resource *) - { - } - - void tizen_video::tizen_video_destroy_resource(Resource *) - { - } - - void tizen_video::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_video *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_video::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_video *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_video::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_video *that = resource->tizen_video_object; - that->m_resource_map.erase(resource->client()); - that->tizen_video_destroy_resource(resource); - delete resource; - } - - tizen_video::Resource *tizen_video::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_video_interface, version, id); - return bind(handle); - } - - tizen_video::Resource *tizen_video::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_video_allocate(); - resource->tizen_video_object = this; - - wl_resource_set_implementation(handle, &m_tizen_video_interface, resource, destroy_func); - resource->handle = handle; - tizen_video_bind_resource(resource); - return resource; - } - tizen_video::Resource *tizen_video::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_video_interface, &m_tizen_video_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_video_interface tizen_video::m_tizen_video_interface = { - tizen_video::handle_get_object, - tizen_video::handle_get_viewport, - tizen_video::handle_destroy - }; - - void tizen_video::tizen_video_get_object(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_video::tizen_video_get_viewport(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_video::tizen_video_destroy(Resource *) - { - } - - - void tizen_video::handle_get_object( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object)->tizen_video_get_object( - r, - id, - surface); - } - - void tizen_video::handle_get_viewport( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object)->tizen_video_get_viewport( - r, - id, - surface); - } - - void tizen_video::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object)->tizen_video_destroy( - r); - } - - void tizen_video::send_format(uint32_t format) - { - DS_ASSERT_X(m_resource, "tizen_video::format", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_video::format as it's not initialised"); - return; - } - send_format( - m_resource->handle, - format); - } - - void tizen_video::send_format(struct ::wl_resource *resource, uint32_t format) - { - tizen_video_send_format( - resource, - format); - } - - - tizen_video_object::tizen_video_object(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_video_object::tizen_video_object(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_video_object::tizen_video_object(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_video_object::tizen_video_object() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_video_object::~tizen_video_object() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_video_object::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_video_object::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_video_object::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_video_object::Resource *tizen_video_object::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_video_object::Resource *tizen_video_object::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_video_object::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_video_object_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_video_object::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_video_object::interface() - { - return &::tizen_video_object_interface; - } - - tizen_video_object::Resource *tizen_video_object::tizen_video_object_allocate() - { - return new Resource; - } - - void tizen_video_object::tizen_video_object_bind_resource(Resource *) - { - } - - void tizen_video_object::tizen_video_object_destroy_resource(Resource *) - { - } - - void tizen_video_object::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_video_object *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_video_object::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_video_object *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_video_object::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_video_object *that = resource->tizen_video_object_object; - that->m_resource_map.erase(resource->client()); - that->tizen_video_object_destroy_resource(resource); - delete resource; - } - - tizen_video_object::Resource *tizen_video_object::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_video_object_interface, version, id); - return bind(handle); - } - - tizen_video_object::Resource *tizen_video_object::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_video_object_allocate(); - resource->tizen_video_object_object = this; - - wl_resource_set_implementation(handle, &m_tizen_video_object_interface, resource, destroy_func); - resource->handle = handle; - tizen_video_object_bind_resource(resource); - return resource; - } - tizen_video_object::Resource *tizen_video_object::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_video_object_interface, &m_tizen_video_object_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_video_object_interface tizen_video_object::m_tizen_video_object_interface = { - tizen_video_object::handle_destroy, - tizen_video_object::handle_set_attribute, - tizen_video_object::handle_follow_topmost_visibility, - tizen_video_object::handle_unfollow_topmost_visibility, - tizen_video_object::handle_allowed_attribute, - tizen_video_object::handle_disallowed_attribute - }; - - void tizen_video_object::tizen_video_object_destroy(Resource *) - { - } - - void tizen_video_object::tizen_video_object_set_attribute(Resource *, const std::string &, int32_t ) - { - } - - void tizen_video_object::tizen_video_object_follow_topmost_visibility(Resource *) - { - } - - void tizen_video_object::tizen_video_object_unfollow_topmost_visibility(Resource *) - { - } - - void tizen_video_object::tizen_video_object_allowed_attribute(Resource *) - { - } - - void tizen_video_object::tizen_video_object_disallowed_attribute(Resource *) - { - } - - - void tizen_video_object::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object_object)->tizen_video_object_destroy( - r); - } - - void tizen_video_object::handle_set_attribute( - ::wl_client *client, - struct wl_resource *resource, - const char *name, - int32_t value) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object_object)->tizen_video_object_set_attribute( - r, - std::string(name), - value); - } - - void tizen_video_object::handle_follow_topmost_visibility( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object_object)->tizen_video_object_follow_topmost_visibility( - r); - } - - void tizen_video_object::handle_unfollow_topmost_visibility( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object_object)->tizen_video_object_unfollow_topmost_visibility( - r); - } - - void tizen_video_object::handle_allowed_attribute( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object_object)->tizen_video_object_allowed_attribute( - r); - } - - void tizen_video_object::handle_disallowed_attribute( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_video_object_object)->tizen_video_object_disallowed_attribute( - r); - } - - void tizen_video_object::send_attribute(const std::string &name, uint32_t value) - { - DS_ASSERT_X(m_resource, "tizen_video_object::attribute", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_video_object::attribute as it's not initialised"); - return; - } - send_attribute( - m_resource->handle, - name, - value); - } - - void tizen_video_object::send_attribute(struct ::wl_resource *resource, const std::string &name, uint32_t value) - { - tizen_video_object_send_attribute( - resource, - name.c_str(), - value); - } - - - void tizen_video_object::send_size(int32_t min_w, int32_t min_h, int32_t max_w, int32_t max_h, int32_t prefer_align) - { - DS_ASSERT_X(m_resource, "tizen_video_object::size", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_video_object::size as it's not initialised"); - return; - } - send_size( - m_resource->handle, - min_w, - min_h, - max_w, - max_h, - prefer_align); - } - - void tizen_video_object::send_size(struct ::wl_resource *resource, int32_t min_w, int32_t min_h, int32_t max_w, int32_t max_h, int32_t prefer_align) - { - tizen_video_object_send_size( - resource, - min_w, - min_h, - max_w, - max_h, - prefer_align); - } - - - tizen_subsurface_watcher::tizen_subsurface_watcher(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_subsurface_watcher::tizen_subsurface_watcher(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_subsurface_watcher::tizen_subsurface_watcher(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_subsurface_watcher::tizen_subsurface_watcher() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_subsurface_watcher::~tizen_subsurface_watcher() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_subsurface_watcher::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_subsurface_watcher::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_subsurface_watcher::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_subsurface_watcher::Resource *tizen_subsurface_watcher::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_subsurface_watcher::Resource *tizen_subsurface_watcher::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_subsurface_watcher::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_subsurface_watcher_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_subsurface_watcher::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_subsurface_watcher::interface() - { - return &::tizen_subsurface_watcher_interface; - } - - tizen_subsurface_watcher::Resource *tizen_subsurface_watcher::tizen_subsurface_watcher_allocate() - { - return new Resource; - } - - void tizen_subsurface_watcher::tizen_subsurface_watcher_bind_resource(Resource *) - { - } - - void tizen_subsurface_watcher::tizen_subsurface_watcher_destroy_resource(Resource *) - { - } - - void tizen_subsurface_watcher::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_subsurface_watcher *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_subsurface_watcher::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_subsurface_watcher *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_subsurface_watcher::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_subsurface_watcher *that = resource->tizen_subsurface_watcher_object; - that->m_resource_map.erase(resource->client()); - that->tizen_subsurface_watcher_destroy_resource(resource); - delete resource; - } - - tizen_subsurface_watcher::Resource *tizen_subsurface_watcher::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_subsurface_watcher_interface, version, id); - return bind(handle); - } - - tizen_subsurface_watcher::Resource *tizen_subsurface_watcher::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_subsurface_watcher_allocate(); - resource->tizen_subsurface_watcher_object = this; - - wl_resource_set_implementation(handle, &m_tizen_subsurface_watcher_interface, resource, destroy_func); - resource->handle = handle; - tizen_subsurface_watcher_bind_resource(resource); - return resource; - } - tizen_subsurface_watcher::Resource *tizen_subsurface_watcher::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_subsurface_watcher_interface, &m_tizen_subsurface_watcher_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_subsurface_watcher_interface tizen_subsurface_watcher::m_tizen_subsurface_watcher_interface = { - tizen_subsurface_watcher::handle_destroy - }; - - void tizen_subsurface_watcher::tizen_subsurface_watcher_destroy(Resource *) - { - } - - - void tizen_subsurface_watcher::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_subsurface_watcher_object)->tizen_subsurface_watcher_destroy( - r); - } - - void tizen_subsurface_watcher::send_message(uint32_t value) - { - DS_ASSERT_X(m_resource, "tizen_subsurface_watcher::message", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_subsurface_watcher::message as it's not initialised"); - return; - } - send_message( - m_resource->handle, - value); - } - - void tizen_subsurface_watcher::send_message(struct ::wl_resource *resource, uint32_t value) - { - tizen_subsurface_watcher_send_message( - resource, - value); - } - - - tizen_viewport::tizen_viewport(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_viewport::tizen_viewport(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_viewport::tizen_viewport(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_viewport::tizen_viewport() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_viewport::~tizen_viewport() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_viewport::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_viewport::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_viewport::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_viewport::Resource *tizen_viewport::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_viewport::Resource *tizen_viewport::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_viewport::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_viewport_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_viewport::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_viewport::interface() - { - return &::tizen_viewport_interface; - } - - tizen_viewport::Resource *tizen_viewport::tizen_viewport_allocate() - { - return new Resource; - } - - void tizen_viewport::tizen_viewport_bind_resource(Resource *) - { - } - - void tizen_viewport::tizen_viewport_destroy_resource(Resource *) - { - } - - void tizen_viewport::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_viewport *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_viewport::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_viewport *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_viewport::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_viewport *that = resource->tizen_viewport_object; - that->m_resource_map.erase(resource->client()); - that->tizen_viewport_destroy_resource(resource); - delete resource; - } - - tizen_viewport::Resource *tizen_viewport::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_viewport_interface, version, id); - return bind(handle); - } - - tizen_viewport::Resource *tizen_viewport::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_viewport_allocate(); - resource->tizen_viewport_object = this; - - wl_resource_set_implementation(handle, &m_tizen_viewport_interface, resource, destroy_func); - resource->handle = handle; - tizen_viewport_bind_resource(resource); - return resource; - } - tizen_viewport::Resource *tizen_viewport::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_viewport_interface, &m_tizen_viewport_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_viewport_interface tizen_viewport::m_tizen_viewport_interface = { - tizen_viewport::handle_destroy, - tizen_viewport::handle_set_transform, - tizen_viewport::handle_set_source, - tizen_viewport::handle_set_destination, - tizen_viewport::handle_set_destination_ratio, - tizen_viewport::handle_get_destination_mode, - tizen_viewport::handle_query_parent_size, - tizen_viewport::handle_follow_parent_transform, - tizen_viewport::handle_unfollow_parent_transform - }; - - void tizen_viewport::tizen_viewport_destroy(Resource *) - { - } - - void tizen_viewport::tizen_viewport_set_transform(Resource *, uint32_t ) - { - } - - void tizen_viewport::tizen_viewport_set_source(Resource *, uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void tizen_viewport::tizen_viewport_set_destination(Resource *, int32_t , int32_t , uint32_t , uint32_t ) - { - } - - void tizen_viewport::tizen_viewport_set_destination_ratio(Resource *, wl_fixed_t , wl_fixed_t , wl_fixed_t , wl_fixed_t ) - { - } - - void tizen_viewport::tizen_viewport_get_destination_mode(Resource *, uint32_t) - { - } - - void tizen_viewport::tizen_viewport_query_parent_size(Resource *) - { - } - - void tizen_viewport::tizen_viewport_follow_parent_transform(Resource *) - { - } - - void tizen_viewport::tizen_viewport_unfollow_parent_transform(Resource *) - { - } - - - void tizen_viewport::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_destroy( - r); - } - - void tizen_viewport::handle_set_transform( - ::wl_client *client, - struct wl_resource *resource, - uint32_t transform) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_set_transform( - r, - transform); - } - - void tizen_viewport::handle_set_source( - ::wl_client *client, - struct wl_resource *resource, - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_set_source( - r, - x, - y, - width, - height); - } - - void tizen_viewport::handle_set_destination( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - uint32_t width, - uint32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_set_destination( - r, - x, - y, - width, - height); - } - - void tizen_viewport::handle_set_destination_ratio( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t x, - wl_fixed_t y, - wl_fixed_t width, - wl_fixed_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_set_destination_ratio( - r, - x, - y, - width, - height); - } - - void tizen_viewport::handle_get_destination_mode( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_get_destination_mode( - r, - id); - } - - void tizen_viewport::handle_query_parent_size( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_query_parent_size( - r); - } - - void tizen_viewport::handle_follow_parent_transform( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_follow_parent_transform( - r); - } - - void tizen_viewport::handle_unfollow_parent_transform( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_viewport_object)->tizen_viewport_unfollow_parent_transform( - r); - } - - void tizen_viewport::send_destination_changed(uint32_t transform, int32_t x, int32_t y, uint32_t width, uint32_t height) - { - DS_ASSERT_X(m_resource, "tizen_viewport::destination_changed", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_viewport::destination_changed as it's not initialised"); - return; - } - send_destination_changed( - m_resource->handle, - transform, - x, - y, - width, - height); - } - - void tizen_viewport::send_destination_changed(struct ::wl_resource *resource, uint32_t transform, int32_t x, int32_t y, uint32_t width, uint32_t height) - { - tizen_viewport_send_destination_changed( - resource, - transform, - x, - y, - width, - height); - } - - - void tizen_viewport::send_parent_size(uint32_t width, uint32_t height) - { - DS_ASSERT_X(m_resource, "tizen_viewport::parent_size", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_viewport::parent_size as it's not initialised"); - return; - } - send_parent_size( - m_resource->handle, - width, - height); - } - - void tizen_viewport::send_parent_size(struct ::wl_resource *resource, uint32_t width, uint32_t height) - { - tizen_viewport_send_parent_size( - resource, - width, - height); - } - - - tizen_destination_mode::tizen_destination_mode(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_destination_mode::tizen_destination_mode(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_destination_mode::tizen_destination_mode(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_destination_mode::tizen_destination_mode() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_destination_mode::~tizen_destination_mode() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_destination_mode::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_destination_mode::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_destination_mode::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_destination_mode::Resource *tizen_destination_mode::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_destination_mode::Resource *tizen_destination_mode::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_destination_mode::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_destination_mode_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_destination_mode::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_destination_mode::interface() - { - return &::tizen_destination_mode_interface; - } - - tizen_destination_mode::Resource *tizen_destination_mode::tizen_destination_mode_allocate() - { - return new Resource; - } - - void tizen_destination_mode::tizen_destination_mode_bind_resource(Resource *) - { - } - - void tizen_destination_mode::tizen_destination_mode_destroy_resource(Resource *) - { - } - - void tizen_destination_mode::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_destination_mode *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_destination_mode::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_destination_mode *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_destination_mode::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_destination_mode *that = resource->tizen_destination_mode_object; - that->m_resource_map.erase(resource->client()); - that->tizen_destination_mode_destroy_resource(resource); - delete resource; - } - - tizen_destination_mode::Resource *tizen_destination_mode::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_destination_mode_interface, version, id); - return bind(handle); - } - - tizen_destination_mode::Resource *tizen_destination_mode::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_destination_mode_allocate(); - resource->tizen_destination_mode_object = this; - - wl_resource_set_implementation(handle, &m_tizen_destination_mode_interface, resource, destroy_func); - resource->handle = handle; - tizen_destination_mode_bind_resource(resource); - return resource; - } - tizen_destination_mode::Resource *tizen_destination_mode::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_destination_mode_interface, &m_tizen_destination_mode_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_destination_mode_interface tizen_destination_mode::m_tizen_destination_mode_interface = { - tizen_destination_mode::handle_destroy, - tizen_destination_mode::handle_follow_parent_transform, - tizen_destination_mode::handle_unfollow_parent_transform, - tizen_destination_mode::handle_set, - tizen_destination_mode::handle_set_ratio, - tizen_destination_mode::handle_set_scale, - tizen_destination_mode::handle_set_align, - tizen_destination_mode::handle_set_offset - }; - - void tizen_destination_mode::tizen_destination_mode_destroy(Resource *) - { - } - - void tizen_destination_mode::tizen_destination_mode_follow_parent_transform(Resource *) - { - } - - void tizen_destination_mode::tizen_destination_mode_unfollow_parent_transform(Resource *) - { - } - - void tizen_destination_mode::tizen_destination_mode_set(Resource *, uint32_t ) - { - } - - void tizen_destination_mode::tizen_destination_mode_set_ratio(Resource *, wl_fixed_t , wl_fixed_t ) - { - } - - void tizen_destination_mode::tizen_destination_mode_set_scale(Resource *, wl_fixed_t , wl_fixed_t ) - { - } - - void tizen_destination_mode::tizen_destination_mode_set_align(Resource *, wl_fixed_t , wl_fixed_t ) - { - } - - void tizen_destination_mode::tizen_destination_mode_set_offset(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - - void tizen_destination_mode::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_destination_mode_object)->tizen_destination_mode_destroy( - r); - } - - void tizen_destination_mode::handle_follow_parent_transform( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_destination_mode_object)->tizen_destination_mode_follow_parent_transform( - r); - } - - void tizen_destination_mode::handle_unfollow_parent_transform( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_destination_mode_object)->tizen_destination_mode_unfollow_parent_transform( - r); - } - - void tizen_destination_mode::handle_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t mode) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_destination_mode_object)->tizen_destination_mode_set( - r, - mode); - } - - void tizen_destination_mode::handle_set_ratio( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t horizontal, - wl_fixed_t vertical) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_destination_mode_object)->tizen_destination_mode_set_ratio( - r, - horizontal, - vertical); - } - - void tizen_destination_mode::handle_set_scale( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t horizontal, - wl_fixed_t vertical) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_destination_mode_object)->tizen_destination_mode_set_scale( - r, - horizontal, - vertical); - } - - void tizen_destination_mode::handle_set_align( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t horizontal, - wl_fixed_t vertical) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_destination_mode_object)->tizen_destination_mode_set_align( - r, - horizontal, - vertical); - } - - void tizen_destination_mode::handle_set_offset( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t w, - int32_t h) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_destination_mode_object)->tizen_destination_mode_set_offset( - r, - x, - y, - w, - h); - } - - tizen_embedded_compositor::tizen_embedded_compositor(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_embedded_compositor::tizen_embedded_compositor(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_embedded_compositor::tizen_embedded_compositor(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_embedded_compositor::tizen_embedded_compositor() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_embedded_compositor::~tizen_embedded_compositor() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_embedded_compositor::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_embedded_compositor::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_embedded_compositor::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_embedded_compositor::Resource *tizen_embedded_compositor::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_embedded_compositor::Resource *tizen_embedded_compositor::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_embedded_compositor::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_embedded_compositor_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_embedded_compositor::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_embedded_compositor::interface() - { - return &::tizen_embedded_compositor_interface; - } - - tizen_embedded_compositor::Resource *tizen_embedded_compositor::tizen_embedded_compositor_allocate() - { - return new Resource; - } - - void tizen_embedded_compositor::tizen_embedded_compositor_bind_resource(Resource *) - { - } - - void tizen_embedded_compositor::tizen_embedded_compositor_destroy_resource(Resource *) - { - } - - void tizen_embedded_compositor::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_embedded_compositor *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_embedded_compositor::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_embedded_compositor *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_embedded_compositor::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_embedded_compositor *that = resource->tizen_embedded_compositor_object; - that->m_resource_map.erase(resource->client()); - that->tizen_embedded_compositor_destroy_resource(resource); - delete resource; - } - - tizen_embedded_compositor::Resource *tizen_embedded_compositor::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_embedded_compositor_interface, version, id); - return bind(handle); - } - - tizen_embedded_compositor::Resource *tizen_embedded_compositor::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_embedded_compositor_allocate(); - resource->tizen_embedded_compositor_object = this; - - wl_resource_set_implementation(handle, &m_tizen_embedded_compositor_interface, resource, destroy_func); - resource->handle = handle; - tizen_embedded_compositor_bind_resource(resource); - return resource; - } - tizen_embedded_compositor::Resource *tizen_embedded_compositor::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_embedded_compositor_interface, &m_tizen_embedded_compositor_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_embedded_compositor_interface tizen_embedded_compositor::m_tizen_embedded_compositor_interface = { - tizen_embedded_compositor::handle_get_socket, - tizen_embedded_compositor::handle_destroy - }; - - void tizen_embedded_compositor::tizen_embedded_compositor_get_socket(Resource *) - { - } - - void tizen_embedded_compositor::tizen_embedded_compositor_destroy(Resource *) - { - } - - - void tizen_embedded_compositor::handle_get_socket( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_embedded_compositor_object)->tizen_embedded_compositor_get_socket( - r); - } - - void tizen_embedded_compositor::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_embedded_compositor_object)->tizen_embedded_compositor_destroy( - r); - } - - void tizen_embedded_compositor::send_socket(int32_t sock_fd) - { - DS_ASSERT_X(m_resource, "tizen_embedded_compositor::socket", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_embedded_compositor::socket as it's not initialised"); - return; - } - send_socket( - m_resource->handle, - sock_fd); - } - - void tizen_embedded_compositor::send_socket(struct ::wl_resource *resource, int32_t sock_fd) - { - tizen_embedded_compositor_send_socket( - resource, - sock_fd); - } - - - tizen_input_device_manager::tizen_input_device_manager(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_input_device_manager::tizen_input_device_manager(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_input_device_manager::tizen_input_device_manager(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_input_device_manager::tizen_input_device_manager() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_input_device_manager::~tizen_input_device_manager() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_input_device_manager::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_input_device_manager::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_input_device_manager::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_input_device_manager::Resource *tizen_input_device_manager::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_input_device_manager::Resource *tizen_input_device_manager::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_input_device_manager::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_input_device_manager_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_input_device_manager::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_input_device_manager::interface() - { - return &::tizen_input_device_manager_interface; - } - - tizen_input_device_manager::Resource *tizen_input_device_manager::tizen_input_device_manager_allocate() - { - return new Resource; - } - - void tizen_input_device_manager::tizen_input_device_manager_bind_resource(Resource *) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_destroy_resource(Resource *) - { - } - - void tizen_input_device_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_input_device_manager *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_input_device_manager::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_input_device_manager *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_input_device_manager::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_input_device_manager *that = resource->tizen_input_device_manager_object; - that->m_resource_map.erase(resource->client()); - that->tizen_input_device_manager_destroy_resource(resource); - delete resource; - } - - tizen_input_device_manager::Resource *tizen_input_device_manager::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_input_device_manager_interface, version, id); - return bind(handle); - } - - tizen_input_device_manager::Resource *tizen_input_device_manager::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_input_device_manager_allocate(); - resource->tizen_input_device_manager_object = this; - - wl_resource_set_implementation(handle, &m_tizen_input_device_manager_interface, resource, destroy_func); - resource->handle = handle; - tizen_input_device_manager_bind_resource(resource); - return resource; - } - tizen_input_device_manager::Resource *tizen_input_device_manager::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_input_device_manager_interface, &m_tizen_input_device_manager_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_input_device_manager_interface tizen_input_device_manager::m_tizen_input_device_manager_interface = { - tizen_input_device_manager::handle_block_events, - tizen_input_device_manager::handle_unblock_events, - tizen_input_device_manager::handle_init_generator, - tizen_input_device_manager::handle_deinit_generator, - tizen_input_device_manager::handle_generate_key, - tizen_input_device_manager::handle_generate_pointer, - tizen_input_device_manager::handle_generate_touch, - tizen_input_device_manager::handle_pointer_warp, - tizen_input_device_manager::handle_init_generator_with_name, - tizen_input_device_manager::handle_destroy, - tizen_input_device_manager::handle_generate_axis, - tizen_input_device_manager::handle_set_touch_count - }; - - void tizen_input_device_manager::tizen_input_device_manager_block_events(Resource *, uint32_t , uint32_t , uint32_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_unblock_events(Resource *, uint32_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_init_generator(Resource *, uint32_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_deinit_generator(Resource *, uint32_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_generate_key(Resource *, const std::string &, uint32_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_generate_pointer(Resource *, uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_generate_touch(Resource *, uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_pointer_warp(Resource *, struct ::wl_resource *, wl_fixed_t , wl_fixed_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_init_generator_with_name(Resource *, uint32_t , const std::string &) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_destroy(Resource *) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_generate_axis(Resource *, uint32_t , wl_fixed_t ) - { - } - - void tizen_input_device_manager::tizen_input_device_manager_set_touch_count(Resource *, int32_t ) - { - } - - - void tizen_input_device_manager::handle_block_events( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t clas, - uint32_t duration) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_block_events( - r, - serial, - clas, - duration); - } - - void tizen_input_device_manager::handle_unblock_events( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_unblock_events( - r, - serial); - } - - void tizen_input_device_manager::handle_init_generator( - ::wl_client *client, - struct wl_resource *resource, - uint32_t clas) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_init_generator( - r, - clas); - } - - void tizen_input_device_manager::handle_deinit_generator( - ::wl_client *client, - struct wl_resource *resource, - uint32_t clas) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_deinit_generator( - r, - clas); - } - - void tizen_input_device_manager::handle_generate_key( - ::wl_client *client, - struct wl_resource *resource, - const char *keyname, - uint32_t pressed) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_generate_key( - r, - std::string(keyname), - pressed); - } - - void tizen_input_device_manager::handle_generate_pointer( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type, - uint32_t x, - uint32_t y, - uint32_t button) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_generate_pointer( - r, - type, - x, - y, - button); - } - - void tizen_input_device_manager::handle_generate_touch( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type, - uint32_t x, - uint32_t y, - uint32_t finger) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_generate_touch( - r, - type, - x, - y, - finger); - } - - void tizen_input_device_manager::handle_pointer_warp( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - wl_fixed_t x, - wl_fixed_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_pointer_warp( - r, - surface, - x, - y); - } - - void tizen_input_device_manager::handle_init_generator_with_name( - ::wl_client *client, - struct wl_resource *resource, - uint32_t clas, - const char *name) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_init_generator_with_name( - r, - clas, - std::string(name)); - } - - void tizen_input_device_manager::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_destroy( - r); - } - - void tizen_input_device_manager::handle_generate_axis( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type, - wl_fixed_t value) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_generate_axis( - r, - type, - value); - } - - void tizen_input_device_manager::handle_set_touch_count( - ::wl_client *client, - struct wl_resource *resource, - int32_t max_count) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_manager_object)->tizen_input_device_manager_set_touch_count( - r, - max_count); - } - - void tizen_input_device_manager::send_device_add(uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat) - { - DS_ASSERT_X(m_resource, "tizen_input_device_manager::device_add", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_input_device_manager::device_add as it's not initialised"); - return; - } - send_device_add( - m_resource->handle, - serial, - identifier, - device, - seat); - } - - void tizen_input_device_manager::send_device_add(struct ::wl_resource *resource, uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat) - { - tizen_input_device_manager_send_device_add( - resource, - serial, - identifier.c_str(), - device, - seat); - } - - - void tizen_input_device_manager::send_device_remove(uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat) - { - DS_ASSERT_X(m_resource, "tizen_input_device_manager::device_remove", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_input_device_manager::device_remove as it's not initialised"); - return; - } - send_device_remove( - m_resource->handle, - serial, - identifier, - device, - seat); - } - - void tizen_input_device_manager::send_device_remove(struct ::wl_resource *resource, uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat) - { - tizen_input_device_manager_send_device_remove( - resource, - serial, - identifier.c_str(), - device, - seat); - } - - - void tizen_input_device_manager::send_error(uint32_t errorcode) - { - DS_ASSERT_X(m_resource, "tizen_input_device_manager::error", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_input_device_manager::error as it's not initialised"); - return; - } - send_error( - m_resource->handle, - errorcode); - } - - void tizen_input_device_manager::send_error(struct ::wl_resource *resource, uint32_t errorcode) - { - tizen_input_device_manager_send_error( - resource, - errorcode); - } - - - void tizen_input_device_manager::send_block_expired() - { - DS_ASSERT_X(m_resource, "tizen_input_device_manager::block_expired", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_input_device_manager::block_expired as it's not initialised"); - return; - } - send_block_expired( - m_resource->handle); - } - - void tizen_input_device_manager::send_block_expired(struct ::wl_resource *resource) - { - tizen_input_device_manager_send_block_expired( - resource); - } - - - void tizen_input_device_manager::send_max_touch_count(uint32_t serial, int32_t max_count, struct ::wl_resource *seat) - { - DS_ASSERT_X(m_resource, "tizen_input_device_manager::max_touch_count", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_input_device_manager::max_touch_count as it's not initialised"); - return; - } - send_max_touch_count( - m_resource->handle, - serial, - max_count, - seat); - } - - void tizen_input_device_manager::send_max_touch_count(struct ::wl_resource *resource, uint32_t serial, int32_t max_count, struct ::wl_resource *seat) - { - tizen_input_device_manager_send_max_touch_count( - resource, - serial, - max_count, - seat); - } - - - tizen_input_device::tizen_input_device(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_input_device::tizen_input_device(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_input_device::tizen_input_device(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_input_device::tizen_input_device() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_input_device::~tizen_input_device() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_input_device::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_input_device::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_input_device::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_input_device::Resource *tizen_input_device::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_input_device::Resource *tizen_input_device::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_input_device::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_input_device_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_input_device::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_input_device::interface() - { - return &::tizen_input_device_interface; - } - - tizen_input_device::Resource *tizen_input_device::tizen_input_device_allocate() - { - return new Resource; - } - - void tizen_input_device::tizen_input_device_bind_resource(Resource *) - { - } - - void tizen_input_device::tizen_input_device_destroy_resource(Resource *) - { - } - - void tizen_input_device::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_input_device *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_input_device::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_input_device *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_input_device::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_input_device *that = resource->tizen_input_device_object; - that->m_resource_map.erase(resource->client()); - that->tizen_input_device_destroy_resource(resource); - delete resource; - } - - tizen_input_device::Resource *tizen_input_device::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_input_device_interface, version, id); - return bind(handle); - } - - tizen_input_device::Resource *tizen_input_device::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_input_device_allocate(); - resource->tizen_input_device_object = this; - - wl_resource_set_implementation(handle, &m_tizen_input_device_interface, resource, destroy_func); - resource->handle = handle; - tizen_input_device_bind_resource(resource); - return resource; - } - tizen_input_device::Resource *tizen_input_device::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_input_device_interface, &m_tizen_input_device_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_input_device_interface tizen_input_device::m_tizen_input_device_interface = { - tizen_input_device::handle_select_axes, - tizen_input_device::handle_release - }; - - void tizen_input_device::tizen_input_device_select_axes(Resource *, struct ::wl_array *) - { - } - - void tizen_input_device::tizen_input_device_release(Resource *) - { - } - - - void tizen_input_device::handle_select_axes( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_array *axes) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_object)->tizen_input_device_select_axes( - r, - axes); - } - - void tizen_input_device::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_input_device_object)->tizen_input_device_release( - r); - } - - void tizen_input_device::send_device_info(const std::string &name, uint32_t clas, uint32_t subclas, struct ::wl_array *axes) - { - DS_ASSERT_X(m_resource, "tizen_input_device::device_info", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_input_device::device_info as it's not initialised"); - return; - } - send_device_info( - m_resource->handle, - name, - clas, - subclas, - axes); - } - - void tizen_input_device::send_device_info(struct ::wl_resource *resource, const std::string &name, uint32_t clas, uint32_t subclas, struct ::wl_array *axes) - { - tizen_input_device_send_device_info( - resource, - name.c_str(), - clas, - subclas, - axes); - } - - - void tizen_input_device::send_event_device(uint32_t serial, const std::string &name, uint32_t time) - { - DS_ASSERT_X(m_resource, "tizen_input_device::event_device", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_input_device::event_device as it's not initialised"); - return; - } - send_event_device( - m_resource->handle, - serial, - name, - time); - } - - void tizen_input_device::send_event_device(struct ::wl_resource *resource, uint32_t serial, const std::string &name, uint32_t time) - { - tizen_input_device_send_event_device( - resource, - serial, - name.c_str(), - time); - } - - - void tizen_input_device::send_axis(uint32_t axis_type, wl_fixed_t value) - { - DS_ASSERT_X(m_resource, "tizen_input_device::axis", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_input_device::axis as it's not initialised"); - return; - } - send_axis( - m_resource->handle, - axis_type, - value); - } - - void tizen_input_device::send_axis(struct ::wl_resource *resource, uint32_t axis_type, wl_fixed_t value) - { - tizen_input_device_send_axis( - resource, - axis_type, - value); - } - - - tizen_launchscreen::tizen_launchscreen(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_launchscreen::tizen_launchscreen(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_launchscreen::tizen_launchscreen(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_launchscreen::tizen_launchscreen() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_launchscreen::~tizen_launchscreen() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_launchscreen::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_launchscreen::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_launchscreen::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_launchscreen::Resource *tizen_launchscreen::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_launchscreen::Resource *tizen_launchscreen::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_launchscreen::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_launchscreen_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_launchscreen::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_launchscreen::interface() - { - return &::tizen_launchscreen_interface; - } - - tizen_launchscreen::Resource *tizen_launchscreen::tizen_launchscreen_allocate() - { - return new Resource; - } - - void tizen_launchscreen::tizen_launchscreen_bind_resource(Resource *) - { - } - - void tizen_launchscreen::tizen_launchscreen_destroy_resource(Resource *) - { - } - - void tizen_launchscreen::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_launchscreen *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_launchscreen::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_launchscreen *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_launchscreen::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_launchscreen *that = resource->tizen_launchscreen_object; - that->m_resource_map.erase(resource->client()); - that->tizen_launchscreen_destroy_resource(resource); - delete resource; - } - - tizen_launchscreen::Resource *tizen_launchscreen::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_launchscreen_interface, version, id); - return bind(handle); - } - - tizen_launchscreen::Resource *tizen_launchscreen::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_launchscreen_allocate(); - resource->tizen_launchscreen_object = this; - - wl_resource_set_implementation(handle, &m_tizen_launchscreen_interface, resource, destroy_func); - resource->handle = handle; - tizen_launchscreen_bind_resource(resource); - return resource; - } - tizen_launchscreen::Resource *tizen_launchscreen::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_launchscreen_interface, &m_tizen_launchscreen_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_launchscreen_interface tizen_launchscreen::m_tizen_launchscreen_interface = { - tizen_launchscreen::handle_create_img, - tizen_launchscreen::handle_destroy - }; - - void tizen_launchscreen::tizen_launchscreen_create_img(Resource *, uint32_t) - { - } - - void tizen_launchscreen::tizen_launchscreen_destroy(Resource *) - { - } - - - void tizen_launchscreen::handle_create_img( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launchscreen_object)->tizen_launchscreen_create_img( - r, - id); - } - - void tizen_launchscreen::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launchscreen_object)->tizen_launchscreen_destroy( - r); - } - - tizen_launch_image::tizen_launch_image(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_launch_image::tizen_launch_image(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_launch_image::tizen_launch_image(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_launch_image::tizen_launch_image() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_launch_image::~tizen_launch_image() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_launch_image::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_launch_image::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_launch_image::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_launch_image::Resource *tizen_launch_image::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_launch_image::Resource *tizen_launch_image::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_launch_image::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_launch_image_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_launch_image::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_launch_image::interface() - { - return &::tizen_launch_image_interface; - } - - tizen_launch_image::Resource *tizen_launch_image::tizen_launch_image_allocate() - { - return new Resource; - } - - void tizen_launch_image::tizen_launch_image_bind_resource(Resource *) - { - } - - void tizen_launch_image::tizen_launch_image_destroy_resource(Resource *) - { - } - - void tizen_launch_image::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_launch_image *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_launch_image::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_launch_image *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_launch_image::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_launch_image *that = resource->tizen_launch_image_object; - that->m_resource_map.erase(resource->client()); - that->tizen_launch_image_destroy_resource(resource); - delete resource; - } - - tizen_launch_image::Resource *tizen_launch_image::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_launch_image_interface, version, id); - return bind(handle); - } - - tizen_launch_image::Resource *tizen_launch_image::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_launch_image_allocate(); - resource->tizen_launch_image_object = this; - - wl_resource_set_implementation(handle, &m_tizen_launch_image_interface, resource, destroy_func); - resource->handle = handle; - tizen_launch_image_bind_resource(resource); - return resource; - } - tizen_launch_image::Resource *tizen_launch_image::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_launch_image_interface, &m_tizen_launch_image_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_launch_image_interface tizen_launch_image::m_tizen_launch_image_interface = { - tizen_launch_image::handle_destroy, - tizen_launch_image::handle_launch, - tizen_launch_image::handle_owner, - tizen_launch_image::handle_show, - tizen_launch_image::handle_hide - }; - - void tizen_launch_image::tizen_launch_image_destroy(Resource *) - { - } - - void tizen_launch_image::tizen_launch_image_launch(Resource *, const std::string &, uint32_t , uint32_t , uint32_t , uint32_t , struct ::wl_array *) - { - } - - void tizen_launch_image::tizen_launch_image_owner(Resource *, uint32_t ) - { - } - - void tizen_launch_image::tizen_launch_image_show(Resource *) - { - } - - void tizen_launch_image::tizen_launch_image_hide(Resource *) - { - } - - - void tizen_launch_image::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_image_object)->tizen_launch_image_destroy( - r); - } - - void tizen_launch_image::handle_launch( - ::wl_client *client, - struct wl_resource *resource, - const char *file, - uint32_t file_type, - uint32_t color_depth, - uint32_t rotation, - uint32_t indicator, - struct ::wl_array *options) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_image_object)->tizen_launch_image_launch( - r, - std::string(file), - file_type, - color_depth, - rotation, - indicator, - options); - } - - void tizen_launch_image::handle_owner( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_image_object)->tizen_launch_image_owner( - r, - pid); - } - - void tizen_launch_image::handle_show( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_image_object)->tizen_launch_image_show( - r); - } - - void tizen_launch_image::handle_hide( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_image_object)->tizen_launch_image_hide( - r); - } - - tizen_effect::tizen_effect(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_effect::tizen_effect(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_effect::tizen_effect(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_effect::tizen_effect() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_effect::~tizen_effect() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_effect::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_effect::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_effect::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_effect::Resource *tizen_effect::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_effect::Resource *tizen_effect::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_effect::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_effect_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_effect::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_effect::interface() - { - return &::tizen_effect_interface; - } - - tizen_effect::Resource *tizen_effect::tizen_effect_allocate() - { - return new Resource; - } - - void tizen_effect::tizen_effect_bind_resource(Resource *) - { - } - - void tizen_effect::tizen_effect_destroy_resource(Resource *) - { - } - - void tizen_effect::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_effect *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_effect::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_effect *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_effect::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_effect *that = resource->tizen_effect_object; - that->m_resource_map.erase(resource->client()); - that->tizen_effect_destroy_resource(resource); - delete resource; - } - - tizen_effect::Resource *tizen_effect::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_effect_interface, version, id); - return bind(handle); - } - - tizen_effect::Resource *tizen_effect::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_effect_allocate(); - resource->tizen_effect_object = this; - - wl_resource_set_implementation(handle, &m_tizen_effect_interface, resource, destroy_func); - resource->handle = handle; - tizen_effect_bind_resource(resource); - return resource; - } - tizen_effect::Resource *tizen_effect::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_effect_interface, &m_tizen_effect_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_effect_interface tizen_effect::m_tizen_effect_interface = { - tizen_effect::handle_destroy - }; - - void tizen_effect::tizen_effect_destroy(Resource *) - { - } - - - void tizen_effect::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_effect_object)->tizen_effect_destroy( - r); - } - - void tizen_effect::send_start(struct ::wl_resource *surface, uint32_t type) - { - DS_ASSERT_X(m_resource, "tizen_effect::start", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_effect::start as it's not initialised"); - return; - } - send_start( - m_resource->handle, - surface, - type); - } - - void tizen_effect::send_start(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t type) - { - tizen_effect_send_start( - resource, - surface, - type); - } - - - void tizen_effect::send_end(struct ::wl_resource *surface, uint32_t type) - { - DS_ASSERT_X(m_resource, "tizen_effect::end", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_effect::end as it's not initialised"); - return; - } - send_end( - m_resource->handle, - surface, - type); - } - - void tizen_effect::send_end(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t type) - { - tizen_effect_send_end( - resource, - surface, - type); - } - - - tizen_display_policy::tizen_display_policy(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_display_policy::tizen_display_policy(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_display_policy::tizen_display_policy(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_display_policy::tizen_display_policy() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_display_policy::~tizen_display_policy() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_display_policy::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_display_policy::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_display_policy::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_display_policy::Resource *tizen_display_policy::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_display_policy::Resource *tizen_display_policy::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_display_policy::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_display_policy_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_display_policy::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_display_policy::interface() - { - return &::tizen_display_policy_interface; - } - - tizen_display_policy::Resource *tizen_display_policy::tizen_display_policy_allocate() - { - return new Resource; - } - - void tizen_display_policy::tizen_display_policy_bind_resource(Resource *) - { - } - - void tizen_display_policy::tizen_display_policy_destroy_resource(Resource *) - { - } - - void tizen_display_policy::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_display_policy *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_display_policy::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_display_policy *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_display_policy::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_display_policy *that = resource->tizen_display_policy_object; - that->m_resource_map.erase(resource->client()); - that->tizen_display_policy_destroy_resource(resource); - delete resource; - } - - tizen_display_policy::Resource *tizen_display_policy::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_display_policy_interface, version, id); - return bind(handle); - } - - tizen_display_policy::Resource *tizen_display_policy::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_display_policy_allocate(); - resource->tizen_display_policy_object = this; - - wl_resource_set_implementation(handle, &m_tizen_display_policy_interface, resource, destroy_func); - resource->handle = handle; - tizen_display_policy_bind_resource(resource); - return resource; - } - tizen_display_policy::Resource *tizen_display_policy::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_display_policy_interface, &m_tizen_display_policy_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_display_policy_interface tizen_display_policy::m_tizen_display_policy_interface = { - tizen_display_policy::handle_set_window_brightness, - tizen_display_policy::handle_destroy - }; - - void tizen_display_policy::tizen_display_policy_set_window_brightness(Resource *, struct ::wl_resource *, int32_t ) - { - } - - void tizen_display_policy::tizen_display_policy_destroy(Resource *) - { - } - - - void tizen_display_policy::handle_set_window_brightness( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t brightness) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_display_policy_object)->tizen_display_policy_set_window_brightness( - r, - surface, - brightness); - } - - void tizen_display_policy::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_display_policy_object)->tizen_display_policy_destroy( - r); - } - - void tizen_display_policy::send_window_brightness_done(struct ::wl_resource *surface, int32_t brightness, uint32_t error_state) - { - DS_ASSERT_X(m_resource, "tizen_display_policy::window_brightness_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_display_policy::window_brightness_done as it's not initialised"); - return; - } - send_window_brightness_done( - m_resource->handle, - surface, - brightness, - error_state); - } - - void tizen_display_policy::send_window_brightness_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t brightness, uint32_t error_state) - { - tizen_display_policy_send_window_brightness_done( - resource, - surface, - brightness, - error_state); - } - - - tizen_indicator::tizen_indicator(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_indicator::tizen_indicator(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_indicator::tizen_indicator(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_indicator::tizen_indicator() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_indicator::~tizen_indicator() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_indicator::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_indicator::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_indicator::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_indicator::Resource *tizen_indicator::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_indicator::Resource *tizen_indicator::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_indicator::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_indicator_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_indicator::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_indicator::interface() - { - return &::tizen_indicator_interface; - } - - tizen_indicator::Resource *tizen_indicator::tizen_indicator_allocate() - { - return new Resource; - } - - void tizen_indicator::tizen_indicator_bind_resource(Resource *) - { - } - - void tizen_indicator::tizen_indicator_destroy_resource(Resource *) - { - } - - void tizen_indicator::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_indicator *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_indicator::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_indicator *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_indicator::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_indicator *that = resource->tizen_indicator_object; - that->m_resource_map.erase(resource->client()); - that->tizen_indicator_destroy_resource(resource); - delete resource; - } - - tizen_indicator::Resource *tizen_indicator::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_indicator_interface, version, id); - return bind(handle); - } - - tizen_indicator::Resource *tizen_indicator::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_indicator_allocate(); - resource->tizen_indicator_object = this; - - wl_resource_set_implementation(handle, &m_tizen_indicator_interface, resource, destroy_func); - resource->handle = handle; - tizen_indicator_bind_resource(resource); - return resource; - } - tizen_indicator::Resource *tizen_indicator::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_indicator_interface, &m_tizen_indicator_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_indicator_interface tizen_indicator::m_tizen_indicator_interface = { - tizen_indicator::handle_destroy, - tizen_indicator::handle_set_state, - tizen_indicator::handle_set_opacity_mode, - tizen_indicator::handle_set_visible_type - }; - - void tizen_indicator::tizen_indicator_destroy(Resource *) - { - } - - void tizen_indicator::tizen_indicator_set_state(Resource *, struct ::wl_resource *, int32_t ) - { - } - - void tizen_indicator::tizen_indicator_set_opacity_mode(Resource *, struct ::wl_resource *, int32_t ) - { - } - - void tizen_indicator::tizen_indicator_set_visible_type(Resource *, struct ::wl_resource *, int32_t ) - { - } - - - void tizen_indicator::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_indicator_object)->tizen_indicator_destroy( - r); - } - - void tizen_indicator::handle_set_state( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t state) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_indicator_object)->tizen_indicator_set_state( - r, - surface, - state); - } - - void tizen_indicator::handle_set_opacity_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t mode) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_indicator_object)->tizen_indicator_set_opacity_mode( - r, - surface, - mode); - } - - void tizen_indicator::handle_set_visible_type( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_indicator_object)->tizen_indicator_set_visible_type( - r, - surface, - type); - } - - void tizen_indicator::send_flick(struct ::wl_resource *surface, int32_t type) - { - DS_ASSERT_X(m_resource, "tizen_indicator::flick", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_indicator::flick as it's not initialised"); - return; - } - send_flick( - m_resource->handle, - surface, - type); - } - - void tizen_indicator::send_flick(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t type) - { - tizen_indicator_send_flick( - resource, - surface, - type); - } - - - tizen_clipboard::tizen_clipboard(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_clipboard::tizen_clipboard(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_clipboard::tizen_clipboard(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_clipboard::tizen_clipboard() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_clipboard::~tizen_clipboard() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_clipboard::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_clipboard::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_clipboard::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_clipboard::Resource *tizen_clipboard::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_clipboard::Resource *tizen_clipboard::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_clipboard::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_clipboard_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_clipboard::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_clipboard::interface() - { - return &::tizen_clipboard_interface; - } - - tizen_clipboard::Resource *tizen_clipboard::tizen_clipboard_allocate() - { - return new Resource; - } - - void tizen_clipboard::tizen_clipboard_bind_resource(Resource *) - { - } - - void tizen_clipboard::tizen_clipboard_destroy_resource(Resource *) - { - } - - void tizen_clipboard::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_clipboard *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_clipboard::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_clipboard *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_clipboard::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_clipboard *that = resource->tizen_clipboard_object; - that->m_resource_map.erase(resource->client()); - that->tizen_clipboard_destroy_resource(resource); - delete resource; - } - - tizen_clipboard::Resource *tizen_clipboard::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_clipboard_interface, version, id); - return bind(handle); - } - - tizen_clipboard::Resource *tizen_clipboard::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_clipboard_allocate(); - resource->tizen_clipboard_object = this; - - wl_resource_set_implementation(handle, &m_tizen_clipboard_interface, resource, destroy_func); - resource->handle = handle; - tizen_clipboard_bind_resource(resource); - return resource; - } - tizen_clipboard::Resource *tizen_clipboard::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_clipboard_interface, &m_tizen_clipboard_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_clipboard_interface tizen_clipboard::m_tizen_clipboard_interface = { - tizen_clipboard::handle_destroy, - tizen_clipboard::handle_show, - tizen_clipboard::handle_hide, - tizen_clipboard::handle_set_data_only - }; - - void tizen_clipboard::tizen_clipboard_destroy(Resource *) - { - } - - void tizen_clipboard::tizen_clipboard_show(Resource *, struct ::wl_resource *) - { - } - - void tizen_clipboard::tizen_clipboard_hide(Resource *, struct ::wl_resource *) - { - } - - void tizen_clipboard::tizen_clipboard_set_data_only(Resource *, uint32_t ) - { - } - - - void tizen_clipboard::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_clipboard_object)->tizen_clipboard_destroy( - r); - } - - void tizen_clipboard::handle_show( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_clipboard_object)->tizen_clipboard_show( - r, - surface); - } - - void tizen_clipboard::handle_hide( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_clipboard_object)->tizen_clipboard_hide( - r, - surface); - } - - void tizen_clipboard::handle_set_data_only( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_clipboard_object)->tizen_clipboard_set_data_only( - r, - set); - } - - void tizen_clipboard::send_data_selected(struct ::wl_resource *surface) - { - DS_ASSERT_X(m_resource, "tizen_clipboard::data_selected", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_clipboard::data_selected as it's not initialised"); - return; - } - send_data_selected( - m_resource->handle, - surface); - } - - void tizen_clipboard::send_data_selected(struct ::wl_resource *resource, struct ::wl_resource *surface) - { - tizen_clipboard_send_data_selected( - resource, - surface); - } - - - void tizen_clipboard::send_allowed_data_only(uint32_t allowed) - { - DS_ASSERT_X(m_resource, "tizen_clipboard::allowed_data_only", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_clipboard::allowed_data_only as it's not initialised"); - return; - } - send_allowed_data_only( - m_resource->handle, - allowed); - } - - void tizen_clipboard::send_allowed_data_only(struct ::wl_resource *resource, uint32_t allowed) - { - tizen_clipboard_send_allowed_data_only( - resource, - allowed); - } - - - tizen_screen_rotation::tizen_screen_rotation(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_screen_rotation::tizen_screen_rotation(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_screen_rotation::tizen_screen_rotation(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_screen_rotation::tizen_screen_rotation() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_screen_rotation::~tizen_screen_rotation() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_screen_rotation::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_screen_rotation::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_screen_rotation::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_screen_rotation::Resource *tizen_screen_rotation::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_screen_rotation::Resource *tizen_screen_rotation::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_screen_rotation::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_screen_rotation_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_screen_rotation::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_screen_rotation::interface() - { - return &::tizen_screen_rotation_interface; - } - - tizen_screen_rotation::Resource *tizen_screen_rotation::tizen_screen_rotation_allocate() - { - return new Resource; - } - - void tizen_screen_rotation::tizen_screen_rotation_bind_resource(Resource *) - { - } - - void tizen_screen_rotation::tizen_screen_rotation_destroy_resource(Resource *) - { - } - - void tizen_screen_rotation::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_screen_rotation *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_screen_rotation::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_screen_rotation *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_screen_rotation::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_screen_rotation *that = resource->tizen_screen_rotation_object; - that->m_resource_map.erase(resource->client()); - that->tizen_screen_rotation_destroy_resource(resource); - delete resource; - } - - tizen_screen_rotation::Resource *tizen_screen_rotation::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_screen_rotation_interface, version, id); - return bind(handle); - } - - tizen_screen_rotation::Resource *tizen_screen_rotation::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_screen_rotation_allocate(); - resource->tizen_screen_rotation_object = this; - - wl_resource_set_implementation(handle, &m_tizen_screen_rotation_interface, resource, destroy_func); - resource->handle = handle; - tizen_screen_rotation_bind_resource(resource); - return resource; - } - tizen_screen_rotation::Resource *tizen_screen_rotation::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_screen_rotation_interface, &m_tizen_screen_rotation_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_screen_rotation_interface tizen_screen_rotation::m_tizen_screen_rotation_interface = { - tizen_screen_rotation::handle_get_ignore_output_transform, - tizen_screen_rotation::handle_destroy - }; - - void tizen_screen_rotation::tizen_screen_rotation_get_ignore_output_transform(Resource *, struct ::wl_resource *) - { - } - - void tizen_screen_rotation::tizen_screen_rotation_destroy(Resource *) - { - } - - - void tizen_screen_rotation::handle_get_ignore_output_transform( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screen_rotation_object)->tizen_screen_rotation_get_ignore_output_transform( - r, - surface); - } - - void tizen_screen_rotation::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_screen_rotation_object)->tizen_screen_rotation_destroy( - r); - } - - void tizen_screen_rotation::send_ignore_output_transform(struct ::wl_resource *surface, uint32_t ignore) - { - DS_ASSERT_X(m_resource, "tizen_screen_rotation::ignore_output_transform", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_screen_rotation::ignore_output_transform as it's not initialised"); - return; - } - send_ignore_output_transform( - m_resource->handle, - surface, - ignore); - } - - void tizen_screen_rotation::send_ignore_output_transform(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t ignore) - { - tizen_screen_rotation_send_ignore_output_transform( - resource, - surface, - ignore); - } - - - tizen_renderer::tizen_renderer(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_renderer::tizen_renderer(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_renderer::tizen_renderer(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_renderer::tizen_renderer() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_renderer::~tizen_renderer() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_renderer::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_renderer::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_renderer::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_renderer::Resource *tizen_renderer::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_renderer::Resource *tizen_renderer::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_renderer::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_renderer_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_renderer::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_renderer::interface() - { - return &::tizen_renderer_interface; - } - - tizen_renderer::Resource *tizen_renderer::tizen_renderer_allocate() - { - return new Resource; - } - - void tizen_renderer::tizen_renderer_bind_resource(Resource *) - { - } - - void tizen_renderer::tizen_renderer_destroy_resource(Resource *) - { - } - - void tizen_renderer::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_renderer *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_renderer::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_renderer *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_renderer::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_renderer *that = resource->tizen_renderer_object; - that->m_resource_map.erase(resource->client()); - that->tizen_renderer_destroy_resource(resource); - delete resource; - } - - tizen_renderer::Resource *tizen_renderer::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_renderer_interface, version, id); - return bind(handle); - } - - tizen_renderer::Resource *tizen_renderer::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_renderer_allocate(); - resource->tizen_renderer_object = this; - - wl_resource_set_implementation(handle, &m_tizen_renderer_interface, resource, destroy_func); - resource->handle = handle; - tizen_renderer_bind_resource(resource); - return resource; - } - tizen_renderer::Resource *tizen_renderer::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_renderer_interface, &m_tizen_renderer_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_renderer_interface tizen_renderer::m_tizen_renderer_interface = { - tizen_renderer::handle_get_renderer_surface, - tizen_renderer::handle_destroy - }; - - void tizen_renderer::tizen_renderer_get_renderer_surface(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_renderer::tizen_renderer_destroy(Resource *) - { - } - - - void tizen_renderer::handle_get_renderer_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_renderer_object)->tizen_renderer_get_renderer_surface( - r, - id, - surface); - } - - void tizen_renderer::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_renderer_object)->tizen_renderer_destroy( - r); - } - - tizen_renderer_surface::tizen_renderer_surface(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_renderer_surface::tizen_renderer_surface(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_renderer_surface::tizen_renderer_surface(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_renderer_surface::tizen_renderer_surface() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_renderer_surface::~tizen_renderer_surface() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_renderer_surface::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_renderer_surface::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_renderer_surface::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_renderer_surface::Resource *tizen_renderer_surface::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_renderer_surface::Resource *tizen_renderer_surface::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_renderer_surface::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_renderer_surface_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_renderer_surface::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_renderer_surface::interface() - { - return &::tizen_renderer_surface_interface; - } - - tizen_renderer_surface::Resource *tizen_renderer_surface::tizen_renderer_surface_allocate() - { - return new Resource; - } - - void tizen_renderer_surface::tizen_renderer_surface_bind_resource(Resource *) - { - } - - void tizen_renderer_surface::tizen_renderer_surface_destroy_resource(Resource *) - { - } - - void tizen_renderer_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_renderer_surface *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_renderer_surface::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_renderer_surface *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_renderer_surface::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_renderer_surface *that = resource->tizen_renderer_surface_object; - that->m_resource_map.erase(resource->client()); - that->tizen_renderer_surface_destroy_resource(resource); - delete resource; - } - - tizen_renderer_surface::Resource *tizen_renderer_surface::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_renderer_surface_interface, version, id); - return bind(handle); - } - - tizen_renderer_surface::Resource *tizen_renderer_surface::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_renderer_surface_allocate(); - resource->tizen_renderer_surface_object = this; - - wl_resource_set_implementation(handle, &m_tizen_renderer_surface_interface, resource, destroy_func); - resource->handle = handle; - tizen_renderer_surface_bind_resource(resource); - return resource; - } - tizen_renderer_surface::Resource *tizen_renderer_surface::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_renderer_surface_interface, &m_tizen_renderer_surface_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_renderer_surface_interface tizen_renderer_surface::m_tizen_renderer_surface_interface = { - tizen_renderer_surface::handle_destroy - }; - - void tizen_renderer_surface::tizen_renderer_surface_destroy(Resource *) - { - } - - - void tizen_renderer_surface::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_renderer_surface_object)->tizen_renderer_surface_destroy( - r); - } - - void tizen_renderer_surface::send_redraw_request() - { - DS_ASSERT_X(m_resource, "tizen_renderer_surface::redraw_request", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_renderer_surface::redraw_request as it's not initialised"); - return; - } - send_redraw_request( - m_resource->handle); - } - - void tizen_renderer_surface::send_redraw_request(struct ::wl_resource *resource) - { - tizen_renderer_surface_send_redraw_request( - resource); - } - -} -/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-tizen-extension.h b/src/DSWaylandServer/dswayland-server-tizen-extension.h deleted file mode 100644 index 5dd83e3..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-extension.h +++ /dev/null @@ -1,3330 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-extension.xml */ - -#ifndef __DS_TIZEN_EXTENSION_PROTOCOL_H__ -#define __DS_TIZEN_EXTENSION_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "tizen-extension-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class tizen_surface - { - public: - tizen_surface(struct ::wl_client *client, uint32_t id, int version); - tizen_surface(struct ::wl_display *display, int version); - tizen_surface(struct ::wl_resource *resource); - tizen_surface(); - - virtual ~tizen_surface(); - - class Resource - { - public: - Resource() : tizen_surface_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_surface *tizen_surface_object; - tizen_surface *object() { return tizen_surface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tizen_surface_allocate(); - - virtual void tizen_surface_bind_resource(Resource *resource); - virtual void tizen_surface_destroy_resource(Resource *resource); - - virtual void tizen_surface_get_tizen_resource(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_surface_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_surface_interface m_tizen_surface_interface; - - static void handle_get_tizen_resource( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_surface *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_resource - { - public: - tizen_resource(struct ::wl_client *client, uint32_t id, int version); - tizen_resource(struct ::wl_display *display, int version); - tizen_resource(struct ::wl_resource *resource); - tizen_resource(); - - virtual ~tizen_resource(); - - class Resource - { - public: - Resource() : tizen_resource_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_resource *tizen_resource_object; - tizen_resource *object() { return tizen_resource_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_resource_id(uint32_t id); - void send_resource_id(struct ::wl_resource *resource, uint32_t id); - - protected: - virtual Resource *tizen_resource_allocate(); - - virtual void tizen_resource_bind_resource(Resource *resource); - virtual void tizen_resource_destroy_resource(Resource *resource); - - virtual void tizen_resource_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_resource_interface m_tizen_resource_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_resource *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_policy - { - public: - tizen_policy(struct ::wl_client *client, uint32_t id, int version); - tizen_policy(struct ::wl_display *display, int version); - tizen_policy(struct ::wl_resource *resource); - tizen_policy(); - - virtual ~tizen_policy(); - - class Resource - { - public: - Resource() : tizen_policy_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_policy *tizen_policy_object; - tizen_policy *object() { return tizen_policy_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum win_type { - win_type_none = 0, - win_type_toplevel = 1, - win_type_fullscreen = 2, - win_type_maximized = 3, - win_type_transient = 4, - win_type_menu = 5, - win_type_dnd = 6, - win_type_custom = 7, - win_type_notification = 8, - win_type_utility = 9, - win_type_dialog = 10, - win_type_dock = 11, - win_type_splash = 12, - }; - - enum conformant_part { - conformant_part_indicator = 0, - conformant_part_keyboard = 1, - conformant_part_clipboard = 2, - }; - - enum error_state { - error_state_none = 0, - error_state_permission_denied = 1, - }; - - enum level { - level_1 = 0, - level_2 = 1, - level_3 = 2, - level_none = -1, - level_default = 10, - level_medium = 20, - level_high = 30, - level_top = 40, - }; - - enum mode { - mode_default = 0, - mode_always_on = 1, - }; - - enum stack_mode { - stack_mode_none = 0, - stack_mode_above = 1, - stack_mode_below = 2, - }; - - void send_conformant(struct ::wl_resource *surface, uint32_t is_conformant); - void send_conformant(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t is_conformant); - void send_conformant_area(struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h); - void send_conformant_area(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h); - void send_notification_done(struct ::wl_resource *surface, int32_t level, uint32_t error_state); - void send_notification_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t level, uint32_t error_state); - void send_transient_for_done(uint32_t child_id); - void send_transient_for_done(struct ::wl_resource *resource, uint32_t child_id); - void send_window_screen_mode_done(struct ::wl_resource *surface, uint32_t mode, uint32_t error_state); - void send_window_screen_mode_done(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t mode, uint32_t error_state); - void send_iconify_state_changed(struct ::wl_resource *surface, uint32_t iconified, uint32_t force); - void send_iconify_state_changed(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t iconified, uint32_t force); - void send_supported_aux_hints(struct ::wl_resource *surface, struct ::wl_array *hints, uint32_t num_hints); - void send_supported_aux_hints(struct ::wl_resource *resource, struct ::wl_resource *surface, struct ::wl_array *hints, uint32_t num_hints); - void send_allowed_aux_hint(struct ::wl_resource *surface, int32_t id); - void send_allowed_aux_hint(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t id); - void send_aux_message(struct ::wl_resource *surface, const std::string &key, const std::string &value, struct ::wl_array *options); - void send_aux_message(struct ::wl_resource *resource, struct ::wl_resource *surface, const std::string &key, const std::string &value, struct ::wl_array *options); - void send_conformant_region(struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial); - void send_conformant_region(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial); - void send_interactive_move_done(struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h); - void send_interactive_move_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h); - void send_interactive_resize_done(struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h); - void send_interactive_resize_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t x, int32_t y, uint32_t w, uint32_t h); - - protected: - virtual Resource *tizen_policy_allocate(); - - virtual void tizen_policy_bind_resource(Resource *resource); - virtual void tizen_policy_destroy_resource(Resource *resource); - - virtual void tizen_policy_get_visibility(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_policy_get_position(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_policy_activate(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_activate_below_by_res_id(Resource *resource, uint32_t res_id, uint32_t below_res_id); - virtual void tizen_policy_raise(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_lower(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_lower_by_res_id(Resource *resource, uint32_t res_id); - virtual void tizen_policy_set_focus_skip(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_unset_focus_skip(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_set_role(Resource *resource, struct ::wl_resource *surface, const std::string &role); - virtual void tizen_policy_set_type(Resource *resource, struct ::wl_resource *surface, uint32_t win_type); - virtual void tizen_policy_set_conformant(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_unset_conformant(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_get_conformant(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_set_notification_level(Resource *resource, struct ::wl_resource *surface, int32_t level); - virtual void tizen_policy_set_transient_for(Resource *resource, uint32_t child_id, uint32_t parent_id); - virtual void tizen_policy_unset_transient_for(Resource *resource, uint32_t child_id); - virtual void tizen_policy_set_window_screen_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode); - virtual void tizen_policy_place_subsurface_below_parent(Resource *resource, struct ::wl_resource *subsurface); - virtual void tizen_policy_set_subsurface_stand_alone(Resource *resource, struct ::wl_resource *subsurface); - virtual void tizen_policy_get_subsurface(Resource *resource, uint32_t id, struct ::wl_resource *surface, uint32_t parent_id); - virtual void tizen_policy_set_opaque_state(Resource *resource, struct ::wl_resource *surface, int32_t state); - virtual void tizen_policy_iconify(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_uniconify(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_add_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &name, const std::string &value); - virtual void tizen_policy_change_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &value); - virtual void tizen_policy_del_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id); - virtual void tizen_policy_get_supported_aux_hints(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_set_background_state(Resource *resource, uint32_t pid); - virtual void tizen_policy_unset_background_state(Resource *resource, uint32_t pid); - virtual void tizen_policy_set_floating_mode(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_unset_floating_mode(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_set_stack_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode); - virtual void tizen_policy_activate_above_by_res_id(Resource *resource, uint32_t res_id, uint32_t above_res_id); - virtual void tizen_policy_get_subsurface_watcher(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_policy_set_parent(Resource *resource, struct ::wl_resource *child, struct ::wl_resource *parent); - virtual void tizen_policy_ack_conformant_region(Resource *resource, struct ::wl_resource *surface, uint32_t serial); - virtual void tizen_policy_destroy(Resource *resource); - virtual void tizen_policy_has_video(Resource *resource, struct ::wl_resource *surface, uint32_t has); - virtual void tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid); - virtual void tizen_policy_show(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_hide(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_policy_set_transient_for_below(Resource *resource, uint32_t child_id, uint32_t parent_id); - virtual void tizen_policy_set_parent_with_below(Resource *resource, struct ::wl_resource *child, struct ::wl_resource *parent); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_policy_interface m_tizen_policy_interface; - - static void handle_get_visibility( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_get_position( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_activate( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_activate_below_by_res_id( - ::wl_client *client, - struct wl_resource *resource, - uint32_t res_id, - uint32_t below_res_id); - static void handle_raise( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_lower( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_lower_by_res_id( - ::wl_client *client, - struct wl_resource *resource, - uint32_t res_id); - static void handle_set_focus_skip( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_unset_focus_skip( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_set_role( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - const char *role); - static void handle_set_type( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t win_type); - static void handle_set_conformant( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_unset_conformant( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_get_conformant( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_set_notification_level( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t level); - static void handle_set_transient_for( - ::wl_client *client, - struct wl_resource *resource, - uint32_t child_id, - uint32_t parent_id); - static void handle_unset_transient_for( - ::wl_client *client, - struct wl_resource *resource, - uint32_t child_id); - static void handle_set_window_screen_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t mode); - static void handle_place_subsurface_below_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *subsurface); - static void handle_set_subsurface_stand_alone( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *subsurface); - static void handle_get_subsurface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface, - uint32_t parent_id); - static void handle_set_opaque_state( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t state); - static void handle_iconify( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_uniconify( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_add_aux_hint( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t id, - const char *name, - const char *value); - static void handle_change_aux_hint( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t id, - const char *value); - static void handle_del_aux_hint( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t id); - static void handle_get_supported_aux_hints( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_set_background_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid); - static void handle_unset_background_state( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid); - static void handle_set_floating_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_unset_floating_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_set_stack_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t mode); - static void handle_activate_above_by_res_id( - ::wl_client *client, - struct wl_resource *resource, - uint32_t res_id, - uint32_t above_res_id); - static void handle_get_subsurface_watcher( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *child, - struct ::wl_resource *parent); - static void handle_ack_conformant_region( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t serial); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_has_video( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t has); - static void handle_set_appid( - ::wl_client *client, - struct wl_resource *resource, - int32_t pid, - const char *appid); - static void handle_show( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_hide( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_set_transient_for_below( - ::wl_client *client, - struct wl_resource *resource, - uint32_t child_id, - uint32_t parent_id); - static void handle_set_parent_with_below( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *child, - struct ::wl_resource *parent); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_policy *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_visibility - { - public: - tizen_visibility(struct ::wl_client *client, uint32_t id, int version); - tizen_visibility(struct ::wl_display *display, int version); - tizen_visibility(struct ::wl_resource *resource); - tizen_visibility(); - - virtual ~tizen_visibility(); - - class Resource - { - public: - Resource() : tizen_visibility_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_visibility *tizen_visibility_object; - tizen_visibility *object() { return tizen_visibility_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum visibility { - visibility_unobscured = 0, - visibility_partially_obscured = 1, - visibility_fully_obscured = 2, - visibility_pre_unobscured = 3, - }; - - void send_notify(uint32_t visibility); - void send_notify(struct ::wl_resource *resource, uint32_t visibility); - void send_changed(uint32_t type, uint32_t option); - void send_changed(struct ::wl_resource *resource, uint32_t type, uint32_t option); - - protected: - virtual Resource *tizen_visibility_allocate(); - - virtual void tizen_visibility_bind_resource(Resource *resource); - virtual void tizen_visibility_destroy_resource(Resource *resource); - - virtual void tizen_visibility_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_visibility_interface m_tizen_visibility_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_visibility *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_position - { - public: - tizen_position(struct ::wl_client *client, uint32_t id, int version); - tizen_position(struct ::wl_display *display, int version); - tizen_position(struct ::wl_resource *resource); - tizen_position(); - - virtual ~tizen_position(); - - class Resource - { - public: - Resource() : tizen_position_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_position *tizen_position_object; - tizen_position *object() { return tizen_position_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_changed(int32_t x, int32_t y); - void send_changed(struct ::wl_resource *resource, int32_t x, int32_t y); - - protected: - virtual Resource *tizen_position_allocate(); - - virtual void tizen_position_bind_resource(Resource *resource); - virtual void tizen_position_destroy_resource(Resource *resource); - - virtual void tizen_position_destroy(Resource *resource); - virtual void tizen_position_set(Resource *resource, int32_t x, int32_t y); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_position_interface m_tizen_position_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_position *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_move_resize - { - public: - tizen_move_resize(struct ::wl_client *client, uint32_t id, int version); - tizen_move_resize(struct ::wl_display *display, int version); - tizen_move_resize(struct ::wl_resource *resource); - tizen_move_resize(); - - virtual ~tizen_move_resize(); - - class Resource - { - public: - Resource() : tizen_move_resize_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_move_resize *tizen_move_resize_object; - tizen_move_resize *object() { return tizen_move_resize_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error_state { - error_state_none = 0, - error_state_invalid_buffer = 1, - error_state_not_supported = 2, - }; - - void send_geometry_done(struct ::wl_resource *surface, uint32_t serial, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t error_state); - void send_geometry_done(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t serial, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t error_state); - - protected: - virtual Resource *tizen_move_resize_allocate(); - - virtual void tizen_move_resize_bind_resource(Resource *resource); - virtual void tizen_move_resize_destroy_resource(Resource *resource); - - virtual void tizen_move_resize_destroy(Resource *resource); - virtual void tizen_move_resize_set_geometry(Resource *resource, struct ::wl_resource *surface, uint32_t serial, int32_t x, int32_t y, int32_t w, int32_t h); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_move_resize_interface m_tizen_move_resize_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_geometry( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t serial, - int32_t x, - int32_t y, - int32_t w, - int32_t h); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_move_resize *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_gesture - { - public: - tizen_gesture(struct ::wl_client *client, uint32_t id, int version); - tizen_gesture(struct ::wl_display *display, int version); - tizen_gesture(struct ::wl_resource *resource); - tizen_gesture(); - - virtual ~tizen_gesture(); - - class Resource - { - public: - Resource() : tizen_gesture_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_gesture *tizen_gesture_object; - tizen_gesture *object() { return tizen_gesture_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_none = 0, - error_invalid_data = 1, - error_no_permission = 2, - error_no_system_resources = 3, - error_grabbed_already = 4, - error_not_supported = 5, - }; - - enum type { - type_edge_swipe = 1, - type_edge_drag = 2, - type_tap = 4, - type_palm_cover = 8, - type_pan = 16, - type_pinch = 32, - type_palm_swipe = 64, - }; - - enum mode { - mode_begin = 1, - mode_update = 2, - mode_end = 3, - mode_done = 4, - }; - - enum edge { - edge_top = 1, - edge_right = 2, - edge_bottom = 3, - edge_left = 4, - }; - - enum edge_size { - edge_size_none = 0, - edge_size_full = 1, - edge_size_partial = 2, - }; - - void send_grab_edge_swipe_notify(uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point, uint32_t error); - void send_grab_edge_swipe_notify(struct ::wl_resource *resource, uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point, uint32_t error); - void send_edge_swipe(uint32_t mode, uint32_t fingers, int32_t sx, int32_t sy, uint32_t edge); - void send_edge_swipe(struct ::wl_resource *resource, uint32_t mode, uint32_t fingers, int32_t sx, int32_t sy, uint32_t edge); - void send_edge_drag_notify(uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point, uint32_t error); - void send_edge_drag_notify(struct ::wl_resource *resource, uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point, uint32_t error); - void send_edge_drag(uint32_t mode, uint32_t fingers, int32_t cx, int32_t cy, uint32_t edge); - void send_edge_drag(struct ::wl_resource *resource, uint32_t mode, uint32_t fingers, int32_t cx, int32_t cy, uint32_t edge); - void send_tap_notify(uint32_t fingers, uint32_t repeats, uint32_t error); - void send_tap_notify(struct ::wl_resource *resource, uint32_t fingers, uint32_t repeats, uint32_t error); - void send_tap(uint32_t mode, uint32_t fingers, uint32_t repeats); - void send_tap(struct ::wl_resource *resource, uint32_t mode, uint32_t fingers, uint32_t repeats); - void send_palm_cover_notify(struct ::wl_resource *surface, uint32_t error); - void send_palm_cover_notify(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t error); - void send_palm_cover(struct ::wl_resource *surface, uint32_t mode, uint32_t duration, int32_t cx, int32_t cy, uint32_t size, wl_fixed_t pressure); - void send_palm_cover(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t mode, uint32_t duration, int32_t cx, int32_t cy, uint32_t size, wl_fixed_t pressure); - void send_activate_notify(struct ::wl_resource *surface, uint32_t type, uint32_t active, uint32_t error); - void send_activate_notify(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t type, uint32_t active, uint32_t error); - - protected: - virtual Resource *tizen_gesture_allocate(); - - virtual void tizen_gesture_bind_resource(Resource *resource); - virtual void tizen_gesture_destroy_resource(Resource *resource); - - virtual void tizen_gesture_grab_edge_swipe(Resource *resource, uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point); - virtual void tizen_gesture_ungrab_edge_swipe(Resource *resource, uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point); - virtual void tizen_gesture_grab_edge_drag(Resource *resource, uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point); - virtual void tizen_gesture_ungrab_edge_drag(Resource *resource, uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point); - virtual void tizen_gesture_grab_tap(Resource *resource, uint32_t fingers, uint32_t repeats); - virtual void tizen_gesture_ungrab_tap(Resource *resource, uint32_t fingers, uint32_t repeats); - virtual void tizen_gesture_grab_palm_cover(Resource *resource); - virtual void tizen_gesture_ungrab_palm_cover(Resource *resource); - virtual void tizen_gesture_select_palm_cover(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_gesture_deselect_palm_cover(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_gesture_activate_set(Resource *resource, struct ::wl_resource *surface, uint32_t type, uint32_t active); - virtual void tizen_gesture_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_gesture_interface m_tizen_gesture_interface; - - static void handle_grab_edge_swipe( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t edge, - uint32_t edge_size, - uint32_t start_point, - uint32_t end_point); - static void handle_ungrab_edge_swipe( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t edge, - uint32_t edge_size, - uint32_t start_point, - uint32_t end_point); - static void handle_grab_edge_drag( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t edge, - uint32_t edge_size, - uint32_t start_point, - uint32_t end_point); - static void handle_ungrab_edge_drag( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t edge, - uint32_t edge_size, - uint32_t start_point, - uint32_t end_point); - static void handle_grab_tap( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t repeats); - static void handle_ungrab_tap( - ::wl_client *client, - struct wl_resource *resource, - uint32_t fingers, - uint32_t repeats); - static void handle_grab_palm_cover( - ::wl_client *client, - struct wl_resource *resource); - static void handle_ungrab_palm_cover( - ::wl_client *client, - struct wl_resource *resource); - static void handle_select_palm_cover( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_deselect_palm_cover( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_activate_set( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t type, - uint32_t active); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_gesture *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_keyrouter - { - public: - tizen_keyrouter(struct ::wl_client *client, uint32_t id, int version); - tizen_keyrouter(struct ::wl_display *display, int version); - tizen_keyrouter(struct ::wl_resource *resource); - tizen_keyrouter(); - - virtual ~tizen_keyrouter(); - - class Resource - { - public: - Resource() : tizen_keyrouter_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_keyrouter *tizen_keyrouter_object; - tizen_keyrouter *object() { return tizen_keyrouter_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_none = 0, // no error - error_invalid_surface = 1, // Given surface is invalid. - error_invalid_key = 2, // Given key is invalid. - error_invalid_mode = 3, // Given mode is invalid. - error_grabbed_already = 4, // The key has been grabbed already. - error_no_permission = 5, // The wl client has no permission to grab the key. - error_no_system_resources = 6, // System resources are insufficient. - error_invalid_array = 7, // Given array has invalid pairs or data type. - }; - - enum mode { - mode_none = 0, // none - mode_shared = 1, // mode to get a key grab with the other client surfaces when the focused client surface gets the key - mode_topmost = 2, // mode to get a key grab when the client surface is the top most surface - mode_overridable_exclusive = 3, // mode to get a key grab exclusively, overridably regardless of the order in the surface stack - mode_exclusive = 4, // mode to get a key grab exclusively regardless of the order in surface stack - mode_registered = 5, // mode to get a key grab only when a requesting surface is on top among the registering surfaces for the key - }; - - enum config_mode { - config_mode_none = 0, // none - config_mode_invisible_set = 1, // mode to set window to enable send event to invisible window below in stack - config_mode_invisible_get = 2, // mode to set window to get event to invisible state if any top window has set register_set - config_mode_num_key_focus = 3, // mode to register for num keys for focus window - config_mode_picture_off = 4, // mode to set picture off for particular key - }; - - void send_keygrab_notify(struct ::wl_resource *surface, uint32_t key, uint32_t mode, uint32_t error); - void send_keygrab_notify(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t key, uint32_t mode, uint32_t error); - void send_keygrab_notify_list(struct ::wl_resource *surface, struct ::wl_array *grab_result); - void send_keygrab_notify_list(struct ::wl_resource *resource, struct ::wl_resource *surface, struct ::wl_array *grab_result); - void send_getgrab_notify_list(struct ::wl_resource *surface, struct ::wl_array *grab_result); - void send_getgrab_notify_list(struct ::wl_resource *resource, struct ::wl_resource *surface, struct ::wl_array *grab_result); - void send_set_register_none_key_notify(struct ::wl_resource *surface, uint32_t mode); - void send_set_register_none_key_notify(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t mode); - void send_keyregister_notify(uint32_t status); - void send_keyregister_notify(struct ::wl_resource *resource, uint32_t status); - void send_set_input_config_notify(uint32_t status); - void send_set_input_config_notify(struct ::wl_resource *resource, uint32_t status); - void send_key_cancel(uint32_t key); - void send_key_cancel(struct ::wl_resource *resource, uint32_t key); - void send_event_surface(struct ::wl_resource *surface, uint32_t key, uint32_t mode); - void send_event_surface(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t key, uint32_t mode); - - protected: - virtual Resource *tizen_keyrouter_allocate(); - - virtual void tizen_keyrouter_bind_resource(Resource *resource); - virtual void tizen_keyrouter_destroy_resource(Resource *resource); - - virtual void tizen_keyrouter_set_keygrab(Resource *resource, struct ::wl_resource *surface, uint32_t key, uint32_t mode); - virtual void tizen_keyrouter_unset_keygrab(Resource *resource, struct ::wl_resource *surface, uint32_t key); - virtual void tizen_keyrouter_get_keygrab_status(Resource *resource, struct ::wl_resource *surface, uint32_t key); - virtual void tizen_keyrouter_set_keygrab_list(Resource *resource, struct ::wl_resource *surface, struct ::wl_array *grab_list); - virtual void tizen_keyrouter_unset_keygrab_list(Resource *resource, struct ::wl_resource *surface, struct ::wl_array *ungrab_list); - virtual void tizen_keyrouter_get_keygrab_list(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_keyrouter_set_register_none_key(Resource *resource, struct ::wl_resource *surface, uint32_t data); - virtual void tizen_keyrouter_get_keyregister_status(Resource *resource, uint32_t data); - virtual void tizen_keyrouter_set_input_config(Resource *resource, struct ::wl_resource *surface, uint32_t config_mode, uint32_t value); - virtual void tizen_keyrouter_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_keyrouter_interface m_tizen_keyrouter_interface; - - static void handle_set_keygrab( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t key, - uint32_t mode); - static void handle_unset_keygrab( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t key); - static void handle_get_keygrab_status( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t key); - static void handle_set_keygrab_list( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - struct ::wl_array *grab_list); - static void handle_unset_keygrab_list( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - struct ::wl_array *ungrab_list); - static void handle_get_keygrab_list( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_set_register_none_key( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t data); - static void handle_get_keyregister_status( - ::wl_client *client, - struct wl_resource *resource, - uint32_t data); - static void handle_set_input_config( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t config_mode, - uint32_t value); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_keyrouter *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_screenshooter - { - public: - tizen_screenshooter(struct ::wl_client *client, uint32_t id, int version); - tizen_screenshooter(struct ::wl_display *display, int version); - tizen_screenshooter(struct ::wl_resource *resource); - tizen_screenshooter(); - - virtual ~tizen_screenshooter(); - - class Resource - { - public: - Resource() : tizen_screenshooter_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_screenshooter *tizen_screenshooter_object; - tizen_screenshooter *object() { return tizen_screenshooter_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_format(uint32_t format); - void send_format(struct ::wl_resource *resource, uint32_t format); - void send_screenshooter_notify(uint32_t noti); - void send_screenshooter_notify(struct ::wl_resource *resource, uint32_t noti); - - protected: - virtual Resource *tizen_screenshooter_allocate(); - - virtual void tizen_screenshooter_bind_resource(Resource *resource); - virtual void tizen_screenshooter_destroy_resource(Resource *resource); - - virtual void tizen_screenshooter_get_screenmirror(Resource *resource, uint32_t id, struct ::wl_resource *output); - virtual void tizen_screenshooter_set_oneshot_auto_rotation(Resource *resource, uint32_t set); - virtual void tizen_screenshooter_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_screenshooter_interface m_tizen_screenshooter_interface; - - static void handle_get_screenmirror( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *output); - static void handle_set_oneshot_auto_rotation( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_screenshooter *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_screenmirror - { - public: - tizen_screenmirror(struct ::wl_client *client, uint32_t id, int version); - tizen_screenmirror(struct ::wl_display *display, int version); - tizen_screenmirror(struct ::wl_resource *resource); - tizen_screenmirror(); - - virtual ~tizen_screenmirror(); - - class Resource - { - public: - Resource() : tizen_screenmirror_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_screenmirror *tizen_screenmirror_object; - tizen_screenmirror *object() { return tizen_screenmirror_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum content { - content_normal = 0, - content_video = 1, - }; - - enum stretch { - stretch_keep_ratio = 0, - stretch_fully = 1, - }; - - void send_dequeued(struct ::wl_resource *buffer); - void send_dequeued(struct ::wl_resource *resource, struct ::wl_resource *buffer); - void send_content(uint32_t content); - void send_content(struct ::wl_resource *resource, uint32_t content); - void send_stop(); - void send_stop(struct ::wl_resource *resource); - - protected: - virtual Resource *tizen_screenmirror_allocate(); - - virtual void tizen_screenmirror_bind_resource(Resource *resource); - virtual void tizen_screenmirror_destroy_resource(Resource *resource); - - virtual void tizen_screenmirror_destroy(Resource *resource); - virtual void tizen_screenmirror_set_stretch(Resource *resource, uint32_t stretch); - virtual void tizen_screenmirror_queue(Resource *resource, struct ::wl_resource *buffer); - virtual void tizen_screenmirror_dequeue(Resource *resource, struct ::wl_resource *buffer); - virtual void tizen_screenmirror_start(Resource *resource); - virtual void tizen_screenmirror_stop(Resource *resource); - virtual void tizen_screenmirror_set_auto_rotation(Resource *resource, uint32_t set); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_screenmirror_interface m_tizen_screenmirror_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_stretch( - ::wl_client *client, - struct wl_resource *resource, - uint32_t stretch); - static void handle_queue( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *buffer); - static void handle_dequeue( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *buffer); - static void handle_start( - ::wl_client *client, - struct wl_resource *resource); - static void handle_stop( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_auto_rotation( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_screenmirror *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_video - { - public: - tizen_video(struct ::wl_client *client, uint32_t id, int version); - tizen_video(struct ::wl_display *display, int version); - tizen_video(struct ::wl_resource *resource); - tizen_video(); - - virtual ~tizen_video(); - - class Resource - { - public: - Resource() : tizen_video_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_video *tizen_video_object; - tizen_video *object() { return tizen_video_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_none = 0, - error_object_exists = 1, - error_viewport_exists = 2, - }; - - void send_format(uint32_t format); - void send_format(struct ::wl_resource *resource, uint32_t format); - - protected: - virtual Resource *tizen_video_allocate(); - - virtual void tizen_video_bind_resource(Resource *resource); - virtual void tizen_video_destroy_resource(Resource *resource); - - virtual void tizen_video_get_object(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_video_get_viewport(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_video_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_video_interface m_tizen_video_interface; - - static void handle_get_object( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_get_viewport( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_video *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_video_object - { - public: - tizen_video_object(struct ::wl_client *client, uint32_t id, int version); - tizen_video_object(struct ::wl_display *display, int version); - tizen_video_object(struct ::wl_resource *resource); - tizen_video_object(); - - virtual ~tizen_video_object(); - - class Resource - { - public: - Resource() : tizen_video_object_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_video_object *tizen_video_object_object; - tizen_video_object *object() { return tizen_video_object_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_attribute(const std::string &name, uint32_t value); - void send_attribute(struct ::wl_resource *resource, const std::string &name, uint32_t value); - void send_size(int32_t min_w, int32_t min_h, int32_t max_w, int32_t max_h, int32_t prefer_align); - void send_size(struct ::wl_resource *resource, int32_t min_w, int32_t min_h, int32_t max_w, int32_t max_h, int32_t prefer_align); - - protected: - virtual Resource *tizen_video_object_allocate(); - - virtual void tizen_video_object_bind_resource(Resource *resource); - virtual void tizen_video_object_destroy_resource(Resource *resource); - - virtual void tizen_video_object_destroy(Resource *resource); - virtual void tizen_video_object_set_attribute(Resource *resource, const std::string &name, int32_t value); - virtual void tizen_video_object_follow_topmost_visibility(Resource *resource); - virtual void tizen_video_object_unfollow_topmost_visibility(Resource *resource); - virtual void tizen_video_object_allowed_attribute(Resource *resource); - virtual void tizen_video_object_disallowed_attribute(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_video_object_interface m_tizen_video_object_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_attribute( - ::wl_client *client, - struct wl_resource *resource, - const char *name, - int32_t value); - static void handle_follow_topmost_visibility( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unfollow_topmost_visibility( - ::wl_client *client, - struct wl_resource *resource); - static void handle_allowed_attribute( - ::wl_client *client, - struct wl_resource *resource); - static void handle_disallowed_attribute( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_video_object *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_subsurface_watcher - { - public: - tizen_subsurface_watcher(struct ::wl_client *client, uint32_t id, int version); - tizen_subsurface_watcher(struct ::wl_display *display, int version); - tizen_subsurface_watcher(struct ::wl_resource *resource); - tizen_subsurface_watcher(); - - virtual ~tizen_subsurface_watcher(); - - class Resource - { - public: - Resource() : tizen_subsurface_watcher_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_subsurface_watcher *tizen_subsurface_watcher_object; - tizen_subsurface_watcher *object() { return tizen_subsurface_watcher_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum msg { - msg_success = 0, - msg_parent_id_invalid = 1, - msg_parent_id_destroyed = 2, - }; - - void send_message(uint32_t value); - void send_message(struct ::wl_resource *resource, uint32_t value); - - protected: - virtual Resource *tizen_subsurface_watcher_allocate(); - - virtual void tizen_subsurface_watcher_bind_resource(Resource *resource); - virtual void tizen_subsurface_watcher_destroy_resource(Resource *resource); - - virtual void tizen_subsurface_watcher_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_subsurface_watcher_interface m_tizen_subsurface_watcher_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_subsurface_watcher *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_viewport - { - public: - tizen_viewport(struct ::wl_client *client, uint32_t id, int version); - tizen_viewport(struct ::wl_display *display, int version); - tizen_viewport(struct ::wl_resource *resource); - tizen_viewport(); - - virtual ~tizen_viewport(); - - class Resource - { - public: - Resource() : tizen_viewport_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_viewport *tizen_viewport_object; - tizen_viewport *object() { return tizen_viewport_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_destination_changed(uint32_t transform, int32_t x, int32_t y, uint32_t width, uint32_t height); - void send_destination_changed(struct ::wl_resource *resource, uint32_t transform, int32_t x, int32_t y, uint32_t width, uint32_t height); - void send_parent_size(uint32_t width, uint32_t height); - void send_parent_size(struct ::wl_resource *resource, uint32_t width, uint32_t height); - - protected: - virtual Resource *tizen_viewport_allocate(); - - virtual void tizen_viewport_bind_resource(Resource *resource); - virtual void tizen_viewport_destroy_resource(Resource *resource); - - virtual void tizen_viewport_destroy(Resource *resource); - virtual void tizen_viewport_set_transform(Resource *resource, uint32_t transform); - virtual void tizen_viewport_set_source(Resource *resource, uint32_t x, uint32_t y, uint32_t width, uint32_t height); - virtual void tizen_viewport_set_destination(Resource *resource, int32_t x, int32_t y, uint32_t width, uint32_t height); - virtual void tizen_viewport_set_destination_ratio(Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height); - virtual void tizen_viewport_get_destination_mode(Resource *resource, uint32_t id); - virtual void tizen_viewport_query_parent_size(Resource *resource); - virtual void tizen_viewport_follow_parent_transform(Resource *resource); - virtual void tizen_viewport_unfollow_parent_transform(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_viewport_interface m_tizen_viewport_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_transform( - ::wl_client *client, - struct wl_resource *resource, - uint32_t transform); - static void handle_set_source( - ::wl_client *client, - struct wl_resource *resource, - uint32_t x, - uint32_t y, - uint32_t width, - uint32_t height); - static void handle_set_destination( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - uint32_t width, - uint32_t height); - static void handle_set_destination_ratio( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t x, - wl_fixed_t y, - wl_fixed_t width, - wl_fixed_t height); - static void handle_get_destination_mode( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_query_parent_size( - ::wl_client *client, - struct wl_resource *resource); - static void handle_follow_parent_transform( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unfollow_parent_transform( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_viewport *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_destination_mode - { - public: - tizen_destination_mode(struct ::wl_client *client, uint32_t id, int version); - tizen_destination_mode(struct ::wl_display *display, int version); - tizen_destination_mode(struct ::wl_resource *resource); - tizen_destination_mode(); - - virtual ~tizen_destination_mode(); - - class Resource - { - public: - Resource() : tizen_destination_mode_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_destination_mode *tizen_destination_mode_object; - tizen_destination_mode *object() { return tizen_destination_mode_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_type = 0, - }; - - enum type { - type_none = 0, - type_letter_box = 1, - type_origin = 2, - type_full = 3, - type_cropped_full = 4, - type_origin_or_letter = 5, - }; - - protected: - virtual Resource *tizen_destination_mode_allocate(); - - virtual void tizen_destination_mode_bind_resource(Resource *resource); - virtual void tizen_destination_mode_destroy_resource(Resource *resource); - - virtual void tizen_destination_mode_destroy(Resource *resource); - virtual void tizen_destination_mode_follow_parent_transform(Resource *resource); - virtual void tizen_destination_mode_unfollow_parent_transform(Resource *resource); - virtual void tizen_destination_mode_set(Resource *resource, uint32_t mode); - virtual void tizen_destination_mode_set_ratio(Resource *resource, wl_fixed_t horizontal, wl_fixed_t vertical); - virtual void tizen_destination_mode_set_scale(Resource *resource, wl_fixed_t horizontal, wl_fixed_t vertical); - virtual void tizen_destination_mode_set_align(Resource *resource, wl_fixed_t horizontal, wl_fixed_t vertical); - virtual void tizen_destination_mode_set_offset(Resource *resource, int32_t x, int32_t y, int32_t w, int32_t h); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_destination_mode_interface m_tizen_destination_mode_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_follow_parent_transform( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unfollow_parent_transform( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t mode); - static void handle_set_ratio( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t horizontal, - wl_fixed_t vertical); - static void handle_set_scale( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t horizontal, - wl_fixed_t vertical); - static void handle_set_align( - ::wl_client *client, - struct wl_resource *resource, - wl_fixed_t horizontal, - wl_fixed_t vertical); - static void handle_set_offset( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t w, - int32_t h); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_destination_mode *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_embedded_compositor - { - public: - tizen_embedded_compositor(struct ::wl_client *client, uint32_t id, int version); - tizen_embedded_compositor(struct ::wl_display *display, int version); - tizen_embedded_compositor(struct ::wl_resource *resource); - tizen_embedded_compositor(); - - virtual ~tizen_embedded_compositor(); - - class Resource - { - public: - Resource() : tizen_embedded_compositor_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_embedded_compositor *tizen_embedded_compositor_object; - tizen_embedded_compositor *object() { return tizen_embedded_compositor_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_socket(int32_t sock_fd); - void send_socket(struct ::wl_resource *resource, int32_t sock_fd); - - protected: - virtual Resource *tizen_embedded_compositor_allocate(); - - virtual void tizen_embedded_compositor_bind_resource(Resource *resource); - virtual void tizen_embedded_compositor_destroy_resource(Resource *resource); - - virtual void tizen_embedded_compositor_get_socket(Resource *resource); - virtual void tizen_embedded_compositor_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_embedded_compositor_interface m_tizen_embedded_compositor_interface; - - static void handle_get_socket( - ::wl_client *client, - struct wl_resource *resource); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_embedded_compositor *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_input_device_manager - { - public: - tizen_input_device_manager(struct ::wl_client *client, uint32_t id, int version); - tizen_input_device_manager(struct ::wl_display *display, int version); - tizen_input_device_manager(struct ::wl_resource *resource); - tizen_input_device_manager(); - - virtual ~tizen_input_device_manager(); - - class Resource - { - public: - Resource() : tizen_input_device_manager_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_input_device_manager *tizen_input_device_manager_object; - tizen_input_device_manager *object() { return tizen_input_device_manager_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum clas { - clas_none = 0, // none of class - clas_mouse = 1, // mouse class - clas_keyboard = 2, // keyboard class - clas_touchscreen = 4, // touchscreen class - }; - - enum error { - error_none = 0, // no error - error_no_permission = 1, // no permission - error_invalid_class = 2, // invalid class - error_blocked_already = 3, // blocked already by the other client - error_no_system_resources = 4, // no system resources such as memory lack - error_invalid_parameter = 5, // argument is invalid - error_invalid_surface = 6, // the given surface is not visible or pointer is not on the given surface - error_no_pointer_available = 7, // there is no pointer available to warp - error_not_allowed = 8, // this request is not allowed in this system - }; - - enum pointer_event_type { - pointer_event_type_begin = 0, - pointer_event_type_update = 1, - pointer_event_type_end = 2, - }; - - enum axis_type { - axis_type_none = 0, // no axis type - axis_type_wheel = 1, // pointer vertical wheel axis - axis_type_hwheel = 2, // pointer horizental wheel axis - axis_type_radius_x = 3, // touch radius of x axis of an event area e.g. touching area with a finger or a pen - axis_type_radius_y = 4, // touch radius of y axis of an event area e.g. touching area with a finger or a pen - axis_type_pressure = 5, // touch pressure in an event area e.g. touching area with a finger or a pen - axis_type_angle = 6, // touch angle in an event area e.g. touching area with a finger or a pen - axis_type_palm = 7, // touch palm in an event area e.g. touching area with a finger or a pen - }; - - void send_device_add(uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat); - void send_device_add(struct ::wl_resource *resource, uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat); - void send_device_remove(uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat); - void send_device_remove(struct ::wl_resource *resource, uint32_t serial, const std::string &identifier, struct ::wl_resource *device, struct ::wl_resource *seat); - void send_error(uint32_t errorcode); - void send_error(struct ::wl_resource *resource, uint32_t errorcode); - void send_block_expired(); - void send_block_expired(struct ::wl_resource *resource); - void send_max_touch_count(uint32_t serial, int32_t max_count, struct ::wl_resource *seat); - void send_max_touch_count(struct ::wl_resource *resource, uint32_t serial, int32_t max_count, struct ::wl_resource *seat); - - protected: - virtual Resource *tizen_input_device_manager_allocate(); - - virtual void tizen_input_device_manager_bind_resource(Resource *resource); - virtual void tizen_input_device_manager_destroy_resource(Resource *resource); - - virtual void tizen_input_device_manager_block_events(Resource *resource, uint32_t serial, uint32_t clas, uint32_t duration); - virtual void tizen_input_device_manager_unblock_events(Resource *resource, uint32_t serial); - virtual void tizen_input_device_manager_init_generator(Resource *resource, uint32_t clas); - virtual void tizen_input_device_manager_deinit_generator(Resource *resource, uint32_t clas); - virtual void tizen_input_device_manager_generate_key(Resource *resource, const std::string &keyname, uint32_t pressed); - virtual void tizen_input_device_manager_generate_pointer(Resource *resource, uint32_t type, uint32_t x, uint32_t y, uint32_t button); - virtual void tizen_input_device_manager_generate_touch(Resource *resource, uint32_t type, uint32_t x, uint32_t y, uint32_t finger); - virtual void tizen_input_device_manager_pointer_warp(Resource *resource, struct ::wl_resource *surface, wl_fixed_t x, wl_fixed_t y); - virtual void tizen_input_device_manager_init_generator_with_name(Resource *resource, uint32_t clas, const std::string &name); - virtual void tizen_input_device_manager_destroy(Resource *resource); - virtual void tizen_input_device_manager_generate_axis(Resource *resource, uint32_t type, wl_fixed_t value); - virtual void tizen_input_device_manager_set_touch_count(Resource *resource, int32_t max_count); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_input_device_manager_interface m_tizen_input_device_manager_interface; - - static void handle_block_events( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - uint32_t clas, - uint32_t duration); - static void handle_unblock_events( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_init_generator( - ::wl_client *client, - struct wl_resource *resource, - uint32_t clas); - static void handle_deinit_generator( - ::wl_client *client, - struct wl_resource *resource, - uint32_t clas); - static void handle_generate_key( - ::wl_client *client, - struct wl_resource *resource, - const char *keyname, - uint32_t pressed); - static void handle_generate_pointer( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type, - uint32_t x, - uint32_t y, - uint32_t button); - static void handle_generate_touch( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type, - uint32_t x, - uint32_t y, - uint32_t finger); - static void handle_pointer_warp( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - wl_fixed_t x, - wl_fixed_t y); - static void handle_init_generator_with_name( - ::wl_client *client, - struct wl_resource *resource, - uint32_t clas, - const char *name); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_generate_axis( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type, - wl_fixed_t value); - static void handle_set_touch_count( - ::wl_client *client, - struct wl_resource *resource, - int32_t max_count); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_input_device_manager *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_input_device - { - public: - tizen_input_device(struct ::wl_client *client, uint32_t id, int version); - tizen_input_device(struct ::wl_display *display, int version); - tizen_input_device(struct ::wl_resource *resource); - tizen_input_device(); - - virtual ~tizen_input_device(); - - class Resource - { - public: - Resource() : tizen_input_device_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_input_device *tizen_input_device_object; - tizen_input_device *object() { return tizen_input_device_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum clas { - clas_none = 0, // none of class - clas_keyboard = 2, // keyboard class - clas_mouse = 3, // mouse class - clas_touchscreen = 4, // touchscreen class - }; - - enum subclas { - subclas_none = 0, // none of subclass - }; - - enum axis_type { - axis_type_none = 0, // radius of x axis of an event area e.g. touching area with a finger or a pen - axis_type_radius_x = 1, // radius of x axis of an event area e.g. touching area with a finger or a pen - axis_type_radius_y = 2, // radius of y axis of an event area e.g. touching area with a finger or a pen - axis_type_pressure = 3, // pressure in an event area e.g. touching area with a finger or a pen - axis_type_angle = 4, // angle in an event area e.g. touching area with a finger or a pen - axis_type_detent = 5, // detent value e.g. moved distance with a rotary device - }; - - void send_device_info(const std::string &name, uint32_t clas, uint32_t subclas, struct ::wl_array *axes); - void send_device_info(struct ::wl_resource *resource, const std::string &name, uint32_t clas, uint32_t subclas, struct ::wl_array *axes); - void send_event_device(uint32_t serial, const std::string &name, uint32_t time); - void send_event_device(struct ::wl_resource *resource, uint32_t serial, const std::string &name, uint32_t time); - void send_axis(uint32_t axis_type, wl_fixed_t value); - void send_axis(struct ::wl_resource *resource, uint32_t axis_type, wl_fixed_t value); - - protected: - virtual Resource *tizen_input_device_allocate(); - - virtual void tizen_input_device_bind_resource(Resource *resource); - virtual void tizen_input_device_destroy_resource(Resource *resource); - - virtual void tizen_input_device_select_axes(Resource *resource, struct ::wl_array *axes); - virtual void tizen_input_device_release(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_input_device_interface m_tizen_input_device_interface; - - static void handle_select_axes( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_array *axes); - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_input_device *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_launchscreen - { - public: - tizen_launchscreen(struct ::wl_client *client, uint32_t id, int version); - tizen_launchscreen(struct ::wl_display *display, int version); - tizen_launchscreen(struct ::wl_resource *resource); - tizen_launchscreen(); - - virtual ~tizen_launchscreen(); - - class Resource - { - public: - Resource() : tizen_launchscreen_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_launchscreen *tizen_launchscreen_object; - tizen_launchscreen *object() { return tizen_launchscreen_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tizen_launchscreen_allocate(); - - virtual void tizen_launchscreen_bind_resource(Resource *resource); - virtual void tizen_launchscreen_destroy_resource(Resource *resource); - - virtual void tizen_launchscreen_create_img(Resource *resource, uint32_t id); - virtual void tizen_launchscreen_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_launchscreen_interface m_tizen_launchscreen_interface; - - static void handle_create_img( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_launchscreen *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_launch_image - { - public: - tizen_launch_image(struct ::wl_client *client, uint32_t id, int version); - tizen_launch_image(struct ::wl_display *display, int version); - tizen_launch_image(struct ::wl_resource *resource); - tizen_launch_image(); - - virtual ~tizen_launch_image(); - - class Resource - { - public: - Resource() : tizen_launch_image_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_launch_image *tizen_launch_image_object; - tizen_launch_image *object() { return tizen_launch_image_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum file_type { - file_type_img = 0, // splash image file path - file_type_edj = 1, // splash edj file path - }; - - enum indicator { - indicator_off = 0, // splash hide indicator - indicator_on = 1, // splash show indicator - }; - - enum rotation { - rotation_0 = 0, // rotation angle 0 degree - rotation_90 = 90, // rotation angle 90 degree - rotation_180 = 180, // rotation angle 180 degree - rotation_270 = 270, // rotation angle 270 degree - }; - - protected: - virtual Resource *tizen_launch_image_allocate(); - - virtual void tizen_launch_image_bind_resource(Resource *resource); - virtual void tizen_launch_image_destroy_resource(Resource *resource); - - virtual void tizen_launch_image_destroy(Resource *resource); - virtual void tizen_launch_image_launch(Resource *resource, const std::string &file, uint32_t file_type, uint32_t color_depth, uint32_t rotation, uint32_t indicator, struct ::wl_array *options); - virtual void tizen_launch_image_owner(Resource *resource, uint32_t pid); - virtual void tizen_launch_image_show(Resource *resource); - virtual void tizen_launch_image_hide(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_launch_image_interface m_tizen_launch_image_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_launch( - ::wl_client *client, - struct wl_resource *resource, - const char *file, - uint32_t file_type, - uint32_t color_depth, - uint32_t rotation, - uint32_t indicator, - struct ::wl_array *options); - static void handle_owner( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid); - static void handle_show( - ::wl_client *client, - struct wl_resource *resource); - static void handle_hide( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_launch_image *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_effect - { - public: - tizen_effect(struct ::wl_client *client, uint32_t id, int version); - tizen_effect(struct ::wl_display *display, int version); - tizen_effect(struct ::wl_resource *resource); - tizen_effect(); - - virtual ~tizen_effect(); - - class Resource - { - public: - Resource() : tizen_effect_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_effect *tizen_effect_object; - tizen_effect *object() { return tizen_effect_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum type { - type_none = 0, // none - type_show = 1, // show effect of window - type_hide = 2, // hide effect of window - type_restack = 3, // restack effect of window - }; - - void send_start(struct ::wl_resource *surface, uint32_t type); - void send_start(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t type); - void send_end(struct ::wl_resource *surface, uint32_t type); - void send_end(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t type); - - protected: - virtual Resource *tizen_effect_allocate(); - - virtual void tizen_effect_bind_resource(Resource *resource); - virtual void tizen_effect_destroy_resource(Resource *resource); - - virtual void tizen_effect_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_effect_interface m_tizen_effect_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_effect *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_display_policy - { - public: - tizen_display_policy(struct ::wl_client *client, uint32_t id, int version); - tizen_display_policy(struct ::wl_display *display, int version); - tizen_display_policy(struct ::wl_resource *resource); - tizen_display_policy(); - - virtual ~tizen_display_policy(); - - class Resource - { - public: - Resource() : tizen_display_policy_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_display_policy *tizen_display_policy_object; - tizen_display_policy *object() { return tizen_display_policy_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error_state { - error_state_none = 0, - error_state_permission_denied = 1, - }; - - void send_window_brightness_done(struct ::wl_resource *surface, int32_t brightness, uint32_t error_state); - void send_window_brightness_done(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t brightness, uint32_t error_state); - - protected: - virtual Resource *tizen_display_policy_allocate(); - - virtual void tizen_display_policy_bind_resource(Resource *resource); - virtual void tizen_display_policy_destroy_resource(Resource *resource); - - virtual void tizen_display_policy_set_window_brightness(Resource *resource, struct ::wl_resource *surface, int32_t brightness); - virtual void tizen_display_policy_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_display_policy_interface m_tizen_display_policy_interface; - - static void handle_set_window_brightness( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t brightness); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_display_policy *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_indicator - { - public: - tizen_indicator(struct ::wl_client *client, uint32_t id, int version); - tizen_indicator(struct ::wl_display *display, int version); - tizen_indicator(struct ::wl_resource *resource); - tizen_indicator(); - - virtual ~tizen_indicator(); - - class Resource - { - public: - Resource() : tizen_indicator_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_indicator *tizen_indicator_object; - tizen_indicator *object() { return tizen_indicator_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum state { - state_unknown = 0, // unknown - state_off = 1, // can not show indicator - state_on = 2, // can show indicator - }; - - enum opacity_mode { - opacity_mode_unknown = 0, // unknown - opacity_mode_opaque = 1, // opaque mode - opacity_mode_translucent = 2, // translucent mode - opacity_mode_transparent = 3, // transparent all mode - opacity_mode_bg_transparent = 4, // transparent only background mode - }; - - enum visible_type { - visible_type_hidden = 0, // hidden type indicator - visible_type_shown = 1, // shown type indicator - }; - - void send_flick(struct ::wl_resource *surface, int32_t type); - void send_flick(struct ::wl_resource *resource, struct ::wl_resource *surface, int32_t type); - - protected: - virtual Resource *tizen_indicator_allocate(); - - virtual void tizen_indicator_bind_resource(Resource *resource); - virtual void tizen_indicator_destroy_resource(Resource *resource); - - virtual void tizen_indicator_destroy(Resource *resource); - virtual void tizen_indicator_set_state(Resource *resource, struct ::wl_resource *surface, int32_t state); - virtual void tizen_indicator_set_opacity_mode(Resource *resource, struct ::wl_resource *surface, int32_t mode); - virtual void tizen_indicator_set_visible_type(Resource *resource, struct ::wl_resource *surface, int32_t type); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_indicator_interface m_tizen_indicator_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_state( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t state); - static void handle_set_opacity_mode( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t mode); - static void handle_set_visible_type( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - int32_t type); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_indicator *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_clipboard - { - public: - tizen_clipboard(struct ::wl_client *client, uint32_t id, int version); - tizen_clipboard(struct ::wl_display *display, int version); - tizen_clipboard(struct ::wl_resource *resource); - tizen_clipboard(); - - virtual ~tizen_clipboard(); - - class Resource - { - public: - Resource() : tizen_clipboard_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_clipboard *tizen_clipboard_object; - tizen_clipboard *object() { return tizen_clipboard_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_data_selected(struct ::wl_resource *surface); - void send_data_selected(struct ::wl_resource *resource, struct ::wl_resource *surface); - void send_allowed_data_only(uint32_t allowed); - void send_allowed_data_only(struct ::wl_resource *resource, uint32_t allowed); - - protected: - virtual Resource *tizen_clipboard_allocate(); - - virtual void tizen_clipboard_bind_resource(Resource *resource); - virtual void tizen_clipboard_destroy_resource(Resource *resource); - - virtual void tizen_clipboard_destroy(Resource *resource); - virtual void tizen_clipboard_show(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_clipboard_hide(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_clipboard_set_data_only(Resource *resource, uint32_t set); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_clipboard_interface m_tizen_clipboard_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_show( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_hide( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_set_data_only( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_clipboard *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_screen_rotation - { - public: - tizen_screen_rotation(struct ::wl_client *client, uint32_t id, int version); - tizen_screen_rotation(struct ::wl_display *display, int version); - tizen_screen_rotation(struct ::wl_resource *resource); - tizen_screen_rotation(); - - virtual ~tizen_screen_rotation(); - - class Resource - { - public: - Resource() : tizen_screen_rotation_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_screen_rotation *tizen_screen_rotation_object; - tizen_screen_rotation *object() { return tizen_screen_rotation_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_ignore_output_transform(struct ::wl_resource *surface, uint32_t ignore); - void send_ignore_output_transform(struct ::wl_resource *resource, struct ::wl_resource *surface, uint32_t ignore); - - protected: - virtual Resource *tizen_screen_rotation_allocate(); - - virtual void tizen_screen_rotation_bind_resource(Resource *resource); - virtual void tizen_screen_rotation_destroy_resource(Resource *resource); - - virtual void tizen_screen_rotation_get_ignore_output_transform(Resource *resource, struct ::wl_resource *surface); - virtual void tizen_screen_rotation_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_screen_rotation_interface m_tizen_screen_rotation_interface; - - static void handle_get_ignore_output_transform( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_screen_rotation *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_renderer - { - public: - tizen_renderer(struct ::wl_client *client, uint32_t id, int version); - tizen_renderer(struct ::wl_display *display, int version); - tizen_renderer(struct ::wl_resource *resource); - tizen_renderer(); - - virtual ~tizen_renderer(); - - class Resource - { - public: - Resource() : tizen_renderer_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_renderer *tizen_renderer_object; - tizen_renderer *object() { return tizen_renderer_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tizen_renderer_allocate(); - - virtual void tizen_renderer_bind_resource(Resource *resource); - virtual void tizen_renderer_destroy_resource(Resource *resource); - - virtual void tizen_renderer_get_renderer_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_renderer_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_renderer_interface m_tizen_renderer_interface; - - static void handle_get_renderer_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_renderer *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_renderer_surface - { - public: - tizen_renderer_surface(struct ::wl_client *client, uint32_t id, int version); - tizen_renderer_surface(struct ::wl_display *display, int version); - tizen_renderer_surface(struct ::wl_resource *resource); - tizen_renderer_surface(); - - virtual ~tizen_renderer_surface(); - - class Resource - { - public: - Resource() : tizen_renderer_surface_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_renderer_surface *tizen_renderer_surface_object; - tizen_renderer_surface *object() { return tizen_renderer_surface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_redraw_request(); - void send_redraw_request(struct ::wl_resource *resource); - - protected: - virtual Resource *tizen_renderer_surface_allocate(); - - virtual void tizen_renderer_surface_bind_resource(Resource *resource); - virtual void tizen_renderer_surface_destroy_resource(Resource *resource); - - virtual void tizen_renderer_surface_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_renderer_surface_interface m_tizen_renderer_surface_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_renderer_surface *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} -/*LCOV_EXCL_STOP*/ - -#endif \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-tizen-hwc.cpp b/src/DSWaylandServer/dswayland-server-tizen-hwc.cpp deleted file mode 100644 index f4edebf..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-hwc.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-hwc.xml */ - -#include "dswayland-server-tizen-hwc.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - tizen_hwc::tizen_hwc(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_hwc::tizen_hwc(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_hwc::tizen_hwc(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_hwc::tizen_hwc() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_hwc::~tizen_hwc() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_hwc::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_hwc::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_hwc::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_hwc::Resource *tizen_hwc::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_hwc::Resource *tizen_hwc::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_hwc::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_hwc_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_hwc::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_hwc::interface() - { - return &::tizen_hwc_interface; - } - - tizen_hwc::Resource *tizen_hwc::tizen_hwc_allocate() - { - return new Resource; - } - - void tizen_hwc::tizen_hwc_bind_resource(Resource *) - { - } - - void tizen_hwc::tizen_hwc_destroy_resource(Resource *) - { - } - - void tizen_hwc::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_hwc *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_hwc::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_hwc *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_hwc::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_hwc *that = resource->tizen_hwc_object; - that->m_resource_map.erase(resource->client()); - that->tizen_hwc_destroy_resource(resource); - delete resource; - } - - tizen_hwc::Resource *tizen_hwc::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_hwc_interface, version, id); - return bind(handle); - } - - tizen_hwc::Resource *tizen_hwc::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_hwc_allocate(); - resource->tizen_hwc_object = this; - - wl_resource_set_implementation(handle, &m_tizen_hwc_interface, resource, destroy_func); - resource->handle = handle; - tizen_hwc_bind_resource(resource); - return resource; - } - tizen_hwc::Resource *tizen_hwc::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_hwc_interface, &m_tizen_hwc_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_hwc_interface tizen_hwc::m_tizen_hwc_interface = { - tizen_hwc::handle_destroy, - tizen_hwc::handle_create_commit_feedback - }; - - void tizen_hwc::tizen_hwc_destroy(Resource *) - { - } - - void tizen_hwc::tizen_hwc_create_commit_feedback(Resource *, struct ::wl_resource *, uint32_t, uint32_t ) - { - } - - - void tizen_hwc::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_hwc_object)->tizen_hwc_destroy( - r); - } - - void tizen_hwc::handle_create_commit_feedback( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t id, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_hwc_object)->tizen_hwc_create_commit_feedback( - r, - surface, - id, - serial); - } - - tizen_hwc_commit_feedback::tizen_hwc_commit_feedback(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_hwc_commit_feedback::tizen_hwc_commit_feedback(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_hwc_commit_feedback::tizen_hwc_commit_feedback(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_hwc_commit_feedback::tizen_hwc_commit_feedback() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_hwc_commit_feedback::~tizen_hwc_commit_feedback() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_hwc_commit_feedback::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_hwc_commit_feedback::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_hwc_commit_feedback::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_hwc_commit_feedback::Resource *tizen_hwc_commit_feedback::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_hwc_commit_feedback::Resource *tizen_hwc_commit_feedback::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_hwc_commit_feedback::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_hwc_commit_feedback_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_hwc_commit_feedback::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_hwc_commit_feedback::interface() - { - return &::tizen_hwc_commit_feedback_interface; - } - - tizen_hwc_commit_feedback::Resource *tizen_hwc_commit_feedback::tizen_hwc_commit_feedback_allocate() - { - return new Resource; - } - - void tizen_hwc_commit_feedback::tizen_hwc_commit_feedback_bind_resource(Resource *) - { - } - - void tizen_hwc_commit_feedback::tizen_hwc_commit_feedback_destroy_resource(Resource *) - { - } - - void tizen_hwc_commit_feedback::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_hwc_commit_feedback *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_hwc_commit_feedback::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_hwc_commit_feedback *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_hwc_commit_feedback::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_hwc_commit_feedback *that = resource->tizen_hwc_commit_feedback_object; - that->m_resource_map.erase(resource->client()); - that->tizen_hwc_commit_feedback_destroy_resource(resource); - delete resource; - } - - tizen_hwc_commit_feedback::Resource *tizen_hwc_commit_feedback::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_hwc_commit_feedback_interface, version, id); - return bind(handle); - } - - tizen_hwc_commit_feedback::Resource *tizen_hwc_commit_feedback::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_hwc_commit_feedback_allocate(); - resource->tizen_hwc_commit_feedback_object = this; - - wl_resource_set_implementation(handle, NULL, resource, destroy_func); - resource->handle = handle; - tizen_hwc_commit_feedback_bind_resource(resource); - return resource; - } - tizen_hwc_commit_feedback::Resource *tizen_hwc_commit_feedback::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_hwc_commit_feedback_interface, NULL)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - void tizen_hwc_commit_feedback::send_committed(uint32_t serial) - { - DS_ASSERT_X(m_resource, "tizen_hwc_commit_feedback::committed", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_hwc_commit_feedback::committed as it's not initialised"); - return; - } - send_committed( - m_resource->handle, - serial); - } - - void tizen_hwc_commit_feedback::send_committed(struct ::wl_resource *resource, uint32_t serial) - { - tizen_hwc_commit_feedback_send_committed( - resource, - serial); - } - - - void tizen_hwc_commit_feedback::send_discarded(uint32_t serial) - { - DS_ASSERT_X(m_resource, "tizen_hwc_commit_feedback::discarded", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_hwc_commit_feedback::discarded as it's not initialised"); - return; - } - send_discarded( - m_resource->handle, - serial); - } - - void tizen_hwc_commit_feedback::send_discarded(struct ::wl_resource *resource, uint32_t serial) - { - tizen_hwc_commit_feedback_send_discarded( - resource, - serial); - } - -} - -/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-tizen-hwc.h b/src/DSWaylandServer/dswayland-server-tizen-hwc.h deleted file mode 100644 index 56d196c..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-hwc.h +++ /dev/null @@ -1,192 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-hwc.xml */ - -#ifndef __DS_TIZEN_HWC_PROTOCOL_H__ -#define __DS_TIZEN_HWC_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "tizen-hwc-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class tizen_hwc - { - public: - tizen_hwc(struct ::wl_client *client, uint32_t id, int version); - tizen_hwc(struct ::wl_display *display, int version); - tizen_hwc(struct ::wl_resource *resource); - tizen_hwc(); - - virtual ~tizen_hwc(); - - class Resource - { - public: - Resource() : tizen_hwc_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_hwc *tizen_hwc_object; - tizen_hwc *object() { return tizen_hwc_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tizen_hwc_allocate(); - - virtual void tizen_hwc_bind_resource(Resource *resource); - virtual void tizen_hwc_destroy_resource(Resource *resource); - - virtual void tizen_hwc_destroy(Resource *resource); - virtual void tizen_hwc_create_commit_feedback(Resource *resource, struct ::wl_resource *surface, uint32_t id, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_hwc_interface m_tizen_hwc_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_create_commit_feedback( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - uint32_t id, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_hwc *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_hwc_commit_feedback - { - public: - tizen_hwc_commit_feedback(struct ::wl_client *client, uint32_t id, int version); - tizen_hwc_commit_feedback(struct ::wl_display *display, int version); - tizen_hwc_commit_feedback(struct ::wl_resource *resource); - tizen_hwc_commit_feedback(); - - virtual ~tizen_hwc_commit_feedback(); - - class Resource - { - public: - Resource() : tizen_hwc_commit_feedback_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_hwc_commit_feedback *tizen_hwc_commit_feedback_object; - tizen_hwc_commit_feedback *object() { return tizen_hwc_commit_feedback_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_committed(uint32_t serial); - void send_committed(struct ::wl_resource *resource, uint32_t serial); - void send_discarded(uint32_t serial); - void send_discarded(struct ::wl_resource *resource, uint32_t serial); - - protected: - virtual Resource *tizen_hwc_commit_feedback_allocate(); - - virtual void tizen_hwc_commit_feedback_bind_resource(Resource *resource); - virtual void tizen_hwc_commit_feedback_destroy_resource(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_hwc_commit_feedback *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ \ No newline at end of file diff --git a/src/DSWaylandServer/dswayland-server-tizen-launch.cpp b/src/DSWaylandServer/dswayland-server-tizen-launch.cpp deleted file mode 100644 index 2f12f98..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-launch.cpp +++ /dev/null @@ -1,849 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-launch.xml */ - -#include "dswayland-server-tizen-launch.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - tizen_launch_effect::tizen_launch_effect(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_launch_effect::tizen_launch_effect(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_launch_effect::tizen_launch_effect(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_launch_effect::tizen_launch_effect() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_launch_effect::~tizen_launch_effect() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_launch_effect::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_launch_effect::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_launch_effect::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_launch_effect::Resource *tizen_launch_effect::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_launch_effect::Resource *tizen_launch_effect::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_launch_effect::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_launch_effect_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_launch_effect::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_launch_effect::interface() - { - return &::tizen_launch_effect_interface; - } - - tizen_launch_effect::Resource *tizen_launch_effect::tizen_launch_effect_allocate() - { - return new Resource; - } - - void tizen_launch_effect::tizen_launch_effect_bind_resource(Resource *) - { - } - - void tizen_launch_effect::tizen_launch_effect_destroy_resource(Resource *) - { - } - - void tizen_launch_effect::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_launch_effect *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_launch_effect::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_launch_effect *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_launch_effect::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_launch_effect *that = resource->tizen_launch_effect_object; - that->m_resource_map.erase(resource->client()); - that->tizen_launch_effect_destroy_resource(resource); - delete resource; - } - - tizen_launch_effect::Resource *tizen_launch_effect::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_launch_effect_interface, version, id); - return bind(handle); - } - - tizen_launch_effect::Resource *tizen_launch_effect::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_launch_effect_allocate(); - resource->tizen_launch_effect_object = this; - - wl_resource_set_implementation(handle, &m_tizen_launch_effect_interface, resource, destroy_func); - resource->handle = handle; - tizen_launch_effect_bind_resource(resource); - return resource; - } - tizen_launch_effect::Resource *tizen_launch_effect::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_launch_effect_interface, &m_tizen_launch_effect_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_launch_effect_interface tizen_launch_effect::m_tizen_launch_effect_interface = { - tizen_launch_effect::handle_create_splash_img, - tizen_launch_effect::handle_type_set, - tizen_launch_effect::handle_type_unset, - tizen_launch_effect::handle_destroy - }; - - void tizen_launch_effect::tizen_launch_effect_create_splash_img(Resource *, uint32_t) - { - } - - void tizen_launch_effect::tizen_launch_effect_type_set(Resource *, const std::string &, uint32_t , struct ::wl_array *) - { - } - - void tizen_launch_effect::tizen_launch_effect_type_unset(Resource *, uint32_t ) - { - } - - void tizen_launch_effect::tizen_launch_effect_destroy(Resource *) - { - } - - - void tizen_launch_effect::handle_create_splash_img( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_effect_object)->tizen_launch_effect_create_splash_img( - r, - id); - } - - void tizen_launch_effect::handle_type_set( - ::wl_client *client, - struct wl_resource *resource, - const char *effect_type, - uint32_t pid, - struct ::wl_array *options) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_effect_object)->tizen_launch_effect_type_set( - r, - std::string(effect_type), - pid, - options); - } - - void tizen_launch_effect::handle_type_unset( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_effect_object)->tizen_launch_effect_type_unset( - r, - pid); - } - - void tizen_launch_effect::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_effect_object)->tizen_launch_effect_destroy( - r); - } - - tizen_launch_splash::tizen_launch_splash(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_launch_splash::tizen_launch_splash(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_launch_splash::tizen_launch_splash(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_launch_splash::tizen_launch_splash() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_launch_splash::~tizen_launch_splash() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_launch_splash::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_launch_splash::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_launch_splash::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_launch_splash::Resource *tizen_launch_splash::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_launch_splash::Resource *tizen_launch_splash::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_launch_splash::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_launch_splash_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_launch_splash::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_launch_splash::interface() - { - return &::tizen_launch_splash_interface; - } - - tizen_launch_splash::Resource *tizen_launch_splash::tizen_launch_splash_allocate() - { - return new Resource; - } - - void tizen_launch_splash::tizen_launch_splash_bind_resource(Resource *) - { - } - - void tizen_launch_splash::tizen_launch_splash_destroy_resource(Resource *) - { - } - - void tizen_launch_splash::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_launch_splash *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_launch_splash::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_launch_splash *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_launch_splash::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_launch_splash *that = resource->tizen_launch_splash_object; - that->m_resource_map.erase(resource->client()); - that->tizen_launch_splash_destroy_resource(resource); - delete resource; - } - - tizen_launch_splash::Resource *tizen_launch_splash::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_launch_splash_interface, version, id); - return bind(handle); - } - - tizen_launch_splash::Resource *tizen_launch_splash::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_launch_splash_allocate(); - resource->tizen_launch_splash_object = this; - - wl_resource_set_implementation(handle, &m_tizen_launch_splash_interface, resource, destroy_func); - resource->handle = handle; - tizen_launch_splash_bind_resource(resource); - return resource; - } - tizen_launch_splash::Resource *tizen_launch_splash::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_launch_splash_interface, &m_tizen_launch_splash_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_launch_splash_interface tizen_launch_splash::m_tizen_launch_splash_interface = { - tizen_launch_splash::handle_destroy, - tizen_launch_splash::handle_launch, - tizen_launch_splash::handle_owner, - tizen_launch_splash::handle_launch_v2 - }; - - void tizen_launch_splash::tizen_launch_splash_destroy(Resource *) - { - } - - void tizen_launch_splash::tizen_launch_splash_launch(Resource *, const std::string &, uint32_t , uint32_t , uint32_t , uint32_t , const std::string &, const std::string &, struct ::wl_array *) - { - } - - void tizen_launch_splash::tizen_launch_splash_owner(Resource *, uint32_t ) - { - } - - void tizen_launch_splash::tizen_launch_splash_launch_v2(Resource *, const std::string &, uint32_t , uint32_t , uint32_t , uint32_t , const std::string &, const std::string &, struct ::wl_array *, struct ::wl_array *) - { - } - - - void tizen_launch_splash::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_splash_object)->tizen_launch_splash_destroy( - r); - } - - void tizen_launch_splash::handle_launch( - ::wl_client *client, - struct wl_resource *resource, - const char *file, - uint32_t file_type, - uint32_t color_depth, - uint32_t rotation, - uint32_t indicator, - const char *effect_type, - const char *theme_type, - struct ::wl_array *options) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_splash_object)->tizen_launch_splash_launch( - r, - std::string(file), - file_type, - color_depth, - rotation, - indicator, - std::string(effect_type), - std::string(theme_type), - options); - } - - void tizen_launch_splash::handle_owner( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_splash_object)->tizen_launch_splash_owner( - r, - pid); - } - - void tizen_launch_splash::handle_launch_v2( - ::wl_client *client, - struct wl_resource *resource, - const char *file, - uint32_t file_type, - uint32_t color_depth, - uint32_t rotation, - uint32_t indicator, - const char *effect_type, - const char *theme_type, - struct ::wl_array *options, - struct ::wl_array *extra_config) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_splash_object)->tizen_launch_splash_launch_v2( - r, - std::string(file), - file_type, - color_depth, - rotation, - indicator, - std::string(effect_type), - std::string(theme_type), - options, - extra_config); - } - - tizen_launch_appinfo::tizen_launch_appinfo(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_launch_appinfo::tizen_launch_appinfo(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_launch_appinfo::tizen_launch_appinfo(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_launch_appinfo::tizen_launch_appinfo() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_launch_appinfo::~tizen_launch_appinfo() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_launch_appinfo::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_launch_appinfo::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_launch_appinfo::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_launch_appinfo::Resource *tizen_launch_appinfo::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_launch_appinfo::Resource *tizen_launch_appinfo::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_launch_appinfo::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_launch_appinfo_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_launch_appinfo::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_launch_appinfo::interface() - { - return &::tizen_launch_appinfo_interface; - } - - tizen_launch_appinfo::Resource *tizen_launch_appinfo::tizen_launch_appinfo_allocate() - { - return new Resource; - } - - void tizen_launch_appinfo::tizen_launch_appinfo_bind_resource(Resource *) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_destroy_resource(Resource *) - { - } - - void tizen_launch_appinfo::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_launch_appinfo *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_launch_appinfo::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_launch_appinfo *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_launch_appinfo::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_launch_appinfo *that = resource->tizen_launch_appinfo_object; - that->m_resource_map.erase(resource->client()); - that->tizen_launch_appinfo_destroy_resource(resource); - delete resource; - } - - tizen_launch_appinfo::Resource *tizen_launch_appinfo::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_launch_appinfo_interface, version, id); - return bind(handle); - } - - tizen_launch_appinfo::Resource *tizen_launch_appinfo::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_launch_appinfo_allocate(); - resource->tizen_launch_appinfo_object = this; - - wl_resource_set_implementation(handle, &m_tizen_launch_appinfo_interface, resource, destroy_func); - resource->handle = handle; - tizen_launch_appinfo_bind_resource(resource); - return resource; - } - tizen_launch_appinfo::Resource *tizen_launch_appinfo::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_launch_appinfo_interface, &m_tizen_launch_appinfo_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_launch_appinfo_interface tizen_launch_appinfo::m_tizen_launch_appinfo_interface = { - tizen_launch_appinfo::handle_destroy, - tizen_launch_appinfo::handle_register_pid, - tizen_launch_appinfo::handle_deregister_pid, - tizen_launch_appinfo::handle_set_appid, - tizen_launch_appinfo::handle_get_base_output_resolution, - tizen_launch_appinfo::handle_register_appid, - tizen_launch_appinfo::handle_deregister_appid, - tizen_launch_appinfo::handle_set_pid, - tizen_launch_appinfo::handle_ready_metadata - }; - - void tizen_launch_appinfo::tizen_launch_appinfo_destroy(Resource *) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_register_pid(Resource *, uint32_t ) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_deregister_pid(Resource *, uint32_t ) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_set_appid(Resource *, uint32_t , const std::string &) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_get_base_output_resolution(Resource *, uint32_t ) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_register_appid(Resource *, const std::string &) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_deregister_appid(Resource *, const std::string &) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_set_pid(Resource *, const std::string &, uint32_t ) - { - } - - void tizen_launch_appinfo::tizen_launch_appinfo_ready_metadata(Resource *, const std::string &, uint32_t ) - { - } - - - void tizen_launch_appinfo::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_destroy( - r); - } - - void tizen_launch_appinfo::handle_register_pid( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_register_pid( - r, - pid); - } - - void tizen_launch_appinfo::handle_deregister_pid( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_deregister_pid( - r, - pid); - } - - void tizen_launch_appinfo::handle_set_appid( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid, - const char *appid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_set_appid( - r, - pid, - std::string(appid)); - } - - void tizen_launch_appinfo::handle_get_base_output_resolution( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_get_base_output_resolution( - r, - pid); - } - - void tizen_launch_appinfo::handle_register_appid( - ::wl_client *client, - struct wl_resource *resource, - const char *appid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_register_appid( - r, - std::string(appid)); - } - - void tizen_launch_appinfo::handle_deregister_appid( - ::wl_client *client, - struct wl_resource *resource, - const char *appid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_deregister_appid( - r, - std::string(appid)); - } - - void tizen_launch_appinfo::handle_set_pid( - ::wl_client *client, - struct wl_resource *resource, - const char *appid, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_set_pid( - r, - std::string(appid), - pid); - } - - void tizen_launch_appinfo::handle_ready_metadata( - ::wl_client *client, - struct wl_resource *resource, - const char *appid, - uint32_t pid) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_launch_appinfo_object)->tizen_launch_appinfo_ready_metadata( - r, - std::string(appid), - pid); - } - - void tizen_launch_appinfo::send_base_output_resolution_done(uint32_t pid, uint32_t width, uint32_t height) - { - DS_ASSERT_X(m_resource, "tizen_launch_appinfo::base_output_resolution_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_launch_appinfo::base_output_resolution_done as it's not initialised"); - return; - } - send_base_output_resolution_done( - m_resource->handle, - pid, - width, - height); - } - - void tizen_launch_appinfo::send_base_output_resolution_done(struct ::wl_resource *resource, uint32_t pid, uint32_t width, uint32_t height) - { - tizen_launch_appinfo_send_base_output_resolution_done( - resource, - pid, - width, - height); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-launch.h b/src/DSWaylandServer/dswayland-server-tizen-launch.h deleted file mode 100644 index 53b4f51..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-launch.h +++ /dev/null @@ -1,379 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-launch.xml */ - -#ifndef __DS_TIZEN_LAUNCH_PROTOCOL_H__ -#define __DS_TIZEN_LAUNCH_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "tizen-launch-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class tizen_launch_effect - { - public: - tizen_launch_effect(struct ::wl_client *client, uint32_t id, int version); - tizen_launch_effect(struct ::wl_display *display, int version); - tizen_launch_effect(struct ::wl_resource *resource); - tizen_launch_effect(); - - virtual ~tizen_launch_effect(); - - class Resource - { - public: - Resource() : tizen_launch_effect_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_launch_effect *tizen_launch_effect_object; - tizen_launch_effect *object() { return tizen_launch_effect_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tizen_launch_effect_allocate(); - - virtual void tizen_launch_effect_bind_resource(Resource *resource); - virtual void tizen_launch_effect_destroy_resource(Resource *resource); - - virtual void tizen_launch_effect_create_splash_img(Resource *resource, uint32_t id); - virtual void tizen_launch_effect_type_set(Resource *resource, const std::string &effect_type, uint32_t pid, struct ::wl_array *options); - virtual void tizen_launch_effect_type_unset(Resource *resource, uint32_t pid); - virtual void tizen_launch_effect_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_launch_effect_interface m_tizen_launch_effect_interface; - - static void handle_create_splash_img( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_type_set( - ::wl_client *client, - struct wl_resource *resource, - const char *effect_type, - uint32_t pid, - struct ::wl_array *options); - static void handle_type_unset( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_launch_effect *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_launch_splash - { - public: - tizen_launch_splash(struct ::wl_client *client, uint32_t id, int version); - tizen_launch_splash(struct ::wl_display *display, int version); - tizen_launch_splash(struct ::wl_resource *resource); - tizen_launch_splash(); - - virtual ~tizen_launch_splash(); - - class Resource - { - public: - Resource() : tizen_launch_splash_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_launch_splash *tizen_launch_splash_object; - tizen_launch_splash *object() { return tizen_launch_splash_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum file_type { - file_type_img = 0, // splash image file path - file_type_edj = 1, // splash edj file path - }; - - enum indicator { - indicator_off = 0, // splash hide indicator - indicator_on = 1, // splash show indicator - }; - - enum rotation { - rotation_0 = 0, // rotation angle 0 degree - rotation_90 = 90, // rotation angle 90 degree - rotation_180 = 180, // rotation angle 180 degree - rotation_270 = 270, // rotation angle 270 degree - }; - - protected: - virtual Resource *tizen_launch_splash_allocate(); - - virtual void tizen_launch_splash_bind_resource(Resource *resource); - virtual void tizen_launch_splash_destroy_resource(Resource *resource); - - virtual void tizen_launch_splash_destroy(Resource *resource); - virtual void tizen_launch_splash_launch(Resource *resource, const std::string &file, uint32_t file_type, uint32_t color_depth, uint32_t rotation, uint32_t indicator, const std::string &effect_type, const std::string &theme_type, struct ::wl_array *options); - virtual void tizen_launch_splash_owner(Resource *resource, uint32_t pid); - virtual void tizen_launch_splash_launch_v2(Resource *resource, const std::string &file, uint32_t file_type, uint32_t color_depth, uint32_t rotation, uint32_t indicator, const std::string &effect_type, const std::string &theme_type, struct ::wl_array *options, struct ::wl_array *extra_config); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_launch_splash_interface m_tizen_launch_splash_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_launch( - ::wl_client *client, - struct wl_resource *resource, - const char *file, - uint32_t file_type, - uint32_t color_depth, - uint32_t rotation, - uint32_t indicator, - const char *effect_type, - const char *theme_type, - struct ::wl_array *options); - static void handle_owner( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid); - static void handle_launch_v2( - ::wl_client *client, - struct wl_resource *resource, - const char *file, - uint32_t file_type, - uint32_t color_depth, - uint32_t rotation, - uint32_t indicator, - const char *effect_type, - const char *theme_type, - struct ::wl_array *options, - struct ::wl_array *extra_config); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_launch_splash *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_launch_appinfo - { - public: - tizen_launch_appinfo(struct ::wl_client *client, uint32_t id, int version); - tizen_launch_appinfo(struct ::wl_display *display, int version); - tizen_launch_appinfo(struct ::wl_resource *resource); - tizen_launch_appinfo(); - - virtual ~tizen_launch_appinfo(); - - class Resource - { - public: - Resource() : tizen_launch_appinfo_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_launch_appinfo *tizen_launch_appinfo_object; - tizen_launch_appinfo *object() { return tizen_launch_appinfo_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_base_output_resolution_done(uint32_t pid, uint32_t width, uint32_t height); - void send_base_output_resolution_done(struct ::wl_resource *resource, uint32_t pid, uint32_t width, uint32_t height); - - protected: - virtual Resource *tizen_launch_appinfo_allocate(); - - virtual void tizen_launch_appinfo_bind_resource(Resource *resource); - virtual void tizen_launch_appinfo_destroy_resource(Resource *resource); - - virtual void tizen_launch_appinfo_destroy(Resource *resource); - virtual void tizen_launch_appinfo_register_pid(Resource *resource, uint32_t pid); - virtual void tizen_launch_appinfo_deregister_pid(Resource *resource, uint32_t pid); - virtual void tizen_launch_appinfo_set_appid(Resource *resource, uint32_t pid, const std::string &appid); - virtual void tizen_launch_appinfo_get_base_output_resolution(Resource *resource, uint32_t pid); - virtual void tizen_launch_appinfo_register_appid(Resource *resource, const std::string &appid); - virtual void tizen_launch_appinfo_deregister_appid(Resource *resource, const std::string &appid); - virtual void tizen_launch_appinfo_set_pid(Resource *resource, const std::string &appid, uint32_t pid); - virtual void tizen_launch_appinfo_ready_metadata(Resource *resource, const std::string &appid, uint32_t pid); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_launch_appinfo_interface m_tizen_launch_appinfo_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_register_pid( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid); - static void handle_deregister_pid( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid); - static void handle_set_appid( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid, - const char *appid); - static void handle_get_base_output_resolution( - ::wl_client *client, - struct wl_resource *resource, - uint32_t pid); - static void handle_register_appid( - ::wl_client *client, - struct wl_resource *resource, - const char *appid); - static void handle_deregister_appid( - ::wl_client *client, - struct wl_resource *resource, - const char *appid); - static void handle_set_pid( - ::wl_client *client, - struct wl_resource *resource, - const char *appid, - uint32_t pid); - static void handle_ready_metadata( - ::wl_client *client, - struct wl_resource *resource, - const char *appid, - uint32_t pid); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_launch_appinfo *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-policy-ext.cpp b/src/DSWaylandServer/dswayland-server-tizen-policy-ext.cpp deleted file mode 100644 index 47b68dd..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-policy-ext.cpp +++ /dev/null @@ -1,580 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-policy-ext.xml */ - -#include "dswayland-server-tizen-policy-ext.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - tizen_policy_ext::tizen_policy_ext(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_policy_ext::tizen_policy_ext(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_policy_ext::tizen_policy_ext(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_policy_ext::tizen_policy_ext() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_policy_ext::~tizen_policy_ext() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_policy_ext::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_policy_ext::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_policy_ext::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_policy_ext::Resource *tizen_policy_ext::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_policy_ext::Resource *tizen_policy_ext::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_policy_ext::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_policy_ext_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_policy_ext::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_policy_ext::interface() - { - return &::tizen_policy_ext_interface; - } - - tizen_policy_ext::Resource *tizen_policy_ext::tizen_policy_ext_allocate() - { - return new Resource; - } - - void tizen_policy_ext::tizen_policy_ext_bind_resource(Resource *) - { - } - - void tizen_policy_ext::tizen_policy_ext_destroy_resource(Resource *) - { - } - - void tizen_policy_ext::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_policy_ext *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_policy_ext::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_policy_ext *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_policy_ext::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_policy_ext *that = resource->tizen_policy_ext_object; - that->m_resource_map.erase(resource->client()); - that->tizen_policy_ext_destroy_resource(resource); - delete resource; - } - - tizen_policy_ext::Resource *tizen_policy_ext::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_policy_ext_interface, version, id); - return bind(handle); - } - - tizen_policy_ext::Resource *tizen_policy_ext::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_policy_ext_allocate(); - resource->tizen_policy_ext_object = this; - - wl_resource_set_implementation(handle, &m_tizen_policy_ext_interface, resource, destroy_func); - resource->handle = handle; - tizen_policy_ext_bind_resource(resource); - return resource; - } - tizen_policy_ext::Resource *tizen_policy_ext::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_policy_ext_interface, &m_tizen_policy_ext_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_policy_ext_interface tizen_policy_ext::m_tizen_policy_ext_interface = { - tizen_policy_ext::handle_get_rotation, - tizen_policy_ext::handle_get_active_angle - }; - - void tizen_policy_ext::tizen_policy_ext_get_rotation(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_policy_ext::tizen_policy_ext_get_active_angle(Resource *, struct ::wl_resource *) - { - } - - - void tizen_policy_ext::handle_get_rotation( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_ext_object)->tizen_policy_ext_get_rotation( - r, - id, - surface); - } - - void tizen_policy_ext::handle_get_active_angle( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_policy_ext_object)->tizen_policy_ext_get_active_angle( - r, - surface); - } - - void tizen_policy_ext::send_active_angle(uint32_t angle) - { - DS_ASSERT_X(m_resource, "tizen_policy_ext::active_angle", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_policy_ext::active_angle as it's not initialised"); - return; - } - send_active_angle( - m_resource->handle, - angle); - } - - void tizen_policy_ext::send_active_angle(struct ::wl_resource *resource, uint32_t angle) - { - tizen_policy_ext_send_active_angle( - resource, - angle); - } - - - tizen_rotation::tizen_rotation(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_rotation::tizen_rotation(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_rotation::tizen_rotation(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_rotation::tizen_rotation() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_rotation::~tizen_rotation() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_rotation::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_rotation::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_rotation::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_rotation::Resource *tizen_rotation::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_rotation::Resource *tizen_rotation::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_rotation::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_rotation_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_rotation::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_rotation::interface() - { - return &::tizen_rotation_interface; - } - - tizen_rotation::Resource *tizen_rotation::tizen_rotation_allocate() - { - return new Resource; - } - - void tizen_rotation::tizen_rotation_bind_resource(Resource *) - { - } - - void tizen_rotation::tizen_rotation_destroy_resource(Resource *) - { - } - - void tizen_rotation::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_rotation *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_rotation::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_rotation *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_rotation::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_rotation *that = resource->tizen_rotation_object; - that->m_resource_map.erase(resource->client()); - that->tizen_rotation_destroy_resource(resource); - delete resource; - } - - tizen_rotation::Resource *tizen_rotation::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_rotation_interface, version, id); - return bind(handle); - } - - tizen_rotation::Resource *tizen_rotation::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_rotation_allocate(); - resource->tizen_rotation_object = this; - - wl_resource_set_implementation(handle, &m_tizen_rotation_interface, resource, destroy_func); - resource->handle = handle; - tizen_rotation_bind_resource(resource); - return resource; - } - tizen_rotation::Resource *tizen_rotation::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_rotation_interface, &m_tizen_rotation_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_rotation_interface tizen_rotation::m_tizen_rotation_interface = { - tizen_rotation::handle_destroy, - tizen_rotation::handle_set_available_angles, - tizen_rotation::handle_set_preferred_angle, - tizen_rotation::handle_ack_angle_change, - tizen_rotation::handle_set_geometry_hint - }; - - void tizen_rotation::tizen_rotation_destroy(Resource *) - { - } - - void tizen_rotation::tizen_rotation_set_available_angles(Resource *, uint32_t ) - { - } - - void tizen_rotation::tizen_rotation_set_preferred_angle(Resource *, uint32_t ) - { - } - - void tizen_rotation::tizen_rotation_ack_angle_change(Resource *, uint32_t ) - { - } - - void tizen_rotation::tizen_rotation_set_geometry_hint(Resource *, uint32_t , uint32_t , uint32_t , uint32_t , uint32_t ) - { - } - - - void tizen_rotation::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_rotation_object)->tizen_rotation_destroy( - r); - } - - void tizen_rotation::handle_set_available_angles( - ::wl_client *client, - struct wl_resource *resource, - uint32_t angles) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_rotation_object)->tizen_rotation_set_available_angles( - r, - angles); - } - - void tizen_rotation::handle_set_preferred_angle( - ::wl_client *client, - struct wl_resource *resource, - uint32_t angle) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_rotation_object)->tizen_rotation_set_preferred_angle( - r, - angle); - } - - void tizen_rotation::handle_ack_angle_change( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_rotation_object)->tizen_rotation_ack_angle_change( - r, - serial); - } - - void tizen_rotation::handle_set_geometry_hint( - ::wl_client *client, - struct wl_resource *resource, - uint32_t angle, - uint32_t x, - uint32_t y, - uint32_t w, - uint32_t h) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_rotation_object)->tizen_rotation_set_geometry_hint( - r, - angle, - x, - y, - w, - h); - } - - void tizen_rotation::send_available_angles_done(uint32_t angles) - { - DS_ASSERT_X(m_resource, "tizen_rotation::available_angles_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_rotation::available_angles_done as it's not initialised"); - return; - } - send_available_angles_done( - m_resource->handle, - angles); - } - - void tizen_rotation::send_available_angles_done(struct ::wl_resource *resource, uint32_t angles) - { - tizen_rotation_send_available_angles_done( - resource, - angles); - } - - - void tizen_rotation::send_preferred_angle_done(uint32_t angle) - { - DS_ASSERT_X(m_resource, "tizen_rotation::preferred_angle_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_rotation::preferred_angle_done as it's not initialised"); - return; - } - send_preferred_angle_done( - m_resource->handle, - angle); - } - - void tizen_rotation::send_preferred_angle_done(struct ::wl_resource *resource, uint32_t angle) - { - tizen_rotation_send_preferred_angle_done( - resource, - angle); - } - - - void tizen_rotation::send_angle_change(uint32_t angle, uint32_t serial) - { - DS_ASSERT_X(m_resource, "tizen_rotation::angle_change", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_rotation::angle_change as it's not initialised"); - return; - } - send_angle_change( - m_resource->handle, - angle, - serial); - } - - void tizen_rotation::send_angle_change(struct ::wl_resource *resource, uint32_t angle, uint32_t serial) - { - tizen_rotation_send_angle_change( - resource, - angle, - serial); - } - - - void tizen_rotation::send_angle_change_with_resize(uint32_t angle, uint32_t serial, uint32_t width, uint32_t height) - { - DS_ASSERT_X(m_resource, "tizen_rotation::angle_change_with_resize", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_rotation::angle_change_with_resize as it's not initialised"); - return; - } - send_angle_change_with_resize( - m_resource->handle, - angle, - serial, - width, - height); - } - - void tizen_rotation::send_angle_change_with_resize(struct ::wl_resource *resource, uint32_t angle, uint32_t serial, uint32_t width, uint32_t height) - { - tizen_rotation_send_angle_change_with_resize( - resource, - angle, - serial, - width, - height); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-policy-ext.h b/src/DSWaylandServer/dswayland-server-tizen-policy-ext.h deleted file mode 100644 index dee296d..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-policy-ext.h +++ /dev/null @@ -1,239 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-policy-ext.xml */ - -#ifndef __DS_TIZEN_POLICY_EXT_PROTOCOL_H__ -#define __DS_TIZEN_POLICY_EXT_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "tizen-policy-ext-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class tizen_policy_ext - { - public: - tizen_policy_ext(struct ::wl_client *client, uint32_t id, int version); - tizen_policy_ext(struct ::wl_display *display, int version); - tizen_policy_ext(struct ::wl_resource *resource); - tizen_policy_ext(); - - virtual ~tizen_policy_ext(); - - class Resource - { - public: - Resource() : tizen_policy_ext_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_policy_ext *tizen_policy_ext_object; - tizen_policy_ext *object() { return tizen_policy_ext_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_active_angle(uint32_t angle); - void send_active_angle(struct ::wl_resource *resource, uint32_t angle); - - protected: - virtual Resource *tizen_policy_ext_allocate(); - - virtual void tizen_policy_ext_bind_resource(Resource *resource); - virtual void tizen_policy_ext_destroy_resource(Resource *resource); - - virtual void tizen_policy_ext_get_rotation(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_policy_ext_get_active_angle(Resource *resource, struct ::wl_resource *surface); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_policy_ext_interface m_tizen_policy_ext_interface; - - static void handle_get_rotation( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_get_active_angle( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_policy_ext *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_rotation - { - public: - tizen_rotation(struct ::wl_client *client, uint32_t id, int version); - tizen_rotation(struct ::wl_display *display, int version); - tizen_rotation(struct ::wl_resource *resource); - tizen_rotation(); - - virtual ~tizen_rotation(); - - class Resource - { - public: - Resource() : tizen_rotation_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_rotation *tizen_rotation_object; - tizen_rotation *object() { return tizen_rotation_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum angle { - angle_none = 0, - angle_0 = 1, - angle_90 = 2, - angle_180 = 4, - angle_270 = 8, - }; - - void send_available_angles_done(uint32_t angles); - void send_available_angles_done(struct ::wl_resource *resource, uint32_t angles); - void send_preferred_angle_done(uint32_t angle); - void send_preferred_angle_done(struct ::wl_resource *resource, uint32_t angle); - void send_angle_change(uint32_t angle, uint32_t serial); - void send_angle_change(struct ::wl_resource *resource, uint32_t angle, uint32_t serial); - void send_angle_change_with_resize(uint32_t angle, uint32_t serial, uint32_t width, uint32_t height); - void send_angle_change_with_resize(struct ::wl_resource *resource, uint32_t angle, uint32_t serial, uint32_t width, uint32_t height); - - protected: - virtual Resource *tizen_rotation_allocate(); - - virtual void tizen_rotation_bind_resource(Resource *resource); - virtual void tizen_rotation_destroy_resource(Resource *resource); - - virtual void tizen_rotation_destroy(Resource *resource); - virtual void tizen_rotation_set_available_angles(Resource *resource, uint32_t angles); - virtual void tizen_rotation_set_preferred_angle(Resource *resource, uint32_t angle); - virtual void tizen_rotation_ack_angle_change(Resource *resource, uint32_t serial); - virtual void tizen_rotation_set_geometry_hint(Resource *resource, uint32_t angle, uint32_t x, uint32_t y, uint32_t w, uint32_t h); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_rotation_interface m_tizen_rotation_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_available_angles( - ::wl_client *client, - struct wl_resource *resource, - uint32_t angles); - static void handle_set_preferred_angle( - ::wl_client *client, - struct wl_resource *resource, - uint32_t angle); - static void handle_ack_angle_change( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_set_geometry_hint( - ::wl_client *client, - struct wl_resource *resource, - uint32_t angle, - uint32_t x, - uint32_t y, - uint32_t w, - uint32_t h); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_rotation *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-remote-surface.cpp b/src/DSWaylandServer/dswayland-server-tizen-remote-surface.cpp deleted file mode 100644 index de98bdb..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-remote-surface.cpp +++ /dev/null @@ -1,1290 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-remote-surface.xml */ - -#include "dswayland-server-tizen-remote-surface.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - tizen_remote_surface_manager::tizen_remote_surface_manager(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_remote_surface_manager::tizen_remote_surface_manager(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_remote_surface_manager::tizen_remote_surface_manager(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_remote_surface_manager::tizen_remote_surface_manager() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_remote_surface_manager::~tizen_remote_surface_manager() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_remote_surface_manager::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_remote_surface_manager::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_remote_surface_manager::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_remote_surface_manager::Resource *tizen_remote_surface_manager::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_remote_surface_manager::Resource *tizen_remote_surface_manager::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_remote_surface_manager::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_remote_surface_manager_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_remote_surface_manager::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_remote_surface_manager::interface() - { - return &::tizen_remote_surface_manager_interface; - } - - tizen_remote_surface_manager::Resource *tizen_remote_surface_manager::tizen_remote_surface_manager_allocate() - { - return new Resource; - } - - void tizen_remote_surface_manager::tizen_remote_surface_manager_bind_resource(Resource *) - { - } - - void tizen_remote_surface_manager::tizen_remote_surface_manager_destroy_resource(Resource *) - { - } - - void tizen_remote_surface_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_remote_surface_manager *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_remote_surface_manager::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_remote_surface_manager *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_remote_surface_manager::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_remote_surface_manager *that = resource->tizen_remote_surface_manager_object; - that->m_resource_map.erase(resource->client()); - that->tizen_remote_surface_manager_destroy_resource(resource); - delete resource; - } - - tizen_remote_surface_manager::Resource *tizen_remote_surface_manager::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_remote_surface_manager_interface, version, id); - return bind(handle); - } - - tizen_remote_surface_manager::Resource *tizen_remote_surface_manager::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_remote_surface_manager_allocate(); - resource->tizen_remote_surface_manager_object = this; - - wl_resource_set_implementation(handle, &m_tizen_remote_surface_manager_interface, resource, destroy_func); - resource->handle = handle; - tizen_remote_surface_manager_bind_resource(resource); - return resource; - } - tizen_remote_surface_manager::Resource *tizen_remote_surface_manager::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_remote_surface_manager_interface, &m_tizen_remote_surface_manager_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_remote_surface_manager_interface tizen_remote_surface_manager::m_tizen_remote_surface_manager_interface = { - tizen_remote_surface_manager::handle_create_provider, - tizen_remote_surface_manager::handle_create_surface, - tizen_remote_surface_manager::handle_bind_surface, - tizen_remote_surface_manager::handle_destroy, - tizen_remote_surface_manager::handle_create_surface_with_wl_surface - }; - - void tizen_remote_surface_manager::tizen_remote_surface_manager_create_provider(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_remote_surface_manager::tizen_remote_surface_manager_create_surface(Resource *, uint32_t, uint32_t , struct ::wl_resource *) - { - } - - void tizen_remote_surface_manager::tizen_remote_surface_manager_bind_surface(Resource *, struct ::wl_resource *, struct ::wl_resource *) - { - } - - void tizen_remote_surface_manager::tizen_remote_surface_manager_destroy(Resource *) - { - } - - void tizen_remote_surface_manager::tizen_remote_surface_manager_create_surface_with_wl_surface(Resource *, uint32_t, uint32_t , struct ::wl_resource *, struct ::wl_resource *) - { - } - - - void tizen_remote_surface_manager::handle_create_provider( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_manager_object)->tizen_remote_surface_manager_create_provider( - r, - id, - surface); - } - - void tizen_remote_surface_manager::handle_create_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t resource_id, - struct ::wl_resource *tbm) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_manager_object)->tizen_remote_surface_manager_create_surface( - r, - id, - resource_id, - tbm); - } - - void tizen_remote_surface_manager::handle_bind_surface( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - struct ::wl_resource *remote_surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_manager_object)->tizen_remote_surface_manager_bind_surface( - r, - surface, - remote_surface); - } - - void tizen_remote_surface_manager::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_manager_object)->tizen_remote_surface_manager_destroy( - r); - } - - void tizen_remote_surface_manager::handle_create_surface_with_wl_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t resource_id, - struct ::wl_resource *tbm, - struct ::wl_resource *wayland_surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_manager_object)->tizen_remote_surface_manager_create_surface_with_wl_surface( - r, - id, - resource_id, - tbm, - wayland_surface); - } - - tizen_remote_surface_provider::tizen_remote_surface_provider(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_remote_surface_provider::tizen_remote_surface_provider(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_remote_surface_provider::tizen_remote_surface_provider(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_remote_surface_provider::tizen_remote_surface_provider() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_remote_surface_provider::~tizen_remote_surface_provider() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_remote_surface_provider::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_remote_surface_provider::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_remote_surface_provider::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_remote_surface_provider::Resource *tizen_remote_surface_provider::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_remote_surface_provider::Resource *tizen_remote_surface_provider::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_remote_surface_provider::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_remote_surface_provider_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_remote_surface_provider::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_remote_surface_provider::interface() - { - return &::tizen_remote_surface_provider_interface; - } - - tizen_remote_surface_provider::Resource *tizen_remote_surface_provider::tizen_remote_surface_provider_allocate() - { - return new Resource; - } - - void tizen_remote_surface_provider::tizen_remote_surface_provider_bind_resource(Resource *) - { - } - - void tizen_remote_surface_provider::tizen_remote_surface_provider_destroy_resource(Resource *) - { - } - - void tizen_remote_surface_provider::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_remote_surface_provider *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_remote_surface_provider::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_remote_surface_provider *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_remote_surface_provider::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_remote_surface_provider *that = resource->tizen_remote_surface_provider_object; - that->m_resource_map.erase(resource->client()); - that->tizen_remote_surface_provider_destroy_resource(resource); - delete resource; - } - - tizen_remote_surface_provider::Resource *tizen_remote_surface_provider::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_remote_surface_provider_interface, version, id); - return bind(handle); - } - - tizen_remote_surface_provider::Resource *tizen_remote_surface_provider::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_remote_surface_provider_allocate(); - resource->tizen_remote_surface_provider_object = this; - - wl_resource_set_implementation(handle, &m_tizen_remote_surface_provider_interface, resource, destroy_func); - resource->handle = handle; - tizen_remote_surface_provider_bind_resource(resource); - return resource; - } - tizen_remote_surface_provider::Resource *tizen_remote_surface_provider::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_remote_surface_provider_interface, &m_tizen_remote_surface_provider_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_remote_surface_provider_interface tizen_remote_surface_provider::m_tizen_remote_surface_provider_interface = { - tizen_remote_surface_provider::handle_destroy, - tizen_remote_surface_provider::handle_offscreen_set, - tizen_remote_surface_provider::handle_set_input_event_filter - }; - - void tizen_remote_surface_provider::tizen_remote_surface_provider_destroy(Resource *) - { - } - - void tizen_remote_surface_provider::tizen_remote_surface_provider_offscreen_set(Resource *, uint32_t ) - { - } - - void tizen_remote_surface_provider::tizen_remote_surface_provider_set_input_event_filter(Resource *, uint32_t ) - { - } - - - void tizen_remote_surface_provider::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_provider_object)->tizen_remote_surface_provider_destroy( - r); - } - - void tizen_remote_surface_provider::handle_offscreen_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_provider_object)->tizen_remote_surface_provider_offscreen_set( - r, - set); - } - - void tizen_remote_surface_provider::handle_set_input_event_filter( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_filter) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_provider_object)->tizen_remote_surface_provider_set_input_event_filter( - r, - event_filter); - } - - void tizen_remote_surface_provider::send_resource_id(uint32_t resource_id) - { - DS_ASSERT_X(m_resource, "tizen_remote_surface_provider::resource_id", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_remote_surface_provider::resource_id as it's not initialised"); - return; - } - send_resource_id( - m_resource->handle, - resource_id); - } - - void tizen_remote_surface_provider::send_resource_id(struct ::wl_resource *resource, uint32_t resource_id) - { - tizen_remote_surface_provider_send_resource_id( - resource, - resource_id); - } - - - void tizen_remote_surface_provider::send_visibility(uint32_t visibility) - { - DS_ASSERT_X(m_resource, "tizen_remote_surface_provider::visibility", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_remote_surface_provider::visibility as it's not initialised"); - return; - } - send_visibility( - m_resource->handle, - visibility); - } - - void tizen_remote_surface_provider::send_visibility(struct ::wl_resource *resource, uint32_t visibility) - { - tizen_remote_surface_provider_send_visibility( - resource, - visibility); - } - - - tizen_remote_surface::tizen_remote_surface(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_remote_surface::tizen_remote_surface(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_remote_surface::tizen_remote_surface(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_remote_surface::tizen_remote_surface() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_remote_surface::~tizen_remote_surface() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_remote_surface::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_remote_surface::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_remote_surface::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_remote_surface::Resource *tizen_remote_surface::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_remote_surface::Resource *tizen_remote_surface::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_remote_surface::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_remote_surface_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_remote_surface::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_remote_surface::interface() - { - return &::tizen_remote_surface_interface; - } - - tizen_remote_surface::Resource *tizen_remote_surface::tizen_remote_surface_allocate() - { - return new Resource; - } - - void tizen_remote_surface::tizen_remote_surface_bind_resource(Resource *) - { - } - - void tizen_remote_surface::tizen_remote_surface_destroy_resource(Resource *) - { - } - - void tizen_remote_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_remote_surface *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_remote_surface::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_remote_surface *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_remote_surface::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_remote_surface *that = resource->tizen_remote_surface_object; - that->m_resource_map.erase(resource->client()); - that->tizen_remote_surface_destroy_resource(resource); - delete resource; - } - - tizen_remote_surface::Resource *tizen_remote_surface::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_remote_surface_interface, version, id); - return bind(handle); - } - - tizen_remote_surface::Resource *tizen_remote_surface::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_remote_surface_allocate(); - resource->tizen_remote_surface_object = this; - - wl_resource_set_implementation(handle, &m_tizen_remote_surface_interface, resource, destroy_func); - resource->handle = handle; - tizen_remote_surface_bind_resource(resource); - return resource; - } - tizen_remote_surface::Resource *tizen_remote_surface::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_remote_surface_interface, &m_tizen_remote_surface_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_remote_surface_interface tizen_remote_surface::m_tizen_remote_surface_interface = { - tizen_remote_surface::handle_destroy, - tizen_remote_surface::handle_redirect, - tizen_remote_surface::handle_unredirect, - tizen_remote_surface::handle_transfer_mouse_event, - tizen_remote_surface::handle_transfer_mouse_wheel, - tizen_remote_surface::handle_transfer_touch_event, - tizen_remote_surface::handle_transfer_touch_cancel, - tizen_remote_surface::handle_transfer_key_event, - tizen_remote_surface::handle_transfer_visibility, - tizen_remote_surface::handle_set_owner, - tizen_remote_surface::handle_create_region, - tizen_remote_surface::handle_release, - tizen_remote_surface::handle_set_remote_render, - tizen_remote_surface::handle_set_changed_buffer_event_filter, - tizen_remote_surface::handle_get_current_buffer - }; - - void tizen_remote_surface::tizen_remote_surface_destroy(Resource *) - { - } - - void tizen_remote_surface::tizen_remote_surface_redirect(Resource *) - { - } - - void tizen_remote_surface::tizen_remote_surface_unredirect(Resource *) - { - } - - void tizen_remote_surface::tizen_remote_surface_transfer_mouse_event(Resource *, uint32_t , int32_t , int32_t , int32_t , int32_t , wl_fixed_t , wl_fixed_t , wl_fixed_t , wl_fixed_t , uint32_t , uint32_t , const std::string &, uint32_t ) - { - } - - void tizen_remote_surface::tizen_remote_surface_transfer_mouse_wheel(Resource *, uint32_t , int32_t , uint32_t , uint32_t , const std::string &, uint32_t ) - { - } - - void tizen_remote_surface::tizen_remote_surface_transfer_touch_event(Resource *, uint32_t , int32_t , int32_t , int32_t , int32_t , wl_fixed_t , wl_fixed_t , wl_fixed_t , wl_fixed_t , uint32_t , uint32_t , const std::string &, uint32_t ) - { - } - - void tizen_remote_surface::tizen_remote_surface_transfer_touch_cancel(Resource *) - { - } - - void tizen_remote_surface::tizen_remote_surface_transfer_key_event(Resource *, uint32_t , int32_t , uint32_t , uint32_t , const std::string &, uint32_t ) - { - } - - void tizen_remote_surface::tizen_remote_surface_transfer_visibility(Resource *, uint32_t ) - { - } - - void tizen_remote_surface::tizen_remote_surface_set_owner(Resource *, struct ::wl_resource *) - { - } - - void tizen_remote_surface::tizen_remote_surface_create_region(Resource *, uint32_t) - { - } - - void tizen_remote_surface::tizen_remote_surface_release(Resource *, struct ::wl_resource *) - { - } - - void tizen_remote_surface::tizen_remote_surface_set_remote_render(Resource *, uint32_t ) - { - } - - void tizen_remote_surface::tizen_remote_surface_set_changed_buffer_event_filter(Resource *, uint32_t ) - { - } - - void tizen_remote_surface::tizen_remote_surface_get_current_buffer(Resource *, uint32_t , uint32_t ) - { - } - - - void tizen_remote_surface::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_destroy( - r); - } - - void tizen_remote_surface::handle_redirect( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_redirect( - r); - } - - void tizen_remote_surface::handle_unredirect( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_unredirect( - r); - } - - void tizen_remote_surface::handle_transfer_mouse_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_type, - int32_t device, - int32_t button, - int32_t x, - int32_t y, - wl_fixed_t radius_x, - wl_fixed_t radius_y, - wl_fixed_t pressure, - wl_fixed_t angle, - uint32_t clas, - uint32_t subclas, - const char *identifier, - uint32_t time) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_transfer_mouse_event( - r, - event_type, - device, - button, - x, - y, - radius_x, - radius_y, - pressure, - angle, - clas, - subclas, - std::string(identifier), - time); - } - - void tizen_remote_surface::handle_transfer_mouse_wheel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t direction, - int32_t z, - uint32_t clas, - uint32_t subclas, - const char *identifier, - uint32_t time) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_transfer_mouse_wheel( - r, - direction, - z, - clas, - subclas, - std::string(identifier), - time); - } - - void tizen_remote_surface::handle_transfer_touch_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_type, - int32_t device, - int32_t button, - int32_t x, - int32_t y, - wl_fixed_t radius_x, - wl_fixed_t radius_y, - wl_fixed_t pressure, - wl_fixed_t angle, - uint32_t clas, - uint32_t subclas, - const char *identifier, - uint32_t time) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_transfer_touch_event( - r, - event_type, - device, - button, - x, - y, - radius_x, - radius_y, - pressure, - angle, - clas, - subclas, - std::string(identifier), - time); - } - - void tizen_remote_surface::handle_transfer_touch_cancel( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_transfer_touch_cancel( - r); - } - - void tizen_remote_surface::handle_transfer_key_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_type, - int32_t keycode, - uint32_t clas, - uint32_t subclas, - const char *identifier, - uint32_t time) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_transfer_key_event( - r, - event_type, - keycode, - clas, - subclas, - std::string(identifier), - time); - } - - void tizen_remote_surface::handle_transfer_visibility( - ::wl_client *client, - struct wl_resource *resource, - uint32_t visibility) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_transfer_visibility( - r, - visibility); - } - - void tizen_remote_surface::handle_set_owner( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *owner) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_set_owner( - r, - owner); - } - - void tizen_remote_surface::handle_create_region( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_create_region( - r, - id); - } - - void tizen_remote_surface::handle_release( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *buffer) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_release( - r, - buffer); - } - - void tizen_remote_surface::handle_set_remote_render( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_set_remote_render( - r, - set); - } - - void tizen_remote_surface::handle_set_changed_buffer_event_filter( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_set_changed_buffer_event_filter( - r, - type); - } - - void tizen_remote_surface::handle_get_current_buffer( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_object)->tizen_remote_surface_get_current_buffer( - r, - type, - serial); - } - - void tizen_remote_surface::send_update_buffer(struct ::wl_resource *buffer, uint32_t time) - { - DS_ASSERT_X(m_resource, "tizen_remote_surface::update_buffer", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_remote_surface::update_buffer as it's not initialised"); - return; - } - send_update_buffer( - m_resource->handle, - buffer, - time); - } - - void tizen_remote_surface::send_update_buffer(struct ::wl_resource *resource, struct ::wl_resource *buffer, uint32_t time) - { - tizen_remote_surface_send_update_buffer( - resource, - buffer, - time); - } - - - void tizen_remote_surface::send_missing() - { - DS_ASSERT_X(m_resource, "tizen_remote_surface::missing", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_remote_surface::missing as it's not initialised"); - return; - } - send_missing( - m_resource->handle); - } - - void tizen_remote_surface::send_missing(struct ::wl_resource *resource) - { - tizen_remote_surface_send_missing( - resource); - } - - - void tizen_remote_surface::send_changed_buffer(uint32_t type, struct ::wl_resource *tbm, int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct ::wl_array *options) - { - DS_ASSERT_X(m_resource, "tizen_remote_surface::changed_buffer", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_remote_surface::changed_buffer as it's not initialised"); - return; - } - send_changed_buffer( - m_resource->handle, - type, - tbm, - img_file_fd, - img_file_size, - time, - options); - } - - void tizen_remote_surface::send_changed_buffer(struct ::wl_resource *resource, uint32_t type, struct ::wl_resource *tbm, int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct ::wl_array *options) - { - tizen_remote_surface_send_changed_buffer( - resource, - type, - tbm, - img_file_fd, - img_file_size, - time, - options); - } - - - void tizen_remote_surface::send_input_event_filter(uint32_t event_filter) - { - DS_ASSERT_X(m_resource, "tizen_remote_surface::input_event_filter", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_remote_surface::input_event_filter as it's not initialised"); - return; - } - send_input_event_filter( - m_resource->handle, - event_filter); - } - - void tizen_remote_surface::send_input_event_filter(struct ::wl_resource *resource, uint32_t event_filter) - { - tizen_remote_surface_send_input_event_filter( - resource, - event_filter); - } - - - tizen_remote_surface_region::tizen_remote_surface_region(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_remote_surface_region::tizen_remote_surface_region(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_remote_surface_region::tizen_remote_surface_region(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_remote_surface_region::tizen_remote_surface_region() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_remote_surface_region::~tizen_remote_surface_region() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_remote_surface_region::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_remote_surface_region::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_remote_surface_region::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_remote_surface_region::Resource *tizen_remote_surface_region::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_remote_surface_region::Resource *tizen_remote_surface_region::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_remote_surface_region::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_remote_surface_region_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_remote_surface_region::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_remote_surface_region::interface() - { - return &::tizen_remote_surface_region_interface; - } - - tizen_remote_surface_region::Resource *tizen_remote_surface_region::tizen_remote_surface_region_allocate() - { - return new Resource; - } - - void tizen_remote_surface_region::tizen_remote_surface_region_bind_resource(Resource *) - { - } - - void tizen_remote_surface_region::tizen_remote_surface_region_destroy_resource(Resource *) - { - } - - void tizen_remote_surface_region::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_remote_surface_region *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_remote_surface_region::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_remote_surface_region *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_remote_surface_region::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_remote_surface_region *that = resource->tizen_remote_surface_region_object; - that->m_resource_map.erase(resource->client()); - that->tizen_remote_surface_region_destroy_resource(resource); - delete resource; - } - - tizen_remote_surface_region::Resource *tizen_remote_surface_region::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_remote_surface_region_interface, version, id); - return bind(handle); - } - - tizen_remote_surface_region::Resource *tizen_remote_surface_region::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_remote_surface_region_allocate(); - resource->tizen_remote_surface_region_object = this; - - wl_resource_set_implementation(handle, &m_tizen_remote_surface_region_interface, resource, destroy_func); - resource->handle = handle; - tizen_remote_surface_region_bind_resource(resource); - return resource; - } - tizen_remote_surface_region::Resource *tizen_remote_surface_region::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_remote_surface_region_interface, &m_tizen_remote_surface_region_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_remote_surface_region_interface tizen_remote_surface_region::m_tizen_remote_surface_region_interface = { - tizen_remote_surface_region::handle_destroy, - tizen_remote_surface_region::handle_set_geometry - }; - - void tizen_remote_surface_region::tizen_remote_surface_region_destroy(Resource *) - { - } - - void tizen_remote_surface_region::tizen_remote_surface_region_set_geometry(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - - void tizen_remote_surface_region::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_region_object)->tizen_remote_surface_region_destroy( - r); - } - - void tizen_remote_surface_region::handle_set_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t w, - int32_t h) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_remote_surface_region_object)->tizen_remote_surface_region_set_geometry( - r, - x, - y, - w, - h); - } -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-remote-surface.h b/src/DSWaylandServer/dswayland-server-tizen-remote-surface.h deleted file mode 100644 index 85216c2..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-remote-surface.h +++ /dev/null @@ -1,579 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-remote-surface.xml */ - -#ifndef __DS_TIZEN_REMOTE_SURFACE_PROTOCOL_H__ -#define __DS_TIZEN_REMOTE_SURFACE_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "tizen-remote-surface-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class tizen_remote_surface_manager - { - public: - tizen_remote_surface_manager(struct ::wl_client *client, uint32_t id, int version); - tizen_remote_surface_manager(struct ::wl_display *display, int version); - tizen_remote_surface_manager(struct ::wl_resource *resource); - tizen_remote_surface_manager(); - - virtual ~tizen_remote_surface_manager(); - - class Resource - { - public: - Resource() : tizen_remote_surface_manager_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_remote_surface_manager *tizen_remote_surface_manager_object; - tizen_remote_surface_manager *object() { return tizen_remote_surface_manager_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tizen_remote_surface_manager_allocate(); - - virtual void tizen_remote_surface_manager_bind_resource(Resource *resource); - virtual void tizen_remote_surface_manager_destroy_resource(Resource *resource); - - virtual void tizen_remote_surface_manager_create_provider(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_remote_surface_manager_create_surface(Resource *resource, uint32_t id, uint32_t resource_id, struct ::wl_resource *tbm); - virtual void tizen_remote_surface_manager_bind_surface(Resource *resource, struct ::wl_resource *surface, struct ::wl_resource *remote_surface); - virtual void tizen_remote_surface_manager_destroy(Resource *resource); - virtual void tizen_remote_surface_manager_create_surface_with_wl_surface(Resource *resource, uint32_t id, uint32_t resource_id, struct ::wl_resource *tbm, struct ::wl_resource *wayland_surface); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_remote_surface_manager_interface m_tizen_remote_surface_manager_interface; - - static void handle_create_provider( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_create_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t resource_id, - struct ::wl_resource *tbm); - static void handle_bind_surface( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *surface, - struct ::wl_resource *remote_surface); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_create_surface_with_wl_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t resource_id, - struct ::wl_resource *tbm, - struct ::wl_resource *wayland_surface); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_remote_surface_manager *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_remote_surface_provider - { - public: - tizen_remote_surface_provider(struct ::wl_client *client, uint32_t id, int version); - tizen_remote_surface_provider(struct ::wl_display *display, int version); - tizen_remote_surface_provider(struct ::wl_resource *resource); - tizen_remote_surface_provider(); - - virtual ~tizen_remote_surface_provider(); - - class Resource - { - public: - Resource() : tizen_remote_surface_provider_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_remote_surface_provider *tizen_remote_surface_provider_object; - tizen_remote_surface_provider *object() { return tizen_remote_surface_provider_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum visibility_type { - visibility_type_visible = 0, - visibility_type_invisible = 1, - }; - - void send_resource_id(uint32_t resource_id); - void send_resource_id(struct ::wl_resource *resource, uint32_t resource_id); - void send_visibility(uint32_t visibility); - void send_visibility(struct ::wl_resource *resource, uint32_t visibility); - - protected: - virtual Resource *tizen_remote_surface_provider_allocate(); - - virtual void tizen_remote_surface_provider_bind_resource(Resource *resource); - virtual void tizen_remote_surface_provider_destroy_resource(Resource *resource); - - virtual void tizen_remote_surface_provider_destroy(Resource *resource); - virtual void tizen_remote_surface_provider_offscreen_set(Resource *resource, uint32_t set); - virtual void tizen_remote_surface_provider_set_input_event_filter(Resource *resource, uint32_t event_filter); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_remote_surface_provider_interface m_tizen_remote_surface_provider_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_offscreen_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set); - static void handle_set_input_event_filter( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_filter); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_remote_surface_provider *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_remote_surface - { - public: - tizen_remote_surface(struct ::wl_client *client, uint32_t id, int version); - tizen_remote_surface(struct ::wl_display *display, int version); - tizen_remote_surface(struct ::wl_resource *resource); - tizen_remote_surface(); - - virtual ~tizen_remote_surface(); - - class Resource - { - public: - Resource() : tizen_remote_surface_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_remote_surface *tizen_remote_surface_object; - tizen_remote_surface *object() { return tizen_remote_surface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum event_type { - event_type_none = 0, - event_type_mouse_down = 1, - event_type_mouse_up = 2, - event_type_mouse_move = 3, - event_type_touch_down = 4, - event_type_touch_up = 5, - event_type_touch_move = 6, - event_type_key_down = 7, - event_type_key_up = 8, - event_type_mouse_in = 9, - event_type_mouse_out = 10, - event_type_key_cancel = 11, - }; - - enum visibility_type { - visibility_type_visible = 0, - visibility_type_invisible = 1, - }; - - enum buffer_type { - buffer_type_tbm = 0, // tbm type - buffer_type_image_file = 1, // image file type - }; - - enum input_event_filter { - input_event_filter_mouse_none = 0x00000001, - input_event_filter_mouse_up_down = 0x00000002, - input_event_filter_mouse_move_x = 0x00000003, - input_event_filter_mouse_move_y = 0x00000004, - input_event_filter_mouse_move_x_y = 0x00000005, - input_event_filter_mouse_up_down_move_x = 0x00000006, - input_event_filter_mouse_up_down_move_y = 0x00000007, - input_event_filter_mouse_up_down_move_x_y = 0x00000008, - input_event_filter_mouse_all = 0x0000000e, - input_event_filter_mouse_flag = 0x0000000f, - input_event_filter_mouse_wheel_none = 0x00000010, - input_event_filter_mouse_wheel_all = 0x000000e0, - input_event_filter_mouse_wheel_flag = 0x000000f0, - input_event_filter_touch_none = 0x00000100, - input_event_filter_touch_up_down = 0x00000200, - input_event_filter_touch_move_x = 0x00000300, - input_event_filter_touch_move_y = 0x00000400, - input_event_filter_touch_move_x_y = 0x00000500, - input_event_filter_touch_up_down_move_x = 0x00000600, - input_event_filter_touch_up_down_move_y = 0x00000700, - input_event_filter_touch_up_down_move_x_y = 0x00000800, - input_event_filter_touch_all = 0x00000e00, - input_event_filter_touch_flag = 0x00000f00, - input_event_filter_touch_cancel_none = 0x00001000, - input_event_filter_touch_cancel_all = 0x0000e000, - input_event_filter_touch_cancel_flag = 0x0000f000, - input_event_filter_key_none = 0x00010000, - input_event_filter_key_all = 0x000e0000, - input_event_filter_key_flag = 0x000f0000, - }; - - enum changed_buffer_event_filter { - changed_buffer_event_filter_none = 0x00000000, // none - changed_buffer_event_filter_tbm = 0x00000001, // tbm type filter - changed_buffer_event_filter_image_file = 0x00000002, // image file type filter - }; - - void send_update_buffer(struct ::wl_resource *buffer, uint32_t time); - void send_update_buffer(struct ::wl_resource *resource, struct ::wl_resource *buffer, uint32_t time); - void send_missing(); - void send_missing(struct ::wl_resource *resource); - void send_changed_buffer(uint32_t type, struct ::wl_resource *tbm, int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct ::wl_array *options); - void send_changed_buffer(struct ::wl_resource *resource, uint32_t type, struct ::wl_resource *tbm, int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct ::wl_array *options); - void send_input_event_filter(uint32_t event_filter); - void send_input_event_filter(struct ::wl_resource *resource, uint32_t event_filter); - - protected: - virtual Resource *tizen_remote_surface_allocate(); - - virtual void tizen_remote_surface_bind_resource(Resource *resource); - virtual void tizen_remote_surface_destroy_resource(Resource *resource); - - virtual void tizen_remote_surface_destroy(Resource *resource); - virtual void tizen_remote_surface_redirect(Resource *resource); - virtual void tizen_remote_surface_unredirect(Resource *resource); - virtual void tizen_remote_surface_transfer_mouse_event(Resource *resource, uint32_t event_type, int32_t device, int32_t button, int32_t x, int32_t y, wl_fixed_t radius_x, wl_fixed_t radius_y, wl_fixed_t pressure, wl_fixed_t angle, uint32_t clas, uint32_t subclas, const std::string &identifier, uint32_t time); - virtual void tizen_remote_surface_transfer_mouse_wheel(Resource *resource, uint32_t direction, int32_t z, uint32_t clas, uint32_t subclas, const std::string &identifier, uint32_t time); - virtual void tizen_remote_surface_transfer_touch_event(Resource *resource, uint32_t event_type, int32_t device, int32_t button, int32_t x, int32_t y, wl_fixed_t radius_x, wl_fixed_t radius_y, wl_fixed_t pressure, wl_fixed_t angle, uint32_t clas, uint32_t subclas, const std::string &identifier, uint32_t time); - virtual void tizen_remote_surface_transfer_touch_cancel(Resource *resource); - virtual void tizen_remote_surface_transfer_key_event(Resource *resource, uint32_t event_type, int32_t keycode, uint32_t clas, uint32_t subclas, const std::string &identifier, uint32_t time); - virtual void tizen_remote_surface_transfer_visibility(Resource *resource, uint32_t visibility); - virtual void tizen_remote_surface_set_owner(Resource *resource, struct ::wl_resource *owner); - virtual void tizen_remote_surface_create_region(Resource *resource, uint32_t id); - virtual void tizen_remote_surface_release(Resource *resource, struct ::wl_resource *buffer); - virtual void tizen_remote_surface_set_remote_render(Resource *resource, uint32_t set); - virtual void tizen_remote_surface_set_changed_buffer_event_filter(Resource *resource, uint32_t type); - virtual void tizen_remote_surface_get_current_buffer(Resource *resource, uint32_t type, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_remote_surface_interface m_tizen_remote_surface_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_redirect( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unredirect( - ::wl_client *client, - struct wl_resource *resource); - static void handle_transfer_mouse_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_type, - int32_t device, - int32_t button, - int32_t x, - int32_t y, - wl_fixed_t radius_x, - wl_fixed_t radius_y, - wl_fixed_t pressure, - wl_fixed_t angle, - uint32_t clas, - uint32_t subclas, - const char *identifier, - uint32_t time); - static void handle_transfer_mouse_wheel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t direction, - int32_t z, - uint32_t clas, - uint32_t subclas, - const char *identifier, - uint32_t time); - static void handle_transfer_touch_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_type, - int32_t device, - int32_t button, - int32_t x, - int32_t y, - wl_fixed_t radius_x, - wl_fixed_t radius_y, - wl_fixed_t pressure, - wl_fixed_t angle, - uint32_t clas, - uint32_t subclas, - const char *identifier, - uint32_t time); - static void handle_transfer_touch_cancel( - ::wl_client *client, - struct wl_resource *resource); - static void handle_transfer_key_event( - ::wl_client *client, - struct wl_resource *resource, - uint32_t event_type, - int32_t keycode, - uint32_t clas, - uint32_t subclas, - const char *identifier, - uint32_t time); - static void handle_transfer_visibility( - ::wl_client *client, - struct wl_resource *resource, - uint32_t visibility); - static void handle_set_owner( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *owner); - static void handle_create_region( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_release( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *buffer); - static void handle_set_remote_render( - ::wl_client *client, - struct wl_resource *resource, - uint32_t set); - static void handle_set_changed_buffer_event_filter( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type); - static void handle_get_current_buffer( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_remote_surface *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_remote_surface_region - { - public: - tizen_remote_surface_region(struct ::wl_client *client, uint32_t id, int version); - tizen_remote_surface_region(struct ::wl_display *display, int version); - tizen_remote_surface_region(struct ::wl_resource *resource); - tizen_remote_surface_region(); - - virtual ~tizen_remote_surface_region(); - - class Resource - { - public: - Resource() : tizen_remote_surface_region_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_remote_surface_region *tizen_remote_surface_region_object; - tizen_remote_surface_region *object() { return tizen_remote_surface_region_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tizen_remote_surface_region_allocate(); - - virtual void tizen_remote_surface_region_bind_resource(Resource *resource); - virtual void tizen_remote_surface_region_destroy_resource(Resource *resource); - - virtual void tizen_remote_surface_region_destroy(Resource *resource); - virtual void tizen_remote_surface_region_set_geometry(Resource *resource, int32_t x, int32_t y, int32_t w, int32_t h); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_remote_surface_region_interface m_tizen_remote_surface_region_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t w, - int32_t h); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_remote_surface_region *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-surface.cpp b/src/DSWaylandServer/dswayland-server-tizen-surface.cpp deleted file mode 100644 index d902887..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-surface.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-surface.xml */ - -#include "dswayland-server-tizen-surface.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - tizen_surface_shm::tizen_surface_shm(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_surface_shm::tizen_surface_shm(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_surface_shm::tizen_surface_shm(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_surface_shm::tizen_surface_shm() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_surface_shm::~tizen_surface_shm() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_surface_shm::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_surface_shm::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_surface_shm::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_surface_shm::Resource *tizen_surface_shm::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_surface_shm::Resource *tizen_surface_shm::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_surface_shm::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_surface_shm_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_surface_shm::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_surface_shm::interface() - { - return &::tizen_surface_shm_interface; - } - - tizen_surface_shm::Resource *tizen_surface_shm::tizen_surface_shm_allocate() - { - return new Resource; - } - - void tizen_surface_shm::tizen_surface_shm_bind_resource(Resource *) - { - } - - void tizen_surface_shm::tizen_surface_shm_destroy_resource(Resource *) - { - } - - void tizen_surface_shm::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_surface_shm *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_surface_shm::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_surface_shm *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_surface_shm::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_surface_shm *that = resource->tizen_surface_shm_object; - that->m_resource_map.erase(resource->client()); - that->tizen_surface_shm_destroy_resource(resource); - delete resource; - } - - tizen_surface_shm::Resource *tizen_surface_shm::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_surface_shm_interface, version, id); - return bind(handle); - } - - tizen_surface_shm::Resource *tizen_surface_shm::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_surface_shm_allocate(); - resource->tizen_surface_shm_object = this; - - wl_resource_set_implementation(handle, &m_tizen_surface_shm_interface, resource, destroy_func); - resource->handle = handle; - tizen_surface_shm_bind_resource(resource); - return resource; - } - tizen_surface_shm::Resource *tizen_surface_shm::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_surface_shm_interface, &m_tizen_surface_shm_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_surface_shm_interface tizen_surface_shm::m_tizen_surface_shm_interface = { - tizen_surface_shm::handle_get_flusher, - tizen_surface_shm::handle_destroy - }; - - void tizen_surface_shm::tizen_surface_shm_get_flusher(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void tizen_surface_shm::tizen_surface_shm_destroy(Resource *) - { - } - - - void tizen_surface_shm::handle_get_flusher( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_surface_shm_object)->tizen_surface_shm_get_flusher( - r, - id, - surface); - } - - void tizen_surface_shm::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_surface_shm_object)->tizen_surface_shm_destroy( - r); - } - - tizen_surface_shm_flusher::tizen_surface_shm_flusher(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_surface_shm_flusher::tizen_surface_shm_flusher(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_surface_shm_flusher::tizen_surface_shm_flusher(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_surface_shm_flusher::tizen_surface_shm_flusher() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_surface_shm_flusher::~tizen_surface_shm_flusher() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_surface_shm_flusher::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_surface_shm_flusher::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_surface_shm_flusher::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_surface_shm_flusher::Resource *tizen_surface_shm_flusher::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_surface_shm_flusher::Resource *tizen_surface_shm_flusher::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_surface_shm_flusher::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_surface_shm_flusher_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_surface_shm_flusher::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_surface_shm_flusher::interface() - { - return &::tizen_surface_shm_flusher_interface; - } - - tizen_surface_shm_flusher::Resource *tizen_surface_shm_flusher::tizen_surface_shm_flusher_allocate() - { - return new Resource; - } - - void tizen_surface_shm_flusher::tizen_surface_shm_flusher_bind_resource(Resource *) - { - } - - void tizen_surface_shm_flusher::tizen_surface_shm_flusher_destroy_resource(Resource *) - { - } - - void tizen_surface_shm_flusher::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_surface_shm_flusher *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_surface_shm_flusher::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_surface_shm_flusher *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_surface_shm_flusher::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_surface_shm_flusher *that = resource->tizen_surface_shm_flusher_object; - that->m_resource_map.erase(resource->client()); - that->tizen_surface_shm_flusher_destroy_resource(resource); - delete resource; - } - - tizen_surface_shm_flusher::Resource *tizen_surface_shm_flusher::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_surface_shm_flusher_interface, version, id); - return bind(handle); - } - - tizen_surface_shm_flusher::Resource *tizen_surface_shm_flusher::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_surface_shm_flusher_allocate(); - resource->tizen_surface_shm_flusher_object = this; - - wl_resource_set_implementation(handle, &m_tizen_surface_shm_flusher_interface, resource, destroy_func); - resource->handle = handle; - tizen_surface_shm_flusher_bind_resource(resource); - return resource; - } - tizen_surface_shm_flusher::Resource *tizen_surface_shm_flusher::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_surface_shm_flusher_interface, &m_tizen_surface_shm_flusher_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_surface_shm_flusher_interface tizen_surface_shm_flusher::m_tizen_surface_shm_flusher_interface = { - tizen_surface_shm_flusher::handle_destroy - }; - - void tizen_surface_shm_flusher::tizen_surface_shm_flusher_destroy(Resource *) - { - } - - - void tizen_surface_shm_flusher::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_surface_shm_flusher_object)->tizen_surface_shm_flusher_destroy( - r); - } - - void tizen_surface_shm_flusher::send_flush() - { - DS_ASSERT_X(m_resource, "tizen_surface_shm_flusher::flush", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_surface_shm_flusher::flush as it's not initialised"); - return; - } - send_flush( - m_resource->handle); - } - - void tizen_surface_shm_flusher::send_flush(struct ::wl_resource *resource) - { - tizen_surface_shm_flusher_send_flush( - resource); - } - - - void tizen_surface_shm_flusher::send_free_flush() - { - DS_ASSERT_X(m_resource, "tizen_surface_shm_flusher::free_flush", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_surface_shm_flusher::free_flush as it's not initialised"); - return; - } - send_free_flush( - m_resource->handle); - } - - void tizen_surface_shm_flusher::send_free_flush(struct ::wl_resource *resource) - { - tizen_surface_shm_flusher_send_free_flush( - resource); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tizen-surface.h b/src/DSWaylandServer/dswayland-server-tizen-surface.h deleted file mode 100644 index a1bc627..0000000 --- a/src/DSWaylandServer/dswayland-server-tizen-surface.h +++ /dev/null @@ -1,199 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tizen-surface.xml */ - -#ifndef __DS_TIZEN_SURFACE_PROTOCOL_H__ -#define __DS_TIZEN_SURFACE_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "tizen-surface-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class tizen_surface_shm - { - public: - tizen_surface_shm(struct ::wl_client *client, uint32_t id, int version); - tizen_surface_shm(struct ::wl_display *display, int version); - tizen_surface_shm(struct ::wl_resource *resource); - tizen_surface_shm(); - - virtual ~tizen_surface_shm(); - - class Resource - { - public: - Resource() : tizen_surface_shm_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_surface_shm *tizen_surface_shm_object; - tizen_surface_shm *object() { return tizen_surface_shm_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tizen_surface_shm_allocate(); - - virtual void tizen_surface_shm_bind_resource(Resource *resource); - virtual void tizen_surface_shm_destroy_resource(Resource *resource); - - virtual void tizen_surface_shm_get_flusher(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void tizen_surface_shm_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_surface_shm_interface m_tizen_surface_shm_interface; - - static void handle_get_flusher( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_surface_shm *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tizen_surface_shm_flusher - { - public: - tizen_surface_shm_flusher(struct ::wl_client *client, uint32_t id, int version); - tizen_surface_shm_flusher(struct ::wl_display *display, int version); - tizen_surface_shm_flusher(struct ::wl_resource *resource); - tizen_surface_shm_flusher(); - - virtual ~tizen_surface_shm_flusher(); - - class Resource - { - public: - Resource() : tizen_surface_shm_flusher_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_surface_shm_flusher *tizen_surface_shm_flusher_object; - tizen_surface_shm_flusher *object() { return tizen_surface_shm_flusher_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_flush(); - void send_flush(struct ::wl_resource *resource); - void send_free_flush(); - void send_free_flush(struct ::wl_resource *resource); - - protected: - virtual Resource *tizen_surface_shm_flusher_allocate(); - - virtual void tizen_surface_shm_flusher_bind_resource(Resource *resource); - virtual void tizen_surface_shm_flusher_destroy_resource(Resource *resource); - - virtual void tizen_surface_shm_flusher_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_surface_shm_flusher_interface m_tizen_surface_shm_flusher_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_surface_shm_flusher *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-transform.cpp b/src/DSWaylandServer/dswayland-server-transform.cpp deleted file mode 100644 index 0964ba6..0000000 --- a/src/DSWaylandServer/dswayland-server-transform.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/transform.xml */ - -#include "dswayland-server-transform.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - wl_transform::wl_transform(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_transform::wl_transform(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_transform::wl_transform(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_transform::wl_transform() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_transform::~wl_transform() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_transform::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_transform::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_transform::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_transform::Resource *wl_transform::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_transform::Resource *wl_transform::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_transform::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_transform_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_transform::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_transform::interface() - { - return &::wl_transform_interface; - } - - wl_transform::Resource *wl_transform::transform_allocate() - { - return new Resource; - } - - void wl_transform::transform_bind_resource(Resource *) - { - } - - void wl_transform::transform_destroy_resource(Resource *) - { - } - - void wl_transform::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_transform *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_transform::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_transform *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_transform::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_transform *that = resource->transform_object; - that->m_resource_map.erase(resource->client()); - that->transform_destroy_resource(resource); - delete resource; - } - - wl_transform::Resource *wl_transform::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_transform_interface, version, id); - return bind(handle); - } - - wl_transform::Resource *wl_transform::bind(struct ::wl_resource *handle) - { - Resource *resource = transform_allocate(); - resource->transform_object = this; - - wl_resource_set_implementation(handle, &m_wl_transform_interface, resource, destroy_func); - resource->handle = handle; - transform_bind_resource(resource); - return resource; - } - wl_transform::Resource *wl_transform::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_transform_interface, &m_wl_transform_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_transform_interface wl_transform::m_wl_transform_interface = { - wl_transform::handle_destroy, - wl_transform::handle_get_rotator - }; - - void wl_transform::transform_destroy(Resource *) - { - } - - void wl_transform::transform_get_rotator(Resource *, uint32_t, struct ::wl_resource *) - { - } - - - void wl_transform::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->transform_object)->transform_destroy( - r); - } - - void wl_transform::handle_get_rotator( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->transform_object)->transform_get_rotator( - r, - id, - surface); - } - - wl_rotator::wl_rotator(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_rotator::wl_rotator(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_rotator::wl_rotator(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_rotator::wl_rotator() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_rotator::~wl_rotator() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_rotator::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_rotator::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_rotator::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_rotator::Resource *wl_rotator::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_rotator::Resource *wl_rotator::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_rotator::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_rotator_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_rotator::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_rotator::interface() - { - return &::wl_rotator_interface; - } - - wl_rotator::Resource *wl_rotator::rotator_allocate() - { - return new Resource; - } - - void wl_rotator::rotator_bind_resource(Resource *) - { - } - - void wl_rotator::rotator_destroy_resource(Resource *) - { - } - - void wl_rotator::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_rotator *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_rotator::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_rotator *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_rotator::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_rotator *that = resource->rotator_object; - that->m_resource_map.erase(resource->client()); - that->rotator_destroy_resource(resource); - delete resource; - } - - wl_rotator::Resource *wl_rotator::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_rotator_interface, version, id); - return bind(handle); - } - - wl_rotator::Resource *wl_rotator::bind(struct ::wl_resource *handle) - { - Resource *resource = rotator_allocate(); - resource->rotator_object = this; - - wl_resource_set_implementation(handle, &m_wl_rotator_interface, resource, destroy_func); - resource->handle = handle; - rotator_bind_resource(resource); - return resource; - } - wl_rotator::Resource *wl_rotator::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_rotator_interface, &m_wl_rotator_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_rotator_interface wl_rotator::m_wl_rotator_interface = { - wl_rotator::handle_destroy, - wl_rotator::handle_set, - wl_rotator::handle_unset - }; - - void wl_rotator::rotator_destroy(Resource *) - { - } - - void wl_rotator::rotator_set(Resource *) - { - } - - void wl_rotator::rotator_unset(Resource *) - { - } - - - void wl_rotator::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->rotator_object)->rotator_destroy( - r); - } - - void wl_rotator::handle_set( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->rotator_object)->rotator_set( - r); - } - - void wl_rotator::handle_unset( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->rotator_object)->rotator_unset( - r); - } -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-transform.h b/src/DSWaylandServer/dswayland-server-transform.h deleted file mode 100644 index 3996463..0000000 --- a/src/DSWaylandServer/dswayland-server-transform.h +++ /dev/null @@ -1,206 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/transform.xml */ - -#ifndef __DS_TRANSFORM_PROTOCOL_H__ -#define __DS_TRANSFORM_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "transform-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class wl_transform - { - public: - wl_transform(struct ::wl_client *client, uint32_t id, int version); - wl_transform(struct ::wl_display *display, int version); - wl_transform(struct ::wl_resource *resource); - wl_transform(); - - virtual ~wl_transform(); - - class Resource - { - public: - Resource() : transform_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_transform *transform_object; - wl_transform *object() { return transform_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *transform_allocate(); - - virtual void transform_bind_resource(Resource *resource); - virtual void transform_destroy_resource(Resource *resource); - - virtual void transform_destroy(Resource *resource); - virtual void transform_get_rotator(Resource *resource, uint32_t id, struct ::wl_resource *surface); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_transform_interface m_wl_transform_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_get_rotator( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_transform *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_rotator - { - public: - wl_rotator(struct ::wl_client *client, uint32_t id, int version); - wl_rotator(struct ::wl_display *display, int version); - wl_rotator(struct ::wl_resource *resource); - wl_rotator(); - - virtual ~wl_rotator(); - - class Resource - { - public: - Resource() : rotator_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_rotator *rotator_object; - wl_rotator *object() { return rotator_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_bad_value = 0, // negative or zero values in width or height - }; - - protected: - virtual Resource *rotator_allocate(); - - virtual void rotator_bind_resource(Resource *resource); - virtual void rotator_destroy_resource(Resource *resource); - - virtual void rotator_destroy(Resource *resource); - virtual void rotator_set(Resource *resource); - virtual void rotator_unset(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_rotator_interface m_wl_rotator_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unset( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_rotator *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tzsh.cpp b/src/DSWaylandServer/dswayland-server-tzsh.cpp deleted file mode 100644 index d6b1d66..0000000 --- a/src/DSWaylandServer/dswayland-server-tzsh.cpp +++ /dev/null @@ -1,3852 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tzsh.xml */ - -#include "dswayland-server-tizen-ws-shell.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - tizen_ws_shell::tizen_ws_shell(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tizen_ws_shell::tizen_ws_shell(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tizen_ws_shell::tizen_ws_shell(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tizen_ws_shell::tizen_ws_shell() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tizen_ws_shell::~tizen_ws_shell() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tizen_ws_shell::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tizen_ws_shell::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tizen_ws_shell::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tizen_ws_shell::Resource *tizen_ws_shell::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tizen_ws_shell::Resource *tizen_ws_shell::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tizen_ws_shell::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tizen_ws_shell_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tizen_ws_shell::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tizen_ws_shell::interface() - { - return &::tizen_ws_shell_interface; - } - - tizen_ws_shell::Resource *tizen_ws_shell::tizen_ws_shell_allocate() - { - return new Resource; - } - - void tizen_ws_shell::tizen_ws_shell_bind_resource(Resource *) - { - } - - void tizen_ws_shell::tizen_ws_shell_destroy_resource(Resource *) - { - } - - void tizen_ws_shell::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tizen_ws_shell *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tizen_ws_shell::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tizen_ws_shell *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tizen_ws_shell::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tizen_ws_shell *that = resource->tizen_ws_shell_object; - that->m_resource_map.erase(resource->client()); - that->tizen_ws_shell_destroy_resource(resource); - delete resource; - } - - tizen_ws_shell::Resource *tizen_ws_shell::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tizen_ws_shell_interface, version, id); - return bind(handle); - } - - tizen_ws_shell::Resource *tizen_ws_shell::bind(struct ::wl_resource *handle) - { - Resource *resource = tizen_ws_shell_allocate(); - resource->tizen_ws_shell_object = this; - - wl_resource_set_implementation(handle, &m_tizen_ws_shell_interface, resource, destroy_func); - resource->handle = handle; - tizen_ws_shell_bind_resource(resource); - return resource; - } - tizen_ws_shell::Resource *tizen_ws_shell::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tizen_ws_shell_interface, &m_tizen_ws_shell_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tizen_ws_shell_interface tizen_ws_shell::m_tizen_ws_shell_interface = { - tizen_ws_shell::handle_destroy, - tizen_ws_shell::handle_service_create, - tizen_ws_shell::handle_region_create, - tizen_ws_shell::handle_quickpanel_get, - tizen_ws_shell::handle_extension_get, - tizen_ws_shell::handle_softkey_get, - tizen_ws_shell::handle_shared_widget_launch_get - }; - - void tizen_ws_shell::tizen_ws_shell_destroy(Resource *) - { - } - - void tizen_ws_shell::tizen_ws_shell_service_create(Resource *, uint32_t, uint32_t , const std::string &) - { - } - - void tizen_ws_shell::tizen_ws_shell_region_create(Resource *, uint32_t) - { - } - - void tizen_ws_shell::tizen_ws_shell_quickpanel_get(Resource *, uint32_t, uint32_t ) - { - } - - void tizen_ws_shell::tizen_ws_shell_extension_get(Resource *, uint32_t, const std::string &) - { - } - - void tizen_ws_shell::tizen_ws_shell_softkey_get(Resource *, uint32_t, uint32_t ) - { - } - - void tizen_ws_shell::tizen_ws_shell_shared_widget_launch_get(Resource *, uint32_t, uint32_t ) - { - } - - - void tizen_ws_shell::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_destroy( - r); - } - - void tizen_ws_shell::handle_service_create( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win, - const char *name) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_service_create( - r, - id, - win, - std::string(name)); - } - - void tizen_ws_shell::handle_region_create( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_region_create( - r, - id); - } - - void tizen_ws_shell::handle_quickpanel_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_quickpanel_get( - r, - id, - win); - } - - void tizen_ws_shell::handle_extension_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - const char *name) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_extension_get( - r, - id, - std::string(name)); - } - - void tizen_ws_shell::handle_softkey_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_softkey_get( - r, - id, - win); - } - - void tizen_ws_shell::handle_shared_widget_launch_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tizen_ws_shell_object)->tizen_ws_shell_shared_widget_launch_get( - r, - id, - win); - } - - void tizen_ws_shell::send_service_register(const std::string &name) - { - DS_ASSERT_X(m_resource, "tizen_ws_shell::service_register", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_ws_shell::service_register as it's not initialised"); - return; - } - send_service_register( - m_resource->handle, - name); - } - - void tizen_ws_shell::send_service_register(struct ::wl_resource *resource, const std::string &name) - { - tizen_ws_shell_send_service_register( - resource, - name.c_str()); - } - - - void tizen_ws_shell::send_service_unregister(const std::string &name) - { - DS_ASSERT_X(m_resource, "tizen_ws_shell::service_unregister", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_ws_shell::service_unregister as it's not initialised"); - return; - } - send_service_unregister( - m_resource->handle, - name); - } - - void tizen_ws_shell::send_service_unregister(struct ::wl_resource *resource, const std::string &name) - { - tizen_ws_shell_send_service_unregister( - resource, - name.c_str()); - } - - - void tizen_ws_shell::send_error(uint32_t error_state) - { - DS_ASSERT_X(m_resource, "tizen_ws_shell::error", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tizen_ws_shell::error as it's not initialised"); - return; - } - send_error( - m_resource->handle, - error_state); - } - - void tizen_ws_shell::send_error(struct ::wl_resource *resource, uint32_t error_state) - { - tizen_ws_shell_send_error( - resource, - error_state); - } - - - tws_quickpanel::tws_quickpanel(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_quickpanel::tws_quickpanel(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_quickpanel::tws_quickpanel(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_quickpanel::tws_quickpanel() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_quickpanel::~tws_quickpanel() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_quickpanel::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_quickpanel::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_quickpanel::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_quickpanel::Resource *tws_quickpanel::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_quickpanel::Resource *tws_quickpanel::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_quickpanel::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_quickpanel_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_quickpanel::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_quickpanel::interface() - { - return &::tws_quickpanel_interface; - } - - tws_quickpanel::Resource *tws_quickpanel::tws_quickpanel_allocate() - { - return new Resource; - } - - void tws_quickpanel::tws_quickpanel_bind_resource(Resource *) - { - } - - void tws_quickpanel::tws_quickpanel_destroy_resource(Resource *) - { - } - - void tws_quickpanel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_quickpanel *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_quickpanel::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_quickpanel *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_quickpanel::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_quickpanel *that = resource->tws_quickpanel_object; - that->m_resource_map.erase(resource->client()); - that->tws_quickpanel_destroy_resource(resource); - delete resource; - } - - tws_quickpanel::Resource *tws_quickpanel::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_quickpanel_interface, version, id); - return bind(handle); - } - - tws_quickpanel::Resource *tws_quickpanel::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_quickpanel_allocate(); - resource->tws_quickpanel_object = this; - - wl_resource_set_implementation(handle, &m_tws_quickpanel_interface, resource, destroy_func); - resource->handle = handle; - tws_quickpanel_bind_resource(resource); - return resource; - } - tws_quickpanel::Resource *tws_quickpanel::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_quickpanel_interface, &m_tws_quickpanel_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_quickpanel_interface tws_quickpanel::m_tws_quickpanel_interface = { - tws_quickpanel::handle_release, - tws_quickpanel::handle_show, - tws_quickpanel::handle_hide, - tws_quickpanel::handle_enable, - tws_quickpanel::handle_disable, - tws_quickpanel::handle_state_get, - tws_quickpanel::handle_type_set, - tws_quickpanel::handle_scrollable_state_set - }; - - void tws_quickpanel::tws_quickpanel_release(Resource *) - { - } - - void tws_quickpanel::tws_quickpanel_show(Resource *) - { - } - - void tws_quickpanel::tws_quickpanel_hide(Resource *) - { - } - - void tws_quickpanel::tws_quickpanel_enable(Resource *) - { - } - - void tws_quickpanel::tws_quickpanel_disable(Resource *) - { - } - - void tws_quickpanel::tws_quickpanel_state_get(Resource *, int32_t ) - { - } - - void tws_quickpanel::tws_quickpanel_type_set(Resource *, uint32_t ) - { - } - - void tws_quickpanel::tws_quickpanel_scrollable_state_set(Resource *, int32_t ) - { - } - - - void tws_quickpanel::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_quickpanel_object)->tws_quickpanel_release( - r); - } - - void tws_quickpanel::handle_show( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_quickpanel_object)->tws_quickpanel_show( - r); - } - - void tws_quickpanel::handle_hide( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_quickpanel_object)->tws_quickpanel_hide( - r); - } - - void tws_quickpanel::handle_enable( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_quickpanel_object)->tws_quickpanel_enable( - r); - } - - void tws_quickpanel::handle_disable( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_quickpanel_object)->tws_quickpanel_disable( - r); - } - - void tws_quickpanel::handle_state_get( - ::wl_client *client, - struct wl_resource *resource, - int32_t type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_quickpanel_object)->tws_quickpanel_state_get( - r, - type); - } - - void tws_quickpanel::handle_type_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_quickpanel_object)->tws_quickpanel_type_set( - r, - type); - } - - void tws_quickpanel::handle_scrollable_state_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_quickpanel_object)->tws_quickpanel_scrollable_state_set( - r, - type); - } - - void tws_quickpanel::send_state_get_done(int32_t type, int32_t value, uint32_t error_state) - { - DS_ASSERT_X(m_resource, "tws_quickpanel::state_get_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_quickpanel::state_get_done as it's not initialised"); - return; - } - send_state_get_done( - m_resource->handle, - type, - value, - error_state); - } - - void tws_quickpanel::send_state_get_done(struct ::wl_resource *resource, int32_t type, int32_t value, uint32_t error_state) - { - tws_quickpanel_send_state_get_done( - resource, - type, - value, - error_state); - } - - - void tws_quickpanel::send_state_changed(struct ::wl_array *states) - { - DS_ASSERT_X(m_resource, "tws_quickpanel::state_changed", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_quickpanel::state_changed as it's not initialised"); - return; - } - send_state_changed( - m_resource->handle, - states); - } - - void tws_quickpanel::send_state_changed(struct ::wl_resource *resource, struct ::wl_array *states) - { - tws_quickpanel_send_state_changed( - resource, - states); - } - - - tws_region::tws_region(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_region::tws_region(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_region::tws_region(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_region::tws_region() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_region::~tws_region() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_region::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_region::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_region::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_region::Resource *tws_region::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_region::Resource *tws_region::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_region::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_region_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_region::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_region::interface() - { - return &::tws_region_interface; - } - - tws_region::Resource *tws_region::tws_region_allocate() - { - return new Resource; - } - - void tws_region::tws_region_bind_resource(Resource *) - { - } - - void tws_region::tws_region_destroy_resource(Resource *) - { - } - - void tws_region::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_region *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_region::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_region *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_region::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_region *that = resource->tws_region_object; - that->m_resource_map.erase(resource->client()); - that->tws_region_destroy_resource(resource); - delete resource; - } - - tws_region::Resource *tws_region::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_region_interface, version, id); - return bind(handle); - } - - tws_region::Resource *tws_region::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_region_allocate(); - resource->tws_region_object = this; - - wl_resource_set_implementation(handle, &m_tws_region_interface, resource, destroy_func); - resource->handle = handle; - tws_region_bind_resource(resource); - return resource; - } - tws_region::Resource *tws_region::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_region_interface, &m_tws_region_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_region_interface tws_region::m_tws_region_interface = { - tws_region::handle_destroy, - tws_region::handle_add, - tws_region::handle_subtract - }; - - void tws_region::tws_region_destroy(Resource *) - { - } - - void tws_region::tws_region_add(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void tws_region::tws_region_subtract(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - - void tws_region::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_region_object)->tws_region_destroy( - r); - } - - void tws_region::handle_add( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t w, - int32_t h) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_region_object)->tws_region_add( - r, - x, - y, - w, - h); - } - - void tws_region::handle_subtract( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t w, - int32_t h) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_region_object)->tws_region_subtract( - r, - x, - y, - w, - h); - } - - tws_service::tws_service(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service::tws_service(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service::tws_service(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service::tws_service() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service::~tws_service() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service::Resource *tws_service::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service::Resource *tws_service::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service::interface() - { - return &::tws_service_interface; - } - - tws_service::Resource *tws_service::tws_service_allocate() - { - return new Resource; - } - - void tws_service::tws_service_bind_resource(Resource *) - { - } - - void tws_service::tws_service_destroy_resource(Resource *) - { - } - - void tws_service::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service *that = resource->tws_service_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_destroy_resource(resource); - delete resource; - } - - tws_service::Resource *tws_service::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_interface, version, id); - return bind(handle); - } - - tws_service::Resource *tws_service::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_allocate(); - resource->tws_service_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_interface, resource, destroy_func); - resource->handle = handle; - tws_service_bind_resource(resource); - return resource; - } - tws_service::Resource *tws_service::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_interface, &m_tws_service_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_interface tws_service::m_tws_service_interface = { - tws_service::handle_destroy, - tws_service::handle_region_set, - tws_service::handle_indicator_get, - tws_service::handle_quickpanel_get, - tws_service::handle_screensaver_manager_get, - tws_service::handle_screensaver_get, - tws_service::handle_cbhm_get, - tws_service::handle_softkey_get, - tws_service::handle_magnifier_get, - tws_service::handle_launcher_get - }; - - void tws_service::tws_service_destroy(Resource *) - { - } - - void tws_service::tws_service_region_set(Resource *, int32_t , int32_t , struct ::wl_resource *) - { - } - - void tws_service::tws_service_indicator_get(Resource *, uint32_t) - { - } - - void tws_service::tws_service_quickpanel_get(Resource *, uint32_t) - { - } - - void tws_service::tws_service_screensaver_manager_get(Resource *, uint32_t) - { - } - - void tws_service::tws_service_screensaver_get(Resource *, uint32_t) - { - } - - void tws_service::tws_service_cbhm_get(Resource *, uint32_t) - { - } - - void tws_service::tws_service_softkey_get(Resource *, uint32_t) - { - } - - void tws_service::tws_service_magnifier_get(Resource *, uint32_t) - { - } - - void tws_service::tws_service_launcher_get(Resource *, uint32_t) - { - } - - - void tws_service::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_destroy( - r); - } - - void tws_service::handle_region_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t type, - int32_t angle, - struct ::wl_resource *region) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_region_set( - r, - type, - angle, - region); - } - - void tws_service::handle_indicator_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_indicator_get( - r, - id); - } - - void tws_service::handle_quickpanel_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_quickpanel_get( - r, - id); - } - - void tws_service::handle_screensaver_manager_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_screensaver_manager_get( - r, - id); - } - - void tws_service::handle_screensaver_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_screensaver_get( - r, - id); - } - - void tws_service::handle_cbhm_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_cbhm_get( - r, - id); - } - - void tws_service::handle_softkey_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_softkey_get( - r, - id); - } - - void tws_service::handle_magnifier_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_magnifier_get( - r, - id); - } - - void tws_service::handle_launcher_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_object)->tws_service_launcher_get( - r, - id); - } - - tws_service_indicator::tws_service_indicator(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service_indicator::tws_service_indicator(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service_indicator::tws_service_indicator(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service_indicator::tws_service_indicator() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service_indicator::~tws_service_indicator() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service_indicator::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service_indicator::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service_indicator::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service_indicator::Resource *tws_service_indicator::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service_indicator::Resource *tws_service_indicator::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service_indicator::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_indicator_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service_indicator::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service_indicator::interface() - { - return &::tws_service_indicator_interface; - } - - tws_service_indicator::Resource *tws_service_indicator::tws_service_indicator_allocate() - { - return new Resource; - } - - void tws_service_indicator::tws_service_indicator_bind_resource(Resource *) - { - } - - void tws_service_indicator::tws_service_indicator_destroy_resource(Resource *) - { - } - - void tws_service_indicator::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service_indicator *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service_indicator::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service_indicator *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service_indicator::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service_indicator *that = resource->tws_service_indicator_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_indicator_destroy_resource(resource); - delete resource; - } - - tws_service_indicator::Resource *tws_service_indicator::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_indicator_interface, version, id); - return bind(handle); - } - - tws_service_indicator::Resource *tws_service_indicator::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_indicator_allocate(); - resource->tws_service_indicator_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_indicator_interface, resource, destroy_func); - resource->handle = handle; - tws_service_indicator_bind_resource(resource); - return resource; - } - tws_service_indicator::Resource *tws_service_indicator::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_indicator_interface, &m_tws_service_indicator_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_indicator_interface tws_service_indicator::m_tws_service_indicator_interface = { - tws_service_indicator::handle_destroy - }; - - void tws_service_indicator::tws_service_indicator_destroy(Resource *) - { - } - - - void tws_service_indicator::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_indicator_object)->tws_service_indicator_destroy( - r); - } - - void tws_service_indicator::send_property_change(int32_t angle, int32_t opacity) - { - DS_ASSERT_X(m_resource, "tws_service_indicator::property_change", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_indicator::property_change as it's not initialised"); - return; - } - send_property_change( - m_resource->handle, - angle, - opacity); - } - - void tws_service_indicator::send_property_change(struct ::wl_resource *resource, int32_t angle, int32_t opacity) - { - tws_service_indicator_send_property_change( - resource, - angle, - opacity); - } - - - tws_service_quickpanel::tws_service_quickpanel(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service_quickpanel::tws_service_quickpanel(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service_quickpanel::tws_service_quickpanel(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service_quickpanel::tws_service_quickpanel() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service_quickpanel::~tws_service_quickpanel() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service_quickpanel::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service_quickpanel::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service_quickpanel::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service_quickpanel::Resource *tws_service_quickpanel::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service_quickpanel::Resource *tws_service_quickpanel::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service_quickpanel::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_quickpanel_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service_quickpanel::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service_quickpanel::interface() - { - return &::tws_service_quickpanel_interface; - } - - tws_service_quickpanel::Resource *tws_service_quickpanel::tws_service_quickpanel_allocate() - { - return new Resource; - } - - void tws_service_quickpanel::tws_service_quickpanel_bind_resource(Resource *) - { - } - - void tws_service_quickpanel::tws_service_quickpanel_destroy_resource(Resource *) - { - } - - void tws_service_quickpanel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service_quickpanel *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service_quickpanel::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service_quickpanel *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service_quickpanel::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service_quickpanel *that = resource->tws_service_quickpanel_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_quickpanel_destroy_resource(resource); - delete resource; - } - - tws_service_quickpanel::Resource *tws_service_quickpanel::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_quickpanel_interface, version, id); - return bind(handle); - } - - tws_service_quickpanel::Resource *tws_service_quickpanel::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_quickpanel_allocate(); - resource->tws_service_quickpanel_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_quickpanel_interface, resource, destroy_func); - resource->handle = handle; - tws_service_quickpanel_bind_resource(resource); - return resource; - } - tws_service_quickpanel::Resource *tws_service_quickpanel::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_quickpanel_interface, &m_tws_service_quickpanel_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_quickpanel_interface tws_service_quickpanel::m_tws_service_quickpanel_interface = { - tws_service_quickpanel::handle_destroy, - tws_service_quickpanel::handle_msg_send, - tws_service_quickpanel::handle_effect_type_set, - tws_service_quickpanel::handle_scroll_lock_set - }; - - void tws_service_quickpanel::tws_service_quickpanel_destroy(Resource *) - { - } - - void tws_service_quickpanel::tws_service_quickpanel_msg_send(Resource *, uint32_t ) - { - } - - void tws_service_quickpanel::tws_service_quickpanel_effect_type_set(Resource *, uint32_t ) - { - } - - void tws_service_quickpanel::tws_service_quickpanel_scroll_lock_set(Resource *, uint32_t ) - { - } - - - void tws_service_quickpanel::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_quickpanel_object)->tws_service_quickpanel_destroy( - r); - } - - void tws_service_quickpanel::handle_msg_send( - ::wl_client *client, - struct wl_resource *resource, - uint32_t msg) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_quickpanel_object)->tws_service_quickpanel_msg_send( - r, - msg); - } - - void tws_service_quickpanel::handle_effect_type_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_quickpanel_object)->tws_service_quickpanel_effect_type_set( - r, - type); - } - - void tws_service_quickpanel::handle_scroll_lock_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t lock) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_quickpanel_object)->tws_service_quickpanel_scroll_lock_set( - r, - lock); - } - - tws_service_screensaver_manager::tws_service_screensaver_manager(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service_screensaver_manager::tws_service_screensaver_manager(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service_screensaver_manager::tws_service_screensaver_manager(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service_screensaver_manager::tws_service_screensaver_manager() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service_screensaver_manager::~tws_service_screensaver_manager() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service_screensaver_manager::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service_screensaver_manager::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service_screensaver_manager::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service_screensaver_manager::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_screensaver_manager_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service_screensaver_manager::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service_screensaver_manager::interface() - { - return &::tws_service_screensaver_manager_interface; - } - - tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::tws_service_screensaver_manager_allocate() - { - return new Resource; - } - - void tws_service_screensaver_manager::tws_service_screensaver_manager_bind_resource(Resource *) - { - } - - void tws_service_screensaver_manager::tws_service_screensaver_manager_destroy_resource(Resource *) - { - } - - void tws_service_screensaver_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service_screensaver_manager *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service_screensaver_manager::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service_screensaver_manager *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service_screensaver_manager::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service_screensaver_manager *that = resource->tws_service_screensaver_manager_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_screensaver_manager_destroy_resource(resource); - delete resource; - } - - tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_screensaver_manager_interface, version, id); - return bind(handle); - } - - tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_screensaver_manager_allocate(); - resource->tws_service_screensaver_manager_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_screensaver_manager_interface, resource, destroy_func); - resource->handle = handle; - tws_service_screensaver_manager_bind_resource(resource); - return resource; - } - tws_service_screensaver_manager::Resource *tws_service_screensaver_manager::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_screensaver_manager_interface, &m_tws_service_screensaver_manager_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_screensaver_manager_interface tws_service_screensaver_manager::m_tws_service_screensaver_manager_interface = { - tws_service_screensaver_manager::handle_destroy, - tws_service_screensaver_manager::handle_enable, - tws_service_screensaver_manager::handle_disable, - tws_service_screensaver_manager::handle_idle_time_set, - tws_service_screensaver_manager::handle_state_get - }; - - void tws_service_screensaver_manager::tws_service_screensaver_manager_destroy(Resource *) - { - } - - void tws_service_screensaver_manager::tws_service_screensaver_manager_enable(Resource *) - { - } - - void tws_service_screensaver_manager::tws_service_screensaver_manager_disable(Resource *) - { - } - - void tws_service_screensaver_manager::tws_service_screensaver_manager_idle_time_set(Resource *, uint32_t ) - { - } - - void tws_service_screensaver_manager::tws_service_screensaver_manager_state_get(Resource *, uint32_t ) - { - } - - - void tws_service_screensaver_manager::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_destroy( - r); - } - - void tws_service_screensaver_manager::handle_enable( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_enable( - r); - } - - void tws_service_screensaver_manager::handle_disable( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_disable( - r); - } - - void tws_service_screensaver_manager::handle_idle_time_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_idle_time_set( - r, - id); - } - - void tws_service_screensaver_manager::handle_state_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state_type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_screensaver_manager_object)->tws_service_screensaver_manager_state_get( - r, - state_type); - } - - void tws_service_screensaver_manager::send_idle() - { - DS_ASSERT_X(m_resource, "tws_service_screensaver_manager::idle", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_screensaver_manager::idle as it's not initialised"); - return; - } - send_idle( - m_resource->handle); - } - - void tws_service_screensaver_manager::send_idle(struct ::wl_resource *resource) - { - tws_service_screensaver_manager_send_idle( - resource); - } - - - void tws_service_screensaver_manager::send_active() - { - DS_ASSERT_X(m_resource, "tws_service_screensaver_manager::active", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_screensaver_manager::active as it's not initialised"); - return; - } - send_active( - m_resource->handle); - } - - void tws_service_screensaver_manager::send_active(struct ::wl_resource *resource) - { - tws_service_screensaver_manager_send_active( - resource); - } - - - void tws_service_screensaver_manager::send_state_get_done(uint32_t state_type, uint32_t value, uint32_t error_state) - { - DS_ASSERT_X(m_resource, "tws_service_screensaver_manager::state_get_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_screensaver_manager::state_get_done as it's not initialised"); - return; - } - send_state_get_done( - m_resource->handle, - state_type, - value, - error_state); - } - - void tws_service_screensaver_manager::send_state_get_done(struct ::wl_resource *resource, uint32_t state_type, uint32_t value, uint32_t error_state) - { - tws_service_screensaver_manager_send_state_get_done( - resource, - state_type, - value, - error_state); - } - - - tws_service_screensaver::tws_service_screensaver(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service_screensaver::tws_service_screensaver(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service_screensaver::tws_service_screensaver(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service_screensaver::tws_service_screensaver() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service_screensaver::~tws_service_screensaver() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service_screensaver::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service_screensaver::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service_screensaver::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service_screensaver::Resource *tws_service_screensaver::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service_screensaver::Resource *tws_service_screensaver::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service_screensaver::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_screensaver_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service_screensaver::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service_screensaver::interface() - { - return &::tws_service_screensaver_interface; - } - - tws_service_screensaver::Resource *tws_service_screensaver::tws_service_screensaver_allocate() - { - return new Resource; - } - - void tws_service_screensaver::tws_service_screensaver_bind_resource(Resource *) - { - } - - void tws_service_screensaver::tws_service_screensaver_destroy_resource(Resource *) - { - } - - void tws_service_screensaver::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service_screensaver *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service_screensaver::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service_screensaver *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service_screensaver::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service_screensaver *that = resource->tws_service_screensaver_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_screensaver_destroy_resource(resource); - delete resource; - } - - tws_service_screensaver::Resource *tws_service_screensaver::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_screensaver_interface, version, id); - return bind(handle); - } - - tws_service_screensaver::Resource *tws_service_screensaver::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_screensaver_allocate(); - resource->tws_service_screensaver_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_screensaver_interface, resource, destroy_func); - resource->handle = handle; - tws_service_screensaver_bind_resource(resource); - return resource; - } - tws_service_screensaver::Resource *tws_service_screensaver::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_screensaver_interface, &m_tws_service_screensaver_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_screensaver_interface tws_service_screensaver::m_tws_service_screensaver_interface = { - tws_service_screensaver::handle_release - }; - - void tws_service_screensaver::tws_service_screensaver_release(Resource *) - { - } - - - void tws_service_screensaver::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_screensaver_object)->tws_service_screensaver_release( - r); - } - - tws_service_cbhm::tws_service_cbhm(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service_cbhm::tws_service_cbhm(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service_cbhm::tws_service_cbhm(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service_cbhm::tws_service_cbhm() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service_cbhm::~tws_service_cbhm() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service_cbhm::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service_cbhm::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service_cbhm::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service_cbhm::Resource *tws_service_cbhm::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service_cbhm::Resource *tws_service_cbhm::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service_cbhm::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_cbhm_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service_cbhm::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service_cbhm::interface() - { - return &::tws_service_cbhm_interface; - } - - tws_service_cbhm::Resource *tws_service_cbhm::tws_service_cbhm_allocate() - { - return new Resource; - } - - void tws_service_cbhm::tws_service_cbhm_bind_resource(Resource *) - { - } - - void tws_service_cbhm::tws_service_cbhm_destroy_resource(Resource *) - { - } - - void tws_service_cbhm::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service_cbhm *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service_cbhm::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service_cbhm *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service_cbhm::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service_cbhm *that = resource->tws_service_cbhm_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_cbhm_destroy_resource(resource); - delete resource; - } - - tws_service_cbhm::Resource *tws_service_cbhm::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_cbhm_interface, version, id); - return bind(handle); - } - - tws_service_cbhm::Resource *tws_service_cbhm::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_cbhm_allocate(); - resource->tws_service_cbhm_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_cbhm_interface, resource, destroy_func); - resource->handle = handle; - tws_service_cbhm_bind_resource(resource); - return resource; - } - tws_service_cbhm::Resource *tws_service_cbhm::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_cbhm_interface, &m_tws_service_cbhm_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_cbhm_interface tws_service_cbhm::m_tws_service_cbhm_interface = { - tws_service_cbhm::handle_destroy, - tws_service_cbhm::handle_msg_send - }; - - void tws_service_cbhm::tws_service_cbhm_destroy(Resource *) - { - } - - void tws_service_cbhm::tws_service_cbhm_msg_send(Resource *, uint32_t ) - { - } - - - void tws_service_cbhm::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_cbhm_object)->tws_service_cbhm_destroy( - r); - } - - void tws_service_cbhm::handle_msg_send( - ::wl_client *client, - struct wl_resource *resource, - uint32_t msg) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_cbhm_object)->tws_service_cbhm_msg_send( - r, - msg); - } - - tws_dummy_extension::tws_dummy_extension(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_dummy_extension::tws_dummy_extension(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_dummy_extension::tws_dummy_extension(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_dummy_extension::tws_dummy_extension() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_dummy_extension::~tws_dummy_extension() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_dummy_extension::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_dummy_extension::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_dummy_extension::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_dummy_extension::Resource *tws_dummy_extension::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_dummy_extension::Resource *tws_dummy_extension::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_dummy_extension::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_dummy_extension_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_dummy_extension::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_dummy_extension::interface() - { - return &::tws_dummy_extension_interface; - } - - tws_dummy_extension::Resource *tws_dummy_extension::tws_dummy_extension_allocate() - { - return new Resource; - } - - void tws_dummy_extension::tws_dummy_extension_bind_resource(Resource *) - { - } - - void tws_dummy_extension::tws_dummy_extension_destroy_resource(Resource *) - { - } - - void tws_dummy_extension::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_dummy_extension *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_dummy_extension::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_dummy_extension *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_dummy_extension::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_dummy_extension *that = resource->tws_dummy_extension_object; - that->m_resource_map.erase(resource->client()); - that->tws_dummy_extension_destroy_resource(resource); - delete resource; - } - - tws_dummy_extension::Resource *tws_dummy_extension::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_dummy_extension_interface, version, id); - return bind(handle); - } - - tws_dummy_extension::Resource *tws_dummy_extension::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_dummy_extension_allocate(); - resource->tws_dummy_extension_object = this; - - wl_resource_set_implementation(handle, &m_tws_dummy_extension_interface, resource, destroy_func); - resource->handle = handle; - tws_dummy_extension_bind_resource(resource); - return resource; - } - tws_dummy_extension::Resource *tws_dummy_extension::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_dummy_extension_interface, &m_tws_dummy_extension_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_dummy_extension_interface tws_dummy_extension::m_tws_dummy_extension_interface = { - tws_dummy_extension::handle_destroy - }; - - void tws_dummy_extension::tws_dummy_extension_destroy(Resource *) - { - } - - - void tws_dummy_extension::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_dummy_extension_object)->tws_dummy_extension_destroy( - r); - } - - tws_service_softkey::tws_service_softkey(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service_softkey::tws_service_softkey(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service_softkey::tws_service_softkey(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service_softkey::tws_service_softkey() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service_softkey::~tws_service_softkey() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service_softkey::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service_softkey::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service_softkey::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service_softkey::Resource *tws_service_softkey::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service_softkey::Resource *tws_service_softkey::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service_softkey::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_softkey_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service_softkey::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service_softkey::interface() - { - return &::tws_service_softkey_interface; - } - - tws_service_softkey::Resource *tws_service_softkey::tws_service_softkey_allocate() - { - return new Resource; - } - - void tws_service_softkey::tws_service_softkey_bind_resource(Resource *) - { - } - - void tws_service_softkey::tws_service_softkey_destroy_resource(Resource *) - { - } - - void tws_service_softkey::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service_softkey *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service_softkey::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service_softkey *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service_softkey::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service_softkey *that = resource->tws_service_softkey_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_softkey_destroy_resource(resource); - delete resource; - } - - tws_service_softkey::Resource *tws_service_softkey::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_softkey_interface, version, id); - return bind(handle); - } - - tws_service_softkey::Resource *tws_service_softkey::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_softkey_allocate(); - resource->tws_service_softkey_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_softkey_interface, resource, destroy_func); - resource->handle = handle; - tws_service_softkey_bind_resource(resource); - return resource; - } - tws_service_softkey::Resource *tws_service_softkey::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_softkey_interface, &m_tws_service_softkey_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_softkey_interface tws_service_softkey::m_tws_service_softkey_interface = { - tws_service_softkey::handle_destroy, - tws_service_softkey::handle_msg_send - }; - - void tws_service_softkey::tws_service_softkey_destroy(Resource *) - { - } - - void tws_service_softkey::tws_service_softkey_msg_send(Resource *, uint32_t ) - { - } - - - void tws_service_softkey::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_softkey_object)->tws_service_softkey_destroy( - r); - } - - void tws_service_softkey::handle_msg_send( - ::wl_client *client, - struct wl_resource *resource, - uint32_t msg) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_softkey_object)->tws_service_softkey_msg_send( - r, - msg); - } - - void tws_service_softkey::send_visible_change_request(int32_t show) - { - DS_ASSERT_X(m_resource, "tws_service_softkey::visible_change_request", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_softkey::visible_change_request as it's not initialised"); - return; - } - send_visible_change_request( - m_resource->handle, - show); - } - - void tws_service_softkey::send_visible_change_request(struct ::wl_resource *resource, int32_t show) - { - tws_service_softkey_send_visible_change_request( - resource, - show); - } - - - void tws_service_softkey::send_expand_change_request(int32_t expand) - { - DS_ASSERT_X(m_resource, "tws_service_softkey::expand_change_request", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_softkey::expand_change_request as it's not initialised"); - return; - } - send_expand_change_request( - m_resource->handle, - expand); - } - - void tws_service_softkey::send_expand_change_request(struct ::wl_resource *resource, int32_t expand) - { - tws_service_softkey_send_expand_change_request( - resource, - expand); - } - - - void tws_service_softkey::send_opacity_change_request(int32_t opacity) - { - DS_ASSERT_X(m_resource, "tws_service_softkey::opacity_change_request", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_softkey::opacity_change_request as it's not initialised"); - return; - } - send_opacity_change_request( - m_resource->handle, - opacity); - } - - void tws_service_softkey::send_opacity_change_request(struct ::wl_resource *resource, int32_t opacity) - { - tws_service_softkey_send_opacity_change_request( - resource, - opacity); - } - - - tws_softkey::tws_softkey(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_softkey::tws_softkey(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_softkey::tws_softkey(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_softkey::tws_softkey() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_softkey::~tws_softkey() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_softkey::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_softkey::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_softkey::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_softkey::Resource *tws_softkey::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_softkey::Resource *tws_softkey::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_softkey::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_softkey_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_softkey::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_softkey::interface() - { - return &::tws_softkey_interface; - } - - tws_softkey::Resource *tws_softkey::tws_softkey_allocate() - { - return new Resource; - } - - void tws_softkey::tws_softkey_bind_resource(Resource *) - { - } - - void tws_softkey::tws_softkey_destroy_resource(Resource *) - { - } - - void tws_softkey::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_softkey *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_softkey::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_softkey *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_softkey::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_softkey *that = resource->tws_softkey_object; - that->m_resource_map.erase(resource->client()); - that->tws_softkey_destroy_resource(resource); - delete resource; - } - - tws_softkey::Resource *tws_softkey::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_softkey_interface, version, id); - return bind(handle); - } - - tws_softkey::Resource *tws_softkey::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_softkey_allocate(); - resource->tws_softkey_object = this; - - wl_resource_set_implementation(handle, &m_tws_softkey_interface, resource, destroy_func); - resource->handle = handle; - tws_softkey_bind_resource(resource); - return resource; - } - tws_softkey::Resource *tws_softkey::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_softkey_interface, &m_tws_softkey_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_softkey_interface tws_softkey::m_tws_softkey_interface = { - tws_softkey::handle_release, - tws_softkey::handle_support_check, - tws_softkey::handle_show, - tws_softkey::handle_hide, - tws_softkey::handle_state_set, - tws_softkey::handle_state_get - }; - - void tws_softkey::tws_softkey_release(Resource *) - { - } - - void tws_softkey::tws_softkey_support_check(Resource *) - { - } - - void tws_softkey::tws_softkey_show(Resource *) - { - } - - void tws_softkey::tws_softkey_hide(Resource *) - { - } - - void tws_softkey::tws_softkey_state_set(Resource *, int32_t , int32_t ) - { - } - - void tws_softkey::tws_softkey_state_get(Resource *, int32_t ) - { - } - - - void tws_softkey::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_softkey_object)->tws_softkey_release( - r); - } - - void tws_softkey::handle_support_check( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_softkey_object)->tws_softkey_support_check( - r); - } - - void tws_softkey::handle_show( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_softkey_object)->tws_softkey_show( - r); - } - - void tws_softkey::handle_hide( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_softkey_object)->tws_softkey_hide( - r); - } - - void tws_softkey::handle_state_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t type, - int32_t val) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_softkey_object)->tws_softkey_state_set( - r, - type, - val); - } - - void tws_softkey::handle_state_get( - ::wl_client *client, - struct wl_resource *resource, - int32_t type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_softkey_object)->tws_softkey_state_get( - r, - type); - } - - void tws_softkey::send_support_check_done(int32_t support) - { - DS_ASSERT_X(m_resource, "tws_softkey::support_check_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_softkey::support_check_done as it's not initialised"); - return; - } - send_support_check_done( - m_resource->handle, - support); - } - - void tws_softkey::send_support_check_done(struct ::wl_resource *resource, int32_t support) - { - tws_softkey_send_support_check_done( - resource, - support); - } - - - void tws_softkey::send_state_get_done(int32_t type, int32_t value, uint32_t error_state) - { - DS_ASSERT_X(m_resource, "tws_softkey::state_get_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_softkey::state_get_done as it's not initialised"); - return; - } - send_state_get_done( - m_resource->handle, - type, - value, - error_state); - } - - void tws_softkey::send_state_get_done(struct ::wl_resource *resource, int32_t type, int32_t value, uint32_t error_state) - { - tws_softkey_send_state_get_done( - resource, - type, - value, - error_state); - } - - - tws_service_magnifier::tws_service_magnifier(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service_magnifier::tws_service_magnifier(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service_magnifier::tws_service_magnifier(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service_magnifier::tws_service_magnifier() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service_magnifier::~tws_service_magnifier() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service_magnifier::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service_magnifier::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service_magnifier::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service_magnifier::Resource *tws_service_magnifier::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service_magnifier::Resource *tws_service_magnifier::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service_magnifier::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_magnifier_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service_magnifier::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service_magnifier::interface() - { - return &::tws_service_magnifier_interface; - } - - tws_service_magnifier::Resource *tws_service_magnifier::tws_service_magnifier_allocate() - { - return new Resource; - } - - void tws_service_magnifier::tws_service_magnifier_bind_resource(Resource *) - { - } - - void tws_service_magnifier::tws_service_magnifier_destroy_resource(Resource *) - { - } - - void tws_service_magnifier::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service_magnifier *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service_magnifier::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service_magnifier *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service_magnifier::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service_magnifier *that = resource->tws_service_magnifier_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_magnifier_destroy_resource(resource); - delete resource; - } - - tws_service_magnifier::Resource *tws_service_magnifier::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_magnifier_interface, version, id); - return bind(handle); - } - - tws_service_magnifier::Resource *tws_service_magnifier::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_magnifier_allocate(); - resource->tws_service_magnifier_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_magnifier_interface, resource, destroy_func); - resource->handle = handle; - tws_service_magnifier_bind_resource(resource); - return resource; - } - tws_service_magnifier::Resource *tws_service_magnifier::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_magnifier_interface, &m_tws_service_magnifier_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_magnifier_interface tws_service_magnifier::m_tws_service_magnifier_interface = { - tws_service_magnifier::handle_destroy, - tws_service_magnifier::handle_zoom_geometry_set, - tws_service_magnifier::handle_zoom_ratio_set, - tws_service_magnifier::handle_zoom_enable_set - }; - - void tws_service_magnifier::tws_service_magnifier_destroy(Resource *) - { - } - - void tws_service_magnifier::tws_service_magnifier_zoom_geometry_set(Resource *, uint32_t , int32_t , int32_t , uint32_t , uint32_t ) - { - } - - void tws_service_magnifier::tws_service_magnifier_zoom_ratio_set(Resource *, int32_t ) - { - } - - void tws_service_magnifier::tws_service_magnifier_zoom_enable_set(Resource *, int32_t ) - { - } - - - void tws_service_magnifier::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_magnifier_object)->tws_service_magnifier_destroy( - r); - } - - void tws_service_magnifier::handle_zoom_geometry_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t angle, - int32_t x, - int32_t y, - uint32_t w, - uint32_t h) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_magnifier_object)->tws_service_magnifier_zoom_geometry_set( - r, - angle, - x, - y, - w, - h); - } - - void tws_service_magnifier::handle_zoom_ratio_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t ratio) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_magnifier_object)->tws_service_magnifier_zoom_ratio_set( - r, - ratio); - } - - void tws_service_magnifier::handle_zoom_enable_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t enable) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_magnifier_object)->tws_service_magnifier_zoom_enable_set( - r, - enable); - } - - tws_service_launcher::tws_service_launcher(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_service_launcher::tws_service_launcher(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_service_launcher::tws_service_launcher(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_service_launcher::tws_service_launcher() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_service_launcher::~tws_service_launcher() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_service_launcher::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_service_launcher::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_service_launcher::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_service_launcher::Resource *tws_service_launcher::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_service_launcher::Resource *tws_service_launcher::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_service_launcher::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_service_launcher_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_service_launcher::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_service_launcher::interface() - { - return &::tws_service_launcher_interface; - } - - tws_service_launcher::Resource *tws_service_launcher::tws_service_launcher_allocate() - { - return new Resource; - } - - void tws_service_launcher::tws_service_launcher_bind_resource(Resource *) - { - } - - void tws_service_launcher::tws_service_launcher_destroy_resource(Resource *) - { - } - - void tws_service_launcher::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_service_launcher *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_service_launcher::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_service_launcher *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_service_launcher::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_service_launcher *that = resource->tws_service_launcher_object; - that->m_resource_map.erase(resource->client()); - that->tws_service_launcher_destroy_resource(resource); - delete resource; - } - - tws_service_launcher::Resource *tws_service_launcher::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_service_launcher_interface, version, id); - return bind(handle); - } - - tws_service_launcher::Resource *tws_service_launcher::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_service_launcher_allocate(); - resource->tws_service_launcher_object = this; - - wl_resource_set_implementation(handle, &m_tws_service_launcher_interface, resource, destroy_func); - resource->handle = handle; - tws_service_launcher_bind_resource(resource); - return resource; - } - tws_service_launcher::Resource *tws_service_launcher::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_service_launcher_interface, &m_tws_service_launcher_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_service_launcher_interface tws_service_launcher::m_tws_service_launcher_interface = { - tws_service_launcher::handle_destroy, - tws_service_launcher::handle_launch, - tws_service_launcher::handle_launch_with_shared_widget, - tws_service_launcher::handle_launching, - tws_service_launcher::handle_launch_done, - tws_service_launcher::handle_launch_cancel - }; - - void tws_service_launcher::tws_service_launcher_destroy(Resource *) - { - } - - void tws_service_launcher::tws_service_launcher_launch(Resource *, const std::string &, const std::string &, int32_t , uint32_t ) - { - } - - void tws_service_launcher::tws_service_launcher_launch_with_shared_widget(Resource *, const std::string &, const std::string &, int32_t , uint32_t ) - { - } - - void tws_service_launcher::tws_service_launcher_launching(Resource *, uint32_t ) - { - } - - void tws_service_launcher::tws_service_launcher_launch_done(Resource *, uint32_t ) - { - } - - void tws_service_launcher::tws_service_launcher_launch_cancel(Resource *, uint32_t ) - { - } - - - void tws_service_launcher::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_launcher_object)->tws_service_launcher_destroy( - r); - } - - void tws_service_launcher::handle_launch( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id, - const char *instance_id, - int32_t pid, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_launcher_object)->tws_service_launcher_launch( - r, - std::string(app_id), - std::string(instance_id), - pid, - serial); - } - - void tws_service_launcher::handle_launch_with_shared_widget( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id, - const char *instance_id, - int32_t pid, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_launcher_object)->tws_service_launcher_launch_with_shared_widget( - r, - std::string(app_id), - std::string(instance_id), - pid, - serial); - } - - void tws_service_launcher::handle_launching( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_launcher_object)->tws_service_launcher_launching( - r, - serial); - } - - void tws_service_launcher::handle_launch_done( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_launcher_object)->tws_service_launcher_launch_done( - r, - serial); - } - - void tws_service_launcher::handle_launch_cancel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_service_launcher_object)->tws_service_launcher_launch_cancel( - r, - serial); - } - - void tws_service_launcher::send_prepare(uint32_t target_type, struct ::wl_array *target_info, uint32_t direction, int32_t x, int32_t y, const std::string &shared_widget_info, uint32_t serial) - { - DS_ASSERT_X(m_resource, "tws_service_launcher::prepare", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_launcher::prepare as it's not initialised"); - return; - } - send_prepare( - m_resource->handle, - target_type, - target_info, - direction, - x, - y, - shared_widget_info, - serial); - } - - void tws_service_launcher::send_prepare(struct ::wl_resource *resource, uint32_t target_type, struct ::wl_array *target_info, uint32_t direction, int32_t x, int32_t y, const std::string &shared_widget_info, uint32_t serial) - { - tws_service_launcher_send_prepare( - resource, - target_type, - target_info, - direction, - x, - y, - shared_widget_info.c_str(), - serial); - } - - - void tws_service_launcher::send_stop(uint32_t serial) - { - DS_ASSERT_X(m_resource, "tws_service_launcher::stop", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_launcher::stop as it's not initialised"); - return; - } - send_stop( - m_resource->handle, - serial); - } - - void tws_service_launcher::send_stop(struct ::wl_resource *resource, uint32_t serial) - { - tws_service_launcher_send_stop( - resource, - serial); - } - - - void tws_service_launcher::send_error(uint32_t code, uint32_t serial) - { - DS_ASSERT_X(m_resource, "tws_service_launcher::error", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_launcher::error as it's not initialised"); - return; - } - send_error( - m_resource->handle, - code, - serial); - } - - void tws_service_launcher::send_error(struct ::wl_resource *resource, uint32_t code, uint32_t serial) - { - tws_service_launcher_send_error( - resource, - code, - serial); - } - - - void tws_service_launcher::send_cleanup(uint32_t serial) - { - DS_ASSERT_X(m_resource, "tws_service_launcher::cleanup", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_service_launcher::cleanup as it's not initialised"); - return; - } - send_cleanup( - m_resource->handle, - serial); - } - - void tws_service_launcher::send_cleanup(struct ::wl_resource *resource, uint32_t serial) - { - tws_service_launcher_send_cleanup( - resource, - serial); - } - - - tws_shared_widget_launch::tws_shared_widget_launch(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - tws_shared_widget_launch::tws_shared_widget_launch(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - tws_shared_widget_launch::tws_shared_widget_launch(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - tws_shared_widget_launch::tws_shared_widget_launch() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - tws_shared_widget_launch::~tws_shared_widget_launch() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - tws_shared_widget_launch::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void tws_shared_widget_launch::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void tws_shared_widget_launch::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - tws_shared_widget_launch::Resource *tws_shared_widget_launch::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - tws_shared_widget_launch::Resource *tws_shared_widget_launch::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void tws_shared_widget_launch::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::tws_shared_widget_launch_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = tws_shared_widget_launch::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *tws_shared_widget_launch::interface() - { - return &::tws_shared_widget_launch_interface; - } - - tws_shared_widget_launch::Resource *tws_shared_widget_launch::tws_shared_widget_launch_allocate() - { - return new Resource; - } - - void tws_shared_widget_launch::tws_shared_widget_launch_bind_resource(Resource *) - { - } - - void tws_shared_widget_launch::tws_shared_widget_launch_destroy_resource(Resource *) - { - } - - void tws_shared_widget_launch::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - tws_shared_widget_launch *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void tws_shared_widget_launch::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - tws_shared_widget_launch *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void tws_shared_widget_launch::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - tws_shared_widget_launch *that = resource->tws_shared_widget_launch_object; - that->m_resource_map.erase(resource->client()); - that->tws_shared_widget_launch_destroy_resource(resource); - delete resource; - } - - tws_shared_widget_launch::Resource *tws_shared_widget_launch::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::tws_shared_widget_launch_interface, version, id); - return bind(handle); - } - - tws_shared_widget_launch::Resource *tws_shared_widget_launch::bind(struct ::wl_resource *handle) - { - Resource *resource = tws_shared_widget_launch_allocate(); - resource->tws_shared_widget_launch_object = this; - - wl_resource_set_implementation(handle, &m_tws_shared_widget_launch_interface, resource, destroy_func); - resource->handle = handle; - tws_shared_widget_launch_bind_resource(resource); - return resource; - } - tws_shared_widget_launch::Resource *tws_shared_widget_launch::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::tws_shared_widget_launch_interface, &m_tws_shared_widget_launch_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::tws_shared_widget_launch_interface tws_shared_widget_launch::m_tws_shared_widget_launch_interface = { - tws_shared_widget_launch::handle_release, - tws_shared_widget_launch::handle_prepare_shared_widget_done - }; - - void tws_shared_widget_launch::tws_shared_widget_launch_release(Resource *) - { - } - - void tws_shared_widget_launch::tws_shared_widget_launch_prepare_shared_widget_done(Resource *, const std::string &, uint32_t , uint32_t ) - { - } - - - void tws_shared_widget_launch::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_shared_widget_launch_object)->tws_shared_widget_launch_release( - r); - } - - void tws_shared_widget_launch::handle_prepare_shared_widget_done( - ::wl_client *client, - struct wl_resource *resource, - const char *shared_widget_info, - uint32_t state, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->tws_shared_widget_launch_object)->tws_shared_widget_launch_prepare_shared_widget_done( - r, - std::string(shared_widget_info), - state, - serial); - } - - void tws_shared_widget_launch::send_prepare_shared_widget(uint32_t state, uint32_t serial) - { - DS_ASSERT_X(m_resource, "tws_shared_widget_launch::prepare_shared_widget", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call tws_shared_widget_launch::prepare_shared_widget as it's not initialised"); - return; - } - send_prepare_shared_widget( - m_resource->handle, - state, - serial); - } - - void tws_shared_widget_launch::send_prepare_shared_widget(struct ::wl_resource *resource, uint32_t state, uint32_t serial) - { - tws_shared_widget_launch_send_prepare_shared_widget( - resource, - state, - serial); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-tzsh.h b/src/DSWaylandServer/dswayland-server-tzsh.h deleted file mode 100644 index 0d347b8..0000000 --- a/src/DSWaylandServer/dswayland-server-tzsh.h +++ /dev/null @@ -1,1684 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/tzsh.xml */ - -#ifndef __DS_TIZEN_WS_SHELL_PROTOCOL_H__ -#define __DS_TIZEN_WS_SHELL_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "tizen-ws-shell-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class tizen_ws_shell - { - public: - tizen_ws_shell(struct ::wl_client *client, uint32_t id, int version); - tizen_ws_shell(struct ::wl_display *display, int version); - tizen_ws_shell(struct ::wl_resource *resource); - tizen_ws_shell(); - - virtual ~tizen_ws_shell(); - - class Resource - { - public: - Resource() : tizen_ws_shell_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tizen_ws_shell *tizen_ws_shell_object; - tizen_ws_shell *object() { return tizen_ws_shell_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_none = 0, // no error. succeed. - error_out_of_memory = 1, // server is not have enought memory. - error_invalid_parameter = 2, // given request have invalid parameter. - error_permission_denied = 3, // client is not have right permission. - error_no_service = 4, // there is no service to support request - error_not_supported = 5, // given request is not supported - }; - - void send_service_register(const std::string &name); - void send_service_register(struct ::wl_resource *resource, const std::string &name); - void send_service_unregister(const std::string &name); - void send_service_unregister(struct ::wl_resource *resource, const std::string &name); - void send_error(uint32_t error_state); - void send_error(struct ::wl_resource *resource, uint32_t error_state); - - protected: - virtual Resource *tizen_ws_shell_allocate(); - - virtual void tizen_ws_shell_bind_resource(Resource *resource); - virtual void tizen_ws_shell_destroy_resource(Resource *resource); - - virtual void tizen_ws_shell_destroy(Resource *resource); - virtual void tizen_ws_shell_service_create(Resource *resource, uint32_t id, uint32_t win, const std::string &name); - virtual void tizen_ws_shell_region_create(Resource *resource, uint32_t id); - virtual void tizen_ws_shell_quickpanel_get(Resource *resource, uint32_t id, uint32_t win); - virtual void tizen_ws_shell_extension_get(Resource *resource, uint32_t id, const std::string &name); - virtual void tizen_ws_shell_softkey_get(Resource *resource, uint32_t id, uint32_t win); - virtual void tizen_ws_shell_shared_widget_launch_get(Resource *resource, uint32_t id, uint32_t win); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tizen_ws_shell_interface m_tizen_ws_shell_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_service_create( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win, - const char *name); - static void handle_region_create( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_quickpanel_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win); - static void handle_extension_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - const char *name); - static void handle_softkey_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win); - static void handle_shared_widget_launch_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - uint32_t win); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tizen_ws_shell *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_quickpanel - { - public: - tws_quickpanel(struct ::wl_client *client, uint32_t id, int version); - tws_quickpanel(struct ::wl_display *display, int version); - tws_quickpanel(struct ::wl_resource *resource); - tws_quickpanel(); - - virtual ~tws_quickpanel(); - - class Resource - { - public: - Resource() : tws_quickpanel_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_quickpanel *tws_quickpanel_object; - tws_quickpanel *object() { return tws_quickpanel_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_request_rejected = 0, // given request is denied - }; - - enum state_type { - state_type_unknown = 0, - state_type_visibility = 1, - state_type_scrollable = 2, - state_type_orientation = 3, - }; - - enum state_value { - state_value_unknown = 0, - state_value_visible_show = 1, - state_value_visible_hide = 2, - state_value_scrollable_set = 3, - state_value_scrollable_unset = 4, - state_value_orientation_0 = 5, - state_value_orientation_90 = 6, - state_value_orientation_180 = 7, - state_value_orientation_270 = 8, - state_value_scrollable_retain = 9, - }; - - enum type_value { - type_value_unknown = 0, - type_value_system_default = 1, - type_value_context_menu = 2, - type_value_apps_menu = 3, - }; - - void send_state_get_done(int32_t type, int32_t value, uint32_t error_state); - void send_state_get_done(struct ::wl_resource *resource, int32_t type, int32_t value, uint32_t error_state); - void send_state_changed(struct ::wl_array *states); - void send_state_changed(struct ::wl_resource *resource, struct ::wl_array *states); - - protected: - virtual Resource *tws_quickpanel_allocate(); - - virtual void tws_quickpanel_bind_resource(Resource *resource); - virtual void tws_quickpanel_destroy_resource(Resource *resource); - - virtual void tws_quickpanel_release(Resource *resource); - virtual void tws_quickpanel_show(Resource *resource); - virtual void tws_quickpanel_hide(Resource *resource); - virtual void tws_quickpanel_enable(Resource *resource); - virtual void tws_quickpanel_disable(Resource *resource); - virtual void tws_quickpanel_state_get(Resource *resource, int32_t type); - virtual void tws_quickpanel_type_set(Resource *resource, uint32_t type); - virtual void tws_quickpanel_scrollable_state_set(Resource *resource, int32_t type); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_quickpanel_interface m_tws_quickpanel_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - static void handle_show( - ::wl_client *client, - struct wl_resource *resource); - static void handle_hide( - ::wl_client *client, - struct wl_resource *resource); - static void handle_enable( - ::wl_client *client, - struct wl_resource *resource); - static void handle_disable( - ::wl_client *client, - struct wl_resource *resource); - static void handle_state_get( - ::wl_client *client, - struct wl_resource *resource, - int32_t type); - static void handle_type_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type); - static void handle_scrollable_state_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t type); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_quickpanel *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_region - { - public: - tws_region(struct ::wl_client *client, uint32_t id, int version); - tws_region(struct ::wl_display *display, int version); - tws_region(struct ::wl_resource *resource); - tws_region(); - - virtual ~tws_region(); - - class Resource - { - public: - Resource() : tws_region_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_region *tws_region_object; - tws_region *object() { return tws_region_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tws_region_allocate(); - - virtual void tws_region_bind_resource(Resource *resource); - virtual void tws_region_destroy_resource(Resource *resource); - - virtual void tws_region_destroy(Resource *resource); - virtual void tws_region_add(Resource *resource, int32_t x, int32_t y, int32_t w, int32_t h); - virtual void tws_region_subtract(Resource *resource, int32_t x, int32_t y, int32_t w, int32_t h); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_region_interface m_tws_region_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_add( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t w, - int32_t h); - static void handle_subtract( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t w, - int32_t h); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_region *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service - { - public: - tws_service(struct ::wl_client *client, uint32_t id, int version); - tws_service(struct ::wl_display *display, int version); - tws_service(struct ::wl_resource *resource); - tws_service(); - - virtual ~tws_service(); - - class Resource - { - public: - Resource() : tws_service_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service *tws_service_object; - tws_service *object() { return tws_service_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum region_type { - region_type_handler = 0, - region_type_content = 1, - }; - - protected: - virtual Resource *tws_service_allocate(); - - virtual void tws_service_bind_resource(Resource *resource); - virtual void tws_service_destroy_resource(Resource *resource); - - virtual void tws_service_destroy(Resource *resource); - virtual void tws_service_region_set(Resource *resource, int32_t type, int32_t angle, struct ::wl_resource *region); - virtual void tws_service_indicator_get(Resource *resource, uint32_t id); - virtual void tws_service_quickpanel_get(Resource *resource, uint32_t id); - virtual void tws_service_screensaver_manager_get(Resource *resource, uint32_t id); - virtual void tws_service_screensaver_get(Resource *resource, uint32_t id); - virtual void tws_service_cbhm_get(Resource *resource, uint32_t id); - virtual void tws_service_softkey_get(Resource *resource, uint32_t id); - virtual void tws_service_magnifier_get(Resource *resource, uint32_t id); - virtual void tws_service_launcher_get(Resource *resource, uint32_t id); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_interface m_tws_service_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_region_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t type, - int32_t angle, - struct ::wl_resource *region); - static void handle_indicator_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_quickpanel_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_screensaver_manager_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_screensaver_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_cbhm_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_softkey_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_magnifier_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_launcher_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service_indicator - { - public: - tws_service_indicator(struct ::wl_client *client, uint32_t id, int version); - tws_service_indicator(struct ::wl_display *display, int version); - tws_service_indicator(struct ::wl_resource *resource); - tws_service_indicator(); - - virtual ~tws_service_indicator(); - - class Resource - { - public: - Resource() : tws_service_indicator_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service_indicator *tws_service_indicator_object; - tws_service_indicator *object() { return tws_service_indicator_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_property_change(int32_t angle, int32_t opacity); - void send_property_change(struct ::wl_resource *resource, int32_t angle, int32_t opacity); - - protected: - virtual Resource *tws_service_indicator_allocate(); - - virtual void tws_service_indicator_bind_resource(Resource *resource); - virtual void tws_service_indicator_destroy_resource(Resource *resource); - - virtual void tws_service_indicator_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_indicator_interface m_tws_service_indicator_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service_indicator *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service_quickpanel - { - public: - tws_service_quickpanel(struct ::wl_client *client, uint32_t id, int version); - tws_service_quickpanel(struct ::wl_display *display, int version); - tws_service_quickpanel(struct ::wl_resource *resource); - tws_service_quickpanel(); - - virtual ~tws_service_quickpanel(); - - class Resource - { - public: - Resource() : tws_service_quickpanel_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service_quickpanel *tws_service_quickpanel_object; - tws_service_quickpanel *object() { return tws_service_quickpanel_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum effect_type { - effect_type_swipe = 0, - effect_type_move = 1, - effect_type_app_custom = 2, - }; - - enum msg { - msg_show = 0, - msg_hide = 1, - }; - - protected: - virtual Resource *tws_service_quickpanel_allocate(); - - virtual void tws_service_quickpanel_bind_resource(Resource *resource); - virtual void tws_service_quickpanel_destroy_resource(Resource *resource); - - virtual void tws_service_quickpanel_destroy(Resource *resource); - virtual void tws_service_quickpanel_msg_send(Resource *resource, uint32_t msg); - virtual void tws_service_quickpanel_effect_type_set(Resource *resource, uint32_t type); - virtual void tws_service_quickpanel_scroll_lock_set(Resource *resource, uint32_t lock); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_quickpanel_interface m_tws_service_quickpanel_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_msg_send( - ::wl_client *client, - struct wl_resource *resource, - uint32_t msg); - static void handle_effect_type_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t type); - static void handle_scroll_lock_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t lock); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service_quickpanel *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service_screensaver_manager - { - public: - tws_service_screensaver_manager(struct ::wl_client *client, uint32_t id, int version); - tws_service_screensaver_manager(struct ::wl_display *display, int version); - tws_service_screensaver_manager(struct ::wl_resource *resource); - tws_service_screensaver_manager(); - - virtual ~tws_service_screensaver_manager(); - - class Resource - { - public: - Resource() : tws_service_screensaver_manager_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service_screensaver_manager *tws_service_screensaver_manager_object; - tws_service_screensaver_manager *object() { return tws_service_screensaver_manager_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum state_type { - state_type_unknown = 0, - state_type_enable = 1, - state_type_active = 2, - state_type_idle_timeout = 3, - }; - - void send_idle(); - void send_idle(struct ::wl_resource *resource); - void send_active(); - void send_active(struct ::wl_resource *resource); - void send_state_get_done(uint32_t state_type, uint32_t value, uint32_t error_state); - void send_state_get_done(struct ::wl_resource *resource, uint32_t state_type, uint32_t value, uint32_t error_state); - - protected: - virtual Resource *tws_service_screensaver_manager_allocate(); - - virtual void tws_service_screensaver_manager_bind_resource(Resource *resource); - virtual void tws_service_screensaver_manager_destroy_resource(Resource *resource); - - virtual void tws_service_screensaver_manager_destroy(Resource *resource); - virtual void tws_service_screensaver_manager_enable(Resource *resource); - virtual void tws_service_screensaver_manager_disable(Resource *resource); - virtual void tws_service_screensaver_manager_idle_time_set(Resource *resource, uint32_t id); - virtual void tws_service_screensaver_manager_state_get(Resource *resource, uint32_t state_type); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_screensaver_manager_interface m_tws_service_screensaver_manager_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_enable( - ::wl_client *client, - struct wl_resource *resource); - static void handle_disable( - ::wl_client *client, - struct wl_resource *resource); - static void handle_idle_time_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_state_get( - ::wl_client *client, - struct wl_resource *resource, - uint32_t state_type); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service_screensaver_manager *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service_screensaver - { - public: - tws_service_screensaver(struct ::wl_client *client, uint32_t id, int version); - tws_service_screensaver(struct ::wl_display *display, int version); - tws_service_screensaver(struct ::wl_resource *resource); - tws_service_screensaver(); - - virtual ~tws_service_screensaver(); - - class Resource - { - public: - Resource() : tws_service_screensaver_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service_screensaver *tws_service_screensaver_object; - tws_service_screensaver *object() { return tws_service_screensaver_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_request_rejected = 0, // given request is denied - }; - - protected: - virtual Resource *tws_service_screensaver_allocate(); - - virtual void tws_service_screensaver_bind_resource(Resource *resource); - virtual void tws_service_screensaver_destroy_resource(Resource *resource); - - virtual void tws_service_screensaver_release(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_screensaver_interface m_tws_service_screensaver_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service_screensaver *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service_cbhm - { - public: - tws_service_cbhm(struct ::wl_client *client, uint32_t id, int version); - tws_service_cbhm(struct ::wl_display *display, int version); - tws_service_cbhm(struct ::wl_resource *resource); - tws_service_cbhm(); - - virtual ~tws_service_cbhm(); - - class Resource - { - public: - Resource() : tws_service_cbhm_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service_cbhm *tws_service_cbhm_object; - tws_service_cbhm *object() { return tws_service_cbhm_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum msg { - msg_show = 0, - msg_hide = 1, - msg_data_selected = 2, - }; - - protected: - virtual Resource *tws_service_cbhm_allocate(); - - virtual void tws_service_cbhm_bind_resource(Resource *resource); - virtual void tws_service_cbhm_destroy_resource(Resource *resource); - - virtual void tws_service_cbhm_destroy(Resource *resource); - virtual void tws_service_cbhm_msg_send(Resource *resource, uint32_t msg); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_cbhm_interface m_tws_service_cbhm_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_msg_send( - ::wl_client *client, - struct wl_resource *resource, - uint32_t msg); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service_cbhm *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_dummy_extension - { - public: - tws_dummy_extension(struct ::wl_client *client, uint32_t id, int version); - tws_dummy_extension(struct ::wl_display *display, int version); - tws_dummy_extension(struct ::wl_resource *resource); - tws_dummy_extension(); - - virtual ~tws_dummy_extension(); - - class Resource - { - public: - Resource() : tws_dummy_extension_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_dummy_extension *tws_dummy_extension_object; - tws_dummy_extension *object() { return tws_dummy_extension_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *tws_dummy_extension_allocate(); - - virtual void tws_dummy_extension_bind_resource(Resource *resource); - virtual void tws_dummy_extension_destroy_resource(Resource *resource); - - virtual void tws_dummy_extension_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_dummy_extension_interface m_tws_dummy_extension_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_dummy_extension *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service_softkey - { - public: - tws_service_softkey(struct ::wl_client *client, uint32_t id, int version); - tws_service_softkey(struct ::wl_display *display, int version); - tws_service_softkey(struct ::wl_resource *resource); - tws_service_softkey(); - - virtual ~tws_service_softkey(); - - class Resource - { - public: - Resource() : tws_service_softkey_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service_softkey *tws_service_softkey_object; - tws_service_softkey *object() { return tws_service_softkey_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum msg { - msg_show = 0, - msg_hide = 1, - }; - - void send_visible_change_request(int32_t show); - void send_visible_change_request(struct ::wl_resource *resource, int32_t show); - void send_expand_change_request(int32_t expand); - void send_expand_change_request(struct ::wl_resource *resource, int32_t expand); - void send_opacity_change_request(int32_t opacity); - void send_opacity_change_request(struct ::wl_resource *resource, int32_t opacity); - - protected: - virtual Resource *tws_service_softkey_allocate(); - - virtual void tws_service_softkey_bind_resource(Resource *resource); - virtual void tws_service_softkey_destroy_resource(Resource *resource); - - virtual void tws_service_softkey_destroy(Resource *resource); - virtual void tws_service_softkey_msg_send(Resource *resource, uint32_t msg); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_softkey_interface m_tws_service_softkey_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_msg_send( - ::wl_client *client, - struct wl_resource *resource, - uint32_t msg); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service_softkey *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_softkey - { - public: - tws_softkey(struct ::wl_client *client, uint32_t id, int version); - tws_softkey(struct ::wl_display *display, int version); - tws_softkey(struct ::wl_resource *resource); - tws_softkey(); - - virtual ~tws_softkey(); - - class Resource - { - public: - Resource() : tws_softkey_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_softkey *tws_softkey_object; - tws_softkey *object() { return tws_softkey_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_none = 0, // no error. succeed. - error_request_rejected = 1, // given request is denied - error_no_service = 2, // there is no softkey - }; - - enum state { - state_visible = 0, - state_expand = 1, - state_opacity = 2, - }; - - enum state_visible { - state_visible_unknown = 0, - state_visible_show = 1, - state_visible_hide = 2, - }; - - enum state_expand { - state_expand_unknown = 10, - state_expand_on = 11, - state_expand_off = 12, - }; - - enum state_opacity { - state_opacity_unknown = 20, - state_opacity_opaque = 21, - state_opacity_transparent = 22, - }; - - void send_support_check_done(int32_t support); - void send_support_check_done(struct ::wl_resource *resource, int32_t support); - void send_state_get_done(int32_t type, int32_t value, uint32_t error_state); - void send_state_get_done(struct ::wl_resource *resource, int32_t type, int32_t value, uint32_t error_state); - - protected: - virtual Resource *tws_softkey_allocate(); - - virtual void tws_softkey_bind_resource(Resource *resource); - virtual void tws_softkey_destroy_resource(Resource *resource); - - virtual void tws_softkey_release(Resource *resource); - virtual void tws_softkey_support_check(Resource *resource); - virtual void tws_softkey_show(Resource *resource); - virtual void tws_softkey_hide(Resource *resource); - virtual void tws_softkey_state_set(Resource *resource, int32_t type, int32_t val); - virtual void tws_softkey_state_get(Resource *resource, int32_t type); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_softkey_interface m_tws_softkey_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - static void handle_support_check( - ::wl_client *client, - struct wl_resource *resource); - static void handle_show( - ::wl_client *client, - struct wl_resource *resource); - static void handle_hide( - ::wl_client *client, - struct wl_resource *resource); - static void handle_state_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t type, - int32_t val); - static void handle_state_get( - ::wl_client *client, - struct wl_resource *resource, - int32_t type); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_softkey *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service_magnifier - { - public: - tws_service_magnifier(struct ::wl_client *client, uint32_t id, int version); - tws_service_magnifier(struct ::wl_display *display, int version); - tws_service_magnifier(struct ::wl_resource *resource); - tws_service_magnifier(); - - virtual ~tws_service_magnifier(); - - class Resource - { - public: - Resource() : tws_service_magnifier_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service_magnifier *tws_service_magnifier_object; - tws_service_magnifier *object() { return tws_service_magnifier_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum zoom_ratio { - zoom_ratio_100 = 100, - zoom_ratio_110 = 110, - zoom_ratio_120 = 120, - zoom_ratio_130 = 130, - zoom_ratio_140 = 140, - zoom_ratio_150 = 150, - zoom_ratio_160 = 160, - zoom_ratio_170 = 170, - zoom_ratio_180 = 180, - zoom_ratio_190 = 190, - zoom_ratio_200 = 200, - }; - - protected: - virtual Resource *tws_service_magnifier_allocate(); - - virtual void tws_service_magnifier_bind_resource(Resource *resource); - virtual void tws_service_magnifier_destroy_resource(Resource *resource); - - virtual void tws_service_magnifier_destroy(Resource *resource); - virtual void tws_service_magnifier_zoom_geometry_set(Resource *resource, uint32_t angle, int32_t x, int32_t y, uint32_t w, uint32_t h); - virtual void tws_service_magnifier_zoom_ratio_set(Resource *resource, int32_t ratio); - virtual void tws_service_magnifier_zoom_enable_set(Resource *resource, int32_t enable); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_magnifier_interface m_tws_service_magnifier_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_zoom_geometry_set( - ::wl_client *client, - struct wl_resource *resource, - uint32_t angle, - int32_t x, - int32_t y, - uint32_t w, - uint32_t h); - static void handle_zoom_ratio_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t ratio); - static void handle_zoom_enable_set( - ::wl_client *client, - struct wl_resource *resource, - int32_t enable); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service_magnifier *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_service_launcher - { - public: - tws_service_launcher(struct ::wl_client *client, uint32_t id, int version); - tws_service_launcher(struct ::wl_display *display, int version); - tws_service_launcher(struct ::wl_resource *resource); - tws_service_launcher(); - - virtual ~tws_service_launcher(); - - class Resource - { - public: - Resource() : tws_service_launcher_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_service_launcher *tws_service_launcher_object; - tws_service_launcher *object() { return tws_service_launcher_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum direction { - direction_forward = 0, // direction of transition to a launched app from a launcher - direction_backward = 1, // direction of transition to a launcher from a launched app - }; - - enum target_type { - target_type_remote_surface = 0, // can get target via remote surface - target_type_edje = 1, // can get target via edj file - target_type_image = 2, // can get target via image file - }; - - enum error { - error_none = 0, // no error. - error_disqualified = 1, // client is disqualified and any requests will be ignored from now. - error_wrong_request = 2, - }; - - void send_prepare(uint32_t target_type, struct ::wl_array *target_info, uint32_t direction, int32_t x, int32_t y, const std::string &shared_widget_info, uint32_t serial); - void send_prepare(struct ::wl_resource *resource, uint32_t target_type, struct ::wl_array *target_info, uint32_t direction, int32_t x, int32_t y, const std::string &shared_widget_info, uint32_t serial); - void send_stop(uint32_t serial); - void send_stop(struct ::wl_resource *resource, uint32_t serial); - void send_error(uint32_t code, uint32_t serial); - void send_error(struct ::wl_resource *resource, uint32_t code, uint32_t serial); - void send_cleanup(uint32_t serial); - void send_cleanup(struct ::wl_resource *resource, uint32_t serial); - - protected: - virtual Resource *tws_service_launcher_allocate(); - - virtual void tws_service_launcher_bind_resource(Resource *resource); - virtual void tws_service_launcher_destroy_resource(Resource *resource); - - virtual void tws_service_launcher_destroy(Resource *resource); - virtual void tws_service_launcher_launch(Resource *resource, const std::string &app_id, const std::string &instance_id, int32_t pid, uint32_t serial); - virtual void tws_service_launcher_launch_with_shared_widget(Resource *resource, const std::string &app_id, const std::string &instance_id, int32_t pid, uint32_t serial); - virtual void tws_service_launcher_launching(Resource *resource, uint32_t serial); - virtual void tws_service_launcher_launch_done(Resource *resource, uint32_t serial); - virtual void tws_service_launcher_launch_cancel(Resource *resource, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_service_launcher_interface m_tws_service_launcher_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_launch( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id, - const char *instance_id, - int32_t pid, - uint32_t serial); - static void handle_launch_with_shared_widget( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id, - const char *instance_id, - int32_t pid, - uint32_t serial); - static void handle_launching( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_launch_done( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_launch_cancel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_service_launcher *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class tws_shared_widget_launch - { - public: - tws_shared_widget_launch(struct ::wl_client *client, uint32_t id, int version); - tws_shared_widget_launch(struct ::wl_display *display, int version); - tws_shared_widget_launch(struct ::wl_resource *resource); - tws_shared_widget_launch(); - - virtual ~tws_shared_widget_launch(); - - class Resource - { - public: - Resource() : tws_shared_widget_launch_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - tws_shared_widget_launch *tws_shared_widget_launch_object; - tws_shared_widget_launch *object() { return tws_shared_widget_launch_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum prepare_state { - prepare_state_widget_show = 0, - prepare_state_widget_hide = 1, - }; - - void send_prepare_shared_widget(uint32_t state, uint32_t serial); - void send_prepare_shared_widget(struct ::wl_resource *resource, uint32_t state, uint32_t serial); - - protected: - virtual Resource *tws_shared_widget_launch_allocate(); - - virtual void tws_shared_widget_launch_bind_resource(Resource *resource); - virtual void tws_shared_widget_launch_destroy_resource(Resource *resource); - - virtual void tws_shared_widget_launch_release(Resource *resource); - virtual void tws_shared_widget_launch_prepare_shared_widget_done(Resource *resource, const std::string &shared_widget_info, uint32_t state, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::tws_shared_widget_launch_interface m_tws_shared_widget_launch_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - static void handle_prepare_shared_widget_done( - ::wl_client *client, - struct wl_resource *resource, - const char *shared_widget_info, - uint32_t state, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - tws_shared_widget_launch *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-wayland.cpp b/src/DSWaylandServer/dswayland-server-wayland.cpp deleted file mode 100644 index 59baf05..0000000 --- a/src/DSWaylandServer/dswayland-server-wayland.cpp +++ /dev/null @@ -1,5378 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland/wayland.xml */ - -#include "dswayland-server-wayland.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - wl_callback::wl_callback(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_callback::wl_callback(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_callback::wl_callback(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_callback::wl_callback() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_callback::~wl_callback() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_callback::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_callback::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_callback::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_callback::Resource *wl_callback::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_callback::Resource *wl_callback::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_callback::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_callback_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_callback::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_callback::interface() - { - return &::wl_callback_interface; - } - - wl_callback::Resource *wl_callback::callback_allocate() - { - return new Resource; - } - - void wl_callback::callback_bind_resource(Resource *) - { - } - - void wl_callback::callback_destroy_resource(Resource *) - { - } - - void wl_callback::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_callback *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_callback::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_callback *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_callback::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_callback *that = resource->callback_object; - that->m_resource_map.erase(resource->client()); - that->callback_destroy_resource(resource); - delete resource; - } - - wl_callback::Resource *wl_callback::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_callback_interface, version, id); - return bind(handle); - } - - wl_callback::Resource *wl_callback::bind(struct ::wl_resource *handle) - { - Resource *resource = callback_allocate(); - resource->callback_object = this; - - wl_resource_set_implementation(handle, NULL, resource, destroy_func); - resource->handle = handle; - callback_bind_resource(resource); - return resource; - } - wl_callback::Resource *wl_callback::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_callback_interface, NULL)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - void wl_callback::send_done(uint32_t callback_data) - { - DS_ASSERT_X(m_resource, "wl_callback::done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_callback::done as it's not initialised"); - return; - } - send_done( - m_resource->handle, - callback_data); - } - - void wl_callback::send_done(struct ::wl_resource *resource, uint32_t callback_data) - { - wl_callback_send_done( - resource, - callback_data); - } - - - wl_compositor::wl_compositor(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_compositor::wl_compositor(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_compositor::wl_compositor(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_compositor::wl_compositor() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_compositor::~wl_compositor() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_compositor::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_compositor::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_compositor::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_compositor::Resource *wl_compositor::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_compositor::Resource *wl_compositor::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_compositor::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_compositor_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_compositor::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_compositor::interface() - { - return &::wl_compositor_interface; - } - - wl_compositor::Resource *wl_compositor::compositor_allocate() - { - return new Resource; - } - - void wl_compositor::compositor_bind_resource(Resource *) - { - } - - void wl_compositor::compositor_destroy_resource(Resource *) - { - } - - void wl_compositor::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_compositor *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_compositor::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_compositor *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_compositor::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_compositor *that = resource->compositor_object; - that->m_resource_map.erase(resource->client()); - that->compositor_destroy_resource(resource); - delete resource; - } - - wl_compositor::Resource *wl_compositor::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_compositor_interface, version, id); - return bind(handle); - } - - wl_compositor::Resource *wl_compositor::bind(struct ::wl_resource *handle) - { - Resource *resource = compositor_allocate(); - resource->compositor_object = this; - - wl_resource_set_implementation(handle, &m_wl_compositor_interface, resource, destroy_func); - resource->handle = handle; - compositor_bind_resource(resource); - return resource; - } - wl_compositor::Resource *wl_compositor::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_compositor_interface, &m_wl_compositor_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_compositor_interface wl_compositor::m_wl_compositor_interface = { - wl_compositor::handle_create_surface, - wl_compositor::handle_create_region - }; - - void wl_compositor::compositor_create_surface(Resource *, uint32_t) - { - } - - void wl_compositor::compositor_create_region(Resource *, uint32_t) - { - } - - - void wl_compositor::handle_create_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->compositor_object)->compositor_create_surface( - r, - id); - } - - void wl_compositor::handle_create_region( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->compositor_object)->compositor_create_region( - r, - id); - } - - wl_shm_pool::wl_shm_pool(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_shm_pool::wl_shm_pool(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_shm_pool::wl_shm_pool(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_shm_pool::wl_shm_pool() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_shm_pool::~wl_shm_pool() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_shm_pool::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_shm_pool::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_shm_pool::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_shm_pool::Resource *wl_shm_pool::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_shm_pool::Resource *wl_shm_pool::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_shm_pool::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_shm_pool_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_shm_pool::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_shm_pool::interface() - { - return &::wl_shm_pool_interface; - } - - wl_shm_pool::Resource *wl_shm_pool::shm_pool_allocate() - { - return new Resource; - } - - void wl_shm_pool::shm_pool_bind_resource(Resource *) - { - } - - void wl_shm_pool::shm_pool_destroy_resource(Resource *) - { - } - - void wl_shm_pool::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_shm_pool *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_shm_pool::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_shm_pool *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_shm_pool::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_shm_pool *that = resource->shm_pool_object; - that->m_resource_map.erase(resource->client()); - that->shm_pool_destroy_resource(resource); - delete resource; - } - - wl_shm_pool::Resource *wl_shm_pool::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_shm_pool_interface, version, id); - return bind(handle); - } - - wl_shm_pool::Resource *wl_shm_pool::bind(struct ::wl_resource *handle) - { - Resource *resource = shm_pool_allocate(); - resource->shm_pool_object = this; - - wl_resource_set_implementation(handle, &m_wl_shm_pool_interface, resource, destroy_func); - resource->handle = handle; - shm_pool_bind_resource(resource); - return resource; - } - wl_shm_pool::Resource *wl_shm_pool::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_shm_pool_interface, &m_wl_shm_pool_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_shm_pool_interface wl_shm_pool::m_wl_shm_pool_interface = { - wl_shm_pool::handle_create_buffer, - wl_shm_pool::handle_destroy, - wl_shm_pool::handle_resize - }; - - void wl_shm_pool::shm_pool_create_buffer(Resource *, uint32_t, int32_t , int32_t , int32_t , int32_t , uint32_t ) - { - } - - void wl_shm_pool::shm_pool_destroy(Resource *) - { - } - - void wl_shm_pool::shm_pool_resize(Resource *, int32_t ) - { - } - - - void wl_shm_pool::handle_create_buffer( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - int32_t offset, - int32_t width, - int32_t height, - int32_t stride, - uint32_t format) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shm_pool_object)->shm_pool_create_buffer( - r, - id, - offset, - width, - height, - stride, - format); - } - - void wl_shm_pool::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shm_pool_object)->shm_pool_destroy( - r); - } - - void wl_shm_pool::handle_resize( - ::wl_client *client, - struct wl_resource *resource, - int32_t size) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shm_pool_object)->shm_pool_resize( - r, - size); - } - - wl_shm::wl_shm(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_shm::wl_shm(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_shm::wl_shm(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_shm::wl_shm() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_shm::~wl_shm() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_shm::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_shm::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_shm::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_shm::Resource *wl_shm::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_shm::Resource *wl_shm::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_shm::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_shm_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_shm::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_shm::interface() - { - return &::wl_shm_interface; - } - - wl_shm::Resource *wl_shm::shm_allocate() - { - return new Resource; - } - - void wl_shm::shm_bind_resource(Resource *) - { - } - - void wl_shm::shm_destroy_resource(Resource *) - { - } - - void wl_shm::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_shm *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_shm::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_shm *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_shm::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_shm *that = resource->shm_object; - that->m_resource_map.erase(resource->client()); - that->shm_destroy_resource(resource); - delete resource; - } - - wl_shm::Resource *wl_shm::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_shm_interface, version, id); - return bind(handle); - } - - wl_shm::Resource *wl_shm::bind(struct ::wl_resource *handle) - { - Resource *resource = shm_allocate(); - resource->shm_object = this; - - wl_resource_set_implementation(handle, &m_wl_shm_interface, resource, destroy_func); - resource->handle = handle; - shm_bind_resource(resource); - return resource; - } - wl_shm::Resource *wl_shm::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_shm_interface, &m_wl_shm_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_shm_interface wl_shm::m_wl_shm_interface = { - wl_shm::handle_create_pool - }; - - void wl_shm::shm_create_pool(Resource *, uint32_t, int32_t , int32_t ) - { - } - - - void wl_shm::handle_create_pool( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - int32_t fd, - int32_t size) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shm_object)->shm_create_pool( - r, - id, - fd, - size); - } - - void wl_shm::send_format(uint32_t format) - { - DS_ASSERT_X(m_resource, "wl_shm::format", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_shm::format as it's not initialised"); - return; - } - send_format( - m_resource->handle, - format); - } - - void wl_shm::send_format(struct ::wl_resource *resource, uint32_t format) - { - wl_shm_send_format( - resource, - format); - } - - - wl_buffer::wl_buffer(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_buffer::wl_buffer(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_buffer::wl_buffer(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_buffer::wl_buffer() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_buffer::~wl_buffer() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_buffer::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_buffer::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_buffer::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_buffer::Resource *wl_buffer::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_buffer::Resource *wl_buffer::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_buffer::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_buffer_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_buffer::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_buffer::interface() - { - return &::wl_buffer_interface; - } - - wl_buffer::Resource *wl_buffer::buffer_allocate() - { - return new Resource; - } - - void wl_buffer::buffer_bind_resource(Resource *) - { - } - - void wl_buffer::buffer_destroy_resource(Resource *) - { - } - - void wl_buffer::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_buffer *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_buffer::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_buffer *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_buffer::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_buffer *that = resource->buffer_object; - that->m_resource_map.erase(resource->client()); - that->buffer_destroy_resource(resource); - delete resource; - } - - wl_buffer::Resource *wl_buffer::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_buffer_interface, version, id); - return bind(handle); - } - - wl_buffer::Resource *wl_buffer::bind(struct ::wl_resource *handle) - { - Resource *resource = buffer_allocate(); - resource->buffer_object = this; - - wl_resource_set_implementation(handle, &m_wl_buffer_interface, resource, destroy_func); - resource->handle = handle; - buffer_bind_resource(resource); - return resource; - } - wl_buffer::Resource *wl_buffer::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_buffer_interface, &m_wl_buffer_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_buffer_interface wl_buffer::m_wl_buffer_interface = { - wl_buffer::handle_destroy - }; - - void wl_buffer::buffer_destroy(Resource *) - { - } - - - void wl_buffer::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->buffer_object)->buffer_destroy( - r); - } - - void wl_buffer::send_release() - { - DS_ASSERT_X(m_resource, "wl_buffer::release", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_buffer::release as it's not initialised"); - return; - } - send_release( - m_resource->handle); - } - - void wl_buffer::send_release(struct ::wl_resource *resource) - { - wl_buffer_send_release( - resource); - } - - - wl_data_offer::wl_data_offer(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_data_offer::wl_data_offer(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_data_offer::wl_data_offer(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_data_offer::wl_data_offer() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_data_offer::~wl_data_offer() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_data_offer::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_data_offer::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_data_offer::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_data_offer::Resource *wl_data_offer::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_data_offer::Resource *wl_data_offer::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_data_offer::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_data_offer_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_data_offer::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_data_offer::interface() - { - return &::wl_data_offer_interface; - } - - wl_data_offer::Resource *wl_data_offer::data_offer_allocate() - { - return new Resource; - } - - void wl_data_offer::data_offer_bind_resource(Resource *) - { - } - - void wl_data_offer::data_offer_destroy_resource(Resource *) - { - } - - void wl_data_offer::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_data_offer *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_data_offer::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_data_offer *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_data_offer::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_data_offer *that = resource->data_offer_object; - that->m_resource_map.erase(resource->client()); - that->data_offer_destroy_resource(resource); - delete resource; - } - - wl_data_offer::Resource *wl_data_offer::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_data_offer_interface, version, id); - return bind(handle); - } - - wl_data_offer::Resource *wl_data_offer::bind(struct ::wl_resource *handle) - { - Resource *resource = data_offer_allocate(); - resource->data_offer_object = this; - - wl_resource_set_implementation(handle, &m_wl_data_offer_interface, resource, destroy_func); - resource->handle = handle; - data_offer_bind_resource(resource); - return resource; - } - wl_data_offer::Resource *wl_data_offer::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_data_offer_interface, &m_wl_data_offer_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_data_offer_interface wl_data_offer::m_wl_data_offer_interface = { - wl_data_offer::handle_accept, - wl_data_offer::handle_receive, - wl_data_offer::handle_destroy, - wl_data_offer::handle_finish, - wl_data_offer::handle_set_actions - }; - - void wl_data_offer::data_offer_accept(Resource *, uint32_t , const std::string &) - { - } - - void wl_data_offer::data_offer_receive(Resource *, const std::string &, int32_t ) - { - } - - void wl_data_offer::data_offer_destroy(Resource *) - { - } - - void wl_data_offer::data_offer_finish(Resource *) - { - } - - void wl_data_offer::data_offer_set_actions(Resource *, uint32_t , uint32_t ) - { - } - - - void wl_data_offer::handle_accept( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *mime_type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_offer_object)->data_offer_accept( - r, - serial, - std::string(mime_type)); - } - - void wl_data_offer::handle_receive( - ::wl_client *client, - struct wl_resource *resource, - const char *mime_type, - int32_t fd) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_offer_object)->data_offer_receive( - r, - std::string(mime_type), - fd); - } - - void wl_data_offer::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_offer_object)->data_offer_destroy( - r); - } - - void wl_data_offer::handle_finish( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_offer_object)->data_offer_finish( - r); - } - - void wl_data_offer::handle_set_actions( - ::wl_client *client, - struct wl_resource *resource, - uint32_t dnd_actions, - uint32_t preferred_action) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_offer_object)->data_offer_set_actions( - r, - dnd_actions, - preferred_action); - } - - void wl_data_offer::send_offer(const std::string &mime_type) - { - DS_ASSERT_X(m_resource, "wl_data_offer::offer", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_offer::offer as it's not initialised"); - return; - } - send_offer( - m_resource->handle, - mime_type); - } - - void wl_data_offer::send_offer(struct ::wl_resource *resource, const std::string &mime_type) - { - wl_data_offer_send_offer( - resource, - mime_type.c_str()); - } - - - void wl_data_offer::send_source_actions(uint32_t source_actions) - { - DS_ASSERT_X(m_resource, "wl_data_offer::source_actions", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_offer::source_actions as it's not initialised"); - return; - } - send_source_actions( - m_resource->handle, - source_actions); - } - - void wl_data_offer::send_source_actions(struct ::wl_resource *resource, uint32_t source_actions) - { - wl_data_offer_send_source_actions( - resource, - source_actions); - } - - - void wl_data_offer::send_action(uint32_t dnd_action) - { - DS_ASSERT_X(m_resource, "wl_data_offer::action", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_offer::action as it's not initialised"); - return; - } - send_action( - m_resource->handle, - dnd_action); - } - - void wl_data_offer::send_action(struct ::wl_resource *resource, uint32_t dnd_action) - { - wl_data_offer_send_action( - resource, - dnd_action); - } - - - wl_data_source::wl_data_source(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_data_source::wl_data_source(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_data_source::wl_data_source(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_data_source::wl_data_source() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_data_source::~wl_data_source() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_data_source::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_data_source::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_data_source::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_data_source::Resource *wl_data_source::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_data_source::Resource *wl_data_source::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_data_source::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_data_source_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_data_source::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_data_source::interface() - { - return &::wl_data_source_interface; - } - - wl_data_source::Resource *wl_data_source::data_source_allocate() - { - return new Resource; - } - - void wl_data_source::data_source_bind_resource(Resource *) - { - } - - void wl_data_source::data_source_destroy_resource(Resource *) - { - } - - void wl_data_source::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_data_source *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_data_source::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_data_source *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_data_source::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_data_source *that = resource->data_source_object; - that->m_resource_map.erase(resource->client()); - that->data_source_destroy_resource(resource); - delete resource; - } - - wl_data_source::Resource *wl_data_source::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_data_source_interface, version, id); - return bind(handle); - } - - wl_data_source::Resource *wl_data_source::bind(struct ::wl_resource *handle) - { - Resource *resource = data_source_allocate(); - resource->data_source_object = this; - - wl_resource_set_implementation(handle, &m_wl_data_source_interface, resource, destroy_func); - resource->handle = handle; - data_source_bind_resource(resource); - return resource; - } - wl_data_source::Resource *wl_data_source::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_data_source_interface, &m_wl_data_source_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_data_source_interface wl_data_source::m_wl_data_source_interface = { - wl_data_source::handle_offer, - wl_data_source::handle_destroy, - wl_data_source::handle_set_actions - }; - - void wl_data_source::data_source_offer(Resource *, const std::string &) - { - } - - void wl_data_source::data_source_destroy(Resource *) - { - } - - void wl_data_source::data_source_set_actions(Resource *, uint32_t ) - { - } - - - void wl_data_source::handle_offer( - ::wl_client *client, - struct wl_resource *resource, - const char *mime_type) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_source_object)->data_source_offer( - r, - std::string(mime_type)); - } - - void wl_data_source::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_source_object)->data_source_destroy( - r); - } - - void wl_data_source::handle_set_actions( - ::wl_client *client, - struct wl_resource *resource, - uint32_t dnd_actions) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_source_object)->data_source_set_actions( - r, - dnd_actions); - } - - void wl_data_source::send_target(const std::string &mime_type) - { - DS_ASSERT_X(m_resource, "wl_data_source::target", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_source::target as it's not initialised"); - return; - } - send_target( - m_resource->handle, - mime_type); - } - - void wl_data_source::send_target(struct ::wl_resource *resource, const std::string &mime_type) - { - wl_data_source_send_target( - resource, - mime_type.c_str()); - } - - - void wl_data_source::send_send(const std::string &mime_type, int32_t fd) - { - DS_ASSERT_X(m_resource, "wl_data_source::send", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_source::send as it's not initialised"); - return; - } - send_send( - m_resource->handle, - mime_type, - fd); - } - - void wl_data_source::send_send(struct ::wl_resource *resource, const std::string &mime_type, int32_t fd) - { - wl_data_source_send_send( - resource, - mime_type.c_str(), - fd); - } - - - void wl_data_source::send_cancelled() - { - DS_ASSERT_X(m_resource, "wl_data_source::cancelled", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_source::cancelled as it's not initialised"); - return; - } - send_cancelled( - m_resource->handle); - } - - void wl_data_source::send_cancelled(struct ::wl_resource *resource) - { - wl_data_source_send_cancelled( - resource); - } - - - void wl_data_source::send_dnd_drop_performed() - { - DS_ASSERT_X(m_resource, "wl_data_source::dnd_drop_performed", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_source::dnd_drop_performed as it's not initialised"); - return; - } - send_dnd_drop_performed( - m_resource->handle); - } - - void wl_data_source::send_dnd_drop_performed(struct ::wl_resource *resource) - { - wl_data_source_send_dnd_drop_performed( - resource); - } - - - void wl_data_source::send_dnd_finished() - { - DS_ASSERT_X(m_resource, "wl_data_source::dnd_finished", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_source::dnd_finished as it's not initialised"); - return; - } - send_dnd_finished( - m_resource->handle); - } - - void wl_data_source::send_dnd_finished(struct ::wl_resource *resource) - { - wl_data_source_send_dnd_finished( - resource); - } - - - void wl_data_source::send_action(uint32_t dnd_action) - { - DS_ASSERT_X(m_resource, "wl_data_source::action", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_source::action as it's not initialised"); - return; - } - send_action( - m_resource->handle, - dnd_action); - } - - void wl_data_source::send_action(struct ::wl_resource *resource, uint32_t dnd_action) - { - wl_data_source_send_action( - resource, - dnd_action); - } - - - wl_data_device::wl_data_device(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_data_device::wl_data_device(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_data_device::wl_data_device(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_data_device::wl_data_device() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_data_device::~wl_data_device() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_data_device::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_data_device::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_data_device::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_data_device::Resource *wl_data_device::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_data_device::Resource *wl_data_device::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_data_device::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_data_device_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_data_device::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_data_device::interface() - { - return &::wl_data_device_interface; - } - - wl_data_device::Resource *wl_data_device::data_device_allocate() - { - return new Resource; - } - - void wl_data_device::data_device_bind_resource(Resource *) - { - } - - void wl_data_device::data_device_destroy_resource(Resource *) - { - } - - void wl_data_device::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_data_device *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_data_device::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_data_device *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_data_device::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_data_device *that = resource->data_device_object; - that->m_resource_map.erase(resource->client()); - that->data_device_destroy_resource(resource); - delete resource; - } - - wl_data_device::Resource *wl_data_device::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_data_device_interface, version, id); - return bind(handle); - } - - wl_data_device::Resource *wl_data_device::bind(struct ::wl_resource *handle) - { - Resource *resource = data_device_allocate(); - resource->data_device_object = this; - - wl_resource_set_implementation(handle, &m_wl_data_device_interface, resource, destroy_func); - resource->handle = handle; - data_device_bind_resource(resource); - return resource; - } - wl_data_device::Resource *wl_data_device::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_data_device_interface, &m_wl_data_device_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_data_device_interface wl_data_device::m_wl_data_device_interface = { - wl_data_device::handle_start_drag, - wl_data_device::handle_set_selection, - wl_data_device::handle_release - }; - - void wl_data_device::data_device_start_drag(Resource *, struct ::wl_resource *, struct ::wl_resource *, struct ::wl_resource *, uint32_t ) - { - } - - void wl_data_device::data_device_set_selection(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void wl_data_device::data_device_release(Resource *) - { - } - - - void wl_data_device::handle_start_drag( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *source, - struct ::wl_resource *origin, - struct ::wl_resource *icon, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_device_object)->data_device_start_drag( - r, - source, - origin, - icon, - serial); - } - - void wl_data_device::handle_set_selection( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *source, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_device_object)->data_device_set_selection( - r, - source, - serial); - } - - void wl_data_device::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_device_object)->data_device_release( - r); - } - - void wl_data_device::send_data_offer(struct ::wl_resource *id) - { - DS_ASSERT_X(m_resource, "wl_data_device::data_offer", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_device::data_offer as it's not initialised"); - return; - } - send_data_offer( - m_resource->handle, - id); - } - - void wl_data_device::send_data_offer(struct ::wl_resource *resource, struct ::wl_resource *id) - { - wl_data_device_send_data_offer( - resource, - id); - } - - - void wl_data_device::send_enter(uint32_t serial, struct ::wl_resource *surface, wl_fixed_t x, wl_fixed_t y, struct ::wl_resource *id) - { - DS_ASSERT_X(m_resource, "wl_data_device::enter", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_device::enter as it's not initialised"); - return; - } - send_enter( - m_resource->handle, - serial, - surface, - x, - y, - id); - } - - void wl_data_device::send_enter(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface, wl_fixed_t x, wl_fixed_t y, struct ::wl_resource *id) - { - wl_data_device_send_enter( - resource, - serial, - surface, - x, - y, - id); - } - - - void wl_data_device::send_leave() - { - DS_ASSERT_X(m_resource, "wl_data_device::leave", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_device::leave as it's not initialised"); - return; - } - send_leave( - m_resource->handle); - } - - void wl_data_device::send_leave(struct ::wl_resource *resource) - { - wl_data_device_send_leave( - resource); - } - - - void wl_data_device::send_motion(uint32_t time, wl_fixed_t x, wl_fixed_t y) - { - DS_ASSERT_X(m_resource, "wl_data_device::motion", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_device::motion as it's not initialised"); - return; - } - send_motion( - m_resource->handle, - time, - x, - y); - } - - void wl_data_device::send_motion(struct ::wl_resource *resource, uint32_t time, wl_fixed_t x, wl_fixed_t y) - { - wl_data_device_send_motion( - resource, - time, - x, - y); - } - - - void wl_data_device::send_drop() - { - DS_ASSERT_X(m_resource, "wl_data_device::drop", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_device::drop as it's not initialised"); - return; - } - send_drop( - m_resource->handle); - } - - void wl_data_device::send_drop(struct ::wl_resource *resource) - { - wl_data_device_send_drop( - resource); - } - - - void wl_data_device::send_selection(struct ::wl_resource *id) - { - DS_ASSERT_X(m_resource, "wl_data_device::selection", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_data_device::selection as it's not initialised"); - return; - } - send_selection( - m_resource->handle, - id); - } - - void wl_data_device::send_selection(struct ::wl_resource *resource, struct ::wl_resource *id) - { - wl_data_device_send_selection( - resource, - id); - } - - - wl_data_device_manager::wl_data_device_manager(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_data_device_manager::wl_data_device_manager(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_data_device_manager::wl_data_device_manager(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_data_device_manager::wl_data_device_manager() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_data_device_manager::~wl_data_device_manager() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_data_device_manager::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_data_device_manager::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_data_device_manager::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_data_device_manager::Resource *wl_data_device_manager::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_data_device_manager::Resource *wl_data_device_manager::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_data_device_manager::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_data_device_manager_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_data_device_manager::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_data_device_manager::interface() - { - return &::wl_data_device_manager_interface; - } - - wl_data_device_manager::Resource *wl_data_device_manager::data_device_manager_allocate() - { - return new Resource; - } - - void wl_data_device_manager::data_device_manager_bind_resource(Resource *) - { - } - - void wl_data_device_manager::data_device_manager_destroy_resource(Resource *) - { - } - - void wl_data_device_manager::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_data_device_manager *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_data_device_manager::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_data_device_manager *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_data_device_manager::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_data_device_manager *that = resource->data_device_manager_object; - that->m_resource_map.erase(resource->client()); - that->data_device_manager_destroy_resource(resource); - delete resource; - } - - wl_data_device_manager::Resource *wl_data_device_manager::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_data_device_manager_interface, version, id); - return bind(handle); - } - - wl_data_device_manager::Resource *wl_data_device_manager::bind(struct ::wl_resource *handle) - { - Resource *resource = data_device_manager_allocate(); - resource->data_device_manager_object = this; - - wl_resource_set_implementation(handle, &m_wl_data_device_manager_interface, resource, destroy_func); - resource->handle = handle; - data_device_manager_bind_resource(resource); - return resource; - } - wl_data_device_manager::Resource *wl_data_device_manager::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_data_device_manager_interface, &m_wl_data_device_manager_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_data_device_manager_interface wl_data_device_manager::m_wl_data_device_manager_interface = { - wl_data_device_manager::handle_create_data_source, - wl_data_device_manager::handle_get_data_device - }; - - void wl_data_device_manager::data_device_manager_create_data_source(Resource *, uint32_t) - { - } - - void wl_data_device_manager::data_device_manager_get_data_device(Resource *, uint32_t, struct ::wl_resource *) - { - } - - - void wl_data_device_manager::handle_create_data_source( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_device_manager_object)->data_device_manager_create_data_source( - r, - id); - } - - void wl_data_device_manager::handle_get_data_device( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *seat) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->data_device_manager_object)->data_device_manager_get_data_device( - r, - id, - seat); - } - - wl_shell::wl_shell(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_shell::wl_shell(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_shell::wl_shell(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_shell::wl_shell() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_shell::~wl_shell() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_shell::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_shell::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_shell::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_shell::Resource *wl_shell::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_shell::Resource *wl_shell::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_shell::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_shell_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_shell::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_shell::interface() - { - return &::wl_shell_interface; - } - - wl_shell::Resource *wl_shell::shell_allocate() - { - return new Resource; - } - - void wl_shell::shell_bind_resource(Resource *) - { - } - - void wl_shell::shell_destroy_resource(Resource *) - { - } - - void wl_shell::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_shell *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_shell::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_shell *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_shell::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_shell *that = resource->shell_object; - that->m_resource_map.erase(resource->client()); - that->shell_destroy_resource(resource); - delete resource; - } - - wl_shell::Resource *wl_shell::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_shell_interface, version, id); - return bind(handle); - } - - wl_shell::Resource *wl_shell::bind(struct ::wl_resource *handle) - { - Resource *resource = shell_allocate(); - resource->shell_object = this; - - wl_resource_set_implementation(handle, &m_wl_shell_interface, resource, destroy_func); - resource->handle = handle; - shell_bind_resource(resource); - return resource; - } - wl_shell::Resource *wl_shell::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_shell_interface, &m_wl_shell_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_shell_interface wl_shell::m_wl_shell_interface = { - wl_shell::handle_get_shell_surface - }; - - void wl_shell::shell_get_shell_surface(Resource *, uint32_t, struct ::wl_resource *) - { - } - - - void wl_shell::handle_get_shell_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_object)->shell_get_shell_surface( - r, - id, - surface); - } - - wl_shell_surface::wl_shell_surface(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_shell_surface::wl_shell_surface(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_shell_surface::wl_shell_surface(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_shell_surface::wl_shell_surface() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_shell_surface::~wl_shell_surface() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_shell_surface::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_shell_surface::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_shell_surface::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_shell_surface::Resource *wl_shell_surface::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_shell_surface::Resource *wl_shell_surface::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_shell_surface::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_shell_surface_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_shell_surface::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_shell_surface::interface() - { - return &::wl_shell_surface_interface; - } - - wl_shell_surface::Resource *wl_shell_surface::shell_surface_allocate() - { - return new Resource; - } - - void wl_shell_surface::shell_surface_bind_resource(Resource *) - { - } - - void wl_shell_surface::shell_surface_destroy_resource(Resource *) - { - } - - void wl_shell_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_shell_surface *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_shell_surface::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_shell_surface *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_shell_surface::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_shell_surface *that = resource->shell_surface_object; - that->m_resource_map.erase(resource->client()); - that->shell_surface_destroy_resource(resource); - delete resource; - } - - wl_shell_surface::Resource *wl_shell_surface::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_shell_surface_interface, version, id); - return bind(handle); - } - - wl_shell_surface::Resource *wl_shell_surface::bind(struct ::wl_resource *handle) - { - Resource *resource = shell_surface_allocate(); - resource->shell_surface_object = this; - - wl_resource_set_implementation(handle, &m_wl_shell_surface_interface, resource, destroy_func); - resource->handle = handle; - shell_surface_bind_resource(resource); - return resource; - } - wl_shell_surface::Resource *wl_shell_surface::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_shell_surface_interface, &m_wl_shell_surface_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_shell_surface_interface wl_shell_surface::m_wl_shell_surface_interface = { - wl_shell_surface::handle_pong, - wl_shell_surface::handle_move, - wl_shell_surface::handle_resize, - wl_shell_surface::handle_set_toplevel, - wl_shell_surface::handle_set_transient, - wl_shell_surface::handle_set_fullscreen, - wl_shell_surface::handle_set_popup, - wl_shell_surface::handle_set_maximized, - wl_shell_surface::handle_set_title, - wl_shell_surface::handle_set_class - }; - - void wl_shell_surface::shell_surface_pong(Resource *, uint32_t ) - { - } - - void wl_shell_surface::shell_surface_move(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void wl_shell_surface::shell_surface_resize(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) - { - } - - void wl_shell_surface::shell_surface_set_toplevel(Resource *) - { - } - - void wl_shell_surface::shell_surface_set_transient(Resource *, struct ::wl_resource *, int32_t , int32_t , uint32_t ) - { - } - - void wl_shell_surface::shell_surface_set_fullscreen(Resource *, uint32_t , uint32_t , struct ::wl_resource *) - { - } - - void wl_shell_surface::shell_surface_set_popup(Resource *, struct ::wl_resource *, uint32_t , struct ::wl_resource *, int32_t , int32_t , uint32_t ) - { - } - - void wl_shell_surface::shell_surface_set_maximized(Resource *, struct ::wl_resource *) - { - } - - void wl_shell_surface::shell_surface_set_title(Resource *, const std::string &) - { - } - - void wl_shell_surface::shell_surface_set_class(Resource *, const std::string &) - { - } - - - void wl_shell_surface::handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_pong( - r, - serial); - } - - void wl_shell_surface::handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_move( - r, - seat, - serial); - } - - void wl_shell_surface::handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_resize( - r, - seat, - serial, - edges); - } - - void wl_shell_surface::handle_set_toplevel( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_set_toplevel( - r); - } - - void wl_shell_surface::handle_set_transient( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent, - int32_t x, - int32_t y, - uint32_t flags) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_set_transient( - r, - parent, - x, - y, - flags); - } - - void wl_shell_surface::handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - uint32_t method, - uint32_t framerate, - struct ::wl_resource *output) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_set_fullscreen( - r, - method, - framerate, - output); - } - - void wl_shell_surface::handle_set_popup( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - struct ::wl_resource *parent, - int32_t x, - int32_t y, - uint32_t flags) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_set_popup( - r, - seat, - serial, - parent, - x, - y, - flags); - } - - void wl_shell_surface::handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_set_maximized( - r, - output); - } - - void wl_shell_surface::handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_set_title( - r, - std::string(title)); - } - - void wl_shell_surface::handle_set_class( - ::wl_client *client, - struct wl_resource *resource, - const char *class_) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->shell_surface_object)->shell_surface_set_class( - r, - std::string(class_)); - } - - void wl_shell_surface::send_ping(uint32_t serial) - { - DS_ASSERT_X(m_resource, "wl_shell_surface::ping", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_shell_surface::ping as it's not initialised"); - return; - } - send_ping( - m_resource->handle, - serial); - } - - void wl_shell_surface::send_ping(struct ::wl_resource *resource, uint32_t serial) - { - wl_shell_surface_send_ping( - resource, - serial); - } - - - void wl_shell_surface::send_configure(uint32_t edges, int32_t width, int32_t height) - { - DS_ASSERT_X(m_resource, "wl_shell_surface::configure", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_shell_surface::configure as it's not initialised"); - return; - } - send_configure( - m_resource->handle, - edges, - width, - height); - } - - void wl_shell_surface::send_configure(struct ::wl_resource *resource, uint32_t edges, int32_t width, int32_t height) - { - wl_shell_surface_send_configure( - resource, - edges, - width, - height); - } - - - void wl_shell_surface::send_popup_done() - { - DS_ASSERT_X(m_resource, "wl_shell_surface::popup_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_shell_surface::popup_done as it's not initialised"); - return; - } - send_popup_done( - m_resource->handle); - } - - void wl_shell_surface::send_popup_done(struct ::wl_resource *resource) - { - wl_shell_surface_send_popup_done( - resource); - } - - - wl_surface::wl_surface(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_surface::wl_surface(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_surface::wl_surface(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_surface::wl_surface() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_surface::~wl_surface() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_surface::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_surface::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_surface::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_surface::Resource *wl_surface::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_surface::Resource *wl_surface::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_surface::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_surface_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_surface::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_surface::interface() - { - return &::wl_surface_interface; - } - - wl_surface::Resource *wl_surface::surface_allocate() - { - return new Resource; - } - - void wl_surface::surface_bind_resource(Resource *) - { - } - - void wl_surface::surface_destroy_resource(Resource *) - { - } - - void wl_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_surface *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_surface::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_surface *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_surface::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_surface *that = resource->surface_object; - that->m_resource_map.erase(resource->client()); - that->surface_destroy_resource(resource); - delete resource; - } - - wl_surface::Resource *wl_surface::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_surface_interface, version, id); - return bind(handle); - } - - wl_surface::Resource *wl_surface::bind(struct ::wl_resource *handle) - { - Resource *resource = surface_allocate(); - resource->surface_object = this; - - wl_resource_set_implementation(handle, &m_wl_surface_interface, resource, destroy_func); - resource->handle = handle; - surface_bind_resource(resource); - return resource; - } - wl_surface::Resource *wl_surface::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_surface_interface, &m_wl_surface_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_surface_interface wl_surface::m_wl_surface_interface = { - wl_surface::handle_destroy, - wl_surface::handle_attach, - wl_surface::handle_damage, - wl_surface::handle_frame, - wl_surface::handle_set_opaque_region, - wl_surface::handle_set_input_region, - wl_surface::handle_commit, - wl_surface::handle_set_buffer_transform, - wl_surface::handle_set_buffer_scale, - wl_surface::handle_damage_buffer - }; - - void wl_surface::surface_destroy(Resource *) - { - } - - void wl_surface::surface_attach(Resource *, struct ::wl_resource *, int32_t , int32_t ) - { - } - - void wl_surface::surface_damage(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void wl_surface::surface_frame(Resource *, uint32_t) - { - } - - void wl_surface::surface_set_opaque_region(Resource *, struct ::wl_resource *) - { - } - - void wl_surface::surface_set_input_region(Resource *, struct ::wl_resource *) - { - } - - void wl_surface::surface_commit(Resource *) - { - } - - void wl_surface::surface_set_buffer_transform(Resource *, int32_t ) - { - } - - void wl_surface::surface_set_buffer_scale(Resource *, int32_t ) - { - } - - void wl_surface::surface_damage_buffer(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - - void wl_surface::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_destroy( - r); - } - - void wl_surface::handle_attach( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *buffer, - int32_t x, - int32_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_attach( - r, - buffer, - x, - y); - } - - void wl_surface::handle_damage( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_damage( - r, - x, - y, - width, - height); - } - - void wl_surface::handle_frame( - ::wl_client *client, - struct wl_resource *resource, - uint32_t callback) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_frame( - r, - callback); - } - - void wl_surface::handle_set_opaque_region( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *region) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_set_opaque_region( - r, - region); - } - - void wl_surface::handle_set_input_region( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *region) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_set_input_region( - r, - region); - } - - void wl_surface::handle_commit( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_commit( - r); - } - - void wl_surface::handle_set_buffer_transform( - ::wl_client *client, - struct wl_resource *resource, - int32_t transform) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_set_buffer_transform( - r, - transform); - } - - void wl_surface::handle_set_buffer_scale( - ::wl_client *client, - struct wl_resource *resource, - int32_t scale) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_set_buffer_scale( - r, - scale); - } - - void wl_surface::handle_damage_buffer( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->surface_object)->surface_damage_buffer( - r, - x, - y, - width, - height); - } - - void wl_surface::send_enter(struct ::wl_resource *output) - { - DS_ASSERT_X(m_resource, "wl_surface::enter", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_surface::enter as it's not initialised"); - return; - } - send_enter( - m_resource->handle, - output); - } - - void wl_surface::send_enter(struct ::wl_resource *resource, struct ::wl_resource *output) - { - wl_surface_send_enter( - resource, - output); - } - - - void wl_surface::send_leave(struct ::wl_resource *output) - { - DS_ASSERT_X(m_resource, "wl_surface::leave", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_surface::leave as it's not initialised"); - return; - } - send_leave( - m_resource->handle, - output); - } - - void wl_surface::send_leave(struct ::wl_resource *resource, struct ::wl_resource *output) - { - wl_surface_send_leave( - resource, - output); - } - - - wl_seat::wl_seat(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_seat::wl_seat(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_seat::wl_seat(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_seat::wl_seat() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_seat::~wl_seat() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_seat::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_seat::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_seat::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_seat::Resource *wl_seat::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_seat::Resource *wl_seat::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_seat::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_seat_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_seat::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_seat::interface() - { - return &::wl_seat_interface; - } - - wl_seat::Resource *wl_seat::seat_allocate() - { - return new Resource; - } - - void wl_seat::seat_bind_resource(Resource *) - { - } - - void wl_seat::seat_destroy_resource(Resource *) - { - } - - void wl_seat::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_seat *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_seat::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_seat *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_seat::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_seat *that = resource->seat_object; - that->m_resource_map.erase(resource->client()); - that->seat_destroy_resource(resource); - delete resource; - } - - wl_seat::Resource *wl_seat::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_seat_interface, version, id); - return bind(handle); - } - - wl_seat::Resource *wl_seat::bind(struct ::wl_resource *handle) - { - Resource *resource = seat_allocate(); - resource->seat_object = this; - - wl_resource_set_implementation(handle, &m_wl_seat_interface, resource, destroy_func); - resource->handle = handle; - seat_bind_resource(resource); - return resource; - } - wl_seat::Resource *wl_seat::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_seat_interface, &m_wl_seat_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_seat_interface wl_seat::m_wl_seat_interface = { - wl_seat::handle_get_pointer, - wl_seat::handle_get_keyboard, - wl_seat::handle_get_touch, - wl_seat::handle_release - }; - - void wl_seat::seat_get_pointer(Resource *, uint32_t) - { - } - - void wl_seat::seat_get_keyboard(Resource *, uint32_t) - { - } - - void wl_seat::seat_get_touch(Resource *, uint32_t) - { - } - - void wl_seat::seat_release(Resource *) - { - } - - - void wl_seat::handle_get_pointer( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->seat_object)->seat_get_pointer( - r, - id); - } - - void wl_seat::handle_get_keyboard( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->seat_object)->seat_get_keyboard( - r, - id); - } - - void wl_seat::handle_get_touch( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->seat_object)->seat_get_touch( - r, - id); - } - - void wl_seat::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->seat_object)->seat_release( - r); - } - - void wl_seat::send_capabilities(uint32_t capabilities) - { - DS_ASSERT_X(m_resource, "wl_seat::capabilities", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_seat::capabilities as it's not initialised"); - return; - } - send_capabilities( - m_resource->handle, - capabilities); - } - - void wl_seat::send_capabilities(struct ::wl_resource *resource, uint32_t capabilities) - { - wl_seat_send_capabilities( - resource, - capabilities); - } - - - void wl_seat::send_name(const std::string &name) - { - DS_ASSERT_X(m_resource, "wl_seat::name", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_seat::name as it's not initialised"); - return; - } - send_name( - m_resource->handle, - name); - } - - void wl_seat::send_name(struct ::wl_resource *resource, const std::string &name) - { - wl_seat_send_name( - resource, - name.c_str()); - } - - - wl_pointer::wl_pointer(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_pointer::wl_pointer(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_pointer::wl_pointer(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_pointer::wl_pointer() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_pointer::~wl_pointer() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_pointer::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_pointer::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_pointer::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_pointer::Resource *wl_pointer::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_pointer::Resource *wl_pointer::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_pointer::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_pointer_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_pointer::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_pointer::interface() - { - return &::wl_pointer_interface; - } - - wl_pointer::Resource *wl_pointer::pointer_allocate() - { - return new Resource; - } - - void wl_pointer::pointer_bind_resource(Resource *) - { - } - - void wl_pointer::pointer_destroy_resource(Resource *) - { - } - - void wl_pointer::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_pointer *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_pointer::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_pointer *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_pointer::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_pointer *that = resource->pointer_object; - that->m_resource_map.erase(resource->client()); - that->pointer_destroy_resource(resource); - delete resource; - } - - wl_pointer::Resource *wl_pointer::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_pointer_interface, version, id); - return bind(handle); - } - - wl_pointer::Resource *wl_pointer::bind(struct ::wl_resource *handle) - { - Resource *resource = pointer_allocate(); - resource->pointer_object = this; - - wl_resource_set_implementation(handle, &m_wl_pointer_interface, resource, destroy_func); - resource->handle = handle; - pointer_bind_resource(resource); - return resource; - } - wl_pointer::Resource *wl_pointer::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_pointer_interface, &m_wl_pointer_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_pointer_interface wl_pointer::m_wl_pointer_interface = { - wl_pointer::handle_set_cursor, - wl_pointer::handle_release - }; - - void wl_pointer::pointer_set_cursor(Resource *, uint32_t , struct ::wl_resource *, int32_t , int32_t ) - { - } - - void wl_pointer::pointer_release(Resource *) - { - } - - - void wl_pointer::handle_set_cursor( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - struct ::wl_resource *surface, - int32_t hotspot_x, - int32_t hotspot_y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->pointer_object)->pointer_set_cursor( - r, - serial, - surface, - hotspot_x, - hotspot_y); - } - - void wl_pointer::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->pointer_object)->pointer_release( - r); - } - - void wl_pointer::send_enter(uint32_t serial, struct ::wl_resource *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) - { - DS_ASSERT_X(m_resource, "wl_pointer::enter", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::enter as it's not initialised"); - return; - } - send_enter( - m_resource->handle, - serial, - surface, - surface_x, - surface_y); - } - - void wl_pointer::send_enter(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) - { - wl_pointer_send_enter( - resource, - serial, - surface, - surface_x, - surface_y); - } - - - void wl_pointer::send_leave(uint32_t serial, struct ::wl_resource *surface) - { - DS_ASSERT_X(m_resource, "wl_pointer::leave", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::leave as it's not initialised"); - return; - } - send_leave( - m_resource->handle, - serial, - surface); - } - - void wl_pointer::send_leave(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface) - { - wl_pointer_send_leave( - resource, - serial, - surface); - } - - - void wl_pointer::send_motion(uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) - { - DS_ASSERT_X(m_resource, "wl_pointer::motion", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::motion as it's not initialised"); - return; - } - send_motion( - m_resource->handle, - time, - surface_x, - surface_y); - } - - void wl_pointer::send_motion(struct ::wl_resource *resource, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) - { - wl_pointer_send_motion( - resource, - time, - surface_x, - surface_y); - } - - - void wl_pointer::send_button(uint32_t serial, uint32_t time, uint32_t button, uint32_t state) - { - DS_ASSERT_X(m_resource, "wl_pointer::button", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::button as it's not initialised"); - return; - } - send_button( - m_resource->handle, - serial, - time, - button, - state); - } - - void wl_pointer::send_button(struct ::wl_resource *resource, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) - { - wl_pointer_send_button( - resource, - serial, - time, - button, - state); - } - - - void wl_pointer::send_axis(uint32_t time, uint32_t axis, wl_fixed_t value) - { - DS_ASSERT_X(m_resource, "wl_pointer::axis", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::axis as it's not initialised"); - return; - } - send_axis( - m_resource->handle, - time, - axis, - value); - } - - void wl_pointer::send_axis(struct ::wl_resource *resource, uint32_t time, uint32_t axis, wl_fixed_t value) - { - wl_pointer_send_axis( - resource, - time, - axis, - value); - } - - - void wl_pointer::send_frame() - { - DS_ASSERT_X(m_resource, "wl_pointer::frame", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::frame as it's not initialised"); - return; - } - send_frame( - m_resource->handle); - } - - void wl_pointer::send_frame(struct ::wl_resource *resource) - { - wl_pointer_send_frame( - resource); - } - - - void wl_pointer::send_axis_source(uint32_t axis_source) - { - DS_ASSERT_X(m_resource, "wl_pointer::axis_source", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::axis_source as it's not initialised"); - return; - } - send_axis_source( - m_resource->handle, - axis_source); - } - - void wl_pointer::send_axis_source(struct ::wl_resource *resource, uint32_t axis_source) - { - wl_pointer_send_axis_source( - resource, - axis_source); - } - - - void wl_pointer::send_axis_stop(uint32_t time, uint32_t axis) - { - DS_ASSERT_X(m_resource, "wl_pointer::axis_stop", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::axis_stop as it's not initialised"); - return; - } - send_axis_stop( - m_resource->handle, - time, - axis); - } - - void wl_pointer::send_axis_stop(struct ::wl_resource *resource, uint32_t time, uint32_t axis) - { - wl_pointer_send_axis_stop( - resource, - time, - axis); - } - - - void wl_pointer::send_axis_discrete(uint32_t axis, int32_t discrete) - { - DS_ASSERT_X(m_resource, "wl_pointer::axis_discrete", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_pointer::axis_discrete as it's not initialised"); - return; - } - send_axis_discrete( - m_resource->handle, - axis, - discrete); - } - - void wl_pointer::send_axis_discrete(struct ::wl_resource *resource, uint32_t axis, int32_t discrete) - { - wl_pointer_send_axis_discrete( - resource, - axis, - discrete); - } - - - wl_keyboard::wl_keyboard(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_keyboard::wl_keyboard(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_keyboard::wl_keyboard(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_keyboard::wl_keyboard() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_keyboard::~wl_keyboard() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_keyboard::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_keyboard::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_keyboard::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_keyboard::Resource *wl_keyboard::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_keyboard::Resource *wl_keyboard::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_keyboard::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_keyboard_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_keyboard::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_keyboard::interface() - { - return &::wl_keyboard_interface; - } - - wl_keyboard::Resource *wl_keyboard::keyboard_allocate() - { - return new Resource; - } - - void wl_keyboard::keyboard_bind_resource(Resource *) - { - } - - void wl_keyboard::keyboard_destroy_resource(Resource *) - { - } - - void wl_keyboard::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_keyboard *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_keyboard::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_keyboard *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_keyboard::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_keyboard *that = resource->keyboard_object; - that->m_resource_map.erase(resource->client()); - that->keyboard_destroy_resource(resource); - delete resource; - } - - wl_keyboard::Resource *wl_keyboard::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_keyboard_interface, version, id); - return bind(handle); - } - - wl_keyboard::Resource *wl_keyboard::bind(struct ::wl_resource *handle) - { - Resource *resource = keyboard_allocate(); - resource->keyboard_object = this; - - wl_resource_set_implementation(handle, &m_wl_keyboard_interface, resource, destroy_func); - resource->handle = handle; - keyboard_bind_resource(resource); - return resource; - } - wl_keyboard::Resource *wl_keyboard::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_keyboard_interface, &m_wl_keyboard_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_keyboard_interface wl_keyboard::m_wl_keyboard_interface = { - wl_keyboard::handle_release - }; - - void wl_keyboard::keyboard_release(Resource *) - { - } - - - void wl_keyboard::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->keyboard_object)->keyboard_release( - r); - } - - void wl_keyboard::send_keymap(uint32_t format, int32_t fd, uint32_t size) - { - DS_ASSERT_X(m_resource, "wl_keyboard::keymap", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_keyboard::keymap as it's not initialised"); - return; - } - send_keymap( - m_resource->handle, - format, - fd, - size); - } - - void wl_keyboard::send_keymap(struct ::wl_resource *resource, uint32_t format, int32_t fd, uint32_t size) - { - wl_keyboard_send_keymap( - resource, - format, - fd, - size); - } - - - void wl_keyboard::send_enter(uint32_t serial, struct ::wl_resource *surface, struct ::wl_array *keys) - { - DS_ASSERT_X(m_resource, "wl_keyboard::enter", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_keyboard::enter as it's not initialised"); - return; - } - send_enter( - m_resource->handle, - serial, - surface, - keys); - } - - void wl_keyboard::send_enter(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface, struct ::wl_array *keys) - { - wl_keyboard_send_enter( - resource, - serial, - surface, - keys); - } - - - void wl_keyboard::send_leave(uint32_t serial, struct ::wl_resource *surface) - { - DS_ASSERT_X(m_resource, "wl_keyboard::leave", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_keyboard::leave as it's not initialised"); - return; - } - send_leave( - m_resource->handle, - serial, - surface); - } - - void wl_keyboard::send_leave(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface) - { - wl_keyboard_send_leave( - resource, - serial, - surface); - } - - - void wl_keyboard::send_key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state) - { - DS_ASSERT_X(m_resource, "wl_keyboard::key", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_keyboard::key as it's not initialised"); - return; - } - send_key( - m_resource->handle, - serial, - time, - key, - state); - } - - void wl_keyboard::send_key(struct ::wl_resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) - { - wl_keyboard_send_key( - resource, - serial, - time, - key, - state); - } - - - void wl_keyboard::send_modifiers(uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) - { - DS_ASSERT_X(m_resource, "wl_keyboard::modifiers", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_keyboard::modifiers as it's not initialised"); - return; - } - send_modifiers( - m_resource->handle, - serial, - mods_depressed, - mods_latched, - mods_locked, - group); - } - - void wl_keyboard::send_modifiers(struct ::wl_resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) - { - wl_keyboard_send_modifiers( - resource, - serial, - mods_depressed, - mods_latched, - mods_locked, - group); - } - - - void wl_keyboard::send_repeat_info(int32_t rate, int32_t delay) - { - DS_ASSERT_X(m_resource, "wl_keyboard::repeat_info", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_keyboard::repeat_info as it's not initialised"); - return; - } - send_repeat_info( - m_resource->handle, - rate, - delay); - } - - void wl_keyboard::send_repeat_info(struct ::wl_resource *resource, int32_t rate, int32_t delay) - { - wl_keyboard_send_repeat_info( - resource, - rate, - delay); - } - - - wl_touch::wl_touch(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_touch::wl_touch(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_touch::wl_touch(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_touch::wl_touch() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_touch::~wl_touch() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_touch::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_touch::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_touch::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_touch::Resource *wl_touch::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_touch::Resource *wl_touch::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_touch::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_touch_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_touch::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_touch::interface() - { - return &::wl_touch_interface; - } - - wl_touch::Resource *wl_touch::touch_allocate() - { - return new Resource; - } - - void wl_touch::touch_bind_resource(Resource *) - { - } - - void wl_touch::touch_destroy_resource(Resource *) - { - } - - void wl_touch::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_touch *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_touch::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_touch *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_touch::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_touch *that = resource->touch_object; - that->m_resource_map.erase(resource->client()); - that->touch_destroy_resource(resource); - delete resource; - } - - wl_touch::Resource *wl_touch::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_touch_interface, version, id); - return bind(handle); - } - - wl_touch::Resource *wl_touch::bind(struct ::wl_resource *handle) - { - Resource *resource = touch_allocate(); - resource->touch_object = this; - - wl_resource_set_implementation(handle, &m_wl_touch_interface, resource, destroy_func); - resource->handle = handle; - touch_bind_resource(resource); - return resource; - } - wl_touch::Resource *wl_touch::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_touch_interface, &m_wl_touch_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_touch_interface wl_touch::m_wl_touch_interface = { - wl_touch::handle_release - }; - - void wl_touch::touch_release(Resource *) - { - } - - - void wl_touch::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->touch_object)->touch_release( - r); - } - - void wl_touch::send_down(uint32_t serial, uint32_t time, struct ::wl_resource *surface, int32_t id, wl_fixed_t x, wl_fixed_t y) - { - DS_ASSERT_X(m_resource, "wl_touch::down", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_touch::down as it's not initialised"); - return; - } - send_down( - m_resource->handle, - serial, - time, - surface, - id, - x, - y); - } - - void wl_touch::send_down(struct ::wl_resource *resource, uint32_t serial, uint32_t time, struct ::wl_resource *surface, int32_t id, wl_fixed_t x, wl_fixed_t y) - { - wl_touch_send_down( - resource, - serial, - time, - surface, - id, - x, - y); - } - - - void wl_touch::send_up(uint32_t serial, uint32_t time, int32_t id) - { - DS_ASSERT_X(m_resource, "wl_touch::up", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_touch::up as it's not initialised"); - return; - } - send_up( - m_resource->handle, - serial, - time, - id); - } - - void wl_touch::send_up(struct ::wl_resource *resource, uint32_t serial, uint32_t time, int32_t id) - { - wl_touch_send_up( - resource, - serial, - time, - id); - } - - - void wl_touch::send_motion(uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y) - { - DS_ASSERT_X(m_resource, "wl_touch::motion", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_touch::motion as it's not initialised"); - return; - } - send_motion( - m_resource->handle, - time, - id, - x, - y); - } - - void wl_touch::send_motion(struct ::wl_resource *resource, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y) - { - wl_touch_send_motion( - resource, - time, - id, - x, - y); - } - - - void wl_touch::send_frame() - { - DS_ASSERT_X(m_resource, "wl_touch::frame", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_touch::frame as it's not initialised"); - return; - } - send_frame( - m_resource->handle); - } - - void wl_touch::send_frame(struct ::wl_resource *resource) - { - wl_touch_send_frame( - resource); - } - - - void wl_touch::send_cancel() - { - DS_ASSERT_X(m_resource, "wl_touch::cancel", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_touch::cancel as it's not initialised"); - return; - } - send_cancel( - m_resource->handle); - } - - void wl_touch::send_cancel(struct ::wl_resource *resource) - { - wl_touch_send_cancel( - resource); - } - - - void wl_touch::send_shape(int32_t id, wl_fixed_t major, wl_fixed_t minor) - { - DS_ASSERT_X(m_resource, "wl_touch::shape", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_touch::shape as it's not initialised"); - return; - } - send_shape( - m_resource->handle, - id, - major, - minor); - } - - void wl_touch::send_shape(struct ::wl_resource *resource, int32_t id, wl_fixed_t major, wl_fixed_t minor) - { - wl_touch_send_shape( - resource, - id, - major, - minor); - } - - - void wl_touch::send_orientation(int32_t id, wl_fixed_t orientation) - { - DS_ASSERT_X(m_resource, "wl_touch::orientation", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_touch::orientation as it's not initialised"); - return; - } - send_orientation( - m_resource->handle, - id, - orientation); - } - - void wl_touch::send_orientation(struct ::wl_resource *resource, int32_t id, wl_fixed_t orientation) - { - wl_touch_send_orientation( - resource, - id, - orientation); - } - - - wl_output::wl_output(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_output::wl_output(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_output::wl_output(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_output::wl_output() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_output::~wl_output() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_output::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_output::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_output::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_output::Resource *wl_output::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_output::Resource *wl_output::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_output::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_output_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_output::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_output::interface() - { - return &::wl_output_interface; - } - - wl_output::Resource *wl_output::output_allocate() - { - return new Resource; - } - - void wl_output::output_bind_resource(Resource *) - { - } - - void wl_output::output_destroy_resource(Resource *) - { - } - - void wl_output::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_output *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_output::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_output *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_output::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_output *that = resource->output_object; - that->m_resource_map.erase(resource->client()); - that->output_destroy_resource(resource); - delete resource; - } - - wl_output::Resource *wl_output::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_output_interface, version, id); - return bind(handle); - } - - wl_output::Resource *wl_output::bind(struct ::wl_resource *handle) - { - Resource *resource = output_allocate(); - resource->output_object = this; - - wl_resource_set_implementation(handle, &m_wl_output_interface, resource, destroy_func); - resource->handle = handle; - output_bind_resource(resource); - return resource; - } - wl_output::Resource *wl_output::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_output_interface, &m_wl_output_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_output_interface wl_output::m_wl_output_interface = { - wl_output::handle_release - }; - - void wl_output::output_release(Resource *) - { - } - - - void wl_output::handle_release( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->output_object)->output_release( - r); - } - - void wl_output::send_geometry(int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const std::string &make, const std::string &model, int32_t transform) - { - DS_ASSERT_X(m_resource, "wl_output::geometry", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_output::geometry as it's not initialised"); - return; - } - send_geometry( - m_resource->handle, - x, - y, - physical_width, - physical_height, - subpixel, - make, - model, - transform); - } - - void wl_output::send_geometry(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const std::string &make, const std::string &model, int32_t transform) - { - wl_output_send_geometry( - resource, - x, - y, - physical_width, - physical_height, - subpixel, - make.c_str(), - model.c_str(), - transform); - } - - - void wl_output::send_mode(uint32_t flags, int32_t width, int32_t height, int32_t refresh) - { - DS_ASSERT_X(m_resource, "wl_output::mode", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_output::mode as it's not initialised"); - return; - } - send_mode( - m_resource->handle, - flags, - width, - height, - refresh); - } - - void wl_output::send_mode(struct ::wl_resource *resource, uint32_t flags, int32_t width, int32_t height, int32_t refresh) - { - wl_output_send_mode( - resource, - flags, - width, - height, - refresh); - } - - - void wl_output::send_done() - { - DS_ASSERT_X(m_resource, "wl_output::done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_output::done as it's not initialised"); - return; - } - send_done( - m_resource->handle); - } - - void wl_output::send_done(struct ::wl_resource *resource) - { - wl_output_send_done( - resource); - } - - - void wl_output::send_scale(int32_t factor) - { - DS_ASSERT_X(m_resource, "wl_output::scale", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call wl_output::scale as it's not initialised"); - return; - } - send_scale( - m_resource->handle, - factor); - } - - void wl_output::send_scale(struct ::wl_resource *resource, int32_t factor) - { - wl_output_send_scale( - resource, - factor); - } - - - wl_region::wl_region(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_region::wl_region(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_region::wl_region(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_region::wl_region() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_region::~wl_region() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_region::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_region::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_region::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_region::Resource *wl_region::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_region::Resource *wl_region::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_region::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_region_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_region::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_region::interface() - { - return &::wl_region_interface; - } - - wl_region::Resource *wl_region::region_allocate() - { - return new Resource; - } - - void wl_region::region_bind_resource(Resource *) - { - } - - void wl_region::region_destroy_resource(Resource *) - { - } - - void wl_region::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_region *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_region::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_region *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_region::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_region *that = resource->region_object; - that->m_resource_map.erase(resource->client()); - that->region_destroy_resource(resource); - delete resource; - } - - wl_region::Resource *wl_region::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_region_interface, version, id); - return bind(handle); - } - - wl_region::Resource *wl_region::bind(struct ::wl_resource *handle) - { - Resource *resource = region_allocate(); - resource->region_object = this; - - wl_resource_set_implementation(handle, &m_wl_region_interface, resource, destroy_func); - resource->handle = handle; - region_bind_resource(resource); - return resource; - } - wl_region::Resource *wl_region::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_region_interface, &m_wl_region_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_region_interface wl_region::m_wl_region_interface = { - wl_region::handle_destroy, - wl_region::handle_add, - wl_region::handle_subtract - }; - - void wl_region::region_destroy(Resource *) - { - } - - void wl_region::region_add(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void wl_region::region_subtract(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - - void wl_region::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->region_object)->region_destroy( - r); - } - - void wl_region::handle_add( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->region_object)->region_add( - r, - x, - y, - width, - height); - } - - void wl_region::handle_subtract( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->region_object)->region_subtract( - r, - x, - y, - width, - height); - } - - wl_subcompositor::wl_subcompositor(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_subcompositor::wl_subcompositor(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_subcompositor::wl_subcompositor(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_subcompositor::wl_subcompositor() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_subcompositor::~wl_subcompositor() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_subcompositor::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_subcompositor::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_subcompositor::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_subcompositor::Resource *wl_subcompositor::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_subcompositor::Resource *wl_subcompositor::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_subcompositor::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_subcompositor_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_subcompositor::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_subcompositor::interface() - { - return &::wl_subcompositor_interface; - } - - wl_subcompositor::Resource *wl_subcompositor::subcompositor_allocate() - { - return new Resource; - } - - void wl_subcompositor::subcompositor_bind_resource(Resource *) - { - } - - void wl_subcompositor::subcompositor_destroy_resource(Resource *) - { - } - - void wl_subcompositor::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_subcompositor *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_subcompositor::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_subcompositor *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_subcompositor::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_subcompositor *that = resource->subcompositor_object; - that->m_resource_map.erase(resource->client()); - that->subcompositor_destroy_resource(resource); - delete resource; - } - - wl_subcompositor::Resource *wl_subcompositor::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_subcompositor_interface, version, id); - return bind(handle); - } - - wl_subcompositor::Resource *wl_subcompositor::bind(struct ::wl_resource *handle) - { - Resource *resource = subcompositor_allocate(); - resource->subcompositor_object = this; - - wl_resource_set_implementation(handle, &m_wl_subcompositor_interface, resource, destroy_func); - resource->handle = handle; - subcompositor_bind_resource(resource); - return resource; - } - wl_subcompositor::Resource *wl_subcompositor::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_subcompositor_interface, &m_wl_subcompositor_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_subcompositor_interface wl_subcompositor::m_wl_subcompositor_interface = { - wl_subcompositor::handle_destroy, - wl_subcompositor::handle_get_subsurface - }; - - void wl_subcompositor::subcompositor_destroy(Resource *) - { - } - - void wl_subcompositor::subcompositor_get_subsurface(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *) - { - } - - - void wl_subcompositor::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->subcompositor_object)->subcompositor_destroy( - r); - } - - void wl_subcompositor::handle_get_subsurface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface, - struct ::wl_resource *parent) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->subcompositor_object)->subcompositor_get_subsurface( - r, - id, - surface, - parent); - } - - wl_subsurface::wl_subsurface(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - wl_subsurface::wl_subsurface(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - wl_subsurface::wl_subsurface(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - wl_subsurface::wl_subsurface() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - wl_subsurface::~wl_subsurface() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - wl_subsurface::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void wl_subsurface::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void wl_subsurface::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - wl_subsurface::Resource *wl_subsurface::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - wl_subsurface::Resource *wl_subsurface::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void wl_subsurface::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::wl_subsurface_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = wl_subsurface::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *wl_subsurface::interface() - { - return &::wl_subsurface_interface; - } - - wl_subsurface::Resource *wl_subsurface::subsurface_allocate() - { - return new Resource; - } - - void wl_subsurface::subsurface_bind_resource(Resource *) - { - } - - void wl_subsurface::subsurface_destroy_resource(Resource *) - { - } - - void wl_subsurface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - wl_subsurface *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void wl_subsurface::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - wl_subsurface *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void wl_subsurface::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - wl_subsurface *that = resource->subsurface_object; - that->m_resource_map.erase(resource->client()); - that->subsurface_destroy_resource(resource); - delete resource; - } - - wl_subsurface::Resource *wl_subsurface::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::wl_subsurface_interface, version, id); - return bind(handle); - } - - wl_subsurface::Resource *wl_subsurface::bind(struct ::wl_resource *handle) - { - Resource *resource = subsurface_allocate(); - resource->subsurface_object = this; - - wl_resource_set_implementation(handle, &m_wl_subsurface_interface, resource, destroy_func); - resource->handle = handle; - subsurface_bind_resource(resource); - return resource; - } - wl_subsurface::Resource *wl_subsurface::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::wl_subsurface_interface, &m_wl_subsurface_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::wl_subsurface_interface wl_subsurface::m_wl_subsurface_interface = { - wl_subsurface::handle_destroy, - wl_subsurface::handle_set_position, - wl_subsurface::handle_place_above, - wl_subsurface::handle_place_below, - wl_subsurface::handle_set_sync, - wl_subsurface::handle_set_desync - }; - - void wl_subsurface::subsurface_destroy(Resource *) - { - } - - void wl_subsurface::subsurface_set_position(Resource *, int32_t , int32_t ) - { - } - - void wl_subsurface::subsurface_place_above(Resource *, struct ::wl_resource *) - { - } - - void wl_subsurface::subsurface_place_below(Resource *, struct ::wl_resource *) - { - } - - void wl_subsurface::subsurface_set_sync(Resource *) - { - } - - void wl_subsurface::subsurface_set_desync(Resource *) - { - } - - - void wl_subsurface::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->subsurface_object)->subsurface_destroy( - r); - } - - void wl_subsurface::handle_set_position( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->subsurface_object)->subsurface_set_position( - r, - x, - y); - } - - void wl_subsurface::handle_place_above( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *sibling) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->subsurface_object)->subsurface_place_above( - r, - sibling); - } - - void wl_subsurface::handle_place_below( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *sibling) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->subsurface_object)->subsurface_place_below( - r, - sibling); - } - - void wl_subsurface::handle_set_sync( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->subsurface_object)->subsurface_set_sync( - r); - } - - void wl_subsurface::handle_set_desync( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->subsurface_object)->subsurface_set_desync( - r); - } -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-wayland.h b/src/DSWaylandServer/dswayland-server-wayland.h deleted file mode 100644 index 4bf6c30..0000000 --- a/src/DSWaylandServer/dswayland-server-wayland.h +++ /dev/null @@ -1,2251 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland/wayland.xml */ - -#ifndef __DS_WAYLAND_PROTOCOL_H__ -#define __DS_WAYLAND_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "wayland-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class wl_callback - { - public: - wl_callback(struct ::wl_client *client, uint32_t id, int version); - wl_callback(struct ::wl_display *display, int version); - wl_callback(struct ::wl_resource *resource); - wl_callback(); - - virtual ~wl_callback(); - - class Resource - { - public: - Resource() : callback_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_callback *callback_object; - wl_callback *object() { return callback_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_done(uint32_t callback_data); - void send_done(struct ::wl_resource *resource, uint32_t callback_data); - - protected: - virtual Resource *callback_allocate(); - - virtual void callback_bind_resource(Resource *resource); - virtual void callback_destroy_resource(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_callback *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_compositor - { - public: - wl_compositor(struct ::wl_client *client, uint32_t id, int version); - wl_compositor(struct ::wl_display *display, int version); - wl_compositor(struct ::wl_resource *resource); - wl_compositor(); - - virtual ~wl_compositor(); - - class Resource - { - public: - Resource() : compositor_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_compositor *compositor_object; - wl_compositor *object() { return compositor_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *compositor_allocate(); - - virtual void compositor_bind_resource(Resource *resource); - virtual void compositor_destroy_resource(Resource *resource); - - virtual void compositor_create_surface(Resource *resource, uint32_t id); - virtual void compositor_create_region(Resource *resource, uint32_t id); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_compositor_interface m_wl_compositor_interface; - - static void handle_create_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_create_region( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_compositor *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_shm_pool - { - public: - wl_shm_pool(struct ::wl_client *client, uint32_t id, int version); - wl_shm_pool(struct ::wl_display *display, int version); - wl_shm_pool(struct ::wl_resource *resource); - wl_shm_pool(); - - virtual ~wl_shm_pool(); - - class Resource - { - public: - Resource() : shm_pool_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_shm_pool *shm_pool_object; - wl_shm_pool *object() { return shm_pool_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *shm_pool_allocate(); - - virtual void shm_pool_bind_resource(Resource *resource); - virtual void shm_pool_destroy_resource(Resource *resource); - - virtual void shm_pool_create_buffer(Resource *resource, uint32_t id, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format); - virtual void shm_pool_destroy(Resource *resource); - virtual void shm_pool_resize(Resource *resource, int32_t size); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_shm_pool_interface m_wl_shm_pool_interface; - - static void handle_create_buffer( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - int32_t offset, - int32_t width, - int32_t height, - int32_t stride, - uint32_t format); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_resize( - ::wl_client *client, - struct wl_resource *resource, - int32_t size); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_shm_pool *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_shm - { - public: - wl_shm(struct ::wl_client *client, uint32_t id, int version); - wl_shm(struct ::wl_display *display, int version); - wl_shm(struct ::wl_resource *resource); - wl_shm(); - - virtual ~wl_shm(); - - class Resource - { - public: - Resource() : shm_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_shm *shm_object; - wl_shm *object() { return shm_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_format = 0, // buffer format is not known - error_invalid_stride = 1, // invalid size or stride during pool or buffer creation - error_invalid_fd = 2, // mmapping the file descriptor failed - }; - - enum format { - format_argb8888 = 0, // 32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian - format_xrgb8888 = 1, // 32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian - format_c8 = 0x20203843, // 8-bit color index format, [7:0] C - format_rgb332 = 0x38424752, // 8-bit RGB format, [7:0] R:G:B 3:3:2 - format_bgr233 = 0x38524742, // 8-bit BGR format, [7:0] B:G:R 2:3:3 - format_xrgb4444 = 0x32315258, // 16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian - format_xbgr4444 = 0x32314258, // 16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian - format_rgbx4444 = 0x32315852, // 16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian - format_bgrx4444 = 0x32315842, // 16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian - format_argb4444 = 0x32315241, // 16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian - format_abgr4444 = 0x32314241, // 16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian - format_rgba4444 = 0x32314152, // 16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian - format_bgra4444 = 0x32314142, // 16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian - format_xrgb1555 = 0x35315258, // 16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian - format_xbgr1555 = 0x35314258, // 16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian - format_rgbx5551 = 0x35315852, // 16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian - format_bgrx5551 = 0x35315842, // 16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian - format_argb1555 = 0x35315241, // 16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian - format_abgr1555 = 0x35314241, // 16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian - format_rgba5551 = 0x35314152, // 16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian - format_bgra5551 = 0x35314142, // 16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian - format_rgb565 = 0x36314752, // 16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian - format_bgr565 = 0x36314742, // 16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian - format_rgb888 = 0x34324752, // 24-bit RGB format, [23:0] R:G:B little endian - format_bgr888 = 0x34324742, // 24-bit BGR format, [23:0] B:G:R little endian - format_xbgr8888 = 0x34324258, // 32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian - format_rgbx8888 = 0x34325852, // 32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian - format_bgrx8888 = 0x34325842, // 32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian - format_abgr8888 = 0x34324241, // 32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian - format_rgba8888 = 0x34324152, // 32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian - format_bgra8888 = 0x34324142, // 32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian - format_xrgb2101010 = 0x30335258, // 32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian - format_xbgr2101010 = 0x30334258, // 32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian - format_rgbx1010102 = 0x30335852, // 32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian - format_bgrx1010102 = 0x30335842, // 32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian - format_argb2101010 = 0x30335241, // 32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian - format_abgr2101010 = 0x30334241, // 32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian - format_rgba1010102 = 0x30334152, // 32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian - format_bgra1010102 = 0x30334142, // 32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian - format_yuyv = 0x56595559, // packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian - format_yvyu = 0x55595659, // packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian - format_uyvy = 0x59565955, // packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian - format_vyuy = 0x59555956, // packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian - format_ayuv = 0x56555941, // packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian - format_nv12 = 0x3231564e, // 2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane - format_nv21 = 0x3132564e, // 2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane - format_nv16 = 0x3631564e, // 2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane - format_nv61 = 0x3136564e, // 2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane - format_yuv410 = 0x39565559, // 3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes - format_yvu410 = 0x39555659, // 3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes - format_yuv411 = 0x31315559, // 3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes - format_yvu411 = 0x31315659, // 3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes - format_yuv420 = 0x32315559, // 3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes - format_yvu420 = 0x32315659, // 3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes - format_yuv422 = 0x36315559, // 3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes - format_yvu422 = 0x36315659, // 3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes - format_yuv444 = 0x34325559, // 3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes - format_yvu444 = 0x34325659, // 3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes - format_r8 = 0x20203852, // [7:0] R - format_r16 = 0x20363152, // [15:0] R little endian - format_rg88 = 0x38384752, // [15:0] R:G 8:8 little endian - format_gr88 = 0x38385247, // [15:0] G:R 8:8 little endian - format_rg1616 = 0x32334752, // [31:0] R:G 16:16 little endian - format_gr1616 = 0x32335247, // [31:0] G:R 16:16 little endian - format_xrgb16161616f = 0x48345258, // [63:0] x:R:G:B 16:16:16:16 little endian - format_xbgr16161616f = 0x48344258, // [63:0] x:B:G:R 16:16:16:16 little endian - format_argb16161616f = 0x48345241, // [63:0] A:R:G:B 16:16:16:16 little endian - format_abgr16161616f = 0x48344241, // [63:0] A:B:G:R 16:16:16:16 little endian - format_xyuv8888 = 0x56555958, // [31:0] X:Y:Cb:Cr 8:8:8:8 little endian - format_vuy888 = 0x34325556, // [23:0] Cr:Cb:Y 8:8:8 little endian - format_vuy101010 = 0x30335556, // Y followed by U then V, 10:10:10. Non-linear modifier only - format_y210 = 0x30313259, // [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 10:6:10:6:10:6:10:6 little endian per 2 Y pixels - format_y212 = 0x32313259, // [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 12:4:12:4:12:4:12:4 little endian per 2 Y pixels - format_y216 = 0x36313259, // [63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels - format_y410 = 0x30313459, // [31:0] A:Cr:Y:Cb 2:10:10:10 little endian - format_y412 = 0x32313459, // [63:0] A:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian - format_y416 = 0x36313459, // [63:0] A:Cr:Y:Cb 16:16:16:16 little endian - format_xvyu2101010 = 0x30335658, // [31:0] X:Cr:Y:Cb 2:10:10:10 little endian - format_xvyu12_16161616 = 0x36335658, // [63:0] X:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian - format_xvyu16161616 = 0x38345658, // [63:0] X:Cr:Y:Cb 16:16:16:16 little endian - format_y0l0 = 0x304c3059, // [63:0] A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian - format_x0l0 = 0x304c3058, // [63:0] X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0 1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian - format_y0l2 = 0x324c3059, // [63:0] A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian - format_x0l2 = 0x324c3058, // [63:0] X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0 1:1:10:10:10:1:1:10:10:10 little endian - format_yuv420_8bit = 0x38305559, - format_yuv420_10bit = 0x30315559, - format_xrgb8888_a8 = 0x38415258, - format_xbgr8888_a8 = 0x38414258, - format_rgbx8888_a8 = 0x38415852, - format_bgrx8888_a8 = 0x38415842, - format_rgb888_a8 = 0x38413852, - format_bgr888_a8 = 0x38413842, - format_rgb565_a8 = 0x38413552, - format_bgr565_a8 = 0x38413542, - format_nv24 = 0x3432564e, // non-subsampled Cr:Cb plane - format_nv42 = 0x3234564e, // non-subsampled Cb:Cr plane - format_p210 = 0x30313250, // 2x1 subsampled Cr:Cb plane, 10 bit per channel - format_p010 = 0x30313050, // 2x2 subsampled Cr:Cb plane 10 bits per channel - format_p012 = 0x32313050, // 2x2 subsampled Cr:Cb plane 12 bits per channel - format_p016 = 0x36313050, // 2x2 subsampled Cr:Cb plane 16 bits per channel - }; - - void send_format(uint32_t format); - void send_format(struct ::wl_resource *resource, uint32_t format); - - protected: - virtual Resource *shm_allocate(); - - virtual void shm_bind_resource(Resource *resource); - virtual void shm_destroy_resource(Resource *resource); - - virtual void shm_create_pool(Resource *resource, uint32_t id, int32_t fd, int32_t size); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_shm_interface m_wl_shm_interface; - - static void handle_create_pool( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - int32_t fd, - int32_t size); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_shm *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_buffer - { - public: - wl_buffer(struct ::wl_client *client, uint32_t id, int version); - wl_buffer(struct ::wl_display *display, int version); - wl_buffer(struct ::wl_resource *resource); - wl_buffer(); - - virtual ~wl_buffer(); - - class Resource - { - public: - Resource() : buffer_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_buffer *buffer_object; - wl_buffer *object() { return buffer_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_release(); - void send_release(struct ::wl_resource *resource); - - protected: - virtual Resource *buffer_allocate(); - - virtual void buffer_bind_resource(Resource *resource); - virtual void buffer_destroy_resource(Resource *resource); - - virtual void buffer_destroy(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_buffer_interface m_wl_buffer_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_buffer *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_data_offer - { - public: - wl_data_offer(struct ::wl_client *client, uint32_t id, int version); - wl_data_offer(struct ::wl_display *display, int version); - wl_data_offer(struct ::wl_resource *resource); - wl_data_offer(); - - virtual ~wl_data_offer(); - - class Resource - { - public: - Resource() : data_offer_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_data_offer *data_offer_object; - wl_data_offer *object() { return data_offer_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_finish = 0, // finish request was called untimely - error_invalid_action_mask = 1, // action mask contains invalid values - error_invalid_action = 2, // action argument has an invalid value - error_invalid_offer = 3, // offer doesn't accept this request - }; - - void send_offer(const std::string &mime_type); - void send_offer(struct ::wl_resource *resource, const std::string &mime_type); - void send_source_actions(uint32_t source_actions); - void send_source_actions(struct ::wl_resource *resource, uint32_t source_actions); - void send_action(uint32_t dnd_action); - void send_action(struct ::wl_resource *resource, uint32_t dnd_action); - - protected: - virtual Resource *data_offer_allocate(); - - virtual void data_offer_bind_resource(Resource *resource); - virtual void data_offer_destroy_resource(Resource *resource); - - virtual void data_offer_accept(Resource *resource, uint32_t serial, const std::string &mime_type); - virtual void data_offer_receive(Resource *resource, const std::string &mime_type, int32_t fd); - virtual void data_offer_destroy(Resource *resource); - virtual void data_offer_finish(Resource *resource); - virtual void data_offer_set_actions(Resource *resource, uint32_t dnd_actions, uint32_t preferred_action); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_data_offer_interface m_wl_data_offer_interface; - - static void handle_accept( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - const char *mime_type); - static void handle_receive( - ::wl_client *client, - struct wl_resource *resource, - const char *mime_type, - int32_t fd); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_finish( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_actions( - ::wl_client *client, - struct wl_resource *resource, - uint32_t dnd_actions, - uint32_t preferred_action); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_data_offer *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_data_source - { - public: - wl_data_source(struct ::wl_client *client, uint32_t id, int version); - wl_data_source(struct ::wl_display *display, int version); - wl_data_source(struct ::wl_resource *resource); - wl_data_source(); - - virtual ~wl_data_source(); - - class Resource - { - public: - Resource() : data_source_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_data_source *data_source_object; - wl_data_source *object() { return data_source_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_action_mask = 0, // action mask contains invalid values - error_invalid_source = 1, // source doesn't accept this request - }; - - void send_target(const std::string &mime_type); - void send_target(struct ::wl_resource *resource, const std::string &mime_type); - void send_send(const std::string &mime_type, int32_t fd); - void send_send(struct ::wl_resource *resource, const std::string &mime_type, int32_t fd); - void send_cancelled(); - void send_cancelled(struct ::wl_resource *resource); - void send_dnd_drop_performed(); - void send_dnd_drop_performed(struct ::wl_resource *resource); - void send_dnd_finished(); - void send_dnd_finished(struct ::wl_resource *resource); - void send_action(uint32_t dnd_action); - void send_action(struct ::wl_resource *resource, uint32_t dnd_action); - - protected: - virtual Resource *data_source_allocate(); - - virtual void data_source_bind_resource(Resource *resource); - virtual void data_source_destroy_resource(Resource *resource); - - virtual void data_source_offer(Resource *resource, const std::string &mime_type); - virtual void data_source_destroy(Resource *resource); - virtual void data_source_set_actions(Resource *resource, uint32_t dnd_actions); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_data_source_interface m_wl_data_source_interface; - - static void handle_offer( - ::wl_client *client, - struct wl_resource *resource, - const char *mime_type); - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_actions( - ::wl_client *client, - struct wl_resource *resource, - uint32_t dnd_actions); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_data_source *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_data_device - { - public: - wl_data_device(struct ::wl_client *client, uint32_t id, int version); - wl_data_device(struct ::wl_display *display, int version); - wl_data_device(struct ::wl_resource *resource); - wl_data_device(); - - virtual ~wl_data_device(); - - class Resource - { - public: - Resource() : data_device_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_data_device *data_device_object; - wl_data_device *object() { return data_device_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_role = 0, // given wl_surface has another role - }; - - void send_data_offer(struct ::wl_resource *id); - void send_data_offer(struct ::wl_resource *resource, struct ::wl_resource *id); - void send_enter(uint32_t serial, struct ::wl_resource *surface, wl_fixed_t x, wl_fixed_t y, struct ::wl_resource *id); - void send_enter(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface, wl_fixed_t x, wl_fixed_t y, struct ::wl_resource *id); - void send_leave(); - void send_leave(struct ::wl_resource *resource); - void send_motion(uint32_t time, wl_fixed_t x, wl_fixed_t y); - void send_motion(struct ::wl_resource *resource, uint32_t time, wl_fixed_t x, wl_fixed_t y); - void send_drop(); - void send_drop(struct ::wl_resource *resource); - void send_selection(struct ::wl_resource *id); - void send_selection(struct ::wl_resource *resource, struct ::wl_resource *id); - - protected: - virtual Resource *data_device_allocate(); - - virtual void data_device_bind_resource(Resource *resource); - virtual void data_device_destroy_resource(Resource *resource); - - virtual void data_device_start_drag(Resource *resource, struct ::wl_resource *source, struct ::wl_resource *origin, struct ::wl_resource *icon, uint32_t serial); - virtual void data_device_set_selection(Resource *resource, struct ::wl_resource *source, uint32_t serial); - virtual void data_device_release(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_data_device_interface m_wl_data_device_interface; - - static void handle_start_drag( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *source, - struct ::wl_resource *origin, - struct ::wl_resource *icon, - uint32_t serial); - static void handle_set_selection( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *source, - uint32_t serial); - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_data_device *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_data_device_manager - { - public: - wl_data_device_manager(struct ::wl_client *client, uint32_t id, int version); - wl_data_device_manager(struct ::wl_display *display, int version); - wl_data_device_manager(struct ::wl_resource *resource); - wl_data_device_manager(); - - virtual ~wl_data_device_manager(); - - class Resource - { - public: - Resource() : data_device_manager_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_data_device_manager *data_device_manager_object; - wl_data_device_manager *object() { return data_device_manager_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum dnd_action { - dnd_action_none = 0, // no action - dnd_action_copy = 1, // copy action - dnd_action_move = 2, // move action - dnd_action_ask = 4, // ask action - }; - - protected: - virtual Resource *data_device_manager_allocate(); - - virtual void data_device_manager_bind_resource(Resource *resource); - virtual void data_device_manager_destroy_resource(Resource *resource); - - virtual void data_device_manager_create_data_source(Resource *resource, uint32_t id); - virtual void data_device_manager_get_data_device(Resource *resource, uint32_t id, struct ::wl_resource *seat); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_data_device_manager_interface m_wl_data_device_manager_interface; - - static void handle_create_data_source( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_get_data_device( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *seat); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_data_device_manager *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_shell - { - public: - wl_shell(struct ::wl_client *client, uint32_t id, int version); - wl_shell(struct ::wl_display *display, int version); - wl_shell(struct ::wl_resource *resource); - wl_shell(); - - virtual ~wl_shell(); - - class Resource - { - public: - Resource() : shell_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_shell *shell_object; - wl_shell *object() { return shell_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_role = 0, // given wl_surface has another role - }; - - protected: - virtual Resource *shell_allocate(); - - virtual void shell_bind_resource(Resource *resource); - virtual void shell_destroy_resource(Resource *resource); - - virtual void shell_get_shell_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_shell_interface m_wl_shell_interface; - - static void handle_get_shell_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_shell *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_shell_surface - { - public: - wl_shell_surface(struct ::wl_client *client, uint32_t id, int version); - wl_shell_surface(struct ::wl_display *display, int version); - wl_shell_surface(struct ::wl_resource *resource); - wl_shell_surface(); - - virtual ~wl_shell_surface(); - - class Resource - { - public: - Resource() : shell_surface_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_shell_surface *shell_surface_object; - wl_shell_surface *object() { return shell_surface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum resize { - resize_none = 0, // no edge - resize_top = 1, // top edge - resize_bottom = 2, // bottom edge - resize_left = 4, // left edge - resize_top_left = 5, // top and left edges - resize_bottom_left = 6, // bottom and left edges - resize_right = 8, // right edge - resize_top_right = 9, // top and right edges - resize_bottom_right = 10, // bottom and right edges - }; - - enum transient { - transient_inactive = 0x1, // do not set keyboard focus - }; - - enum fullscreen_method { - fullscreen_method_default = 0, // no preference, apply default policy - fullscreen_method_scale = 1, // scale, preserve the surface's aspect ratio and center on output - fullscreen_method_driver = 2, // switch output mode to the smallest mode that can fit the surface, add black borders to compensate size mismatch - fullscreen_method_fill = 3, // no upscaling, center on output and add black borders to compensate size mismatch - }; - - void send_ping(uint32_t serial); - void send_ping(struct ::wl_resource *resource, uint32_t serial); - void send_configure(uint32_t edges, int32_t width, int32_t height); - void send_configure(struct ::wl_resource *resource, uint32_t edges, int32_t width, int32_t height); - void send_popup_done(); - void send_popup_done(struct ::wl_resource *resource); - - protected: - virtual Resource *shell_surface_allocate(); - - virtual void shell_surface_bind_resource(Resource *resource); - virtual void shell_surface_destroy_resource(Resource *resource); - - virtual void shell_surface_pong(Resource *resource, uint32_t serial); - virtual void shell_surface_move(Resource *resource, struct ::wl_resource *seat, uint32_t serial); - virtual void shell_surface_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges); - virtual void shell_surface_set_toplevel(Resource *resource); - virtual void shell_surface_set_transient(Resource *resource, struct ::wl_resource *parent, int32_t x, int32_t y, uint32_t flags); - virtual void shell_surface_set_fullscreen(Resource *resource, uint32_t method, uint32_t framerate, struct ::wl_resource *output); - virtual void shell_surface_set_popup(Resource *resource, struct ::wl_resource *seat, uint32_t serial, struct ::wl_resource *parent, int32_t x, int32_t y, uint32_t flags); - virtual void shell_surface_set_maximized(Resource *resource, struct ::wl_resource *output); - virtual void shell_surface_set_title(Resource *resource, const std::string &title); - virtual void shell_surface_set_class(Resource *resource, const std::string &class_); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_shell_surface_interface m_wl_shell_surface_interface; - - static void handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - static void handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial); - static void handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges); - static void handle_set_toplevel( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_transient( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent, - int32_t x, - int32_t y, - uint32_t flags); - static void handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - uint32_t method, - uint32_t framerate, - struct ::wl_resource *output); - static void handle_set_popup( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - struct ::wl_resource *parent, - int32_t x, - int32_t y, - uint32_t flags); - static void handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output); - static void handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title); - static void handle_set_class( - ::wl_client *client, - struct wl_resource *resource, - const char *class_); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_shell_surface *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_surface - { - public: - wl_surface(struct ::wl_client *client, uint32_t id, int version); - wl_surface(struct ::wl_display *display, int version); - wl_surface(struct ::wl_resource *resource); - wl_surface(); - - virtual ~wl_surface(); - - class Resource - { - public: - Resource() : surface_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_surface *surface_object; - wl_surface *object() { return surface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_scale = 0, // buffer scale value is invalid - error_invalid_transform = 1, // buffer transform value is invalid - error_invalid_size = 2, // buffer size is invalid - }; - - void send_enter(struct ::wl_resource *output); - void send_enter(struct ::wl_resource *resource, struct ::wl_resource *output); - void send_leave(struct ::wl_resource *output); - void send_leave(struct ::wl_resource *resource, struct ::wl_resource *output); - - protected: - virtual Resource *surface_allocate(); - - virtual void surface_bind_resource(Resource *resource); - virtual void surface_destroy_resource(Resource *resource); - - virtual void surface_destroy(Resource *resource); - virtual void surface_attach(Resource *resource, struct ::wl_resource *buffer, int32_t x, int32_t y); - virtual void surface_damage(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void surface_frame(Resource *resource, uint32_t callback); - virtual void surface_set_opaque_region(Resource *resource, struct ::wl_resource *region); - virtual void surface_set_input_region(Resource *resource, struct ::wl_resource *region); - virtual void surface_commit(Resource *resource); - virtual void surface_set_buffer_transform(Resource *resource, int32_t transform); - virtual void surface_set_buffer_scale(Resource *resource, int32_t scale); - virtual void surface_damage_buffer(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_surface_interface m_wl_surface_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_attach( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *buffer, - int32_t x, - int32_t y); - static void handle_damage( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_frame( - ::wl_client *client, - struct wl_resource *resource, - uint32_t callback); - static void handle_set_opaque_region( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *region); - static void handle_set_input_region( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *region); - static void handle_commit( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_buffer_transform( - ::wl_client *client, - struct wl_resource *resource, - int32_t transform); - static void handle_set_buffer_scale( - ::wl_client *client, - struct wl_resource *resource, - int32_t scale); - static void handle_damage_buffer( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_surface *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_seat - { - public: - wl_seat(struct ::wl_client *client, uint32_t id, int version); - wl_seat(struct ::wl_display *display, int version); - wl_seat(struct ::wl_resource *resource); - wl_seat(); - - virtual ~wl_seat(); - - class Resource - { - public: - Resource() : seat_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_seat *seat_object; - wl_seat *object() { return seat_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum capability { - capability_pointer = 1, // the seat has pointer devices - capability_keyboard = 2, // the seat has one or more keyboards - capability_touch = 4, // the seat has touch devices - }; - - enum error { - error_missing_capability = 0, // get_pointer, get_keyboard or get_touch called on seat without the matching capability - }; - - void send_capabilities(uint32_t capabilities); - void send_capabilities(struct ::wl_resource *resource, uint32_t capabilities); - void send_name(const std::string &name); - void send_name(struct ::wl_resource *resource, const std::string &name); - - protected: - virtual Resource *seat_allocate(); - - virtual void seat_bind_resource(Resource *resource); - virtual void seat_destroy_resource(Resource *resource); - - virtual void seat_get_pointer(Resource *resource, uint32_t id); - virtual void seat_get_keyboard(Resource *resource, uint32_t id); - virtual void seat_get_touch(Resource *resource, uint32_t id); - virtual void seat_release(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_seat_interface m_wl_seat_interface; - - static void handle_get_pointer( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_get_keyboard( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_get_touch( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_seat *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_pointer - { - public: - wl_pointer(struct ::wl_client *client, uint32_t id, int version); - wl_pointer(struct ::wl_display *display, int version); - wl_pointer(struct ::wl_resource *resource); - wl_pointer(); - - virtual ~wl_pointer(); - - class Resource - { - public: - Resource() : pointer_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_pointer *pointer_object; - wl_pointer *object() { return pointer_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_role = 0, // given wl_surface has another role - }; - - enum button_state { - button_state_released = 0, // the button is not pressed - button_state_pressed = 1, // the button is pressed - }; - - enum axis { - axis_vertical_scroll = 0, // vertical axis - axis_horizontal_scroll = 1, // horizontal axis - }; - - enum axis_source { - axis_source_wheel = 0, // a physical wheel rotation - axis_source_finger = 1, // finger on a touch surface - axis_source_continuous = 2, // continuous coordinate space - axis_source_wheel_tilt = 3, // a physical wheel tilt - }; - - void send_enter(uint32_t serial, struct ::wl_resource *surface, wl_fixed_t surface_x, wl_fixed_t surface_y); - void send_enter(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface, wl_fixed_t surface_x, wl_fixed_t surface_y); - void send_leave(uint32_t serial, struct ::wl_resource *surface); - void send_leave(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface); - void send_motion(uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y); - void send_motion(struct ::wl_resource *resource, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y); - void send_button(uint32_t serial, uint32_t time, uint32_t button, uint32_t state); - void send_button(struct ::wl_resource *resource, uint32_t serial, uint32_t time, uint32_t button, uint32_t state); - void send_axis(uint32_t time, uint32_t axis, wl_fixed_t value); - void send_axis(struct ::wl_resource *resource, uint32_t time, uint32_t axis, wl_fixed_t value); - void send_frame(); - void send_frame(struct ::wl_resource *resource); - void send_axis_source(uint32_t axis_source); - void send_axis_source(struct ::wl_resource *resource, uint32_t axis_source); - void send_axis_stop(uint32_t time, uint32_t axis); - void send_axis_stop(struct ::wl_resource *resource, uint32_t time, uint32_t axis); - void send_axis_discrete(uint32_t axis, int32_t discrete); - void send_axis_discrete(struct ::wl_resource *resource, uint32_t axis, int32_t discrete); - - protected: - virtual Resource *pointer_allocate(); - - virtual void pointer_bind_resource(Resource *resource); - virtual void pointer_destroy_resource(Resource *resource); - - virtual void pointer_set_cursor(Resource *resource, uint32_t serial, struct ::wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y); - virtual void pointer_release(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_pointer_interface m_wl_pointer_interface; - - static void handle_set_cursor( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial, - struct ::wl_resource *surface, - int32_t hotspot_x, - int32_t hotspot_y); - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_pointer *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_keyboard - { - public: - wl_keyboard(struct ::wl_client *client, uint32_t id, int version); - wl_keyboard(struct ::wl_display *display, int version); - wl_keyboard(struct ::wl_resource *resource); - wl_keyboard(); - - virtual ~wl_keyboard(); - - class Resource - { - public: - Resource() : keyboard_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_keyboard *keyboard_object; - wl_keyboard *object() { return keyboard_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum keymap_format { - keymap_format_no_keymap = 0, // no keymap; client must understand how to interpret the raw keycode - keymap_format_xkb_v1 = 1, // libxkbcommon compatible; to determine the xkb keycode, clients must add 8 to the key event keycode - }; - - enum key_state { - key_state_released = 0, // key is not pressed - key_state_pressed = 1, // key is pressed - }; - - void send_keymap(uint32_t format, int32_t fd, uint32_t size); - void send_keymap(struct ::wl_resource *resource, uint32_t format, int32_t fd, uint32_t size); - void send_enter(uint32_t serial, struct ::wl_resource *surface, struct ::wl_array *keys); - void send_enter(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface, struct ::wl_array *keys); - void send_leave(uint32_t serial, struct ::wl_resource *surface); - void send_leave(struct ::wl_resource *resource, uint32_t serial, struct ::wl_resource *surface); - void send_key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state); - void send_key(struct ::wl_resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); - void send_modifiers(uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); - void send_modifiers(struct ::wl_resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); - void send_repeat_info(int32_t rate, int32_t delay); - void send_repeat_info(struct ::wl_resource *resource, int32_t rate, int32_t delay); - - protected: - virtual Resource *keyboard_allocate(); - - virtual void keyboard_bind_resource(Resource *resource); - virtual void keyboard_destroy_resource(Resource *resource); - - virtual void keyboard_release(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_keyboard_interface m_wl_keyboard_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_keyboard *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_touch - { - public: - wl_touch(struct ::wl_client *client, uint32_t id, int version); - wl_touch(struct ::wl_display *display, int version); - wl_touch(struct ::wl_resource *resource); - wl_touch(); - - virtual ~wl_touch(); - - class Resource - { - public: - Resource() : touch_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_touch *touch_object; - wl_touch *object() { return touch_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - void send_down(uint32_t serial, uint32_t time, struct ::wl_resource *surface, int32_t id, wl_fixed_t x, wl_fixed_t y); - void send_down(struct ::wl_resource *resource, uint32_t serial, uint32_t time, struct ::wl_resource *surface, int32_t id, wl_fixed_t x, wl_fixed_t y); - void send_up(uint32_t serial, uint32_t time, int32_t id); - void send_up(struct ::wl_resource *resource, uint32_t serial, uint32_t time, int32_t id); - void send_motion(uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y); - void send_motion(struct ::wl_resource *resource, uint32_t time, int32_t id, wl_fixed_t x, wl_fixed_t y); - void send_frame(); - void send_frame(struct ::wl_resource *resource); - void send_cancel(); - void send_cancel(struct ::wl_resource *resource); - void send_shape(int32_t id, wl_fixed_t major, wl_fixed_t minor); - void send_shape(struct ::wl_resource *resource, int32_t id, wl_fixed_t major, wl_fixed_t minor); - void send_orientation(int32_t id, wl_fixed_t orientation); - void send_orientation(struct ::wl_resource *resource, int32_t id, wl_fixed_t orientation); - - protected: - virtual Resource *touch_allocate(); - - virtual void touch_bind_resource(Resource *resource); - virtual void touch_destroy_resource(Resource *resource); - - virtual void touch_release(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_touch_interface m_wl_touch_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_touch *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_output - { - public: - wl_output(struct ::wl_client *client, uint32_t id, int version); - wl_output(struct ::wl_display *display, int version); - wl_output(struct ::wl_resource *resource); - wl_output(); - - virtual ~wl_output(); - - class Resource - { - public: - Resource() : output_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_output *output_object; - wl_output *object() { return output_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum subpixel { - subpixel_unknown = 0, // unknown geometry - subpixel_none = 1, // no geometry - subpixel_horizontal_rgb = 2, // horizontal RGB - subpixel_horizontal_bgr = 3, // horizontal BGR - subpixel_vertical_rgb = 4, // vertical RGB - subpixel_vertical_bgr = 5, // vertical BGR - }; - - enum transform { - transform_normal = 0, // no transform - transform_90 = 1, // 90 degrees counter-clockwise - transform_180 = 2, // 180 degrees counter-clockwise - transform_270 = 3, // 270 degrees counter-clockwise - transform_flipped = 4, // 180 degree flip around a vertical axis - transform_flipped_90 = 5, // flip and rotate 90 degrees counter-clockwise - transform_flipped_180 = 6, // flip and rotate 180 degrees counter-clockwise - transform_flipped_270 = 7, // flip and rotate 270 degrees counter-clockwise - }; - - enum mode { - mode_current = 0x1, // indicates this is the current mode - mode_preferred = 0x2, // indicates this is the preferred mode - }; - - void send_geometry(int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const std::string &make, const std::string &model, int32_t transform); - void send_geometry(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, int32_t subpixel, const std::string &make, const std::string &model, int32_t transform); - void send_mode(uint32_t flags, int32_t width, int32_t height, int32_t refresh); - void send_mode(struct ::wl_resource *resource, uint32_t flags, int32_t width, int32_t height, int32_t refresh); - void send_done(); - void send_done(struct ::wl_resource *resource); - void send_scale(int32_t factor); - void send_scale(struct ::wl_resource *resource, int32_t factor); - - protected: - virtual Resource *output_allocate(); - - virtual void output_bind_resource(Resource *resource); - virtual void output_destroy_resource(Resource *resource); - - virtual void output_release(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_output_interface m_wl_output_interface; - - static void handle_release( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_output *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_region - { - public: - wl_region(struct ::wl_client *client, uint32_t id, int version); - wl_region(struct ::wl_display *display, int version); - wl_region(struct ::wl_resource *resource); - wl_region(); - - virtual ~wl_region(); - - class Resource - { - public: - Resource() : region_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_region *region_object; - wl_region *object() { return region_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - protected: - virtual Resource *region_allocate(); - - virtual void region_bind_resource(Resource *resource); - virtual void region_destroy_resource(Resource *resource); - - virtual void region_destroy(Resource *resource); - virtual void region_add(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void region_subtract(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_region_interface m_wl_region_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_add( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_subtract( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_region *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_subcompositor - { - public: - wl_subcompositor(struct ::wl_client *client, uint32_t id, int version); - wl_subcompositor(struct ::wl_display *display, int version); - wl_subcompositor(struct ::wl_resource *resource); - wl_subcompositor(); - - virtual ~wl_subcompositor(); - - class Resource - { - public: - Resource() : subcompositor_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_subcompositor *subcompositor_object; - wl_subcompositor *object() { return subcompositor_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_bad_surface = 0, // the to-be sub-surface is invalid - }; - - protected: - virtual Resource *subcompositor_allocate(); - - virtual void subcompositor_bind_resource(Resource *resource); - virtual void subcompositor_destroy_resource(Resource *resource); - - virtual void subcompositor_destroy(Resource *resource); - virtual void subcompositor_get_subsurface(Resource *resource, uint32_t id, struct ::wl_resource *surface, struct ::wl_resource *parent); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_subcompositor_interface m_wl_subcompositor_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_get_subsurface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface, - struct ::wl_resource *parent); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_subcompositor *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class wl_subsurface - { - public: - wl_subsurface(struct ::wl_client *client, uint32_t id, int version); - wl_subsurface(struct ::wl_display *display, int version); - wl_subsurface(struct ::wl_resource *resource); - wl_subsurface(); - - virtual ~wl_subsurface(); - - class Resource - { - public: - Resource() : subsurface_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - wl_subsurface *subsurface_object; - wl_subsurface *object() { return subsurface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_bad_surface = 0, // wl_surface is not a sibling or the parent - }; - - protected: - virtual Resource *subsurface_allocate(); - - virtual void subsurface_bind_resource(Resource *resource); - virtual void subsurface_destroy_resource(Resource *resource); - - virtual void subsurface_destroy(Resource *resource); - virtual void subsurface_set_position(Resource *resource, int32_t x, int32_t y); - virtual void subsurface_place_above(Resource *resource, struct ::wl_resource *sibling); - virtual void subsurface_place_below(Resource *resource, struct ::wl_resource *sibling); - virtual void subsurface_set_sync(Resource *resource); - virtual void subsurface_set_desync(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::wl_subsurface_interface m_wl_subsurface_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_position( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y); - static void handle_place_above( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *sibling); - static void handle_place_below( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *sibling); - static void handle_set_sync( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_desync( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - wl_subsurface *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp b/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp deleted file mode 100644 index eba1832..0000000 --- a/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp +++ /dev/null @@ -1,1508 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/xdg-shell-unstable-v6.xml */ - -#include "dswayland-server-xdg-shell-unstable-v6.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - zxdg_shell_v6::zxdg_shell_v6(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zxdg_shell_v6::zxdg_shell_v6(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zxdg_shell_v6::zxdg_shell_v6(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zxdg_shell_v6::zxdg_shell_v6() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zxdg_shell_v6::~zxdg_shell_v6() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zxdg_shell_v6::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zxdg_shell_v6::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zxdg_shell_v6::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zxdg_shell_v6::Resource *zxdg_shell_v6::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zxdg_shell_v6::Resource *zxdg_shell_v6::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zxdg_shell_v6::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zxdg_shell_v6_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zxdg_shell_v6::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zxdg_shell_v6::interface() - { - return &::zxdg_shell_v6_interface; - } - - zxdg_shell_v6::Resource *zxdg_shell_v6::zxdg_shell_v6_allocate() - { - return new Resource; - } - - void zxdg_shell_v6::zxdg_shell_v6_bind_resource(Resource *) - { - } - - void zxdg_shell_v6::zxdg_shell_v6_destroy_resource(Resource *) - { - } - - void zxdg_shell_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zxdg_shell_v6 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zxdg_shell_v6::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zxdg_shell_v6 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zxdg_shell_v6::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zxdg_shell_v6 *that = resource->zxdg_shell_v6_object; - that->m_resource_map.erase(resource->client()); - that->zxdg_shell_v6_destroy_resource(resource); - delete resource; - } - - zxdg_shell_v6::Resource *zxdg_shell_v6::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_shell_v6_interface, version, id); - return bind(handle); - } - - zxdg_shell_v6::Resource *zxdg_shell_v6::bind(struct ::wl_resource *handle) - { - Resource *resource = zxdg_shell_v6_allocate(); - resource->zxdg_shell_v6_object = this; - - wl_resource_set_implementation(handle, &m_zxdg_shell_v6_interface, resource, destroy_func); - resource->handle = handle; - zxdg_shell_v6_bind_resource(resource); - return resource; - } - zxdg_shell_v6::Resource *zxdg_shell_v6::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zxdg_shell_v6_interface, &m_zxdg_shell_v6_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zxdg_shell_v6_interface zxdg_shell_v6::m_zxdg_shell_v6_interface = { - zxdg_shell_v6::handle_destroy, - zxdg_shell_v6::handle_create_positioner, - zxdg_shell_v6::handle_get_xdg_surface, - zxdg_shell_v6::handle_pong - }; - - void zxdg_shell_v6::zxdg_shell_v6_destroy(Resource *) - { - } - - void zxdg_shell_v6::zxdg_shell_v6_create_positioner(Resource *, uint32_t) - { - } - - void zxdg_shell_v6::zxdg_shell_v6_get_xdg_surface(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void zxdg_shell_v6::zxdg_shell_v6_pong(Resource *, uint32_t ) - { - } - - - void zxdg_shell_v6::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_shell_v6_object)->zxdg_shell_v6_destroy( - r); - } - - void zxdg_shell_v6::handle_create_positioner( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_shell_v6_object)->zxdg_shell_v6_create_positioner( - r, - id); - } - - void zxdg_shell_v6::handle_get_xdg_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_shell_v6_object)->zxdg_shell_v6_get_xdg_surface( - r, - id, - surface); - } - - void zxdg_shell_v6::handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_shell_v6_object)->zxdg_shell_v6_pong( - r, - serial); - } - - void zxdg_shell_v6::send_ping(uint32_t serial) - { - DS_ASSERT_X(m_resource, "zxdg_shell_v6::ping", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zxdg_shell_v6::ping as it's not initialised"); - return; - } - send_ping( - m_resource->handle, - serial); - } - - void zxdg_shell_v6::send_ping(struct ::wl_resource *resource, uint32_t serial) - { - zxdg_shell_v6_send_ping( - resource, - serial); - } - - - zxdg_positioner_v6::zxdg_positioner_v6(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zxdg_positioner_v6::zxdg_positioner_v6(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zxdg_positioner_v6::zxdg_positioner_v6(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zxdg_positioner_v6::zxdg_positioner_v6() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zxdg_positioner_v6::~zxdg_positioner_v6() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zxdg_positioner_v6::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zxdg_positioner_v6::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zxdg_positioner_v6::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zxdg_positioner_v6::Resource *zxdg_positioner_v6::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zxdg_positioner_v6::Resource *zxdg_positioner_v6::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zxdg_positioner_v6::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zxdg_positioner_v6_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zxdg_positioner_v6::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zxdg_positioner_v6::interface() - { - return &::zxdg_positioner_v6_interface; - } - - zxdg_positioner_v6::Resource *zxdg_positioner_v6::zxdg_positioner_v6_allocate() - { - return new Resource; - } - - void zxdg_positioner_v6::zxdg_positioner_v6_bind_resource(Resource *) - { - } - - void zxdg_positioner_v6::zxdg_positioner_v6_destroy_resource(Resource *) - { - } - - void zxdg_positioner_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zxdg_positioner_v6 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zxdg_positioner_v6::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zxdg_positioner_v6 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zxdg_positioner_v6::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zxdg_positioner_v6 *that = resource->zxdg_positioner_v6_object; - that->m_resource_map.erase(resource->client()); - that->zxdg_positioner_v6_destroy_resource(resource); - delete resource; - } - - zxdg_positioner_v6::Resource *zxdg_positioner_v6::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_positioner_v6_interface, version, id); - return bind(handle); - } - - zxdg_positioner_v6::Resource *zxdg_positioner_v6::bind(struct ::wl_resource *handle) - { - Resource *resource = zxdg_positioner_v6_allocate(); - resource->zxdg_positioner_v6_object = this; - - wl_resource_set_implementation(handle, &m_zxdg_positioner_v6_interface, resource, destroy_func); - resource->handle = handle; - zxdg_positioner_v6_bind_resource(resource); - return resource; - } - zxdg_positioner_v6::Resource *zxdg_positioner_v6::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zxdg_positioner_v6_interface, &m_zxdg_positioner_v6_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zxdg_positioner_v6_interface zxdg_positioner_v6::m_zxdg_positioner_v6_interface = { - zxdg_positioner_v6::handle_destroy, - zxdg_positioner_v6::handle_set_size, - zxdg_positioner_v6::handle_set_anchor_rect, - zxdg_positioner_v6::handle_set_anchor, - zxdg_positioner_v6::handle_set_gravity, - zxdg_positioner_v6::handle_set_constraint_adjustment, - zxdg_positioner_v6::handle_set_offset - }; - - void zxdg_positioner_v6::zxdg_positioner_v6_destroy(Resource *) - { - } - - void zxdg_positioner_v6::zxdg_positioner_v6_set_size(Resource *, int32_t , int32_t ) - { - } - - void zxdg_positioner_v6::zxdg_positioner_v6_set_anchor_rect(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void zxdg_positioner_v6::zxdg_positioner_v6_set_anchor(Resource *, uint32_t ) - { - } - - void zxdg_positioner_v6::zxdg_positioner_v6_set_gravity(Resource *, uint32_t ) - { - } - - void zxdg_positioner_v6::zxdg_positioner_v6_set_constraint_adjustment(Resource *, uint32_t ) - { - } - - void zxdg_positioner_v6::zxdg_positioner_v6_set_offset(Resource *, int32_t , int32_t ) - { - } - - - void zxdg_positioner_v6::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_destroy( - r); - } - - void zxdg_positioner_v6::handle_set_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_size( - r, - width, - height); - } - - void zxdg_positioner_v6::handle_set_anchor_rect( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_anchor_rect( - r, - x, - y, - width, - height); - } - - void zxdg_positioner_v6::handle_set_anchor( - ::wl_client *client, - struct wl_resource *resource, - uint32_t anchor) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_anchor( - r, - anchor); - } - - void zxdg_positioner_v6::handle_set_gravity( - ::wl_client *client, - struct wl_resource *resource, - uint32_t gravity) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_gravity( - r, - gravity); - } - - void zxdg_positioner_v6::handle_set_constraint_adjustment( - ::wl_client *client, - struct wl_resource *resource, - uint32_t constraint_adjustment) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_constraint_adjustment( - r, - constraint_adjustment); - } - - void zxdg_positioner_v6::handle_set_offset( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_positioner_v6_object)->zxdg_positioner_v6_set_offset( - r, - x, - y); - } - - zxdg_surface_v6::zxdg_surface_v6(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zxdg_surface_v6::zxdg_surface_v6(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zxdg_surface_v6::zxdg_surface_v6(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zxdg_surface_v6::zxdg_surface_v6() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zxdg_surface_v6::~zxdg_surface_v6() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zxdg_surface_v6::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zxdg_surface_v6::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zxdg_surface_v6::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zxdg_surface_v6::Resource *zxdg_surface_v6::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zxdg_surface_v6::Resource *zxdg_surface_v6::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zxdg_surface_v6::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zxdg_surface_v6_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zxdg_surface_v6::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zxdg_surface_v6::interface() - { - return &::zxdg_surface_v6_interface; - } - - zxdg_surface_v6::Resource *zxdg_surface_v6::zxdg_surface_v6_allocate() - { - return new Resource; - } - - void zxdg_surface_v6::zxdg_surface_v6_bind_resource(Resource *) - { - } - - void zxdg_surface_v6::zxdg_surface_v6_destroy_resource(Resource *) - { - } - - void zxdg_surface_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zxdg_surface_v6 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zxdg_surface_v6::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zxdg_surface_v6 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zxdg_surface_v6::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zxdg_surface_v6 *that = resource->zxdg_surface_v6_object; - that->m_resource_map.erase(resource->client()); - that->zxdg_surface_v6_destroy_resource(resource); - delete resource; - } - - zxdg_surface_v6::Resource *zxdg_surface_v6::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_surface_v6_interface, version, id); - return bind(handle); - } - - zxdg_surface_v6::Resource *zxdg_surface_v6::bind(struct ::wl_resource *handle) - { - Resource *resource = zxdg_surface_v6_allocate(); - resource->zxdg_surface_v6_object = this; - - wl_resource_set_implementation(handle, &m_zxdg_surface_v6_interface, resource, destroy_func); - resource->handle = handle; - zxdg_surface_v6_bind_resource(resource); - return resource; - } - zxdg_surface_v6::Resource *zxdg_surface_v6::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zxdg_surface_v6_interface, &m_zxdg_surface_v6_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zxdg_surface_v6_interface zxdg_surface_v6::m_zxdg_surface_v6_interface = { - zxdg_surface_v6::handle_destroy, - zxdg_surface_v6::handle_get_toplevel, - zxdg_surface_v6::handle_get_popup, - zxdg_surface_v6::handle_set_window_geometry, - zxdg_surface_v6::handle_ack_configure - }; - - void zxdg_surface_v6::zxdg_surface_v6_destroy(Resource *) - { - } - - void zxdg_surface_v6::zxdg_surface_v6_get_toplevel(Resource *, uint32_t) - { - } - - void zxdg_surface_v6::zxdg_surface_v6_get_popup(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *) - { - } - - void zxdg_surface_v6::zxdg_surface_v6_set_window_geometry(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void zxdg_surface_v6::zxdg_surface_v6_ack_configure(Resource *, uint32_t ) - { - } - - - void zxdg_surface_v6::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_destroy( - r); - } - - void zxdg_surface_v6::handle_get_toplevel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_get_toplevel( - r, - id); - } - - void zxdg_surface_v6::handle_get_popup( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *parent, - struct ::wl_resource *positioner) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_get_popup( - r, - id, - parent, - positioner); - } - - void zxdg_surface_v6::handle_set_window_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_set_window_geometry( - r, - x, - y, - width, - height); - } - - void zxdg_surface_v6::handle_ack_configure( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_surface_v6_object)->zxdg_surface_v6_ack_configure( - r, - serial); - } - - void zxdg_surface_v6::send_configure(uint32_t serial) - { - DS_ASSERT_X(m_resource, "zxdg_surface_v6::configure", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zxdg_surface_v6::configure as it's not initialised"); - return; - } - send_configure( - m_resource->handle, - serial); - } - - void zxdg_surface_v6::send_configure(struct ::wl_resource *resource, uint32_t serial) - { - zxdg_surface_v6_send_configure( - resource, - serial); - } - - - zxdg_toplevel_v6::zxdg_toplevel_v6(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zxdg_toplevel_v6::zxdg_toplevel_v6(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zxdg_toplevel_v6::zxdg_toplevel_v6(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zxdg_toplevel_v6::zxdg_toplevel_v6() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zxdg_toplevel_v6::~zxdg_toplevel_v6() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zxdg_toplevel_v6::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zxdg_toplevel_v6::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zxdg_toplevel_v6::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zxdg_toplevel_v6::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zxdg_toplevel_v6_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zxdg_toplevel_v6::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zxdg_toplevel_v6::interface() - { - return &::zxdg_toplevel_v6_interface; - } - - zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::zxdg_toplevel_v6_allocate() - { - return new Resource; - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_bind_resource(Resource *) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_destroy_resource(Resource *) - { - } - - void zxdg_toplevel_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zxdg_toplevel_v6 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zxdg_toplevel_v6::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zxdg_toplevel_v6 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zxdg_toplevel_v6::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zxdg_toplevel_v6 *that = resource->zxdg_toplevel_v6_object; - that->m_resource_map.erase(resource->client()); - that->zxdg_toplevel_v6_destroy_resource(resource); - delete resource; - } - - zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_toplevel_v6_interface, version, id); - return bind(handle); - } - - zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::bind(struct ::wl_resource *handle) - { - Resource *resource = zxdg_toplevel_v6_allocate(); - resource->zxdg_toplevel_v6_object = this; - - wl_resource_set_implementation(handle, &m_zxdg_toplevel_v6_interface, resource, destroy_func); - resource->handle = handle; - zxdg_toplevel_v6_bind_resource(resource); - return resource; - } - zxdg_toplevel_v6::Resource *zxdg_toplevel_v6::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zxdg_toplevel_v6_interface, &m_zxdg_toplevel_v6_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zxdg_toplevel_v6_interface zxdg_toplevel_v6::m_zxdg_toplevel_v6_interface = { - zxdg_toplevel_v6::handle_destroy, - zxdg_toplevel_v6::handle_set_parent, - zxdg_toplevel_v6::handle_set_title, - zxdg_toplevel_v6::handle_set_app_id, - zxdg_toplevel_v6::handle_show_window_menu, - zxdg_toplevel_v6::handle_move, - zxdg_toplevel_v6::handle_resize, - zxdg_toplevel_v6::handle_set_max_size, - zxdg_toplevel_v6::handle_set_min_size, - zxdg_toplevel_v6::handle_set_maximized, - zxdg_toplevel_v6::handle_unset_maximized, - zxdg_toplevel_v6::handle_set_fullscreen, - zxdg_toplevel_v6::handle_unset_fullscreen, - zxdg_toplevel_v6::handle_set_minimized - }; - - void zxdg_toplevel_v6::zxdg_toplevel_v6_destroy(Resource *) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_set_parent(Resource *, struct ::wl_resource *) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_set_title(Resource *, const std::string &) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_set_app_id(Resource *, const std::string &) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_show_window_menu(Resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t ) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_move(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_resize(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_set_max_size(Resource *, int32_t , int32_t ) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_set_min_size(Resource *, int32_t , int32_t ) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_set_maximized(Resource *) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_unset_maximized(Resource *) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_set_fullscreen(Resource *, struct ::wl_resource *) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_unset_fullscreen(Resource *) - { - } - - void zxdg_toplevel_v6::zxdg_toplevel_v6_set_minimized(Resource *) - { - } - - - void zxdg_toplevel_v6::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_destroy( - r); - } - - void zxdg_toplevel_v6::handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_parent( - r, - parent); - } - - void zxdg_toplevel_v6::handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_title( - r, - std::string(title)); - } - - void zxdg_toplevel_v6::handle_set_app_id( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_app_id( - r, - std::string(app_id)); - } - - void zxdg_toplevel_v6::handle_show_window_menu( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_show_window_menu( - r, - seat, - serial, - x, - y); - } - - void zxdg_toplevel_v6::handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_move( - r, - seat, - serial); - } - - void zxdg_toplevel_v6::handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_resize( - r, - seat, - serial, - edges); - } - - void zxdg_toplevel_v6::handle_set_max_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_max_size( - r, - width, - height); - } - - void zxdg_toplevel_v6::handle_set_min_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_min_size( - r, - width, - height); - } - - void zxdg_toplevel_v6::handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_maximized( - r); - } - - void zxdg_toplevel_v6::handle_unset_maximized( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_unset_maximized( - r); - } - - void zxdg_toplevel_v6::handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_fullscreen( - r, - output); - } - - void zxdg_toplevel_v6::handle_unset_fullscreen( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_unset_fullscreen( - r); - } - - void zxdg_toplevel_v6::handle_set_minimized( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_toplevel_v6_object)->zxdg_toplevel_v6_set_minimized( - r); - } - - void zxdg_toplevel_v6::send_configure(int32_t width, int32_t height, struct ::wl_array *states) - { - DS_ASSERT_X(m_resource, "zxdg_toplevel_v6::configure", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zxdg_toplevel_v6::configure as it's not initialised"); - return; - } - send_configure( - m_resource->handle, - width, - height, - states); - } - - void zxdg_toplevel_v6::send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, struct ::wl_array *states) - { - zxdg_toplevel_v6_send_configure( - resource, - width, - height, - states); - } - - - void zxdg_toplevel_v6::send_close() - { - DS_ASSERT_X(m_resource, "zxdg_toplevel_v6::close", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zxdg_toplevel_v6::close as it's not initialised"); - return; - } - send_close( - m_resource->handle); - } - - void zxdg_toplevel_v6::send_close(struct ::wl_resource *resource) - { - zxdg_toplevel_v6_send_close( - resource); - } - - - zxdg_popup_v6::zxdg_popup_v6(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - zxdg_popup_v6::zxdg_popup_v6(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - zxdg_popup_v6::zxdg_popup_v6(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - zxdg_popup_v6::zxdg_popup_v6() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - zxdg_popup_v6::~zxdg_popup_v6() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - zxdg_popup_v6::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void zxdg_popup_v6::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void zxdg_popup_v6::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - zxdg_popup_v6::Resource *zxdg_popup_v6::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - zxdg_popup_v6::Resource *zxdg_popup_v6::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void zxdg_popup_v6::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::zxdg_popup_v6_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = zxdg_popup_v6::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *zxdg_popup_v6::interface() - { - return &::zxdg_popup_v6_interface; - } - - zxdg_popup_v6::Resource *zxdg_popup_v6::zxdg_popup_v6_allocate() - { - return new Resource; - } - - void zxdg_popup_v6::zxdg_popup_v6_bind_resource(Resource *) - { - } - - void zxdg_popup_v6::zxdg_popup_v6_destroy_resource(Resource *) - { - } - - void zxdg_popup_v6::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - zxdg_popup_v6 *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void zxdg_popup_v6::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - zxdg_popup_v6 *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void zxdg_popup_v6::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - zxdg_popup_v6 *that = resource->zxdg_popup_v6_object; - that->m_resource_map.erase(resource->client()); - that->zxdg_popup_v6_destroy_resource(resource); - delete resource; - } - - zxdg_popup_v6::Resource *zxdg_popup_v6::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::zxdg_popup_v6_interface, version, id); - return bind(handle); - } - - zxdg_popup_v6::Resource *zxdg_popup_v6::bind(struct ::wl_resource *handle) - { - Resource *resource = zxdg_popup_v6_allocate(); - resource->zxdg_popup_v6_object = this; - - wl_resource_set_implementation(handle, &m_zxdg_popup_v6_interface, resource, destroy_func); - resource->handle = handle; - zxdg_popup_v6_bind_resource(resource); - return resource; - } - zxdg_popup_v6::Resource *zxdg_popup_v6::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::zxdg_popup_v6_interface, &m_zxdg_popup_v6_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::zxdg_popup_v6_interface zxdg_popup_v6::m_zxdg_popup_v6_interface = { - zxdg_popup_v6::handle_destroy, - zxdg_popup_v6::handle_grab - }; - - void zxdg_popup_v6::zxdg_popup_v6_destroy(Resource *) - { - } - - void zxdg_popup_v6::zxdg_popup_v6_grab(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - - void zxdg_popup_v6::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_popup_v6_object)->zxdg_popup_v6_destroy( - r); - } - - void zxdg_popup_v6::handle_grab( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->zxdg_popup_v6_object)->zxdg_popup_v6_grab( - r, - seat, - serial); - } - - void zxdg_popup_v6::send_configure(int32_t x, int32_t y, int32_t width, int32_t height) - { - DS_ASSERT_X(m_resource, "zxdg_popup_v6::configure", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zxdg_popup_v6::configure as it's not initialised"); - return; - } - send_configure( - m_resource->handle, - x, - y, - width, - height); - } - - void zxdg_popup_v6::send_configure(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) - { - zxdg_popup_v6_send_configure( - resource, - x, - y, - width, - height); - } - - - void zxdg_popup_v6::send_popup_done() - { - DS_ASSERT_X(m_resource, "zxdg_popup_v6::popup_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call zxdg_popup_v6::popup_done as it's not initialised"); - return; - } - send_popup_done( - m_resource->handle); - } - - void zxdg_popup_v6::send_popup_done(struct ::wl_resource *resource) - { - zxdg_popup_v6_send_popup_done( - resource); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h b/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h deleted file mode 100644 index 3de2c92..0000000 --- a/src/DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h +++ /dev/null @@ -1,666 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/xdg-shell-unstable-v6.xml */ - -#ifndef __DS_XDG_SHELL_UNSTABLE_V6_PROTOCOL_H__ -#define __DS_XDG_SHELL_UNSTABLE_V6_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "xdg-shell-unstable-v6-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class zxdg_shell_v6 - { - public: - zxdg_shell_v6(struct ::wl_client *client, uint32_t id, int version); - zxdg_shell_v6(struct ::wl_display *display, int version); - zxdg_shell_v6(struct ::wl_resource *resource); - zxdg_shell_v6(); - - virtual ~zxdg_shell_v6(); - - class Resource - { - public: - Resource() : zxdg_shell_v6_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zxdg_shell_v6 *zxdg_shell_v6_object; - zxdg_shell_v6 *object() { return zxdg_shell_v6_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_role = 0, // given wl_surface has another role - error_defunct_surfaces = 1, // xdg_shell was destroyed before children - error_not_the_topmost_popup = 2, // the client tried to map or destroy a non-topmost popup - error_invalid_popup_parent = 3, // the client specified an invalid popup parent surface - error_invalid_surface_state = 4, // the client provided an invalid surface state - error_invalid_positioner = 5, // the client provided an invalid positioner - }; - - void send_ping(uint32_t serial); - void send_ping(struct ::wl_resource *resource, uint32_t serial); - - protected: - virtual Resource *zxdg_shell_v6_allocate(); - - virtual void zxdg_shell_v6_bind_resource(Resource *resource); - virtual void zxdg_shell_v6_destroy_resource(Resource *resource); - - virtual void zxdg_shell_v6_destroy(Resource *resource); - virtual void zxdg_shell_v6_create_positioner(Resource *resource, uint32_t id); - virtual void zxdg_shell_v6_get_xdg_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void zxdg_shell_v6_pong(Resource *resource, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zxdg_shell_v6_interface m_zxdg_shell_v6_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_create_positioner( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_get_xdg_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zxdg_shell_v6 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class zxdg_positioner_v6 - { - public: - zxdg_positioner_v6(struct ::wl_client *client, uint32_t id, int version); - zxdg_positioner_v6(struct ::wl_display *display, int version); - zxdg_positioner_v6(struct ::wl_resource *resource); - zxdg_positioner_v6(); - - virtual ~zxdg_positioner_v6(); - - class Resource - { - public: - Resource() : zxdg_positioner_v6_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zxdg_positioner_v6 *zxdg_positioner_v6_object; - zxdg_positioner_v6 *object() { return zxdg_positioner_v6_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_input = 0, // invalid input provided - }; - - enum anchor { - anchor_none = 0, // the center of the anchor rectangle - anchor_top = 1, // the top edge of the anchor rectangle - anchor_bottom = 2, // the bottom edge of the anchor rectangle - anchor_left = 4, // the left edge of the anchor rectangle - anchor_right = 8, // the right edge of the anchor rectangle - }; - - enum gravity { - gravity_none = 0, // center over the anchor edge - gravity_top = 1, // position above the anchor edge - gravity_bottom = 2, // position below the anchor edge - gravity_left = 4, // position to the left of the anchor edge - gravity_right = 8, // position to the right of the anchor edge - }; - - enum constraint_adjustment { - constraint_adjustment_none = 0, - constraint_adjustment_slide_x = 1, - constraint_adjustment_slide_y = 2, - constraint_adjustment_flip_x = 4, - constraint_adjustment_flip_y = 8, - constraint_adjustment_resize_x = 16, - constraint_adjustment_resize_y = 32, - }; - - protected: - virtual Resource *zxdg_positioner_v6_allocate(); - - virtual void zxdg_positioner_v6_bind_resource(Resource *resource); - virtual void zxdg_positioner_v6_destroy_resource(Resource *resource); - - virtual void zxdg_positioner_v6_destroy(Resource *resource); - virtual void zxdg_positioner_v6_set_size(Resource *resource, int32_t width, int32_t height); - virtual void zxdg_positioner_v6_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void zxdg_positioner_v6_set_anchor(Resource *resource, uint32_t anchor); - virtual void zxdg_positioner_v6_set_gravity(Resource *resource, uint32_t gravity); - virtual void zxdg_positioner_v6_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment); - virtual void zxdg_positioner_v6_set_offset(Resource *resource, int32_t x, int32_t y); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zxdg_positioner_v6_interface m_zxdg_positioner_v6_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - static void handle_set_anchor_rect( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_set_anchor( - ::wl_client *client, - struct wl_resource *resource, - uint32_t anchor); - static void handle_set_gravity( - ::wl_client *client, - struct wl_resource *resource, - uint32_t gravity); - static void handle_set_constraint_adjustment( - ::wl_client *client, - struct wl_resource *resource, - uint32_t constraint_adjustment); - static void handle_set_offset( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zxdg_positioner_v6 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class zxdg_surface_v6 - { - public: - zxdg_surface_v6(struct ::wl_client *client, uint32_t id, int version); - zxdg_surface_v6(struct ::wl_display *display, int version); - zxdg_surface_v6(struct ::wl_resource *resource); - zxdg_surface_v6(); - - virtual ~zxdg_surface_v6(); - - class Resource - { - public: - Resource() : zxdg_surface_v6_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zxdg_surface_v6 *zxdg_surface_v6_object; - zxdg_surface_v6 *object() { return zxdg_surface_v6_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_not_constructed = 1, - error_already_constructed = 2, - error_unconfigured_buffer = 3, - }; - - void send_configure(uint32_t serial); - void send_configure(struct ::wl_resource *resource, uint32_t serial); - - protected: - virtual Resource *zxdg_surface_v6_allocate(); - - virtual void zxdg_surface_v6_bind_resource(Resource *resource); - virtual void zxdg_surface_v6_destroy_resource(Resource *resource); - - virtual void zxdg_surface_v6_destroy(Resource *resource); - virtual void zxdg_surface_v6_get_toplevel(Resource *resource, uint32_t id); - virtual void zxdg_surface_v6_get_popup(Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner); - virtual void zxdg_surface_v6_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void zxdg_surface_v6_ack_configure(Resource *resource, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zxdg_surface_v6_interface m_zxdg_surface_v6_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_get_toplevel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_get_popup( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *parent, - struct ::wl_resource *positioner); - static void handle_set_window_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_ack_configure( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zxdg_surface_v6 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class zxdg_toplevel_v6 - { - public: - zxdg_toplevel_v6(struct ::wl_client *client, uint32_t id, int version); - zxdg_toplevel_v6(struct ::wl_display *display, int version); - zxdg_toplevel_v6(struct ::wl_resource *resource); - zxdg_toplevel_v6(); - - virtual ~zxdg_toplevel_v6(); - - class Resource - { - public: - Resource() : zxdg_toplevel_v6_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zxdg_toplevel_v6 *zxdg_toplevel_v6_object; - zxdg_toplevel_v6 *object() { return zxdg_toplevel_v6_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum resize_edge { - resize_edge_none = 0, - resize_edge_top = 1, - resize_edge_bottom = 2, - resize_edge_left = 4, - resize_edge_top_left = 5, - resize_edge_bottom_left = 6, - resize_edge_right = 8, - resize_edge_top_right = 9, - resize_edge_bottom_right = 10, - }; - - enum state { - state_maximized = 1, // the surface is maximized - state_fullscreen = 2, // the surface is fullscreen - state_resizing = 3, // the surface is being resized - state_activated = 4, // the surface is now activated - }; - - void send_configure(int32_t width, int32_t height, struct ::wl_array *states); - void send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, struct ::wl_array *states); - void send_close(); - void send_close(struct ::wl_resource *resource); - - protected: - virtual Resource *zxdg_toplevel_v6_allocate(); - - virtual void zxdg_toplevel_v6_bind_resource(Resource *resource); - virtual void zxdg_toplevel_v6_destroy_resource(Resource *resource); - - virtual void zxdg_toplevel_v6_destroy(Resource *resource); - virtual void zxdg_toplevel_v6_set_parent(Resource *resource, struct ::wl_resource *parent); - virtual void zxdg_toplevel_v6_set_title(Resource *resource, const std::string &title); - virtual void zxdg_toplevel_v6_set_app_id(Resource *resource, const std::string &app_id); - virtual void zxdg_toplevel_v6_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y); - virtual void zxdg_toplevel_v6_move(Resource *resource, struct ::wl_resource *seat, uint32_t serial); - virtual void zxdg_toplevel_v6_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges); - virtual void zxdg_toplevel_v6_set_max_size(Resource *resource, int32_t width, int32_t height); - virtual void zxdg_toplevel_v6_set_min_size(Resource *resource, int32_t width, int32_t height); - virtual void zxdg_toplevel_v6_set_maximized(Resource *resource); - virtual void zxdg_toplevel_v6_unset_maximized(Resource *resource); - virtual void zxdg_toplevel_v6_set_fullscreen(Resource *resource, struct ::wl_resource *output); - virtual void zxdg_toplevel_v6_unset_fullscreen(Resource *resource); - virtual void zxdg_toplevel_v6_set_minimized(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zxdg_toplevel_v6_interface m_zxdg_toplevel_v6_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent); - static void handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title); - static void handle_set_app_id( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id); - static void handle_show_window_menu( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - static void handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial); - static void handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges); - static void handle_set_max_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - static void handle_set_min_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - static void handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unset_maximized( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output); - static void handle_unset_fullscreen( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_minimized( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zxdg_toplevel_v6 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class zxdg_popup_v6 - { - public: - zxdg_popup_v6(struct ::wl_client *client, uint32_t id, int version); - zxdg_popup_v6(struct ::wl_display *display, int version); - zxdg_popup_v6(struct ::wl_resource *resource); - zxdg_popup_v6(); - - virtual ~zxdg_popup_v6(); - - class Resource - { - public: - Resource() : zxdg_popup_v6_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - zxdg_popup_v6 *zxdg_popup_v6_object; - zxdg_popup_v6 *object() { return zxdg_popup_v6_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_grab = 0, // tried to grab after being mapped - }; - - void send_configure(int32_t x, int32_t y, int32_t width, int32_t height); - void send_configure(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - void send_popup_done(); - void send_popup_done(struct ::wl_resource *resource); - - protected: - virtual Resource *zxdg_popup_v6_allocate(); - - virtual void zxdg_popup_v6_bind_resource(Resource *resource); - virtual void zxdg_popup_v6_destroy_resource(Resource *resource); - - virtual void zxdg_popup_v6_destroy(Resource *resource); - virtual void zxdg_popup_v6_grab(Resource *resource, struct ::wl_resource *seat, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::zxdg_popup_v6_interface m_zxdg_popup_v6_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_grab( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - zxdg_popup_v6 *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-xdg-shell.cpp b/src/DSWaylandServer/dswayland-server-xdg-shell.cpp deleted file mode 100644 index 54a147d..0000000 --- a/src/DSWaylandServer/dswayland-server-xdg-shell.cpp +++ /dev/null @@ -1,1508 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/xdg-shell.xml */ - -#include "dswayland-server-xdg-shell.h" - -#ifndef DS_UNLIKELY -#define DS_UNLIKELY(X) X -#endif -#ifndef DS_UNUSED -#define DS_UNUSED(X) (void)X -#endif -#ifndef DS_ASSERT -#define DS_ASSERT(COND) assert(COND) -#endif -#ifndef DS_ASSERT_X -#define DS_ASSERT_X(COND, ERR_TAG, ERR_MSG, X...) \ - do {\ - if (! (COND))\ - {\ - fprintf(stderr, "%s :: "#ERR_MSG, ERR_TAG, ##X);\ - assert(COND);\ - }\ - } while(0) -#endif -#ifndef WRN -#define WRN(X...) fprintf(stderr,##X) -#endif - -namespace DSWaylandServer { - xdg_wm_base::xdg_wm_base(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - xdg_wm_base::xdg_wm_base(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - xdg_wm_base::xdg_wm_base(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - xdg_wm_base::xdg_wm_base() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - xdg_wm_base::~xdg_wm_base() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - xdg_wm_base::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_wm_base::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_wm_base::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_wm_base::Resource *xdg_wm_base::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - xdg_wm_base::Resource *xdg_wm_base::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void xdg_wm_base::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_wm_base_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_wm_base::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_wm_base::interface() - { - return &::xdg_wm_base_interface; - } - - xdg_wm_base::Resource *xdg_wm_base::xdg_wm_base_allocate() - { - return new Resource; - } - - void xdg_wm_base::xdg_wm_base_bind_resource(Resource *) - { - } - - void xdg_wm_base::xdg_wm_base_destroy_resource(Resource *) - { - } - - void xdg_wm_base::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_wm_base *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void xdg_wm_base::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - xdg_wm_base *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void xdg_wm_base::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - xdg_wm_base *that = resource->xdg_wm_base_object; - that->m_resource_map.erase(resource->client()); - that->xdg_wm_base_destroy_resource(resource); - delete resource; - } - - xdg_wm_base::Resource *xdg_wm_base::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_wm_base_interface, version, id); - return bind(handle); - } - - xdg_wm_base::Resource *xdg_wm_base::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_wm_base_allocate(); - resource->xdg_wm_base_object = this; - - wl_resource_set_implementation(handle, &m_xdg_wm_base_interface, resource, destroy_func); - resource->handle = handle; - xdg_wm_base_bind_resource(resource); - return resource; - } - xdg_wm_base::Resource *xdg_wm_base::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::xdg_wm_base_interface, &m_xdg_wm_base_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::xdg_wm_base_interface xdg_wm_base::m_xdg_wm_base_interface = { - xdg_wm_base::handle_destroy, - xdg_wm_base::handle_create_positioner, - xdg_wm_base::handle_get_xdg_surface, - xdg_wm_base::handle_pong - }; - - void xdg_wm_base::xdg_wm_base_destroy(Resource *) - { - } - - void xdg_wm_base::xdg_wm_base_create_positioner(Resource *, uint32_t) - { - } - - void xdg_wm_base::xdg_wm_base_get_xdg_surface(Resource *, uint32_t, struct ::wl_resource *) - { - } - - void xdg_wm_base::xdg_wm_base_pong(Resource *, uint32_t ) - { - } - - - void xdg_wm_base::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_wm_base_object)->xdg_wm_base_destroy( - r); - } - - void xdg_wm_base::handle_create_positioner( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_wm_base_object)->xdg_wm_base_create_positioner( - r, - id); - } - - void xdg_wm_base::handle_get_xdg_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_wm_base_object)->xdg_wm_base_get_xdg_surface( - r, - id, - surface); - } - - void xdg_wm_base::handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_wm_base_object)->xdg_wm_base_pong( - r, - serial); - } - - void xdg_wm_base::send_ping(uint32_t serial) - { - DS_ASSERT_X(m_resource, "xdg_wm_base::ping", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call xdg_wm_base::ping as it's not initialised"); - return; - } - send_ping( - m_resource->handle, - serial); - } - - void xdg_wm_base::send_ping(struct ::wl_resource *resource, uint32_t serial) - { - xdg_wm_base_send_ping( - resource, - serial); - } - - - xdg_positioner::xdg_positioner(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - xdg_positioner::xdg_positioner(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - xdg_positioner::xdg_positioner(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - xdg_positioner::xdg_positioner() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - xdg_positioner::~xdg_positioner() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - xdg_positioner::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_positioner::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_positioner::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_positioner::Resource *xdg_positioner::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - xdg_positioner::Resource *xdg_positioner::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void xdg_positioner::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_positioner_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_positioner::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_positioner::interface() - { - return &::xdg_positioner_interface; - } - - xdg_positioner::Resource *xdg_positioner::xdg_positioner_allocate() - { - return new Resource; - } - - void xdg_positioner::xdg_positioner_bind_resource(Resource *) - { - } - - void xdg_positioner::xdg_positioner_destroy_resource(Resource *) - { - } - - void xdg_positioner::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_positioner *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void xdg_positioner::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - xdg_positioner *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void xdg_positioner::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - xdg_positioner *that = resource->xdg_positioner_object; - that->m_resource_map.erase(resource->client()); - that->xdg_positioner_destroy_resource(resource); - delete resource; - } - - xdg_positioner::Resource *xdg_positioner::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_positioner_interface, version, id); - return bind(handle); - } - - xdg_positioner::Resource *xdg_positioner::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_positioner_allocate(); - resource->xdg_positioner_object = this; - - wl_resource_set_implementation(handle, &m_xdg_positioner_interface, resource, destroy_func); - resource->handle = handle; - xdg_positioner_bind_resource(resource); - return resource; - } - xdg_positioner::Resource *xdg_positioner::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::xdg_positioner_interface, &m_xdg_positioner_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::xdg_positioner_interface xdg_positioner::m_xdg_positioner_interface = { - xdg_positioner::handle_destroy, - xdg_positioner::handle_set_size, - xdg_positioner::handle_set_anchor_rect, - xdg_positioner::handle_set_anchor, - xdg_positioner::handle_set_gravity, - xdg_positioner::handle_set_constraint_adjustment, - xdg_positioner::handle_set_offset - }; - - void xdg_positioner::xdg_positioner_destroy(Resource *) - { - } - - void xdg_positioner::xdg_positioner_set_size(Resource *, int32_t , int32_t ) - { - } - - void xdg_positioner::xdg_positioner_set_anchor_rect(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void xdg_positioner::xdg_positioner_set_anchor(Resource *, uint32_t ) - { - } - - void xdg_positioner::xdg_positioner_set_gravity(Resource *, uint32_t ) - { - } - - void xdg_positioner::xdg_positioner_set_constraint_adjustment(Resource *, uint32_t ) - { - } - - void xdg_positioner::xdg_positioner_set_offset(Resource *, int32_t , int32_t ) - { - } - - - void xdg_positioner::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_positioner_object)->xdg_positioner_destroy( - r); - } - - void xdg_positioner::handle_set_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_positioner_object)->xdg_positioner_set_size( - r, - width, - height); - } - - void xdg_positioner::handle_set_anchor_rect( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_positioner_object)->xdg_positioner_set_anchor_rect( - r, - x, - y, - width, - height); - } - - void xdg_positioner::handle_set_anchor( - ::wl_client *client, - struct wl_resource *resource, - uint32_t anchor) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_positioner_object)->xdg_positioner_set_anchor( - r, - anchor); - } - - void xdg_positioner::handle_set_gravity( - ::wl_client *client, - struct wl_resource *resource, - uint32_t gravity) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_positioner_object)->xdg_positioner_set_gravity( - r, - gravity); - } - - void xdg_positioner::handle_set_constraint_adjustment( - ::wl_client *client, - struct wl_resource *resource, - uint32_t constraint_adjustment) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_positioner_object)->xdg_positioner_set_constraint_adjustment( - r, - constraint_adjustment); - } - - void xdg_positioner::handle_set_offset( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_positioner_object)->xdg_positioner_set_offset( - r, - x, - y); - } - - xdg_surface::xdg_surface(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - xdg_surface::xdg_surface(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - xdg_surface::xdg_surface(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - xdg_surface::xdg_surface() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - xdg_surface::~xdg_surface() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - xdg_surface::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_surface::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_surface::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_surface::Resource *xdg_surface::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - xdg_surface::Resource *xdg_surface::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void xdg_surface::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_surface_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_surface::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_surface::interface() - { - return &::xdg_surface_interface; - } - - xdg_surface::Resource *xdg_surface::xdg_surface_allocate() - { - return new Resource; - } - - void xdg_surface::xdg_surface_bind_resource(Resource *) - { - } - - void xdg_surface::xdg_surface_destroy_resource(Resource *) - { - } - - void xdg_surface::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_surface *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void xdg_surface::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - xdg_surface *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void xdg_surface::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - xdg_surface *that = resource->xdg_surface_object; - that->m_resource_map.erase(resource->client()); - that->xdg_surface_destroy_resource(resource); - delete resource; - } - - xdg_surface::Resource *xdg_surface::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_surface_interface, version, id); - return bind(handle); - } - - xdg_surface::Resource *xdg_surface::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_surface_allocate(); - resource->xdg_surface_object = this; - - wl_resource_set_implementation(handle, &m_xdg_surface_interface, resource, destroy_func); - resource->handle = handle; - xdg_surface_bind_resource(resource); - return resource; - } - xdg_surface::Resource *xdg_surface::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::xdg_surface_interface, &m_xdg_surface_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::xdg_surface_interface xdg_surface::m_xdg_surface_interface = { - xdg_surface::handle_destroy, - xdg_surface::handle_get_toplevel, - xdg_surface::handle_get_popup, - xdg_surface::handle_set_window_geometry, - xdg_surface::handle_ack_configure - }; - - void xdg_surface::xdg_surface_destroy(Resource *) - { - } - - void xdg_surface::xdg_surface_get_toplevel(Resource *, uint32_t) - { - } - - void xdg_surface::xdg_surface_get_popup(Resource *, uint32_t, struct ::wl_resource *, struct ::wl_resource *) - { - } - - void xdg_surface::xdg_surface_set_window_geometry(Resource *, int32_t , int32_t , int32_t , int32_t ) - { - } - - void xdg_surface::xdg_surface_ack_configure(Resource *, uint32_t ) - { - } - - - void xdg_surface::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_surface_object)->xdg_surface_destroy( - r); - } - - void xdg_surface::handle_get_toplevel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_surface_object)->xdg_surface_get_toplevel( - r, - id); - } - - void xdg_surface::handle_get_popup( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *parent, - struct ::wl_resource *positioner) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_surface_object)->xdg_surface_get_popup( - r, - id, - parent, - positioner); - } - - void xdg_surface::handle_set_window_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_surface_object)->xdg_surface_set_window_geometry( - r, - x, - y, - width, - height); - } - - void xdg_surface::handle_ack_configure( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_surface_object)->xdg_surface_ack_configure( - r, - serial); - } - - void xdg_surface::send_configure(uint32_t serial) - { - DS_ASSERT_X(m_resource, "xdg_surface::configure", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call xdg_surface::configure as it's not initialised"); - return; - } - send_configure( - m_resource->handle, - serial); - } - - void xdg_surface::send_configure(struct ::wl_resource *resource, uint32_t serial) - { - xdg_surface_send_configure( - resource, - serial); - } - - - xdg_toplevel::xdg_toplevel(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - xdg_toplevel::xdg_toplevel(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - xdg_toplevel::xdg_toplevel(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - xdg_toplevel::xdg_toplevel() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - xdg_toplevel::~xdg_toplevel() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - xdg_toplevel::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_toplevel::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_toplevel::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_toplevel::Resource *xdg_toplevel::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - xdg_toplevel::Resource *xdg_toplevel::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void xdg_toplevel::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_toplevel_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_toplevel::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_toplevel::interface() - { - return &::xdg_toplevel_interface; - } - - xdg_toplevel::Resource *xdg_toplevel::xdg_toplevel_allocate() - { - return new Resource; - } - - void xdg_toplevel::xdg_toplevel_bind_resource(Resource *) - { - } - - void xdg_toplevel::xdg_toplevel_destroy_resource(Resource *) - { - } - - void xdg_toplevel::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_toplevel *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void xdg_toplevel::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - xdg_toplevel *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void xdg_toplevel::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - xdg_toplevel *that = resource->xdg_toplevel_object; - that->m_resource_map.erase(resource->client()); - that->xdg_toplevel_destroy_resource(resource); - delete resource; - } - - xdg_toplevel::Resource *xdg_toplevel::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_toplevel_interface, version, id); - return bind(handle); - } - - xdg_toplevel::Resource *xdg_toplevel::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_toplevel_allocate(); - resource->xdg_toplevel_object = this; - - wl_resource_set_implementation(handle, &m_xdg_toplevel_interface, resource, destroy_func); - resource->handle = handle; - xdg_toplevel_bind_resource(resource); - return resource; - } - xdg_toplevel::Resource *xdg_toplevel::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::xdg_toplevel_interface, &m_xdg_toplevel_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::xdg_toplevel_interface xdg_toplevel::m_xdg_toplevel_interface = { - xdg_toplevel::handle_destroy, - xdg_toplevel::handle_set_parent, - xdg_toplevel::handle_set_title, - xdg_toplevel::handle_set_app_id, - xdg_toplevel::handle_show_window_menu, - xdg_toplevel::handle_move, - xdg_toplevel::handle_resize, - xdg_toplevel::handle_set_max_size, - xdg_toplevel::handle_set_min_size, - xdg_toplevel::handle_set_maximized, - xdg_toplevel::handle_unset_maximized, - xdg_toplevel::handle_set_fullscreen, - xdg_toplevel::handle_unset_fullscreen, - xdg_toplevel::handle_set_minimized - }; - - void xdg_toplevel::xdg_toplevel_destroy(Resource *) - { - } - - void xdg_toplevel::xdg_toplevel_set_parent(Resource *, struct ::wl_resource *) - { - } - - void xdg_toplevel::xdg_toplevel_set_title(Resource *, const std::string &) - { - } - - void xdg_toplevel::xdg_toplevel_set_app_id(Resource *, const std::string &) - { - } - - void xdg_toplevel::xdg_toplevel_show_window_menu(Resource *, struct ::wl_resource *, uint32_t , int32_t , int32_t ) - { - } - - void xdg_toplevel::xdg_toplevel_move(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - void xdg_toplevel::xdg_toplevel_resize(Resource *, struct ::wl_resource *, uint32_t , uint32_t ) - { - } - - void xdg_toplevel::xdg_toplevel_set_max_size(Resource *, int32_t , int32_t ) - { - } - - void xdg_toplevel::xdg_toplevel_set_min_size(Resource *, int32_t , int32_t ) - { - } - - void xdg_toplevel::xdg_toplevel_set_maximized(Resource *) - { - } - - void xdg_toplevel::xdg_toplevel_unset_maximized(Resource *) - { - } - - void xdg_toplevel::xdg_toplevel_set_fullscreen(Resource *, struct ::wl_resource *) - { - } - - void xdg_toplevel::xdg_toplevel_unset_fullscreen(Resource *) - { - } - - void xdg_toplevel::xdg_toplevel_set_minimized(Resource *) - { - } - - - void xdg_toplevel::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_destroy( - r); - } - - void xdg_toplevel::handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_parent( - r, - parent); - } - - void xdg_toplevel::handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_title( - r, - std::string(title)); - } - - void xdg_toplevel::handle_set_app_id( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_app_id( - r, - std::string(app_id)); - } - - void xdg_toplevel::handle_show_window_menu( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_show_window_menu( - r, - seat, - serial, - x, - y); - } - - void xdg_toplevel::handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_move( - r, - seat, - serial); - } - - void xdg_toplevel::handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_resize( - r, - seat, - serial, - edges); - } - - void xdg_toplevel::handle_set_max_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_max_size( - r, - width, - height); - } - - void xdg_toplevel::handle_set_min_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_min_size( - r, - width, - height); - } - - void xdg_toplevel::handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_maximized( - r); - } - - void xdg_toplevel::handle_unset_maximized( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_unset_maximized( - r); - } - - void xdg_toplevel::handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_fullscreen( - r, - output); - } - - void xdg_toplevel::handle_unset_fullscreen( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_unset_fullscreen( - r); - } - - void xdg_toplevel::handle_set_minimized( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_toplevel_object)->xdg_toplevel_set_minimized( - r); - } - - void xdg_toplevel::send_configure(int32_t width, int32_t height, struct ::wl_array *states) - { - DS_ASSERT_X(m_resource, "xdg_toplevel::configure", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call xdg_toplevel::configure as it's not initialised"); - return; - } - send_configure( - m_resource->handle, - width, - height, - states); - } - - void xdg_toplevel::send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, struct ::wl_array *states) - { - xdg_toplevel_send_configure( - resource, - width, - height, - states); - } - - - void xdg_toplevel::send_close() - { - DS_ASSERT_X(m_resource, "xdg_toplevel::close", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call xdg_toplevel::close as it's not initialised"); - return; - } - send_close( - m_resource->handle); - } - - void xdg_toplevel::send_close(struct ::wl_resource *resource) - { - xdg_toplevel_send_close( - resource); - } - - - xdg_popup::xdg_popup(struct ::wl_client *client, uint32_t id, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(client, id, version); - } - - xdg_popup::xdg_popup(struct ::wl_display *display, int version) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(display, version); - } - - xdg_popup::xdg_popup(struct ::wl_resource *resource) - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - init(resource); - } - - xdg_popup::xdg_popup() - : m_resource_map() - , m_resource(NULL) - , m_global(NULL) - , m_globalVersion(0) - , m_displayDestroyedListener() - { - } - - xdg_popup::~xdg_popup() - { - std::multimap::iterator it; - for (it = m_resource_map.begin() ; it != m_resource_map.end() ; it++) { - xdg_popup::Resource *resource = (*it).second; - wl_resource_set_implementation(resource->handle, NULL, NULL, NULL); - } - - if (m_global) { - wl_global_destroy(m_global); - wl_list_remove(&m_displayDestroyedListener.link); - } - } - - void xdg_popup::init(struct ::wl_client *client, uint32_t id, int version) - { - m_resource = bind(client, id, version); - } - - void xdg_popup::init(struct ::wl_resource *resource) - { - m_resource = bind(resource); - } - - xdg_popup::Resource *xdg_popup::add(struct ::wl_client *client, int version) - { - Resource *resource = bind(client, 0, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - xdg_popup::Resource *xdg_popup::add(struct ::wl_client *client, uint32_t id, int version) - { - Resource *resource = bind(client, id, version); - m_resource_map.insert(std::pair(client, resource)); - return resource; - } - - void xdg_popup::init(struct ::wl_display *display, int version) - { - m_global = wl_global_create(display, &::xdg_popup_interface, version, this, bind_func); - m_globalVersion = version; - m_displayDestroyedListener.notify = xdg_popup::display_destroy_func; - m_displayDestroyedListener.parent = this; - wl_display_add_destroy_listener(display, &m_displayDestroyedListener); - } - - const struct wl_interface *xdg_popup::interface() - { - return &::xdg_popup_interface; - } - - xdg_popup::Resource *xdg_popup::xdg_popup_allocate() - { - return new Resource; - } - - void xdg_popup::xdg_popup_bind_resource(Resource *) - { - } - - void xdg_popup::xdg_popup_destroy_resource(Resource *) - { - } - - void xdg_popup::bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id) - { - xdg_popup *that = static_cast(data); - that->add(client, id, std::min(that->m_globalVersion, version)); - } - - void xdg_popup::display_destroy_func(struct ::wl_listener *listener, void *data) - { - DS_UNUSED(data); - xdg_popup *that = static_cast(listener)->parent; - that->m_global = NULL; - } - - void xdg_popup::destroy_func(struct ::wl_resource *client_resource) - { - Resource *resource = Resource::fromResource(client_resource); - DS_ASSERT(resource); - xdg_popup *that = resource->xdg_popup_object; - that->m_resource_map.erase(resource->client()); - that->xdg_popup_destroy_resource(resource); - delete resource; - } - - xdg_popup::Resource *xdg_popup::bind(struct ::wl_client *client, uint32_t id, int version) - { - DS_ASSERT_X(!wl_client_get_object(client, id), "DSWaylandObject bind", "binding to object %u more than once", id); - struct ::wl_resource *handle = wl_resource_create(client, &::xdg_popup_interface, version, id); - return bind(handle); - } - - xdg_popup::Resource *xdg_popup::bind(struct ::wl_resource *handle) - { - Resource *resource = xdg_popup_allocate(); - resource->xdg_popup_object = this; - - wl_resource_set_implementation(handle, &m_xdg_popup_interface, resource, destroy_func); - resource->handle = handle; - xdg_popup_bind_resource(resource); - return resource; - } - xdg_popup::Resource *xdg_popup::Resource::fromResource(struct ::wl_resource *resource) - { - if (DS_UNLIKELY(!resource)) - return NULL; - if (wl_resource_instance_of(resource, &::xdg_popup_interface, &m_xdg_popup_interface)) - return static_cast(wl_resource_get_user_data(resource)); - return NULL; - } - - const struct ::xdg_popup_interface xdg_popup::m_xdg_popup_interface = { - xdg_popup::handle_destroy, - xdg_popup::handle_grab - }; - - void xdg_popup::xdg_popup_destroy(Resource *) - { - } - - void xdg_popup::xdg_popup_grab(Resource *, struct ::wl_resource *, uint32_t ) - { - } - - - void xdg_popup::handle_destroy( - ::wl_client *client, - struct wl_resource *resource) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_popup_object)->xdg_popup_destroy( - r); - } - - void xdg_popup::handle_grab( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial) - { - DS_UNUSED(client); - Resource *r = Resource::fromResource(resource); - static_cast(r->xdg_popup_object)->xdg_popup_grab( - r, - seat, - serial); - } - - void xdg_popup::send_configure(int32_t x, int32_t y, int32_t width, int32_t height) - { - DS_ASSERT_X(m_resource, "xdg_popup::configure", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call xdg_popup::configure as it's not initialised"); - return; - } - send_configure( - m_resource->handle, - x, - y, - width, - height); - } - - void xdg_popup::send_configure(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) - { - xdg_popup_send_configure( - resource, - x, - y, - width, - height); - } - - - void xdg_popup::send_popup_done() - { - DS_ASSERT_X(m_resource, "xdg_popup::popup_done", "Uninitialised resource"); - if (DS_UNLIKELY(!m_resource)) { - WRN("could not call xdg_popup::popup_done as it's not initialised"); - return; - } - send_popup_done( - m_resource->handle); - } - - void xdg_popup::send_popup_done(struct ::wl_resource *resource) - { - xdg_popup_send_popup_done( - resource); - } - -} - -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWaylandServer/dswayland-server-xdg-shell.h b/src/DSWaylandServer/dswayland-server-xdg-shell.h deleted file mode 100644 index 68073fe..0000000 --- a/src/DSWaylandServer/dswayland-server-xdg-shell.h +++ /dev/null @@ -1,678 +0,0 @@ -/*LCOV_EXCL_START*/ -/* Protocol XML file : wayland-extension/xdg-shell.xml */ - -#ifndef __DS_XDG_SHELL_PROTOCOL_H__ -#define __DS_XDG_SHELL_PROTOCOL_H__ - -#include "wayland-server-core.h" -#include "xdg-shell-server-protocol.h" -#include -#include -#include -#include -#include - -#ifndef WAYLAND_VERSION_CHECK -#define WAYLAND_VERSION_CHECK(major, minor, micro) \ - ((WAYLAND_VERSION_MAJOR > (major)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \ - (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro))) -#endif - - -namespace DSWaylandServer { - class xdg_wm_base - { - public: - xdg_wm_base(struct ::wl_client *client, uint32_t id, int version); - xdg_wm_base(struct ::wl_display *display, int version); - xdg_wm_base(struct ::wl_resource *resource); - xdg_wm_base(); - - virtual ~xdg_wm_base(); - - class Resource - { - public: - Resource() : xdg_wm_base_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - xdg_wm_base *xdg_wm_base_object; - xdg_wm_base *object() { return xdg_wm_base_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_role = 0, // given wl_surface has another role - error_defunct_surfaces = 1, // xdg_wm_base was destroyed before children - error_not_the_topmost_popup = 2, // the client tried to map or destroy a non-topmost popup - error_invalid_popup_parent = 3, // the client specified an invalid popup parent surface - error_invalid_surface_state = 4, // the client provided an invalid surface state - error_invalid_positioner = 5, // the client provided an invalid positioner - }; - - void send_ping(uint32_t serial); - void send_ping(struct ::wl_resource *resource, uint32_t serial); - - protected: - virtual Resource *xdg_wm_base_allocate(); - - virtual void xdg_wm_base_bind_resource(Resource *resource); - virtual void xdg_wm_base_destroy_resource(Resource *resource); - - virtual void xdg_wm_base_destroy(Resource *resource); - virtual void xdg_wm_base_create_positioner(Resource *resource, uint32_t id); - virtual void xdg_wm_base_get_xdg_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface); - virtual void xdg_wm_base_pong(Resource *resource, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_wm_base_interface m_xdg_wm_base_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_create_positioner( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_get_xdg_surface( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *surface); - static void handle_pong( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_wm_base *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class xdg_positioner - { - public: - xdg_positioner(struct ::wl_client *client, uint32_t id, int version); - xdg_positioner(struct ::wl_display *display, int version); - xdg_positioner(struct ::wl_resource *resource); - xdg_positioner(); - - virtual ~xdg_positioner(); - - class Resource - { - public: - Resource() : xdg_positioner_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - xdg_positioner *xdg_positioner_object; - xdg_positioner *object() { return xdg_positioner_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_input = 0, // invalid input provided - }; - - enum anchor { - anchor_none = 0, - anchor_top = 1, - anchor_bottom = 2, - anchor_left = 3, - anchor_right = 4, - anchor_top_left = 5, - anchor_bottom_left = 6, - anchor_top_right = 7, - anchor_bottom_right = 8, - }; - - enum gravity { - gravity_none = 0, - gravity_top = 1, - gravity_bottom = 2, - gravity_left = 3, - gravity_right = 4, - gravity_top_left = 5, - gravity_bottom_left = 6, - gravity_top_right = 7, - gravity_bottom_right = 8, - }; - - enum constraint_adjustment { - constraint_adjustment_none = 0, - constraint_adjustment_slide_x = 1, - constraint_adjustment_slide_y = 2, - constraint_adjustment_flip_x = 4, - constraint_adjustment_flip_y = 8, - constraint_adjustment_resize_x = 16, - constraint_adjustment_resize_y = 32, - }; - - protected: - virtual Resource *xdg_positioner_allocate(); - - virtual void xdg_positioner_bind_resource(Resource *resource); - virtual void xdg_positioner_destroy_resource(Resource *resource); - - virtual void xdg_positioner_destroy(Resource *resource); - virtual void xdg_positioner_set_size(Resource *resource, int32_t width, int32_t height); - virtual void xdg_positioner_set_anchor_rect(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void xdg_positioner_set_anchor(Resource *resource, uint32_t anchor); - virtual void xdg_positioner_set_gravity(Resource *resource, uint32_t gravity); - virtual void xdg_positioner_set_constraint_adjustment(Resource *resource, uint32_t constraint_adjustment); - virtual void xdg_positioner_set_offset(Resource *resource, int32_t x, int32_t y); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_positioner_interface m_xdg_positioner_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - static void handle_set_anchor_rect( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_set_anchor( - ::wl_client *client, - struct wl_resource *resource, - uint32_t anchor); - static void handle_set_gravity( - ::wl_client *client, - struct wl_resource *resource, - uint32_t gravity); - static void handle_set_constraint_adjustment( - ::wl_client *client, - struct wl_resource *resource, - uint32_t constraint_adjustment); - static void handle_set_offset( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_positioner *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class xdg_surface - { - public: - xdg_surface(struct ::wl_client *client, uint32_t id, int version); - xdg_surface(struct ::wl_display *display, int version); - xdg_surface(struct ::wl_resource *resource); - xdg_surface(); - - virtual ~xdg_surface(); - - class Resource - { - public: - Resource() : xdg_surface_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - xdg_surface *xdg_surface_object; - xdg_surface *object() { return xdg_surface_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_not_constructed = 1, - error_already_constructed = 2, - error_unconfigured_buffer = 3, - }; - - void send_configure(uint32_t serial); - void send_configure(struct ::wl_resource *resource, uint32_t serial); - - protected: - virtual Resource *xdg_surface_allocate(); - - virtual void xdg_surface_bind_resource(Resource *resource); - virtual void xdg_surface_destroy_resource(Resource *resource); - - virtual void xdg_surface_destroy(Resource *resource); - virtual void xdg_surface_get_toplevel(Resource *resource, uint32_t id); - virtual void xdg_surface_get_popup(Resource *resource, uint32_t id, struct ::wl_resource *parent, struct ::wl_resource *positioner); - virtual void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - virtual void xdg_surface_ack_configure(Resource *resource, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_surface_interface m_xdg_surface_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_get_toplevel( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id); - static void handle_get_popup( - ::wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct ::wl_resource *parent, - struct ::wl_resource *positioner); - static void handle_set_window_geometry( - ::wl_client *client, - struct wl_resource *resource, - int32_t x, - int32_t y, - int32_t width, - int32_t height); - static void handle_ack_configure( - ::wl_client *client, - struct wl_resource *resource, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_surface *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class xdg_toplevel - { - public: - xdg_toplevel(struct ::wl_client *client, uint32_t id, int version); - xdg_toplevel(struct ::wl_display *display, int version); - xdg_toplevel(struct ::wl_resource *resource); - xdg_toplevel(); - - virtual ~xdg_toplevel(); - - class Resource - { - public: - Resource() : xdg_toplevel_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - xdg_toplevel *xdg_toplevel_object; - xdg_toplevel *object() { return xdg_toplevel_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum resize_edge { - resize_edge_none = 0, - resize_edge_top = 1, - resize_edge_bottom = 2, - resize_edge_left = 4, - resize_edge_top_left = 5, - resize_edge_bottom_left = 6, - resize_edge_right = 8, - resize_edge_top_right = 9, - resize_edge_bottom_right = 10, - }; - - enum state { - state_maximized = 1, // the surface is maximized - state_fullscreen = 2, // the surface is fullscreen - state_resizing = 3, // the surface is being resized - state_activated = 4, // the surface is now activated - state_tiled_left = 5, - state_tiled_right = 6, - state_tiled_top = 7, - state_tiled_bottom = 8, - }; - - void send_configure(int32_t width, int32_t height, struct ::wl_array *states); - void send_configure(struct ::wl_resource *resource, int32_t width, int32_t height, struct ::wl_array *states); - void send_close(); - void send_close(struct ::wl_resource *resource); - - protected: - virtual Resource *xdg_toplevel_allocate(); - - virtual void xdg_toplevel_bind_resource(Resource *resource); - virtual void xdg_toplevel_destroy_resource(Resource *resource); - - virtual void xdg_toplevel_destroy(Resource *resource); - virtual void xdg_toplevel_set_parent(Resource *resource, struct ::wl_resource *parent); - virtual void xdg_toplevel_set_title(Resource *resource, const std::string &title); - virtual void xdg_toplevel_set_app_id(Resource *resource, const std::string &app_id); - virtual void xdg_toplevel_show_window_menu(Resource *resource, struct ::wl_resource *seat, uint32_t serial, int32_t x, int32_t y); - virtual void xdg_toplevel_move(Resource *resource, struct ::wl_resource *seat, uint32_t serial); - virtual void xdg_toplevel_resize(Resource *resource, struct ::wl_resource *seat, uint32_t serial, uint32_t edges); - virtual void xdg_toplevel_set_max_size(Resource *resource, int32_t width, int32_t height); - virtual void xdg_toplevel_set_min_size(Resource *resource, int32_t width, int32_t height); - virtual void xdg_toplevel_set_maximized(Resource *resource); - virtual void xdg_toplevel_unset_maximized(Resource *resource); - virtual void xdg_toplevel_set_fullscreen(Resource *resource, struct ::wl_resource *output); - virtual void xdg_toplevel_unset_fullscreen(Resource *resource); - virtual void xdg_toplevel_set_minimized(Resource *resource); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_toplevel_interface m_xdg_toplevel_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_parent( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *parent); - static void handle_set_title( - ::wl_client *client, - struct wl_resource *resource, - const char *title); - static void handle_set_app_id( - ::wl_client *client, - struct wl_resource *resource, - const char *app_id); - static void handle_show_window_menu( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - int32_t x, - int32_t y); - static void handle_move( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial); - static void handle_resize( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial, - uint32_t edges); - static void handle_set_max_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - static void handle_set_min_size( - ::wl_client *client, - struct wl_resource *resource, - int32_t width, - int32_t height); - static void handle_set_maximized( - ::wl_client *client, - struct wl_resource *resource); - static void handle_unset_maximized( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_fullscreen( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *output); - static void handle_unset_fullscreen( - ::wl_client *client, - struct wl_resource *resource); - static void handle_set_minimized( - ::wl_client *client, - struct wl_resource *resource); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_toplevel *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; - - class xdg_popup - { - public: - xdg_popup(struct ::wl_client *client, uint32_t id, int version); - xdg_popup(struct ::wl_display *display, int version); - xdg_popup(struct ::wl_resource *resource); - xdg_popup(); - - virtual ~xdg_popup(); - - class Resource - { - public: - Resource() : xdg_popup_object(NULL), handle(NULL) {} - virtual ~Resource() {} - - xdg_popup *xdg_popup_object; - xdg_popup *object() { return xdg_popup_object; } - struct ::wl_resource *handle; - - struct ::wl_client *client() const { return wl_resource_get_client(handle); } - int version() const { return wl_resource_get_version(handle); } - - static Resource *fromResource(struct ::wl_resource *resource); - }; - - void init(struct ::wl_client *client, uint32_t id, int version); - void init(struct ::wl_display *display, int version); - void init(struct ::wl_resource *resource); - - Resource *add(struct ::wl_client *client, int version); - Resource *add(struct ::wl_client *client, uint32_t id, int version); - Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version); - - Resource *resource() { return m_resource; } - const Resource *resource() const { return m_resource; } - - std::multimap resourceMap() { return m_resource_map; } - const std::multimap resourceMap() const { return m_resource_map; } - - bool isGlobal() const { return m_global != NULL; } - bool isResource() const { return m_resource != NULL; } - - static const struct ::wl_interface *interface(); - static std::string interfaceName() { return interface()->name; } - static int interfaceVersion() { return interface()->version; } - - - enum error { - error_invalid_grab = 0, // tried to grab after being mapped - }; - - void send_configure(int32_t x, int32_t y, int32_t width, int32_t height); - void send_configure(struct ::wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height); - void send_popup_done(); - void send_popup_done(struct ::wl_resource *resource); - - protected: - virtual Resource *xdg_popup_allocate(); - - virtual void xdg_popup_bind_resource(Resource *resource); - virtual void xdg_popup_destroy_resource(Resource *resource); - - virtual void xdg_popup_destroy(Resource *resource); - virtual void xdg_popup_grab(Resource *resource, struct ::wl_resource *seat, uint32_t serial); - - private: - static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id); - static void destroy_func(struct ::wl_resource *client_resource); - static void display_destroy_func(struct ::wl_listener *listener, void *data); - - Resource *bind(struct ::wl_client *client, uint32_t id, int version); - Resource *bind(struct ::wl_resource *handle); - - static const struct ::xdg_popup_interface m_xdg_popup_interface; - - static void handle_destroy( - ::wl_client *client, - struct wl_resource *resource); - static void handle_grab( - ::wl_client *client, - struct wl_resource *resource, - struct ::wl_resource *seat, - uint32_t serial); - - std::multimap m_resource_map; - Resource *m_resource; - struct ::wl_global *m_global; - uint32_t m_globalVersion; - struct DisplayDestroyedListener : ::wl_listener { - xdg_popup *parent; - DisplayDestroyedListener(): parent(NULL) {} - }; - DisplayDestroyedListener m_displayDestroyedListener; - }; -} - -#endif -/*LCOV_EXCL_STOP*/ diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp deleted file mode 100644 index 300e29d..0000000 --- a/src/DSWindow/DSWindow.cpp +++ /dev/null @@ -1,534 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWindow.h" -#include "DSWindowPrivate.h" -#include "DSWaylandSurface.h" -#include "IDSBuffer.h" - -namespace display_server -{ - -DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr), - __parent(nullptr), - __type(0), - __x(0), - __y(0), - __w(0), - __h(0), - __zOrder(0), - __committedW(0), - __committedH(0), - __created(false), - __hasFocus(false), - __waylandSurface(nullptr), - __acceptsFocus(true), - __allowUserGeometry(false), - __title(""), - __vkbd_floating(false), - __renderView(nullptr), - __displayDeviceHWCWindow(nullptr) -{ -} - -DSWindowPrivate::~DSWindowPrivate() -{ -} - -bool DSWindowPrivate::create(std::shared_ptr waylandSurface) -{ - __waylandSurface = waylandSurface; - __created = true; - - __waylandSurface->registerCallbackSurfaceCommitted(this, std::bind(&DSWindowPrivate::__onSurfaceCommitted, this, std::placeholders::_1)); - - return true; -} - -void DSWindowPrivate::destroy(void) -{ -} - -void DSWindowPrivate::setType(int type) -{ - __type = type; -} - -int DSWindowPrivate::getType(void) -{ - return __type; -} - -void DSWindowPrivate::setParent(DSWindow *parent) -{ - __parent = parent; -} - -DSWindow *DSWindowPrivate::getParent(void) -{ - return __parent; -} - -bool DSWindowPrivate::show(void) -{ - return true; -} - -bool DSWindowPrivate::hide(bool autoFocus) -{ - return true; -} - -int DSWindowPrivate::showState(void) -{ - return 0; -} - -bool DSWindowPrivate::setTitle(const std::string &title) -{ - __title.replace(__title.begin(), __title.end(), title); - return true; -} - -const std::string DSWindowPrivate::getTitle(void) -{ - return __title; -} - -bool DSWindowPrivate::setSkipFocus(bool set) -{ - __acceptsFocus = !set; - return true; -} - -bool DSWindowPrivate::getSkipFocus(void) -{ - if (__acceptsFocus) - return false; - else - return true; -} - -void DSWindowPrivate::allowUserGeometry(bool set) -{ - __allowUserGeometry = set; -} - -bool DSWindowPrivate::isAllowUserGeometry(void) -{ - return __allowUserGeometry; -} - -bool DSWindowPrivate::setLayer(int layer) -{ - return true; -} - -bool DSWindowPrivate::raise(void) -{ - raiseToTop(); - return true; -} - -bool DSWindowPrivate::lower(void) -{ - lowerToBottom(); - return true; -} - -bool DSWindowPrivate::raiseToTop() -{ - if (__renderView) - __renderView->raiseToTop(); - - // TODO: set raiseToTop to hwc window ??? - // if (__displayDeviceHWCWindow) - // __displayDeviceHWCWindow->raiseToTop(); - - return true; -} - -bool DSWindowPrivate::lowerToBottom() -{ - if (__renderView) - __renderView->lowerToBottom(); - - // TODO: set lowerToBottom to hwc window ??? - // if (__displayDeviceHWCWindow) - // __displayDeviceHWCWindow->lowerToBottom(); - - return true; -} - -bool DSWindowPrivate::unsetFocus(void) -{ - __hasFocus = false; - return true; -} - -bool DSWindowPrivate::setFocus(void) -{ - __hasFocus = true; - return true; -} - -bool DSWindowPrivate::isCreated() -{ - return __created; -} - -void DSWindowPrivate::setPosition(int x, int y) -{ - __x = x; - __y = y; - - if (__renderView) - __renderView->setPosition(x, y); - - // TODO: set lowerToBottom to hwc window ??? - // if (__displayDeviceHWCWindow) - // __displayDeviceHWCWindow->lowerToBottom(); -} - -bool DSWindowPrivate::setVkbdFloating(bool set) -{ - __vkbd_floating = set; - return true; -} - -bool DSWindowPrivate::getVkbdFloating() -{ - return __vkbd_floating; -} - -void DSWindowPrivate::setRenderView(std::shared_ptr &renderView) -{ - __renderView = renderView; -} - -void DSWindowPrivate::setDisplayDeviceHWCWindow(std::shared_ptr &displayDeviceHWCWindow) -{ - __displayDeviceHWCWindow = displayDeviceHWCWindow; -} - -void DSWindowPrivate::__onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo) -{ - DS_GET_PUB(DSWindow); - - if (!waylandSurfaceCommitInfo->bufferChanged()) - return; - - std::shared_ptr buffer = waylandSurfaceCommitInfo->getBuffer(); - - if (__renderView) { - __renderView->setBuffer(buffer); - } - - //TODO: set the buffer to the hwc window - // if (__displayDeviceHWCWindow) { - // __displayDeviceHWCWindow->setBuffer(buffer); - //} - - // TODO: get more information from waylandSurfaceCommitInfo. ex) damageSurface, damageBuffer, transform, scale and so on - - // emit a signal of the buffer changed - pub->__bufferChangedSignal.emit(buffer); -} - -DSWindow::DSWindow() - : DS_INIT_PRIVATE_PTR(DSWindow) -{} - -DSWindow::DSWindow(std::shared_ptr waylandSurface) - : DS_INIT_PRIVATE_PTR(DSWindow) -{ - create(waylandSurface); -} - -DSWindow::~DSWindow() -{ -} - -bool DSWindow::create(std::shared_ptr waylandSurface) -{ - DS_GET_PRIV(DSWindow); - - if (!priv->isCreated()) - { - return priv->create(waylandSurface); - } - - return true; -} - -void DSWindow::destroy(void) -{ - DS_GET_PRIV(DSWindow); - - priv->destroy(); -} - -void DSWindow::setType(int type) -{ - DSLOG_DBG("DSWindow", "Set type (%d). DSWindow:%p", type, this); - DS_GET_PRIV(DSWindow); - priv->setType(type); -} - -int DSWindow::getType(void) -{ - DS_GET_PRIV(DSWindow); - return priv->getType(); -} - -void DSWindow::setParent(DSWindow *parent) -{ - if (parent == this) return; - - DS_GET_PRIV(DSWindow); - priv->setParent(parent); -} - -DSWindow *DSWindow::getParent(void) -{ - DS_GET_PRIV(DSWindow); - return priv->getParent(); -} - -bool DSWindow::show(void) -{ - DS_GET_PRIV(DSWindow); - - return priv->show(); -} - -bool DSWindow::hide(bool autoFocus) -{ - DS_GET_PRIV(DSWindow); - - return priv->hide(autoFocus); -} - -int DSWindow::showState(void) -{ - DS_GET_PRIV(DSWindow); - - return priv->showState(); -} - -bool DSWindow::setTitle(const std::string &title) -{ - DSLOG_DBG("DSWindow", "title:%s. DSWindow:%p", title.c_str(), this); - - DS_GET_PRIV(DSWindow); - return priv->setTitle(title); -} - -const std::string DSWindow::getTitle(void) -{ - DS_GET_PRIV(DSWindow); - return priv->getTitle(); -} - -bool DSWindow::setSkipFocus(bool set) -{ - DS_GET_PRIV(DSWindow); - return priv->setSkipFocus(set); -} - -bool DSWindow::getSkipFocus(void) -{ - DS_GET_PRIV(DSWindow); - return priv->getSkipFocus(); -} - -void DSWindow::allowUserGeometry(bool set) -{ - DS_GET_PRIV(DSWindow); - priv->allowUserGeometry(set); -} - -bool DSWindow::isAllowUserGeometry(void) -{ - DS_GET_PRIV(DSWindow); - return priv->isAllowUserGeometry(); -} - -bool DSWindow::setLayer(int layer) -{ - DS_GET_PRIV(DSWindow); - - return priv->setLayer(layer); -} - -bool DSWindow::raise(void) -{ - DS_GET_PRIV(DSWindow); - - return priv->raise(); -} - -bool DSWindow::lower(void) -{ - DS_GET_PRIV(DSWindow); - - return priv->lower(); -} - -bool DSWindow::raiseToTop() -{ - DS_GET_PRIV(DSWindow); - - return priv->raiseToTop(); -} - -bool DSWindow::lowerToBottom() -{ - DS_GET_PRIV(DSWindow); - - return priv->lowerToBottom(); -} - -bool DSWindow::unsetFocus(void) -{ - DS_GET_PRIV(DSWindow); - - return priv->unsetFocus(); -} - -bool DSWindow::setFocus(void) -{ - DS_GET_PRIV(DSWindow); - - return priv->setFocus(); -} - -bool DSWindow::hasFocus(void) -{ - DS_GET_PRIV(DSWindow); - - return priv->__hasFocus; -} - -void DSWindow::setPosition(int x, int y) -{ - DS_GET_PRIV(DSWindow); - - priv->setPosition(x, y); -} - -stPosition DSWindow::getPosition(void) -{ - DS_GET_PRIV(DSWindow); - - stPosition pos; - pos.x = priv->__x; - pos.y = priv->__y; - - return pos; -} - -stSize DSWindow::getSize() -{ - DS_GET_PRIV(DSWindow); - - stSize size; - size.w = priv->__w; - size.h = priv->__h; - - return size; -} - -void DSWindow::setSize(unsigned int w, unsigned int h) -{ - DS_GET_PRIV(DSWindow); - - priv->__w = w; - priv->__h = h; -} - -void DSWindow::setSize(stSize size) -{ - DS_GET_PRIV(DSWindow); - - priv->__w = size.w; - priv->__h = size.h; -} - -void DSWindow::setZOrder(unsigned int zOrder) -{ - DS_GET_PRIV(DSWindow); - - priv->__zOrder = zOrder; -} - -unsigned int DSWindow::getZOrder() -{ - DS_GET_PRIV(DSWindow); - - return priv->__zOrder; -} - -bool DSWindow::setVkbdFloating(bool set) -{ - DS_GET_PRIV(DSWindow); - - return priv->setVkbdFloating(set); -} - -bool DSWindow::getVkbdFloating() -{ - DS_GET_PRIV(DSWindow); - - return priv->getVkbdFloating(); -} - -DSWaylandSurface *DSWindow::surface() -{ - DS_GET_PRIV(DSWindow); - - return priv->__waylandSurface.get(); -} - -void DSWindow::setRenderView(std::shared_ptr &renderView) -{ - DS_GET_PRIV(DSWindow); - - priv->setRenderView(renderView); -} - -void DSWindow::setDisplayDeviceHWCWindow(std::shared_ptr &displayDeviceHWCWindow) -{ - DS_GET_PRIV(DSWindow); - - priv->setDisplayDeviceHWCWindow(displayDeviceHWCWindow); -} - -void DSWindow::registerCallbackBufferChanged(DSObject *slot, std::function)> func) -{ - __bufferChangedSignal.connect(slot, func); -} - -} // namespace display_server diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h deleted file mode 100644 index ac303b7..0000000 --- a/src/DSWindow/DSWindow.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WINDOW_H_ -#define _DS_WINDOW_H_ - -#include "DSCore.h" -#include "DSStruct.h" -#include "DSObject.h" -#include "DSSignal.h" -#include "IDSBuffer.h" -#include "DSRenderView.h" -#include "IDSDisplayDeviceHWCWindow.h" - -namespace display_server -{ - -class DSWindowPrivate; -class DSWaylandSurface; - -class DSWindow : public DSObject -{ - DS_PIMPL_USE_PRIVATE(DSWindow) - -public: - explicit DSWindow(); - DSWindow(std::shared_ptr waylandSurface); - virtual ~DSWindow(); - - bool create(std::shared_ptr waylandSurface); - void destroy(void); - - void setType(int type); - int getType(void); - - void setParent(DSWindow *parent); - DSWindow *getParent(void); - - bool show(void); - bool hide(bool autoFocus = true); - int showState(void); - - bool setTitle(const std::string &title); - const std::string getTitle(void); - - bool setSkipFocus(bool set); - bool getSkipFocus(void); - - void allowUserGeometry(bool set); - bool isAllowUserGeometry(void); - - bool setLayer(int layer); - bool raise(void); - bool lower(void); - bool raiseToTop(); - bool lowerToBottom(); - - bool unsetFocus(void); - bool setFocus(void); - bool hasFocus(void); - - void setPosition(int x, int y); - stPosition getPosition(void); - - stSize getSize(void); - void setSize(unsigned int w, unsigned int h); - void setSize(stSize size); - - void setZOrder(unsigned int zOrder); - unsigned int getZOrder(); - - bool setVkbdFloating(bool set); - bool getVkbdFloating(); - - DSWaylandSurface *surface(); - - void setRenderView(std::shared_ptr &renderView); - void setDisplayDeviceHWCWindow(std::shared_ptr &displayDeviceHWCWindow); - - void registerCallbackBufferChanged(DSObject *slot, std::function)> func); - -protected: - //virtual bool _onFocus(void); - //virtual bool _onShowStateChange(void); - -private: - // signals - DSSignal> __bufferChangedSignal; -}; - -} - -#endif // _DS_WINDOW_H_ diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h deleted file mode 100644 index eb71181..0000000 --- a/src/DSWindow/DSWindowPrivate.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WINDOW_PRIVATE_H_ -#define _DS_WINDOW_PRIVATE_H_ - -#include "DSCore.h" -#include "DSObjectPrivate.h" -#include "DSWaylandSurface.h" -#include "DSRenderView.h" -#include "IDSDisplayDeviceHWCWindow.h" - -namespace display_server -{ - -class DSWindow; - -class DSWindowPrivate : public DSObjectPrivate, public DSObject -{ - DS_PIMPL_USE_PUBLIC(DSWindow) - -public: - DSWindowPrivate() = delete; - DSWindowPrivate(DSWindow *p_ptr); - ~DSWindowPrivate(); - - bool create(std::shared_ptr waylandSurface); - void destroy(void); - - void setType(int type); - int getType(void); - - void setParent(DSWindow *parent); - DSWindow *getParent(void); - - bool show(void); - bool hide(bool autoFocus); - int showState(void); - - bool setTitle(const std::string &title); - const std::string getTitle(void); - - bool setSkipFocus(bool set); - bool getSkipFocus(void); - - void allowUserGeometry(bool set); - bool isAllowUserGeometry(void); - - bool setLayer(int layer); - bool raise(void); - bool lower(void); - bool raiseToTop(); - bool lowerToBottom(); - - bool unsetFocus(void); - bool setFocus(void); - bool isCreated(); - - void setPosition(int x, int y); - - bool setVkbdFloating(bool set); - bool getVkbdFloating(); - - void setRenderView(std::shared_ptr &renderView); - void setDisplayDeviceHWCWindow(std::shared_ptr &displayDeviceHWCWindow); - -private: - void __onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo); - - DSWindow *__parent; - std::list __childList; - int __type; - int __x, __y; - unsigned int __w; - unsigned int __h; - unsigned int __zOrder; - unsigned int __committedW, __committedH; - bool __created; - bool __hasFocus; - std::shared_ptr __waylandSurface; - bool __acceptsFocus; - bool __allowUserGeometry; - std::string __title; - - bool __vkbd_floating; - - std::shared_ptr __renderView; - std::shared_ptr __displayDeviceHWCWindow; -}; - -} - -#endif // _DS_WINDOW_PRIVATE_H_ diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp deleted file mode 100644 index 7ee3873..0000000 --- a/src/DSWindowManager/DSWindowManager.cpp +++ /dev/null @@ -1,599 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWindowManager.h" -#include "DSWindowManagerPrivate.h" -#include "DSZone.h" -#include "DSWindow.h" -#include "DSWaylandSurface.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -/* reference count, mutex and compositor pointer for DSWindowManager singleton */ -int DSWindowManager::__refCount { 0 }; -std::mutex DSWindowManager::__mutex; -DSWindowManager* DSWindowManager::__windowMgr { nullptr }; - -DSWindowManagerPrivate::DSWindowManagerPrivate(DSWindowManager *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) -{ -} - -DSWindowManagerPrivate::~DSWindowManagerPrivate() -{ -} - -DSZone *DSWindowManagerPrivate::__getZone(DSWindow *window) -{ - auto it = __zoneWinMap.find(window); - if (it != __zoneWinMap.end()) - return it->second; - - return nullptr; -} - -DSZone *DSWindowManagerPrivate::__getZone(DSWaylandSurface *surface) -{ - auto it = __zoneSurfaceMap.find(surface); - if (it != __zoneSurfaceMap.end()) - return it->second; - - return nullptr; -} - -bool DSWindowManagerPrivate::__checkZone(DSZone *zone) -{ - std::list zList = __zoneList; - for (DSZone *z : zList) - { - if (z == zone) - { - return true; - } - } - - return false; -} - -void DSWindowManagerPrivate::__registerZone(DSZone *zone) -{ - __zoneList.push_front(zone); -} - -bool DSWindowManagerPrivate::registerZone(DSZone *zone) -{ - // find zone in zone List - if (__checkZone(zone)) - { - // Error... Already exist!!! - return false; - } - - DSLOG_DBG("WindowManager", "Register Zone:%p", zone); - // add zone to list - __registerZone(zone); - return true; -} - -void DSWindowManagerPrivate::__unregisterZone(DSZone *zone) -{ - __zoneList.remove(zone); -} - -void DSWindowManagerPrivate::unregisterZone(DSZone *zone) -{ - // find zone in zone list - if (!__checkZone(zone)) return; - - DSLOG_DBG("WindowManager", "Unregister Zone:%p", zone); - // remove zone from list - __unregisterZone(zone); -} - -void DSWindowManagerPrivate::__registerWindow(DSZone *zone, DSWindow *window) -{ - __zoneWinMap.insert(std::make_pair(window, zone)); -} - -bool DSWindowManagerPrivate::registerWindow(DSZone *zone, DSWindow *window) -{ - // find zone in zone list - if (!__checkZone(zone)) - { - // Error.. Zone is not exist - return false; - } - - // map window to zone - __registerWindow(zone, window); - return true; -} - -void DSWindowManagerPrivate::__unregisterWindow(DSWindow *window) -{ - __zoneWinMap.erase(window); -} - -void DSWindowManagerPrivate::unregisterWindow(DSZone *zone, DSWindow *window) -{ - // find zone in zone list - if (!__checkZone(zone)) - { - // Error.. Zone is not exist - return; - } - - // unmap window from zone - __unregisterWindow(window); -} - -DSZone *DSWindowManagerPrivate::getZone(DSWindow *window) -{ - return __getZone(window); -} - -void DSWindowManagerPrivate::__registerSurface(DSZone *zone, DSWaylandSurface *surface) -{ - __zoneSurfaceMap.insert(std::make_pair(surface, zone)); -} - -bool DSWindowManagerPrivate::registerSurface(DSZone *zone, DSWaylandSurface *surface) -{ - // find zone in zone list - if (!__checkZone(zone)) - { - // Error.. Zone is not exist - return false; - } - - DSLOG_DBG("WindowManager", "Register Surface:%p to Zone:%p", surface, zone); - - // map window to zone - __registerSurface(zone, surface); - return true; -} - -void DSWindowManagerPrivate::__unregisterSurface(DSWaylandSurface *surface) -{ - __zoneSurfaceMap.erase(surface); -} - -void DSWindowManagerPrivate::unregisterSurface(DSZone *zone, DSWaylandSurface *surface) -{ - // find zone in zone list - if (!__checkZone(zone)) - { - // Error.. Zone is not exist - return; - } - - DSLOG_DBG("WindowManager", "Unregister Surface:%p from Zone:%p", surface, zone); - - // unmap window from zone - __unregisterSurface(surface); -} - -DSZone *DSWindowManagerPrivate::getZone(DSWaylandSurface *surface) -{ - return __getZone(surface); -} - -bool DSWindowManagerPrivate::setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface) -{ - // find dsSurface's window - DSZone *zone = __getZone(dswlSurface); - if (!zone) return false; - - if (dswlParentSurface) - { - DSZone *pZone = __getZone(dswlParentSurface); - if (zone != pZone) return false; - } - - return zone->setWindowParent(dswlSurface, dswlParentSurface); -} - -void DSWindowManagerPrivate::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title) -{ - // find dsSurface's window - DSZone *zone = __getZone(dsSurface); - if (zone) - { - zone->setWindowTitle(dsSurface, title); - } - else - { - // Do something if there is no zone - } -} - -void DSWindowManagerPrivate::setWindowType(DSWaylandSurface *dsSurface, int type) -{ - // find dsSurface's window - DSZone *zone = __getZone(dsSurface); - if (zone) - { - zone->setWindowType(dsSurface, type); - } - else - { - // Do something if there is no zone - } -} - -void DSWindowManagerPrivate::setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h) -{ - // find dsSurface's window - DSZone *zone = __getZone(dsSurface); - if (zone) - { - zone->setWindowGeometry(dsSurface, x, y, w, h); - } - else - { - // Do something if there is no zone - } -} - -void DSWindowManagerPrivate::setWindowPosition(DSWaylandSurface *dsSurface, int x, int y) -{ - // find dsSurface's window - DSZone *zone = __getZone(dsSurface); - if (zone) - { - zone->setWindowPosition(dsSurface, x, y); - } - else - { - // Do something if there is no zone - } -} - -stGeometry DSWindowManagerPrivate::getWindowGeometry(DSWaylandSurface *dsSurface) -{ - DSZone *zone = __getZone(dsSurface); - stGeometry geometry = {0, }; - if (zone) - { - return zone->getWindowGeometry(dsSurface); - } - return geometry; -} - -void DSWindowManagerPrivate::addWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &name, const std::string &value) -{ - // find dsSurface's window - DSZone *zone = __getZone(dswlSurface); - if (!zone) return; - - zone->addWindowAuxHint(dswlSurface, id, name, value); -} - -void DSWindowManagerPrivate::changeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &value) -{ - // find dsSurface's window - DSZone *zone = __getZone(dswlSurface); - if (!zone) return; - - zone->changeWindowAuxHint(dswlSurface, id, value); -} - -void DSWindowManagerPrivate::removeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id) -{ - // find dsSurface's window - DSZone *zone = __getZone(dswlSurface); - if (!zone) return; - - zone->removeWindowAuxHint(dswlSurface, id); -} - -std::list DSWindowManagerPrivate::getWindowSupportedAuxHints(DSWaylandSurface *dswlSurface) -{ - // find dsSurface's window - DSZone *zone = __getZone(dswlSurface); - if (!zone) - { - std::list nullList; - return nullList; - } - - return zone->getWindowSupportedAuxHints(dswlSurface); -} - -void DSWindowManagerPrivate::activateWindow(DSWaylandSurface *dswlSurface) -{ - // find dswlSurface's window - DSZone *zone = __getZone(dswlSurface); - if (zone) - { - zone->activateWindow(dswlSurface); - } -} - -void DSWindowManagerPrivate::raiseWindow(DSWaylandSurface *dswlSurface) -{ - // find dswlSurface's window - DSZone *zone = __getZone(dswlSurface); - if (zone) - { - zone->raiseWindow(dswlSurface); - } -} - -void DSWindowManagerPrivate::lowerWindow(DSWaylandSurface *dswlSurface) -{ - // find dswlSurface's window - DSZone *zone = __getZone(dswlSurface); - if (zone) - { - zone->lowerWindow(dswlSurface); - } -} - -void DSWindowManagerPrivate::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) -{ - // find dswlSurface's window - DSZone *zone = __getZone(dswlSurface); - if (zone) - { - zone->setWindowSkipFocus(dswlSurface, set); - } -} - -bool DSWindowManagerPrivate::setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set) -{ - // find dswlSurface's window - DSZone *zone = __getZone(dswlSurface); - if (zone) - { - return zone->setWindowVkbdFloating(dswlSurface, set); - } - else - return false; -} - -bool DSWindowManagerPrivate::getWindowVkbdFloating(DSWaylandSurface *dswlSurface) -{ - // find dswlSurface's window - DSZone *zone = __getZone(dswlSurface); - if (zone) - { - return zone->getWindowVkbdFloating(dswlSurface); - } - else - return false; -} - -void DSWindowManagerPrivate::setWindowAllowUserGeometry(DSWaylandSurface *dswlSurface, bool set) -{ - DSZone *zone = __getZone(dswlSurface); - if (zone) - zone->setWindowAllowUserGeometry(dswlSurface, set); -} - - -DSWindowManager::DSWindowManager(DSObject *parent) - : DS_INIT_PRIVATE_PTR(DSWindowManager) -{ -} - -DSWindowManager::~DSWindowManager() -{ -} - -/* getInstance for DSWindowManager singleton */ -//static -DSWindowManager *DSWindowManager::getInstance() -{ - std::lock_guard tLock(__mutex); - - DSLOG_INF("DSWindowManager", - "[Get] instance __refCount=%d !", __refCount); - - if (!__windowMgr && (__refCount == 0)) - { - __windowMgr = new DSWindowManager(new DSObject); - DSLOG_INF("DSWindowManager", - "DSWindowManager instance has been created !"); - } - - ++__refCount; - return __windowMgr; -} - -/* releaseInstance for DSWindowManager singleton */ -// static -void DSWindowManager::releaseInstance() -{ - std::lock_guard tLock(__mutex); - - --__refCount; - if (__refCount < 0) - __refCount = 0; - DSLOG_INF("DSWindowManager", - "[Release] instance __refCount=%d !", __refCount); - - if ((0 == __refCount) && __windowMgr) - { - delete __windowMgr; - __windowMgr = nullptr; - DSLOG_INF("DSWindowManager", - "DSWindowManager instance has been removed !"); - } -} - -bool DSWindowManager::registerZone(DSZone *zone) -{ - DS_GET_PRIV(DSWindowManager); - return priv->registerZone(zone); -} - -void DSWindowManager::unregisterZone(DSZone *zone) -{ - DS_GET_PRIV(DSWindowManager); - priv->unregisterZone(zone); -} - -bool DSWindowManager::registerWindow(DSZone *zone, DSWindow *window) -{ - DS_GET_PRIV(DSWindowManager); - return priv->registerWindow(zone, window); -} - -void DSWindowManager::unregisterWindow(DSZone *zone, DSWindow *window) -{ - DS_GET_PRIV(DSWindowManager); - priv->unregisterWindow(zone, window); -} - -DSZone *DSWindowManager::getZone(DSWindow *window) -{ - DS_GET_PRIV(DSWindowManager); - return priv->getZone(window); -} - -bool DSWindowManager::registerSurface(DSZone *zone, DSWaylandSurface *surface) -{ - DS_GET_PRIV(DSWindowManager); - return priv->registerSurface(zone, surface); -} - -void DSWindowManager::unregisterSurface(DSZone *zone, DSWaylandSurface *surface) -{ - DS_GET_PRIV(DSWindowManager); - priv->unregisterSurface(zone, surface); -} - -DSZone *DSWindowManager::getZone(DSWaylandSurface *surface) -{ - DS_GET_PRIV(DSWindowManager); - return priv->getZone(surface); -} - -bool DSWindowManager::setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface) -{ - DS_GET_PRIV(DSWindowManager); - return priv->setWindowParent(dswlSurface, dswlParentSurface); -} - -void DSWindowManager::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title) -{ - DS_GET_PRIV(DSWindowManager); - priv->setWindowTitle(dsSurface, title); -} - -void DSWindowManager::setWindowType(DSWaylandSurface *dsSurface, int type) -{ - DS_GET_PRIV(DSWindowManager); - priv->setWindowType(dsSurface, type); -} - -void DSWindowManager::setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h) -{ - DS_GET_PRIV(DSWindowManager); - priv->setWindowGeometry(dsSurface, x, y, w, h); -} - -void DSWindowManager::setWindowPosition(DSWaylandSurface *dsSurface, int x, int y) -{ - DS_GET_PRIV(DSWindowManager); - priv->setWindowPosition(dsSurface, x, y); -} - -stGeometry DSWindowManager::getWindowGeometry(DSWaylandSurface *dsSurface) -{ - DS_GET_PRIV(DSWindowManager); - return priv->getWindowGeometry(dsSurface); -} - -void DSWindowManager::addWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &name, const std::string &value) -{ - DS_GET_PRIV(DSWindowManager); - priv->addWindowAuxHint(dswlSurface, id, name, value); -} - -void DSWindowManager::changeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &value) -{ - DS_GET_PRIV(DSWindowManager); - priv->changeWindowAuxHint(dswlSurface, id, value); -} - -void DSWindowManager::removeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id) -{ - DS_GET_PRIV(DSWindowManager); - priv->removeWindowAuxHint(dswlSurface, id); -} - -std::list DSWindowManager::getWindowSupportedAuxHints(DSWaylandSurface *dswlSurface) -{ - DS_GET_PRIV(DSWindowManager); - return priv->getWindowSupportedAuxHints(dswlSurface); -} - -void DSWindowManager::activateWindow(DSWaylandSurface *dswlSurface) -{ - DS_GET_PRIV(DSWindowManager); - priv->activateWindow(dswlSurface); -} - -void DSWindowManager::raiseWindow(DSWaylandSurface *dswlSurface) -{ - DS_GET_PRIV(DSWindowManager); - priv->raiseWindow(dswlSurface); -} - -void DSWindowManager::lowerWindow(DSWaylandSurface *dswlSurface) -{ - DS_GET_PRIV(DSWindowManager); - priv->lowerWindow(dswlSurface); -} - -void DSWindowManager::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) -{ - DS_GET_PRIV(DSWindowManager); - priv->setWindowSkipFocus(dswlSurface, set); -} - -bool DSWindowManager::setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set) -{ - DS_GET_PRIV(DSWindowManager); - return priv->setWindowVkbdFloating(dswlSurface, set); -} - -bool DSWindowManager::getWindowVkbdFloating(DSWaylandSurface *dswlSurface) -{ - DS_GET_PRIV(DSWindowManager); - return priv->getWindowVkbdFloating(dswlSurface); -} - -void DSWindowManager::setWindowAllowUserGeometry(DSWaylandSurface *dswlSurface, bool set) -{ - DS_GET_PRIV(DSWindowManager); - - priv->setWindowAllowUserGeometry(dswlSurface, set); -} - -} // namespace display_server diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h deleted file mode 100644 index 730826c..0000000 --- a/src/DSWindowManager/DSWindowManager.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WINDOW_MANAGER_H__ -#define __DS_WINDOW_MANAGER_H__ - -#include "DSCore.h" -#include "DSObject.h" -#include "DSStruct.h" - -namespace display_server -{ - -class DSWindowManagerPrivate; -class DSZone; -class DSWindow; -class DSWaylandSurface; - -class DSWindowManager : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSWindowManager) - -public: - static DSWindowManager *getInstance(); - static void releaseInstance(); - - // APIs for DSZone related - bool registerZone(DSZone *zone); - void unregisterZone(DSZone *zone); - - bool registerWindow(DSZone *zone, DSWindow *window); - void unregisterWindow(DSZone *zone, DSWindow *window); - DSZone *getZone(DSWindow *window); - - bool registerSurface(DSZone *zone, DSWaylandSurface *surface); - void unregisterSurface(DSZone *zone, DSWaylandSurface *surface); - DSZone *getZone(DSWaylandSurface *surface); - - bool setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface); - void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title); - void setWindowType(DSWaylandSurface *dsSurface, int type); - void setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h); - void setWindowPosition(DSWaylandSurface *dsSurface, int x, int y); - stGeometry getWindowGeometry(DSWaylandSurface *dsSurface); - - void addWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &name, const std::string &value); - void changeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &value); - void removeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id); - std::list getWindowSupportedAuxHints(DSWaylandSurface *dswlSurface); - - void activateWindow(DSWaylandSurface *dswlSurface); - void raiseWindow(DSWaylandSurface *dswlSurface); - void lowerWindow(DSWaylandSurface *dswlSurface); - - void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); - - bool setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set); - bool getWindowVkbdFloating(DSWaylandSurface *dswlSurface); - - void setWindowAllowUserGeometry(DSWaylandSurface *dswlSurface, bool set); - -protected: - -private: - DSWindowManager() = delete; - ~DSWindowManager(); - DSWindowManager(DSObject *parent); - DSWindowManager& operator=(const DSWindowManager&) = delete; - -private: - static std::mutex __mutex; - static DSWindowManager *__windowMgr; - static int __refCount; -}; - -} - -#endif // __DS_WINDOW_MANAGER_H__ diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h deleted file mode 100644 index 956ec03..0000000 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_WINDOW_MANAGER_PRIVATE__ -#define __DS_WINDOW_MANAGER_PRIVATE__ - -#include -#include "DSWindowManager.h" - -namespace display_server -{ - -class DSWindowManagerPrivate : public DSObjectPrivate -{ - DS_PIMPL_USE_PUBLIC(DSWindowManager); - -public: - DSWindowManagerPrivate() = delete; - DSWindowManagerPrivate(DSWindowManager *p_ptr); - ~DSWindowManagerPrivate(); - - bool registerZone(DSZone *zone); - void unregisterZone(DSZone *zone); - - bool registerWindow(DSZone *zone, DSWindow *window); - void unregisterWindow(DSZone *zone, DSWindow *window); - DSZone *getZone(DSWindow *window); - - bool registerSurface(DSZone *zone, DSWaylandSurface *surface); - void unregisterSurface(DSZone *zone, DSWaylandSurface *surface); - DSZone *getZone(DSWaylandSurface *surface); - - bool setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface); - void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title); - void setWindowType(DSWaylandSurface *dsSurface, int type); - void setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h); - void setWindowPosition(DSWaylandSurface *dsSurface, int x, int y); - stGeometry getWindowGeometry(DSWaylandSurface *dsSurface); - - void addWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &name, const std::string &value); - void changeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &value); - void removeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id); - std::list getWindowSupportedAuxHints(DSWaylandSurface *dswlSurface); - - void activateWindow(DSWaylandSurface *dswlSurface); - void raiseWindow(DSWaylandSurface *dswlSurface); - void lowerWindow(DSWaylandSurface *dswlSurface); - - void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); - - bool setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set); - bool getWindowVkbdFloating(DSWaylandSurface *dswlSurface); - - void setWindowAllowUserGeometry(DSWaylandSurface *dswlSurface, bool set); - -private: - DSZone *__getZone(DSWindow *window); - DSZone *__getZone(DSWaylandSurface *surface); - bool __checkZone(DSZone *zone); - - void __registerZone(DSZone *zone); - void __unregisterZone(DSZone *zone); - - void __registerWindow(DSZone *zone, DSWindow *window); - void __unregisterWindow(DSWindow *window); - - void __registerSurface(DSZone *zone, DSWaylandSurface *surface); - void __unregisterSurface(DSWaylandSurface *surface); - - -private: - std::list __zoneList; - std::unordered_map __zoneWinMap; - std::unordered_map __zoneSurfaceMap; -}; - -} // namespace display_server - -#endif diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp deleted file mode 100644 index cba4622..0000000 --- a/src/DSWindowShell/DSWindowShell.cpp +++ /dev/null @@ -1,386 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSWindowShell.h" -#include "DSWindowShellPrivate.h" - -namespace display_server -{ - -struct DTWindowShell -{ -}; - -DSWindowShell::DSWindowShell(DSWindow *window) - : _d_ptr(std::make_unique(this, window)) -{} - -DSWindowShell::~DSWindowShell() -{ - -} - -bool DSWindowShell::create(DSWindowShell *pParent) -{ - return true; -} - -bool DSWindowShell::create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent) -{ - return true; -} - -void DSWindowShell::destroy(void) -{ - -} - -bool DSWindowShell::setZone(DSZone *zone) -{ - DS_GET_PRIV(DSWindowShell); - return priv->setZone(zone); -} - -DSZone *DSWindowShell::getZone(void) -{ - DS_GET_PRIV(DSWindowShell); - return priv->getZone(); -} - -void DSWindowShell::setShellSurface(IDSWaylandShellSurface *shellSurface) -{ - DS_GET_PRIV(DSWindowShell); - priv->setShellSurface(shellSurface); -} - -IDSWaylandShellSurface *DSWindowShell::getShellSurface(void) -{ - DS_GET_PRIV(DSWindowShell); - return priv->getShellSurface(); -} - -DSWindow *DSWindowShell::getWindow(void) -{ - DS_GET_PRIV(DSWindowShell); - return priv->getWindow(); -} - -bool DSWindowShell::setParent(DSWindowShell *parentWinShell) -{ - if (parentWinShell == this) - return false; - - DS_GET_PRIV(DSWindowShell); - return priv->setParent(parentWinShell); -} - -DSWindowShell *DSWindowShell::getParent(void) -{ - DS_GET_PRIV(DSWindowShell); - return priv->getParent(); -} - -bool DSWindowShell::addChild(DSWindowShell *childWinShell) -{ - DS_GET_PRIV(DSWindowShell); - return priv->addChild(childWinShell); -} - -void DSWindowShell::removeChild(DSWindowShell *childWinShell) -{ - DS_GET_PRIV(DSWindowShell); - priv->removeChild(childWinShell); -} - -bool DSWindowShell::setTitle(const std::string &title) -{ - DS_GET_PRIV(DSWindowShell); - return priv->setTitle(title); -} - -bool DSWindowShell::setSkipFocus(bool set) -{ - DS_GET_PRIV(DSWindowShell); - return priv->setSkipFocus(set); -} - -bool DSWindowShell::setPosition(int x, int y) -{ - DSLOG_DBG("DSWindowShell", "DSWindowShell:%p, Set Position (%d, %d)", this, x, y); - - DS_GET_PRIV(DSWindowShell); - return priv->setPosition(x, y); -} - -stPosition DSWindowShell::getPosition(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->getPosition(); -} - -bool DSWindowShell::setSize(unsigned int w, unsigned int h) -{ - DSLOG_DBG("DSWindowShell", "DSWindowShell:%p, Set Size (%d, %d)", this, w, h); - - DS_GET_PRIV(DSWindowShell); - return priv->setSize(w, h); -} - -bool DSWindowShell::setGeometry(int x, int y, unsigned int w, unsigned int h) -{ - DSLOG_DBG("DSWindowShell", "DSWindowShell:%p, Set Geometry (%d, %d, %d, %d)", this, x, y, w, h); - - DS_GET_PRIV(DSWindowShell); - return priv->setGeometry(x, y, w, h); -} - -stGeometry DSWindowShell::getGeometry(void) -{ - DS_GET_PRIV(DSWindowShell); - return priv->getGeometry(); -} - -void DSWindowShell::addAuxHint(int32_t id, const std::string &name, const std::string &value) -{ - DS_GET_PRIV(DSWindowShell); - priv->addAuxHint(id, name, value); -} - -void DSWindowShell::changeAuxHint(int32_t id, const std::string &value) -{ - DS_GET_PRIV(DSWindowShell); - priv->changeAuxHint(id, value); -} - -void DSWindowShell::removeAuxHint(int32_t id) -{ - DS_GET_PRIV(DSWindowShell); - priv->removeAuxHint(id); -} - -bool DSWindowShell::show(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->show(); -} - -bool DSWindowShell::hide(bool autoFocus) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->hide(autoFocus); -} - -int DSWindowShell::showState(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->showState(); -} - - -bool DSWindowShell::setLayer(int layer) -{ - DS_GET_PRIV(DSWindowShell); - return priv->setLayer(layer); -} - -int DSWindowShell::getLayer(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->getLayer(); -} - - -bool DSWindowShell::raise(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->raise(); -} - -bool DSWindowShell::lower(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->lower(); -} - -bool DSWindowShell::unsetFocus(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->unsetFocus(); -} - -bool DSWindowShell::setFocus(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->setFocus(); -} - -bool DSWindowShell::isFocused(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->isFocused(); -} - - -bool DSWindowShell::activate(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->activate(); -} - -bool DSWindowShell::isActivated(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->isActivated(); -} - - -bool DSWindowShell::iconify(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->iconify(); -} - -bool DSWindowShell::iconify(bool by_client) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->iconify(by_client); -} - -bool DSWindowShell::uniconify(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->uniconify(); -} - -bool DSWindowShell::uniconify(bool by_client) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->uniconify(by_client); -} - -int DSWindowShell::getIconicState(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->getIconicState(); -} - - -bool DSWindowShell::setType(int type) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->setType(type); -} - -int DSWindowShell::getType(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->getType(); -} - - -bool DSWindowShell::maximize(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->maximize(); -} - -bool DSWindowShell::isMaximized(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->isMaximized(); -} - - -bool DSWindowShell::fullscreen(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->fullscreen(); -} - -bool DSWindowShell::isFullscreen(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->isFullscreen(); -} - - -bool DSWindowShell::setRole(const char *role) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->setRole(role); -} - -const char* DSWindowShell::getRole(void) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->getRole(); -} - -bool DSWindowShell::setVkbdFloating(bool set) -{ - DS_GET_PRIV(DSWindowShell); - - return priv->setVkbdFloating(set); -} - -bool DSWindowShell::getVkbdFloating() -{ - DS_GET_PRIV(DSWindowShell); - - return priv->getVkbdFloating(); -} - -void DSWindowShell::setAllowUserGeometry(bool set) -{ - DS_GET_PRIV(DSWindowShell); - - priv->setAllowUserGeometry(set); -} - - -} // namespace display_server diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h deleted file mode 100644 index 84123c5..0000000 --- a/src/DSWindowShell/DSWindowShell.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WINDOW_SHELL_H_ -#define _DS_WINDOW_SHELL_H_ - -#include "DSStruct.h" -#include "DSCore.h" -#include "IDSWaylandShell.h" - -namespace display_server -{ - -class DSWindow; -class DSWindowShellPrivate; -class DSZone; - -class DSWindowShell -{ -DS_PIMPL_USE_PRIVATE(DSWindowShell) - -public: - explicit DSWindowShell(DSWindow *window); - virtual ~DSWindowShell(); - - bool create(DSWindowShell *pParent); - bool create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent); - - void destroy(void); - - bool setZone(DSZone *zone); - DSZone *getZone(void); - - void setShellSurface(IDSWaylandShellSurface *zxdgSurface); - IDSWaylandShellSurface *getShellSurface(void); - - DSWindow *getWindow(void); - - bool setParent(DSWindowShell *parentWinShell); - DSWindowShell *getParent(void); - - bool addChild(DSWindowShell *childWinShell); - void removeChild(DSWindowShell *childWinShell); - - bool setTitle(const std::string &title); - - bool setSkipFocus(bool set); - - bool setPosition(int x, int y); - stPosition getPosition(void); - - bool setSize(unsigned int w, unsigned int h); - - bool setGeometry(int x, int y, unsigned int w, unsigned int h); - stGeometry getGeometry(void); - - void addAuxHint(int32_t id, const std::string &name, const std::string &value); - void changeAuxHint(int32_t id, const std::string &value); - void removeAuxHint(int32_t id); - - bool show(void); - bool hide(bool autoFocus = true); - int showState(void); - - bool setLayer(int layer); - int getLayer(void); - - bool raise(void); - bool lower(void); - - bool unsetFocus(void); - bool setFocus(void); - bool isFocused(void); - - bool activate(void); - bool isActivated(void); - - bool iconify(void); - bool iconify(bool by_client); - bool uniconify(void); - bool uniconify(bool by_client); - int getIconicState(void); - - bool setType(int type); - int getType(void); - - bool maximize(void); - bool isMaximized(void); - - bool fullscreen(void); - bool isFullscreen(void); - - bool setRole(const char *role); - const char* getRole(void); - - bool setVkbdFloating(bool set); - bool getVkbdFloating(); - - void setAllowUserGeometry(bool set); - -protected: - -private: -}; - -} - -#endif // _DS_WINDOW_SHELL_H_ diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp deleted file mode 100644 index 45233be..0000000 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ /dev/null @@ -1,698 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSZone.h" -#include "DSWindowShell.h" -#include "DSWindowShellPrivate.h" - -namespace display_server -{ - -enum _Hint_Type -{ - DS_WINDOW_HINT_USER_GEOMETRY = 0, - DS_WINDOW_HINT_FIXED_RESIZE = 1, - DS_WINDOW_HINT_DEICONIFY_UPDATE = 2, - DS_WINDOW_HINT_ICONIFY = 3, - DS_WINDOW_HINT_ABOVE_LOCKSCREEN = 4, - DS_WINDOW_HINT_GESTURE_DISABLE = 5, - DS_WINDOW_HINT_EFFECT_DISABLE = 6, - DS_WINDOW_HINT_MSG_USE = 7, - DS_WINDOW_HINT_ALWAYS_SELECTIVE = 8, - DS_WINDOW_HINT_DEPENDENT_ROTATION = 9, - DS_WINDOW_HINT_ROT_RENDER_NOPENDING = 10, - DS_WINDOW_HINT_ICONIFY_BUFFER_FLUSH = 11, -}; - -static const char *sHintNames[] = -{ - "wm.policy.win.user.geometry", - "wm.policy.win.fixed.resize", - "wm.policy.win.deiconify.update", - "wm.policy.win.iconify", - "wm.policy.win.above.lock", - "wm.policy.win.gesture.disable", - "wm.policy.win.effect.disable", - "wm.policy.win.msg.use", - "wm.comp.win.always.selective.mode", - "wm.policy.win.rot.dependent", - "wm.policy.win.rot.render.nopending", - "wm.policy.win.iconify.buffer.flush", -}; - -DSWindowShellPrivate::DSWindowShellPrivate(DSWindowShell *p_ptr, DSWindow *window) - : __p_ptr(p_ptr), - __window(window), - __shellSurface(nullptr), - __zone(nullptr), - __x(0), __y(0), - __w(0), __h(0), - __reqX(0), __reqY(0), - __reqW(0), __reqH(0), - __parent(nullptr), - __layer(0), - __firstCommit(true), - __changedGeometry(false), - __visible(false) -{ - if (__window) - __window->registerCallbackBufferChanged(this, std::bind(&DSWindowShellPrivate::__onWindowBufferChanged, this, std::placeholders::_1)); -} - -DSWindowShellPrivate::~DSWindowShellPrivate() -{ - for (stWindowAuxHint *hint : __auxHintsList) - { - delete hint; - } -} - -bool DSWindowShellPrivate::__findInChildList(DSWindowShell *parentWinShell) -{ - for (auto ws : __childList) - { - if (ws == parentWinShell) - return true; - } - - return false; -} - -bool DSWindowShellPrivate::__setParent(DSWindowShell *parentWinShell) -{ - DS_GET_PUB(DSWindowShell); - - if (__parent == parentWinShell) - return true; - - if (__findInChildList(parentWinShell)) - { - DSLOG_ERR("DSWindowShell", "Fatal error. Set parent each other. winShell:%p, parentWinShell:%p", pub, parentWinShell); - return false; - } - - if (__parent) - { - // remove this from old parent's child list - __parent->removeChild(pub); - } - - __parent = parentWinShell; - if (__parent) - { - __parent->addChild(pub); - } - - if (__window) - { - if (__parent) - { - DSWindow *parentWin = __parent->getWindow(); - __window->setParent(parentWin); - } - else - __window->setParent(nullptr); - } - - return true; -} - -struct stWindowAuxHint *DSWindowShellPrivate::__findAuxHint(int32_t id) -{ - for (stWindowAuxHint* hint : __auxHintsList) - { - if (hint->id == id) - return hint; - } - - return nullptr; -} - -void DSWindowShellPrivate::__handleAuxHint(stWindowAuxHint *hint) -{ - if (!__window) return; - - // do something for each hints - if (hint->name == sHintNames[DS_WINDOW_HINT_USER_GEOMETRY]) // user geometry - { - bool set; - - if (hint->value == "1") - set = true; - else - set = false; - - __handleUserGeometryProperty(set); - } -} - -bool DSWindowShellPrivate::__handleUserGeometryProperty(bool setUserGeometry) -{ - if (!__window) return false; - - __window->allowUserGeometry(setUserGeometry); - if (setUserGeometry) - { - // reset windows geometry - __x = __y = __w = __h = 0; - __window->setPosition(__x, __y); - __window->setSize(__w, __h); - __changedGeometry = true; - } - else - { - // apply zone's geometry - if (__zone) - { - stPosition zPos = __zone->getPosition(); - stSize zSize = __zone->getSize(); - __x = zPos.x; - __y = zPos.y; - __w = zSize.w; - __h = zSize.h; - - __window->setPosition(__x, __y); - __window->setSize(__w, __h); - __changedGeometry = true; - } - } - - return true; -} - -bool DSWindowShellPrivate::create(DSWindowShell *pParent) -{ - return true; -} - -bool DSWindowShellPrivate::create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent) -{ - __x = x; - __y = y; - __w = w; - __h = h; - - if (__window) - { - __window->setPosition(__x, __y); - __window->setSize(__w, __h); - __changedGeometry = true; - } - - return true; -} - - -void DSWindowShellPrivate::destroy(void) -{ - -} - -bool DSWindowShellPrivate::setZone(DSZone *zone) -{ - if (__zone) - { - // unset information for old zone - } - - __zone = zone; - if (__zone) - { - stPosition zPos = __zone->getPosition(); - stSize zSize = __zone->getSize(); - - // check whether DSWindowShell's geometry has to change or not - if (__window) - { - if (!__window->isAllowUserGeometry()) - { - __x = zPos.x; - __y = zPos.y; - __w = zSize.w; - __h = zSize.h; - - __window->setPosition(__x, __y); - __window->setSize(__w, __h); - __changedGeometry = true; - } - } - else - { - __x = zPos.x; - __y = zPos.y; - __w = zSize.w; - __h = zSize.h; - } - } - - return true; -} - -DSZone *DSWindowShellPrivate::getZone(void) -{ - return __zone; -} - -void DSWindowShellPrivate::setShellSurface(IDSWaylandShellSurface *shellSurface) -{ - __shellSurface = shellSurface; - DSLOG_DBG("DSWindowShell", "Set ShellSurface(%p). Send configure", shellSurface); - __sendConfigure(); -} - -IDSWaylandShellSurface *DSWindowShellPrivate::getShellSurface(void) -{ - return __shellSurface; -} - -DSWindow *DSWindowShellPrivate::getWindow(void) -{ - return __window; -} - -bool DSWindowShellPrivate::setParent(DSWindowShell *parentWinShell) -{ - return __setParent(parentWinShell); -} - -DSWindowShell *DSWindowShellPrivate::getParent(void) -{ - return __parent; -} - -bool DSWindowShellPrivate::addChild(DSWindowShell *childWinShell) -{ - __childList.push_back(childWinShell); - return true; -} - -void DSWindowShellPrivate::removeChild(DSWindowShell *childWinShell) -{ - __childList.remove(childWinShell); -} - -bool DSWindowShellPrivate::setTitle(const std::string &title) -{ - if (__window) - { - __window->setTitle(title); - return true; - } - else - return false; -} - -bool DSWindowShellPrivate::setSkipFocus(bool set) -{ - if (__window) - { - __window->setSkipFocus(set); - return true; - } - else - return false; -} - -bool DSWindowShellPrivate::setPosition(int x, int y) -{ - __reqX = x; - __reqY = y; - - if (__window) - { - if (__window->isAllowUserGeometry()) - { - __x = x; - __y = y; - __window->setPosition(__x, __y); - __changedGeometry = true; - } - } - else - { - __x = x; - __y = y; - } - - return true; -} - -stPosition DSWindowShellPrivate::getPosition(void) -{ - stPosition pos; - - pos.x = __x; - pos.y = __y; - - return pos; -} - -bool DSWindowShellPrivate::setSize(unsigned int w, unsigned int h) -{ - __reqW = w; - __reqH = h; - - if (__window) - { - if (__window->isAllowUserGeometry()) - { - __w = w; - __h = h; - __window->setSize(__w, __h); - } - } - else - { - __w = w; - __h = h; - } - - return true; -} - -bool DSWindowShellPrivate::setGeometry(int x, int y, unsigned int w, unsigned int h) -{ - __reqX = x; - __reqY = y; - __reqW = w; - __reqH = h; - - if (__window) - { - if (__window->isAllowUserGeometry()) - { - __x = x; - __y = y; - __w = w; - __h = h; - __window->setPosition(__x, __y); - __window->setSize(__w, __h); - __changedGeometry = true; - } - } - else - { - __x = x; - __y = y; - __w = w; - __h = h; - } - - return true; -} - -stGeometry DSWindowShellPrivate::getGeometry(void) -{ - stGeometry geo; - geo.x = __x; - geo.y = __y; - geo.w = __w; - geo.h = __h; - return geo; -} - -void DSWindowShellPrivate::addAuxHint(int32_t id, const std::string &name, const std::string &value) -{ - stWindowAuxHint *hint; - hint = __findAuxHint(id); - if (!hint) - { - hint = new stWindowAuxHint(); - if (!hint) return; - - __auxHintsList.push_back(hint); - } - - hint->id = id; - hint->name = name; - hint->value = value; - hint->changed = true; - hint->deleted = false; - - DSLOG_DBG("DSWindowShell", "Add aux hint... id:%d, name:%s, value:%s", id, name.c_str(), value.c_str()); - - __handleAuxHint(hint); -} - -void DSWindowShellPrivate::changeAuxHint(int32_t id, const std::string &value) -{ - stWindowAuxHint *hint; - hint = __findAuxHint(id); - if (!hint) return; - - hint->value = value; - hint->changed = true; - - __handleAuxHint(hint); -} - -void DSWindowShellPrivate::removeAuxHint(int32_t id) -{ - stWindowAuxHint *hint; - hint = __findAuxHint(id); - if (!hint) return; - - hint->changed = true; - hint->deleted = true; - - __auxHintsList.remove(hint); -} - -bool DSWindowShellPrivate::show(void) -{ - return true; -} - -bool DSWindowShellPrivate::hide(bool autoFocus) -{ - return true; -} - -int DSWindowShellPrivate::showState(void) -{ - return 0; -} - - -bool DSWindowShellPrivate::setLayer(int layer) -{ - __layer = layer; - return true; -} - -int DSWindowShellPrivate::getLayer(void) -{ - return __layer; -} - - -bool DSWindowShellPrivate::raise(void) -{ - if (__window) - return __window->raise(); - - return false; -} - -bool DSWindowShellPrivate::lower(void) -{ - if (__window) - return __window->lower(); - - return false; -} - -bool DSWindowShellPrivate::unsetFocus(void) -{ - if (__window) - return __window->unsetFocus(); - return false; -} - -bool DSWindowShellPrivate::setFocus(void) -{ - if (__window) - return __window->setFocus(); - return false; -} - -bool DSWindowShellPrivate::isFocused(void) -{ - if (__window) - return __window->hasFocus(); - return false; -} - - -bool DSWindowShellPrivate::activate(void) -{ - if (__window) - return __window->raiseToTop(); - - return false; -} - -bool DSWindowShellPrivate::isActivated(void) -{ - return true; -} - - -bool DSWindowShellPrivate::iconify(void) -{ - return true; -} - -bool DSWindowShellPrivate::iconify(bool by_client) -{ - return true; -} - -bool DSWindowShellPrivate::uniconify(void) -{ - return true; -} - -bool DSWindowShellPrivate::uniconify(bool by_client) -{ - return true; -} - -int DSWindowShellPrivate::getIconicState(void) -{ - return 0; -} - - -bool DSWindowShellPrivate::setType(int type) -{ - if (__window) - __window->setType(type); - - if (type == 9) // utility - __handleUserGeometryProperty(true); - - return true; -} - -int DSWindowShellPrivate::getType(void) -{ - if (__window) - return __window->getType(); - - return 0; -} - - -bool DSWindowShellPrivate::maximize(void) -{ - return true; -} - -bool DSWindowShellPrivate::isMaximized(void) -{ - return true; -} - - -bool DSWindowShellPrivate::fullscreen(void) -{ - return true; -} - -bool DSWindowShellPrivate::isFullscreen(void) -{ - return true; -} - - -bool DSWindowShellPrivate::setRole(const char *role) -{ - return true; -} - -const char* DSWindowShellPrivate::getRole(void) -{ - return nullptr; -} - -bool DSWindowShellPrivate::setVkbdFloating(bool set) -{ - if (__window) - { - __window->setVkbdFloating(set); - return true; - } - else - return false; -} - -bool DSWindowShellPrivate::getVkbdFloating() -{ - if (__window) - { - return __window->getVkbdFloating(); - } - else - return false; -} - -void DSWindowShellPrivate::setAllowUserGeometry(bool set) -{ - __handleUserGeometryProperty(set); -} - - -void DSWindowShellPrivate::__sendConfigure(void) -{ - if (__shellSurface) - { - __shellSurface->sendConfigure(__x, __y, __w, __h); - } -} - -void DSWindowShellPrivate::__onWindowBufferChanged(std::shared_ptr buffer) -{ - if (__firstCommit) - { - DSLOG_DBG("DSWindow", "First Commit!!! "); - __firstCommit = false; - } - - if (__changedGeometry) - { - std::shared_ptr bufferSize = buffer->getSize(); - DSLOG_DBG("DSWindow", "Geometry Changed!!! Send Configure... geo(%d,%d,%d,%d) commit(%d,%d)", __x, __y, __w, __h, bufferSize->w, bufferSize->h); - __sendConfigure(); - __changedGeometry = false; - } - - if (buffer) { - __visible = true; - } else { - __visible = false; - } - -} - -} // namespace display_server diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h deleted file mode 100644 index d882d40..0000000 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef _DS_WINDOW_SHELL_PRIVATE_H_ -#define _DS_WINDOW_SHELL_PRIVATE_H_ - -#include "DSWindow.h" - -namespace display_server -{ - -struct stWindowAuxHint -{ - int32_t id; - std::string name; - std::string value; - bool changed; - bool deleted; -}; - -class DSWindowShellPrivate : public DSObject -{ -DS_PIMPL_USE_PUBLIC(DSWindowShell) - -public: - DSWindowShellPrivate() = delete; - DSWindowShellPrivate(DSWindowShell *p_ptr, DSWindow *window); - ~DSWindowShellPrivate(); - - bool create(DSWindowShell *pParent); - bool create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pParent); - - void destroy(void); - - bool setZone(DSZone *zone); - DSZone *getZone(void); - - void setShellSurface(IDSWaylandShellSurface *shellSurface); - IDSWaylandShellSurface *getShellSurface(void); - - DSWindow *getWindow(void); - - bool setParent(DSWindowShell *parentWinShell); - DSWindowShell *getParent(void); - - bool addChild(DSWindowShell *childWinShell); - void removeChild(DSWindowShell *childWinShell); - - bool setTitle(const std::string &title); - - bool setSkipFocus(bool set); - - bool setPosition(int x, int y); - stPosition getPosition(void); - - bool setSize(unsigned int w, unsigned int h); - - bool setGeometry(int x, int y, unsigned int w, unsigned int h); - stGeometry getGeometry(void); - - void addAuxHint(int32_t id, const std::string &name, const std::string &value); - void changeAuxHint(int32_t id, const std::string &value); - void removeAuxHint(int32_t id); - - bool show(void); - bool hide(bool autoFocus = true); - int showState(void); - - bool setLayer(int layer); - int getLayer(void); - - bool raise(void); - bool lower(void); - - bool unsetFocus(void); - bool setFocus(void); - bool isFocused(void); - - bool activate(void); - bool isActivated(void); - - bool iconify(void); - bool iconify(bool by_client); - bool uniconify(void); - bool uniconify(bool by_client); - int getIconicState(void); - - bool setType(int type); - int getType(void); - - bool maximize(void); - bool isMaximized(void); - - bool fullscreen(void); - bool isFullscreen(void); - - bool setRole(const char *role); - const char* getRole(void); - - bool setVkbdFloating(bool set); - bool getVkbdFloating(); - - void setAllowUserGeometry(bool set); - -private: - bool __create(int x, int y, unsigned int w, unsigned int h, DSWindowShell *pWin, DSWindowShell *pParent); - bool __findInChildList(DSWindowShell *parentWinShell); - bool __setParent(DSWindowShell *parentWinShell); - void __sendConfigure(void); - - struct stWindowAuxHint* __findAuxHint(int32_t id); - void __handleAuxHint(stWindowAuxHint *hint); - bool __handleUserGeometryProperty(bool setUserGeometry); - - void __onWindowBufferChanged(std::shared_ptr buffer); - -private: - DSWindow *__window; - IDSWaylandShellSurface *__shellSurface; - DSZone *__zone; - int __x, __y; // real (applied) position - unsigned int __w, __h; // real (applied) size - int __reqX, __reqY; // requested position by client - unsigned int __reqW, __reqH; // requested size by client - DSWindowShell *__parent; - int __layer; - bool __firstCommit; - bool __changedGeometry; - bool __visible; - std::list __childList; - std::list __auxHintsList; -}; - -} - -#endif // _DS_WINDOW_SHELL_PRIVATE_H_ diff --git a/src/DSXkb/DSXkb.cpp b/src/DSXkb/DSXkb.cpp deleted file mode 100644 index 9e9549e..0000000 --- a/src/DSXkb/DSXkb.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSXkb.h" -#include "DSXkbPrivate.h" - -#include -#include - -namespace display_server -{ - -DSXkbPrivate::DSXkbPrivate(DSXkb *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), - __xkb_state(nullptr), __xkb_keymap(nullptr), __xkb_context(nullptr), - __keymap_fd(-1), __keymap_size(0), __keymap_area(nullptr), - __depressed(0), __latched(0), __locked(0), __group(0) -{ -} - -DSXkbPrivate::~DSXkbPrivate() -{ - xkb_state_unref(__xkb_state); - xkb_keymap_unref(__xkb_keymap); - xkb_context_unref(__xkb_context); -} - -bool DSXkbPrivate::makeKeymap() -{ - DS_GET_PUB(DSXkb); - - __xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); - if (!__xkb_context) - { - DSLOG_ERR("DSXkb", "Failed to xkb_context_new()..\n"); - return false; - } - - struct ::xkb_rule_names names = { pub->__rules.c_str(), pub->__model.c_str(), pub->__layout.c_str(), pub->__variant.c_str(), pub->__options.c_str() }; - - __xkb_keymap = xkb_map_new_from_names(__xkb_context, &names, XKB_KEYMAP_COMPILE_NO_FLAGS); - if (!__xkb_keymap) - { - DSLOG_ERR("DSXkb", "Failed to xkb_map_new_from_names()..\n"); - xkb_context_unref(__xkb_context); - return false; - } - - __xkb_state = xkb_state_new(__xkb_keymap); - if (!__xkb_state) - { - DSLOG_ERR("DSXkb", "Failed to xkb_state_new()..\n"); - xkb_keymap_unref(__xkb_keymap); - xkb_context_unref(__xkb_context); - return false; - } - - return true; -} - -void DSXkbPrivate::mmapKeymap() -{ - char *tmp; - - if (__keymap_area) - { - munmap(__keymap_area, __keymap_size); - } - if (__keymap_fd >= 0) - { - close(__keymap_fd); - __keymap_fd = -1; - } - __keymap_size = 0; - - if (!(tmp = xkb_map_get_as_string(__xkb_keymap))) - { - DSLOG_ERR("DSXkb", "Could not get keymap string"); - return; - } - - __keymap_size = strlen(tmp) + 1; - __keymap_fd = __getKeymapFd(__keymap_size); - if (__keymap_fd < 0) - { - DSLOG_ERR("DSXkb", "Could not create keymap file"); - free(tmp); - __keymap_size = 0; - return; - } - - __keymap_area = (char *)mmap(nullptr, __keymap_size, (PROT_READ | PROT_WRITE), MAP_SHARED, __keymap_fd, 0); - if (__keymap_area == MAP_FAILED) - { - DSLOG_ERR("DSXkb", "Failed to mmap keymap area: %m"); - free(tmp); - __keymap_size = 0; - close(__keymap_fd); - __keymap_fd = -1; - return; - } - - strncpy(__keymap_area, tmp, __keymap_size); - free(tmp); -} - -void DSXkbPrivate::updateModifier(int keycode, bool pressed) -{ - enum xkb_key_direction direction; - - if (pressed) - direction = XKB_KEY_DOWN; - else - direction = XKB_KEY_UP; - - xkb_state_update_key(__xkb_state, keycode, direction); - - __depressed = xkb_state_serialize_mods(__xkb_state, XKB_STATE_MODS_DEPRESSED); - __latched = xkb_state_serialize_mods(__xkb_state, XKB_STATE_MODS_LATCHED); - __locked = xkb_state_serialize_mods(__xkb_state, XKB_STATE_MODS_LOCKED); - __group = xkb_state_serialize_mods(__xkb_state, XKB_STATE_LAYOUT_EFFECTIVE); -} - -uint32_t DSXkbPrivate::getModifierDepressed() -{ - return __depressed; -} - -uint32_t DSXkbPrivate::getModifierLatched() -{ - return __latched; -} - -uint32_t DSXkbPrivate::getModifierLocked() -{ - return __locked; -} - -uint32_t DSXkbPrivate::getModifierGroup() -{ - return __group; -} - -int DSXkbPrivate::getKeymapFd() -{ - return __keymap_fd; -} - -int DSXkbPrivate::getKeymapSize() -{ - return __keymap_size; -} - -std::string DSXkbPrivate::getKeyname(int keycode) -{ - int nsyms; - const xkb_keysym_t *syms; - xkb_keysym_t sym = XKB_KEY_NoSymbol; - char key[256] = {0, }; - std::string keyname; - - nsyms = xkb_key_get_syms(__xkb_state, keycode, &syms); - if (nsyms == 1) sym = syms[0]; - - if (sym == XKB_KEY_NoSymbol) - { - snprintf(key, sizeof(key), "Keycode-%u", keycode); - } - else - { - /* get the keyname for this sym */ - xkb_keysym_get_name(sym, key, sizeof(key)); - } - - if (key[0] == '\0') - { - snprintf(key, sizeof(key), "Keycode-%u", keycode); - } - - keyname = key; - return keyname; -} - -typedef struct _keycode_map -{ - xkb_keysym_t keysym; - xkb_keycode_t keycode; -} keycode_map; - -static void -find_keycode(struct xkb_keymap *keymap, xkb_keycode_t key, void *data) -{ - keycode_map *found_keycodes = (keycode_map *)data; - xkb_keysym_t keysym = found_keycodes->keysym; - int nsyms = 0; - const xkb_keysym_t *syms_out = NULL; - - if (found_keycodes->keycode) return; - - nsyms = xkb_keymap_key_get_syms_by_level(keymap, key, 0, 0, &syms_out); - if (nsyms && syms_out) - { - if (*syms_out == keysym) - { - found_keycodes->keycode = key; - } - } -} - -int DSXkbPrivate::getKeycode(std::string keyname) -{ - xkb_keysym_t keysym = 0x0; - xkb_keycode_t keycode = 0; - - if (keyname.compare("Keycode-") == 0) - { - keycode = std::stoi(keyname); - } - else - { - keysym = xkb_keysym_from_name(keyname.c_str(), XKB_KEYSYM_NO_FLAGS); - keycode_map found_keycodes = {0,}; - found_keycodes.keysym = keysym; - xkb_keymap_key_for_each(__xkb_keymap, find_keycode, &found_keycodes); - - keycode = found_keycodes.keycode; - } - - return keycode; -} - -int DSXkbPrivate::__getKeymapFd(off_t size) -{ - int fd = 0, blen = 0, len = 0; - char *path = nullptr, *env = nullptr; - char tmp[PATH_MAX] = {0, }; - long flags; - mode_t old_umask; - - blen = sizeof(tmp) - 20; - - env = getenv("XDG_RUNTIME_DIR"); - if (env) - { - path = strdup(env); - } - if (!path) return -1; - - len = strlen(path) + 19; - if (len < blen) - { - strncpy(tmp, path, PATH_MAX - 20); - strncat(tmp, "/e-wl-keymap-XXXXXX", 19); - free(path); - } - else - { - free(path); - return -1; - } - - old_umask = umask(S_IRWXG|S_IRWXO); - fd = mkstemp(tmp); - umask(old_umask); - - if (fd < 0) - { - return -1; - } - - flags = fcntl(fd, F_GETFD); - if (flags < 0) - { - close(fd); - return -1; - } - - if (fcntl(fd, F_SETFD, (flags | FD_CLOEXEC)) == -1) - { - close(fd); - return -1; - } - - if (ftruncate(fd, size) < 0) - { - close(fd); - return -1; - } - - unlink(tmp); - return fd; -} - - -DSXkb::DSXkb(DSSeat *seat) - : DS_INIT_PRIVATE_PTR(DSXkb), - __seat(seat), - __rules("evdev"), __model("pc105"), __layout("us"), __variant(""), __options("") -{ - DS_GET_PRIV(DSXkb); - - priv->makeKeymap(); - priv->mmapKeymap(); -} - -DSXkb::DSXkb(DSSeat *seat, std::string rules, std::string model, std::string layout, std::string variant, std::string options) - : DS_INIT_PRIVATE_PTR(DSXkb), - __seat(seat), - __rules(rules), __model(model), __layout(layout), __variant(variant), __options(options) -{ - DS_GET_PRIV(DSXkb); - - priv->makeKeymap(); - priv->mmapKeymap(); -} - -DSXkb::~DSXkb() -{ -} - -void DSXkb::updateModifier(int keycode, bool pressed) -{ - DS_GET_PRIV(DSXkb); - - priv->updateModifier(keycode, pressed); -} - -uint32_t DSXkb::getModifierDepressed() -{ - DS_GET_PRIV(DSXkb); - - return priv->getModifierDepressed(); -} - -uint32_t DSXkb::getModifierLatched() -{ - DS_GET_PRIV(DSXkb); - - return priv->getModifierLatched(); -} - -uint32_t DSXkb::getModifierLocked() -{ - DS_GET_PRIV(DSXkb); - - return priv->getModifierLocked(); -} - -uint32_t DSXkb::getModifierGroup() -{ - DS_GET_PRIV(DSXkb); - - return priv->getModifierGroup(); -} - -int DSXkb::getKeymapFd() -{ - DS_GET_PRIV(DSXkb); - - return priv->getKeymapFd(); -} - -int DSXkb::getKeymapSize() -{ - DS_GET_PRIV(DSXkb); - - return priv->getKeymapSize(); -} - -std::string DSXkb::getKeyname(int keycode) -{ - DS_GET_PRIV(DSXkb); - - return priv->getKeyname(keycode); -} - -int DSXkb::getKeycode(std::string keyname) -{ - DS_GET_PRIV(DSXkb); - - return priv->getKeycode(keyname); -} - -} // namespace display_server diff --git a/src/DSXkb/DSXkb.h b/src/DSXkb/DSXkb.h deleted file mode 100644 index c01bc94..0000000 --- a/src/DSXkb/DSXkb.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_XKB_H__ -#define __DS_XKB_H__ - -#include -#include - -namespace display_server -{ - -class DSXkbPrivate; - -class DSXkb : public DSObject -{ -DS_PIMPL_USE_PRIVATE(DSXkb); -public: - DSXkb(DSSeat *seat); - DSXkb(DSSeat *seat, std::string rules, std::string model, std::string layout, std::string variant, std::string options); - ~DSXkb() override; - - void updateModifier(int keycode, bool pressed); - uint32_t getModifierDepressed(); - uint32_t getModifierLatched(); - uint32_t getModifierLocked(); - uint32_t getModifierGroup(); - int getKeymapFd(); - int getKeymapSize(); - - std::string getKeyname(int keycode); - int getKeycode(std::string keyname); - -private: - DSSeat* __seat; - std::string __rules; - std::string __model; - std::string __layout; - std::string __variant; - std::string __options; -}; - -} - -#endif diff --git a/src/DSXkb/DSXkbPrivate.h b/src/DSXkb/DSXkbPrivate.h deleted file mode 100644 index 56e4711..0000000 --- a/src/DSXkb/DSXkbPrivate.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_XKB_PRIVATE_H__ -#define __DS_XKB_PRIVATE_H__ - -#include -#include -#include "DSXkb.h" - -#include - -namespace display_server -{ - -class DSXkbPrivate : public DSObjectPrivate -{ -DS_PIMPL_USE_PUBLIC(DSXkb); -public: - DSXkbPrivate() = delete; - DSXkbPrivate(DSXkb *p_ptr); - ~DSXkbPrivate(); - - bool makeKeymap(); - void updateModifier(int keycode, bool pressed); - xkb_mod_mask_t getModifierDepressed(); - xkb_mod_mask_t getModifierLatched(); - xkb_mod_mask_t getModifierLocked(); - xkb_mod_mask_t getModifierGroup(); - int getKeymapFd(); - int getKeymapSize(); - - std::string getKeyname(int keycode); - int getKeycode(std::string keyname); - -protected: - void mmapKeymap(); - -private: - struct ::xkb_state *__xkb_state; - struct ::xkb_keymap *__xkb_keymap; - struct ::xkb_context *__xkb_context; - - int __keymap_fd; - size_t __keymap_size; - char *__keymap_area; - - xkb_mod_mask_t __depressed; - xkb_mod_mask_t __latched; - xkb_mod_mask_t __locked; - xkb_mod_mask_t __group; - - int __getKeymapFd(off_t size); -}; - -} - -#endif diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp deleted file mode 100644 index 3997032..0000000 --- a/src/DSZone/DSZone.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "DSZone.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandSurface.h" -#include "IDSWaylandShell.h" -#include "DSWaylandZxdgShellV6.h" -#include "DSDebugLog.h" - -namespace display_server -{ - -DSZone::DSZone() - : __position{0, 0}, - __size{0, 0}, - __waylandCompositor(nullptr), - __wm(nullptr), - __eventLoop(nullptr), - __waylandShell(nullptr), - __stackChanged(false) -{ - __waylandCompositor = DSWaylandCompositor::getInstance(); - if (__waylandCompositor) - { - __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&DSZone::__onSurfaceCreated, this, std::placeholders::_1)); - __waylandCompositor->registerCallbackSurfaceDestroy(this, std::bind(&DSZone::__onSurfaceDestroy, this, std::placeholders::_1)); - - __wm = DSWindowManager::getInstance(); - if (__wm) - __wm->registerZone(this); - - __eventLoop = DSEventLoop::getInstance(); - if (__eventLoop) - __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSZone::__onEventIdleEnterer, this, std::placeholders::_1)); - - - __waylandShell = __waylandCompositor->getShell(); - if (__waylandShell) - { - __waylandShell->registerCallbackShellSurfaceCreated(this, std::bind(&DSZone::__onShellSurfaceCreated, this, std::placeholders::_1)); - __waylandShell->registerCallbackShellSurfaceDestroyed(this, std::bind(&DSZone::__onShellSurfaceDestroyed, this, std::placeholders::_1)); - } - } - - __setSupportAuxHints(); -} - -DSZone::~DSZone() -{ - if (__wm) - __wm->unregisterZone(this); - if (__eventLoop) - DSEventLoop::releaseInstance(); - if (__wm) - DSWindowManager::releaseInstance(); - if (__waylandCompositor) - DSWaylandCompositor::releaseInstance(); -} - -void DSZone::__setSupportAuxHints(void) -{ - __supportedAuxHints.push_back("wm.policy.win.user.geometry"); -} - -void DSZone::setPosition(stPosition &position) -{ - __position.x = position.x; - __position.y = position.y; -} - -void DSZone::setSize(stSize &size) -{ - __size.w = size.w; - __size.h = size.h; -} - -stPosition DSZone::getPosition() -{ - stPosition position; - position.x = __position.x; - position.y = __position.y; - - return position; -} - -stSize DSZone::getSize() -{ - stSize size; - size.w = __size.w; - size.h = __size.h; - - return size; -} - -void DSZone::registerCallbackWindowCreated(DSObject *slot, std::function)> func) -{ - __windowCreatedSignal.connect(slot, func); -} - -void DSZone::registerCallbackWindowShellCreated(DSObject *slot, std::function)> func) -{ - __windowShellCreatedSignal.connect(slot, func); -} - -void DSZone::registerCallbackWindowStackChanged(DSObject *slot, std::function)> func) -{ - __windowStackChangedSignal.connect(slot, func); -} - -void DSZone::registerCallbackWindowDestroy(DSObject *slot, std::function)> func) -{ - __windowDestroySignal.connect(slot, func); -} - -void DSZone::callCallbackWindowCreated() -{ - __windowCreatedSignal.emit(nullptr); -} - -void DSZone::__onEventIdleEnterer(void *data) -{ - if (__stackChanged) - { - DSLOG_DBG("DSZone", "Calculate Visibility..."); - - // calculate visibility? - __stackChanged = false; - } -} - -void DSZone::__onSurfaceCreated(std::shared_ptr waylandSurface) -{ - DSLOG_DBG("DSZone", "waylandSurface:(shared:%p, pure:%p)", waylandSurface, waylandSurface.get()); - - if (__wm) - __wm->registerSurface(this, waylandSurface.get()); - - // create DSWindow - std::shared_ptr window = __createWindow(waylandSurface); - - // create DSWindowShell - std::shared_ptr shell = __createWindowShell(window); -} - -void DSZone::__onSurfaceDestroy(std::shared_ptr waylandSurface) -{ - DSWaylandSurface *dswSurfacePtr = waylandSurface.get(); - - if (__wm) - __wm->unregisterSurface(this, dswSurfacePtr); - - DSWindowShell *shell = __findWindowShell(dswSurfacePtr); - __destroyWindowShell(shell, dswSurfacePtr); - - std::shared_ptr window = __findWindow(dswSurfacePtr); - __destroyWindow(window); -} - -void DSZone::__onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface) -{ - DSLOG_DBG("DSZone", "Created waylandShellSurface:(pure:%p)", waylandShellSurface); - - if (waylandShellSurface) - { - struct ::wl_resource *wlSurface = waylandShellSurface->getWlSurface(); - DSLOG_DBG("DSZone", "get wl_surface:%p", wlSurface); - - DSWaylandSurface *dsSurface = waylandShellSurface->getSurface(); - DSLOG_DBG("DSZone", "get DSWaylandSurface:%p", dsSurface); - - if (dsSurface) - { - // find DSWindowShell associated with DSWaylandSurface - DSWindowShell *dsWinShell = __findWindowShell(dsSurface); - if (dsWinShell) - { - DSLOG_DBG("DSZONE", "Find DSWindowShell (%p)... setShellSurface!", dsWinShell); - dsWinShell->setShellSurface(waylandShellSurface); - } - } - } -} - -void DSZone::__onShellSurfaceDestroyed(IDSWaylandShellSurface *waylandShellSurface) -{ - DSLOG_DBG("DSZone", "Destroyed waylandShellSurface:(pure:%p)", waylandShellSurface); - - if (waylandShellSurface) - { - struct ::wl_resource *wlSurface = waylandShellSurface->getWlSurface(); - DSLOG_DBG("DSZone", "get wl_surface:%p", wlSurface); - - DSWaylandSurface *dsSurface = waylandShellSurface->getSurface(); - DSLOG_DBG("DSZone", "get DSWaylandSurface:%p", dsSurface); - - if (dsSurface) - { - // find DSWindowShell associated with DSWaylandSurface - DSWindowShell *dsWinShell = __findWindowShell(dsSurface); - if (dsWinShell) - { - DSLOG_DBG("DSZONE", "Find DSWindowShell (%p)... setShellSurface to nullptr!", dsWinShell); - dsWinShell->setShellSurface(nullptr); - } - } - } -} - -// for Test -void DSZone::callCallbackWindowShellCreated(std::shared_ptr winShell) -{ - __windowShellCreatedSignal.emit(winShell); -} - -bool DSZone::testCreateWindow(std::shared_ptr waylandSurface) -{ - if (waylandSurface == nullptr) - return false; - - __onSurfaceCreated(waylandSurface); - return true; -} - -bool DSZone::testDestroyWindow(std::shared_ptr waylandSurface) -{ - if (waylandSurface == nullptr) - return false; - - __onSurfaceDestroy(waylandSurface); - return true; -} - -std::list> DSZone::getWindowList() -{ - return __windowList; -} - -std::list> DSZone::getWindowShellList() -{ - return __windowShellList; -} - -void DSZone::__prependWindowList(std::shared_ptr window) -{ - __windowList.remove(window); - __windowList.push_front(window); - - __stackChanged = true; - __updateWindowOrder(); - - std::shared_ptr wTop(__windowList.front()); - __windowStackChangedSignal.emit(wTop); -} - -void DSZone::__appendWindowList(std::shared_ptr window) -{ - __windowList.remove(window); - __windowList.push_back(window); - - __stackChanged = true; - __updateWindowOrder(); - - std::shared_ptr wTop(__windowList.front()); - __windowStackChangedSignal.emit(wTop); -} - -std::shared_ptr DSZone::__findWindow(DSWaylandSurface *dswlSurface) -{ - std::list> wList = getWindowList(); - for (auto w : wList) - { - if (w->surface() == dswlSurface) - { - DSLOG_INF("DSZone", "Window found (win=%p, surface=%p)", w, dswlSurface); - return w; - } - } - - return nullptr; -} - -DSWindowShell *DSZone::__findWindowShell(DSWaylandSurface *dswlSurface) -{ - DSWindowShell *dsWinShell = nullptr; - - std::map::iterator iter; - iter = __windowShellMap.find(dswlSurface); - if(iter == __windowShellMap.end()) - { - DSLOG_DBG("DSZone", "Doesn't Exist DSWindowShell... DSWaylandSurface(%p)", dswlSurface); - return nullptr; - } - - dsWinShell = iter->second; - return dsWinShell; -} - -std::shared_ptr DSZone::__createWindow(std::shared_ptr waylandSurface) -{ - std::shared_ptr window = std::make_shared(waylandSurface); - __prependWindowList(window); - - // emit a signal of the surface committed - __windowCreatedSignal.emit(window); - - return window; -} - -void DSZone::__destroyWindow(std::shared_ptr window) -{ - __windowDestroySignal.emit(window); - __windowList.remove(window); - - __stackChanged = true; - __updateWindowOrder(); - - std::shared_ptr wTop(__windowList.front()); - __windowStackChangedSignal.emit(wTop); -} - -void DSZone::__updateWindowOrder(void) -{ - uint32_t zOrder = 0; - std::list> wList = getWindowList(); - for (auto w : wList) - { - /* TODO : check if the w is in its visible state */ - w->setZOrder(zOrder++); - } -} - -std::shared_ptr DSZone::__createWindowShell(std::shared_ptr window) -{ - DSWindow *ptrWindow = window.get(); - - std::shared_ptr shell = std::make_shared(ptrWindow); - if (!shell) return nullptr; - - shell->setZone(this); - - __windowShellList.push_front(shell); - - __windowShellMap.insert(std::make_pair(ptrWindow->surface(), shell.get())); - - // emit a signal of the shell created - __windowShellCreatedSignal.emit(shell); - - return shell; -} - -void DSZone::__destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface *surface) -{ - // remove from map - __windowShellMap.erase(surface); - - // remove from __windowShellList - std::list> wsList = getWindowShellList(); - for (auto ws : wsList) - { - if (ws.get() == windowShell) - { - __windowShellDestroySignal.emit(ws); - __windowShellList.remove(ws); - break; - } - } -} - -bool DSZone::setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface) -{ - DSWindowShell *wShell = __findWindowShell(dswlSurface); - if (!wShell) return false; - - DSWindowShell *pwShell = __findWindowShell(dswlParentSurface); - - return wShell->setParent(pwShell); -} - -bool DSZone::setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title) -{ - DSWindowShell *wShell = __findWindowShell(dswSurface); - if (!wShell) return false; - - return wShell->setTitle(title); - -/* - std::shared_ptr window = __findWindow(dswSurface); - if (!window) return false; - - return window->setTitle(title); -*/ -} - -bool DSZone::setWindowType(DSWaylandSurface *dswSurface, int type) -{ - DSWindowShell *wShell = __findWindowShell(dswSurface); - if (!wShell) return false; - - return wShell->setType(type); - -/* - std::shared_ptr window = __findWindow(dswSurface); - if (!window) return false; - - return window->setType(type); -*/ -} - -bool DSZone::setWindowGeometry(DSWaylandSurface *dswSurface, int x, int y, unsigned int w, unsigned h) -{ - DSWindowShell *wShell = __findWindowShell(dswSurface); - if (!wShell) return false; - - return wShell->setGeometry(x, y, w, h); - -/* - std::shared_ptr window = __findWindow(dswSurface); - if (!window) return false; - - return window->setGeometry(x, y, w, h); -*/ -} - -bool DSZone::setWindowPosition(DSWaylandSurface *dswSurface, int x, int y) -{ - DSWindowShell *wShell = __findWindowShell(dswSurface); - if (!wShell) return false; - - return wShell->setPosition(x, y); - -/* - std::shared_ptr window = __findWindow(dswSurface); - if (!window) return false; - - return window->setPosition(x, y); -*/ -} - -stGeometry DSZone::getWindowGeometry(DSWaylandSurface *dswSurface) -{ - stGeometry geometry = {0, }; - DSWindowShell *wShell = __findWindowShell(dswSurface); - if (!wShell) return geometry; - - return wShell->getGeometry(); -} - -void DSZone::addWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &name, const std::string &value) -{ - DSWindowShell *wShell = __findWindowShell(dswlSurface); - if (!wShell) return; - - wShell->addAuxHint(id, name, value); -} - -void DSZone::changeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &value) -{ - DSWindowShell *wShell = __findWindowShell(dswlSurface); - if (!wShell) return; - - wShell->changeAuxHint(id, value); -} - -void DSZone::removeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id) -{ - DSWindowShell *wShell = __findWindowShell(dswlSurface); - if (!wShell) return; - - wShell->removeAuxHint(id); -} - -std::list DSZone::getWindowSupportedAuxHints(DSWaylandSurface *dswlSurface) -{ - // TODO: we have to change code to use DSPolicy instead of DSZone - return __supportedAuxHints; -} - -void DSZone::activateWindow(DSWaylandSurface *dswlSurface) -{ - if (!dswlSurface) return; - - std::shared_ptr window = __findWindow(dswlSurface); - __prependWindowList(window); - - DSWindowShell *wShell = __findWindowShell(dswlSurface); - if (!wShell) return; - - wShell->activate(); -} - -void DSZone::raiseWindow(DSWaylandSurface* dswlSurface) -{ - if (!dswlSurface) return; - - std::shared_ptr window = __findWindow(dswlSurface); - __prependWindowList(window); - - DSWindowShell *wShell = __findWindowShell(dswlSurface); - if (!wShell) return; - - wShell->raise(); -} - -void DSZone::lowerWindow(DSWaylandSurface* dswlSurface) -{ - if (!dswlSurface) return; - - std::shared_ptr window = __findWindow(dswlSurface); - __appendWindowList(window); - - DSWindowShell *wShell = __findWindowShell(dswlSurface); - if (!wShell) return; - - wShell->lower(); -} - -void DSZone::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) -{ - DSWindowShell *wShell = __findWindowShell(dswlSurface); - if (!wShell) return; - - wShell->setSkipFocus(set); -} - -bool DSZone::setWindowVkbdFloating(DSWaylandSurface *dswlsurface, bool set) -{ - DSWindowShell *wShell = __findWindowShell(dswlsurface); - if (!wShell) return false; - - return wShell->setVkbdFloating(set); -} - -bool DSZone::getWindowVkbdFloating(DSWaylandSurface *dswlsurface) -{ - DSWindowShell *wShell = __findWindowShell(dswlsurface); - if (!wShell) return false; - - return wShell->getVkbdFloating(); -} - -void DSZone::setWindowAllowUserGeometry(DSWaylandSurface *dswlsurface, bool set) -{ - DSWindowShell *wShell = __findWindowShell(dswlsurface); - if (!wShell) return; - - wShell->setAllowUserGeometry(set); -} - -} // namespace display_server diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h deleted file mode 100644 index 3857d70..0000000 --- a/src/DSZone/DSZone.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __DS_ZONE_H__ -#define __DS_ZONE_H__ - -#include -#include "DSWindowManager.h" -#include "DSWindow.h" -#include "DSWindowShell.h" -#include "DSSignal.h" -#include "DSStruct.h" -#include "DSEventLoop.h" - -namespace display_server -{ -class DSWaylandCompositor; -class DSWaylandSurface; -class DSWaylandZxdgSurfaceV6; -class IDSWaylandShell; -class IDSWaylandShellSurface; - -class DSZone : public DSObject -{ -public: - explicit DSZone(); - virtual ~DSZone(); - - void setPosition(stPosition &position); - void setSize(stSize &size); - stPosition getPosition(); - stSize getSize(); - - // Callback methods - void registerCallbackWindowCreated(DSObject *slot, std::function)> func); - void registerCallbackWindowDestroy(DSObject *slot, std::function)> func); - void registerCallbackWindowShellCreated(DSObject *slot, std::function)> func); - void registerCallbackWindowStackChanged(DSObject *slot, std::function)> func); - - // emit functions for testing - void callCallbackWindowCreated(); - void callCallbackWindowShellCreated(std::shared_ptr winShell); - // for test - bool testCreateWindow(std::shared_ptr waylandSurface); - bool testDestroyWindow(std::shared_ptr waylandSurface); - - // for window property - bool setWindowParent(DSWaylandSurface *dswlSurface, DSWaylandSurface *dswlParentSurface); - bool setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title); - bool setWindowType(DSWaylandSurface *dswSurface, int type); - bool setWindowGeometry(DSWaylandSurface *dswSurface, int x, int y, unsigned int w, unsigned h); - bool setWindowPosition(DSWaylandSurface *dswSurface, int x, int y); - stGeometry getWindowGeometry(DSWaylandSurface *dswSurface); - - void addWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &name, const std::string &value); - void changeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id, const std::string &value); - void removeWindowAuxHint(DSWaylandSurface *dswlSurface, int32_t id); - std::list getWindowSupportedAuxHints(DSWaylandSurface *dswlSurface); - - void activateWindow(DSWaylandSurface *dswlSurface); - void raiseWindow(DSWaylandSurface* dswlSurface); - void lowerWindow(DSWaylandSurface* dswlSurface); - - void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); - - bool setWindowVkbdFloating(DSWaylandSurface *dswlSurface, bool set); - bool getWindowVkbdFloating(DSWaylandSurface *dswlSurface); - - void setWindowAllowUserGeometry(DSWaylandSurface *dswlSurface, bool set); - - std::list> getWindowList(); - std::list> getWindowShellList(); - -private: - void __onEventIdleEnterer(void *data); - - void __onSurfaceCreated(std::shared_ptr waylandSurface); - void __onSurfaceDestroy(std::shared_ptr waylandSurface); - - void __onShellSurfaceCreated(IDSWaylandShellSurface *waylandShellSurface); - void __onShellSurfaceDestroyed(IDSWaylandShellSurface *waylandShellSurface); - - std::shared_ptr __createWindow(std::shared_ptr waylandSurface); - void __destroyWindow(std::shared_ptr window); - void __updateWindowOrder(void); - - std::shared_ptr __createWindowShell(std::shared_ptr window); - void __destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface *surface); - - void __prependWindowList(std::shared_ptr window); - void __appendWindowList(std::shared_ptr window); - - std::shared_ptr __findWindow(DSWaylandSurface *dswlSurface); - DSWindowShell* __findWindowShell(DSWaylandSurface *dswlSurface); - - void __setSupportAuxHints(void); - - stPosition __position; - stSize __size; - std::list> __windowList; - std::list> __windowShellList; - DSWaylandCompositor *__waylandCompositor; - DSWindowManager *__wm; - DSEventLoop *__eventLoop; - IDSWaylandShell *__waylandShell; - bool __stackChanged; - - std::map __windowShellMap; - std::list __supportedAuxHints; - - // signals - DSSignal> __windowCreatedSignal; - DSSignal> __windowDestroySignal; - DSSignal> __windowStackChangedSignal; - DSSignal> __windowShellCreatedSignal; - DSSignal> __windowShellDestroySignal; -}; - -} - -#endif diff --git a/src/meson.build b/src/meson.build deleted file mode 100644 index 06c2d12..0000000 --- a/src/meson.build +++ /dev/null @@ -1,285 +0,0 @@ - -libds_srcs = [ - 'DSBase/DSRefBase.cpp', - 'DSBase/DSRefBase.h', - 'DSBuffer/DSBufferQueueTBMImpl.cpp', - 'DSBuffer/DSBufferTBMImpl.cpp', - 'DSBuffer/DSBufferManager.cpp', - 'DSBuffer/DSBufferManager.h', - 'DSBuffer/DSBufferManagerPrivate.h', - 'DSBuffer/DSBufferRef.cpp', - 'DSBuffer/DSBufferRef.h', - 'DSCallback/DSCallback.h', - 'DSCanvas/DSCanvas.cpp', - 'DSCompositor/DSCompositor.cpp', - 'DSDebug/DSDebugLog.cpp', - 'DSDisplayArea/DSDisplayArea.cpp', - 'DSDisplayDevice/DSDisplayDeviceHWCTDMImpl.cpp', - 'DSDisplayDevice/DSDisplayDeviceHWCWindowTDMImpl.cpp', - 'DSDisplayDevice/DSDisplayDeviceHWCWindowTDMTargetImpl.cpp', - 'DSDisplayDevice/DSDisplayDeviceOutputModeTDMImpl.cpp', - 'DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp', - 'DSDisplayDevice/DSDisplayDeviceTDMImpl.cpp', - 'DSEventLoop/DSEventLoop.cpp', - 'DSInput/DSInput.cpp', - 'DSInput/DSInput.h', - 'DSInput/DSInputPrivate.h', - 'DSInput/DSInputEvent.h', - 'DSInput/DSLibinput.cpp', - 'DSInput/DSLibinput.h', - 'DSObject/DSObject.cpp', - 'DSObject/DSObject.h', - 'DSObject/DSObjectPrivate.cpp', - 'DSObject/DSObjectPrivate.h', - 'DSOutput/DSOutputImpl.cpp', - 'DSPolicyArea/DSPolicyArea.cpp', - 'DSProperty/DSProperty.cpp', - 'DSProperty/DSProperty.h', - 'DSProperty/DSPropertyPrivate.cpp', - 'DSProperty/DSPropertyPrivate.h', - 'DSRender/DSRenderEngineEcoreEvasImpl.cpp', - 'DSRender/DSRenderEngineDaliImpl.cpp', - 'DSRender/DSRenderView.cpp', - 'DSRender/DSRenderViewEcoreEvasImpl.cpp', - 'DSRender/DSRenderViewDaliImpl.cpp', - 'DSSeat/DSSeat.cpp', - 'DSSeat/DSKeyboard.cpp', - 'DSSeat/DSKeyboard.h', - 'DSSeat/DSPointer.cpp', - 'DSSeat/DSPointer.h', - 'DSSeat/DSTouch.cpp', - 'DSSeat/DSTouch.h', - 'DSSignal/DSSignal.cpp', - 'DSSignal/DSSignal.h', - 'DSSignal/DSSignalBroker.cpp', - 'DSSignal/DSSignalBroker.h', - 'DSCore/DSStruct.h', - 'DSCore/DSCore.h', - 'DSWaylandExtension/DSWaylandExtension.cpp', - 'DSTizenAppinfo/DSTizenAppinfo.h', - 'DSTizenAppinfo/DSTizenAppinfo.cpp', - 'DSTizenAppinfo/DSTizenAppinfoMgr.h', - 'DSTizenAppinfo/DSTizenAppinfoMgrPrivate.h', - 'DSTizenAppinfo/DSTizenAppinfoMgr.cpp', - 'DSWindow/DSWindow.h', - 'DSWindow/DSWindowPrivate.h', - 'DSWindow/DSWindow.cpp', - 'DSWindowManager/DSWindowManager.cpp', - 'DSWindowShell/DSWindowShell.cpp', - 'DSWindowShell/DSWindowShellPrivate.cpp', - 'DSZone/DSZone.cpp', - 'DSClient/DSClientPrivate.h', - 'DSClient/DSClient.h', - 'DSClient/DSClient.cpp', - 'DSXkb/DSXkbPrivate.h', - 'DSXkb/DSXkb.h', - 'DSXkb/DSXkb.cpp', - 'DSTextInput/DSTextInputPrivate.h', - 'DSTextInput/DSTextInput.h', - 'DSTextInput/DSTextInput.cpp', - 'DSUtil/DSUtilSocket.h', - 'DSUtil/DSUtilSocket.cpp', - 'DSTraceInfo/DSTraceInfo.h', - 'DSTraceInfo/DSTraceInfo.cpp', - ] - -libds_wayland_srcs = [ - 'DSWaylandServer/dswayland-server-wayland.cpp', - 'DSWaylandServer/dswayland-server-wayland.h', - 'DSWaylandServer/dswayland-server-tizen-extension.cpp', - 'DSWaylandServer/dswayland-server-tizen-extension.h', - 'DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.cpp', - 'DSWaylandServer/dswayland-server-xdg-shell-unstable-v6.h', - 'DSWaylandServer/dswayland-server-xdg-shell.cpp', - 'DSWaylandServer/dswayland-server-xdg-shell.h', - 'DSWaylandServer/dswayland-server-tizen-surface.cpp', - 'DSWaylandServer/dswayland-server-tizen-surface.h', - 'DSWaylandServer/dswayland-server-text.cpp', - 'DSWaylandServer/dswayland-server-text.h', - 'DSWaylandServer/dswayland-server-tizen-launch.cpp', - 'DSWaylandServer/dswayland-server-tizen-launch.h', - 'DSWaylandServer/dswayland-server-input-method-unstable-v1.cpp', - 'DSWaylandServer/dswayland-server-input-method-unstable-v1.h', - 'DSWaylandServer/dswayland-server-tizen-policy-ext.cpp', - 'DSWaylandServer/dswayland-server-tizen-policy-ext.h', - 'DSWaylandServer/DSWaylandCallback.cpp', - 'DSWaylandServer/DSWaylandCallback.h', - 'DSWaylandServer/DSWaylandCallbackPrivate.h', - 'DSWaylandServer/DSWaylandOutput.cpp', - 'DSWaylandServer/DSWaylandOutput.h', - 'DSWaylandServer/DSWaylandOutputPrivate.h', - 'DSWaylandServer/DSWaylandSurface.cpp', - 'DSWaylandServer/DSWaylandSurface.h', - 'DSWaylandServer/DSWaylandSurfacePrivate.h', - 'DSWaylandServer/DSWaylandRegion.cpp', - 'DSWaylandServer/DSWaylandRegion.h', - 'DSWaylandServer/DSWaylandRegionPrivate.h', - 'DSWaylandServer/DSWaylandTizenInputDevice.h', - 'DSWaylandServer/DSWaylandTizenInputDevicePrivate.h', - 'DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp', - 'DSWaylandServer/DSWaylandTizenInputDeviceManager.h', - 'DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h', - 'DSWaylandServer/DSWaylandTizenPolicy.cpp', - 'DSWaylandServer/DSWaylandTizenPosition.cpp', - 'DSWaylandServer/DSWaylandTizenVisibility.cpp', - 'DSWaylandServer/DSWaylandTizenSurface.cpp', - 'DSWaylandServer/DSWaylandTizenSurface.h', - 'DSWaylandServer/DSWaylandTizenSurfacePrivate.h', - 'DSWaylandServer/DSWaylandTizenSurfaceShm.cpp', - 'DSWaylandServer/DSWaylandTizenSurfaceShm.h', - 'DSWaylandServer/DSWaylandTizenSurfaceShmPrivate.h', - 'DSWaylandServer/DSWaylandZxdgShellV6.cpp', - 'DSWaylandServer/DSWaylandZxdgShellV6.h', - 'DSWaylandServer/DSWaylandZxdgShellV6Private.h', - 'DSWaylandServer/DSWaylandCompositorPrivate.h', - 'DSWaylandServer/DSWaylandCompositor.h', - 'DSWaylandServer/DSWaylandCompositor.cpp', - 'DSWaylandServer/DSWaylandClientPrivate.h', - 'DSWaylandServer/DSWaylandClient.h', - 'DSWaylandServer/DSWaylandClient.cpp', - 'DSWaylandServer/DSWaylandSeatPrivate.h', - 'DSWaylandServer/DSWaylandSeat.h', - 'DSWaylandServer/DSWaylandSeat.cpp', - 'DSWaylandServer/DSWaylandPointerPrivate.h', - 'DSWaylandServer/DSWaylandPointer.h', - 'DSWaylandServer/DSWaylandPointer.cpp', - 'DSWaylandServer/DSWaylandKeyboardPrivate.h', - 'DSWaylandServer/DSWaylandKeyboard.h', - 'DSWaylandServer/DSWaylandKeyboard.cpp', - 'DSWaylandServer/DSWaylandTouchPrivate.h', - 'DSWaylandServer/DSWaylandTouch.h', - 'DSWaylandServer/DSWaylandTouch.cpp', - 'DSWaylandServer/DSWaylandBufferPrivate.h', - 'DSWaylandServer/DSWaylandBuffer.h', - 'DSWaylandServer/DSWaylandBuffer.cpp', - 'DSWaylandServer/DSWaylandTizenIndicatorPrivate.h', - 'DSWaylandServer/DSWaylandTizenIndicator.h', - 'DSWaylandServer/DSWaylandTizenIndicator.cpp', - 'DSWaylandServer/DSWaylandInputMethodContextPrivate.h', - 'DSWaylandServer/DSWaylandInputMethodContext.h', - 'DSWaylandServer/DSWaylandInputMethodPrivate.h', - 'DSWaylandServer/DSWaylandInputMethod.h', - 'DSWaylandServer/DSWaylandInputMethod.cpp', - 'DSWaylandServer/DSWaylandTextInputManagerPrivate.h', - 'DSWaylandServer/DSWaylandTextInputManager.h', - 'DSWaylandServer/DSWaylandTextInputPrivate.h', - 'DSWaylandServer/DSWaylandTextInput.h', - 'DSWaylandServer/DSWaylandTextInput.cpp', - 'DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h', - 'DSWaylandServer/DSWaylandInputPanelSurface.h', - 'DSWaylandServer/DSWaylandInputPanelPrivate.h', - 'DSWaylandServer/DSWaylandInputPanel.h', - 'DSWaylandServer/DSWaylandInputPanel.cpp', - 'DSWaylandServer/DSWaylandTizenAppinfoPrivate.h', - 'DSWaylandServer/DSWaylandTizenAppinfo.h', - 'DSWaylandServer/DSWaylandTizenAppinfo.cpp', - 'DSWaylandServer/DSWaylandTizenLaunchEffectPrivate.h', - 'DSWaylandServer/DSWaylandTizenLaunchEffect.h', - 'DSWaylandServer/DSWaylandTizenLaunchEffect.cpp', - 'DSWaylandServer/DSWaylandTizenLaunchSplashPrivate.h', - 'DSWaylandServer/DSWaylandTizenLaunchSplash.h', - 'DSWaylandServer/DSWaylandTizenLaunchSplash.cpp', - 'DSWaylandServer/DSWaylandProtocolTracePrivate.h', - 'DSWaylandServer/DSWaylandProtocolTraceStruct.h', - 'DSWaylandServer/DSWaylandProtocolTrace.h', - 'DSWaylandServer/DSWaylandProtocolTrace.cpp', - 'DSWaylandServer/DSWaylandTizenPolicyExt.h', - 'DSWaylandServer/DSWaylandTizenPolicyExtPrivate.h', - 'DSWaylandServer/DSWaylandTizenPolicyExt.cpp', - ] - -libds_srcs += libds_wayland_srcs - -install_headers( - 'DSObject/DSObject.h', - 'DSSignal/DSSignal.h', - 'DSBase/DSRefBase.h', - ) - -pkgconfig = import('pkgconfig') -ecore_dep = dependency('ecore') -ecore_evas_dep = dependency('ecore-evas') -dlog_dep = dependency('dlog') -libtdm_dep = dependency('libtdm') -libtbm_dep = dependency('libtbm') -wayland_tbm_server_dep = dependency('wayland-tbm-server') -wayland_dep = dependency('wayland-server') -libinput_dep = dependency('libinput') -libudev_dep = dependency('libudev') -xkbcommon_dep = dependency('xkbcommon') - -tizen_ext_dep = dependency('tizen-extension-server') -xdg_shell_unstable_v6_dep = dependency('xdg-shell-unstable-v6-server') -xdg_shell_dep = dependency('xdg-shell-server') -tizen_surface_dep = dependency('tizen-surface-server') -input_method_dep = dependency('input-method-server') -text_dep = dependency('text-server') -tizen_launch_dep = dependency('tizen-launch-server') -tizen_policy_ext_dep = dependency('tizen-policy-ext-server') - -dali_core_dep = dependency('dali2-core') -dali_adaptor_dep = dependency('dali2-adaptor') -dali_toolkit_dep = dependency('dali2-toolkit') - -dali_deps = [dali_core_dep, dali_adaptor_dep, dali_toolkit_dep] -tizen_ext_deps = [tizen_ext_dep, input_method_dep, text_dep, tizen_launch_dep, tizen_surface_dep] -tizen_ext_deps += [xdg_shell_unstable_v6_dep, xdg_shell_dep, tizen_policy_ext_dep] -libds_deps = [ecore_dep] - -libds_include_dirs = include_directories( - '.', - './DSBase', - './DSBuffer', - './DSCallback', - './DSCanvas', - './DSCompositor', - './DSDebug', - './DSDisplayArea', - './DSDisplayDevice', - './DSEventLoop', - './DSInput', - './DSObject', - './DSOutput', - './DSPolicyArea', - './DSProperty', - './DSRender', - './DSSeat', - './DSSignal', - './DSCore', - './DSWaylandExtension', - './DSWaylandServer', - './DSWindow', - './DSWindowManager', - './DSWindowShell', - './DSZone', - './DSClient', - './DSXkb', - './DSTextInput', - './DSTizenAppinfo', - './DSUtil', - './DSTraceInfo', - ) - -libds_lib = shared_library( - 'ds', - libds_srcs, - dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps], - include_directories : [libds_include_dirs], - version : meson.project_version(), - install : true - ) - -pkgconfig.generate( - filebase : 'libds', - name : 'libds', - description : 'Display Server library', - version : meson.project_version(), - libraries : libds_lib - ) - -libds_declared_dep = declare_dependency( - link_with : libds_lib, - dependencies : [libds_deps, ecore_dep], - include_directories : [libds_include_dirs] - ) - diff --git a/tests/DSBufferManager-test.cpp b/tests/DSBufferManager-test.cpp deleted file mode 100644 index 9f6a1d2..0000000 --- a/tests/DSBufferManager-test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "IDSBuffer.h" -#include "DSBufferManager.h" -#include "DSBufferTBMImpl.h" -#include "DSWaylandCompositor.h" - -using namespace display_server; - -class DSBufferManagerTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSBufferManagerTest, GetBufferManager) -{ - DSBufferManager* bufferManager = DSBufferManager::getInstance(); - EXPECT_TRUE(bufferManager != nullptr); - - DSBufferManager::releaseInstance(); -} diff --git a/tests/DSBufferRef-test.cpp b/tests/DSBufferRef-test.cpp deleted file mode 100644 index fa99f39..0000000 --- a/tests/DSBufferRef-test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "IDSBuffer.h" -#include "DSBufferRef.h" -#include "DSBufferTBMImpl.h" - -using namespace display_server; - -class DSBufferRefTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSBufferRefTest, CreateBufferRef) -{ - std::shared_ptr buffer = std::make_unique(100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(buffer.get() != nullptr); - - std::shared_ptr bufferRef = std::make_shared(buffer); - EXPECT_TRUE(bufferRef.get() != nullptr); -} diff --git a/tests/DSBufferTBMImpl-test.cpp b/tests/DSBufferTBMImpl-test.cpp deleted file mode 100644 index fac2480..0000000 --- a/tests/DSBufferTBMImpl-test.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "IDSBuffer.h" -#include "DSBufferTBMImpl.h" -#include "DSBufferQueueTBMImpl.h" - -using namespace display_server; - -class DSBufferTBMImplTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSBufferTBMImplTest, CreateBuffer) -{ - std::unique_ptr buffer = std::make_unique(100, 200, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(buffer.get() != nullptr); - - std::shared_ptr size = buffer->getSize(); - EXPECT_TRUE(size->w == 100); - EXPECT_TRUE(size->h == 200); -} - -TEST_F(DSBufferTBMImplTest, CreateBufferQueue) -{ - std::unique_ptr bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue.get() != nullptr); -} - -TEST_F(DSBufferTBMImplTest, CheckInitialValues) -{ - std::unique_ptr bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue.get() != nullptr); - EXPECT_TRUE(bufferQueue->getBufferWidth() == 100); - EXPECT_TRUE(bufferQueue->getBufferHeight() == 100); - EXPECT_TRUE(bufferQueue->getNativeBufferQueue() != nullptr); -} - -TEST_F(DSBufferTBMImplTest, DequeueBuffer) -{ - std::unique_ptr bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue.get() != nullptr); - - std::shared_ptr buffer = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer != nullptr); -} - -TEST_F(DSBufferTBMImplTest, EnqueueBuffer) -{ - std::unique_ptr bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue.get() != nullptr); - - std::shared_ptr buffer = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer != nullptr); - EXPECT_TRUE(bufferQueue->enqueueBuffer(buffer)); -} - -TEST_F(DSBufferTBMImplTest, AcquireBuffer) -{ - std::unique_ptr bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue.get() != nullptr); - - std::shared_ptr buffer1 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer1 != nullptr); - EXPECT_TRUE(bufferQueue->enqueueBuffer(buffer1)); - std::shared_ptr buffer2 = bufferQueue->acquireBuffer(); - EXPECT_TRUE(buffer2 != nullptr); -} - -TEST_F(DSBufferTBMImplTest, ReleaseBuffer) -{ - std::unique_ptr bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue.get() != nullptr); - - std::shared_ptr buffer1 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer1 != nullptr); - EXPECT_TRUE(bufferQueue->enqueueBuffer(buffer1)); - std::shared_ptr buffer2 = bufferQueue->acquireBuffer(); - EXPECT_TRUE(buffer2 != nullptr); - EXPECT_TRUE(bufferQueue->releaseBuffer(buffer2)); -} - -TEST_F(DSBufferTBMImplTest, DequeueBuffer_4Times) -{ - std::unique_ptr bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue.get() != nullptr); - - std::shared_ptr buffer1 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer1 != nullptr); - std::shared_ptr buffer2 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer2 != nullptr); - std::shared_ptr buffer3 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer3 != nullptr); - EXPECT_TRUE(bufferQueue->releaseBuffer(buffer1)); - EXPECT_TRUE(bufferQueue->releaseBuffer(buffer2)); - EXPECT_TRUE(bufferQueue->releaseBuffer(buffer3)); - - std::shared_ptr buffer4 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer1.get() == buffer4.get()); - std::shared_ptr buffer5 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer2.get() == buffer5.get()); - std::shared_ptr buffer6 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer3.get() == buffer6.get()); - EXPECT_TRUE(bufferQueue->releaseBuffer(buffer4)); - EXPECT_TRUE(bufferQueue->releaseBuffer(buffer5)); - EXPECT_TRUE(bufferQueue->releaseBuffer(buffer6)); -} - -TEST_F(DSBufferTBMImplTest, CanAcquireBuffer) -{ - auto bufferQueue = std::make_unique(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue.get() != nullptr); - - auto buffer1 = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer1 != nullptr); - EXPECT_TRUE(bufferQueue->enqueueBuffer(buffer1)); - EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); -} diff --git a/tests/DSCanvas-test.cpp b/tests/DSCanvas-test.cpp deleted file mode 100644 index 0fd165f..0000000 --- a/tests/DSCanvas-test.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSCanvas.h" -#include "IDSOutput.h" -#include "DSOutputImpl.h" -#include "IDSDisplayDeviceOutput.h" -#include "DSDisplayDeviceTDMImpl.h" - -using namespace display_server; - -class DSCanvasTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSCanvasTest, NewDSCanvas) -{ - auto canvas = std::make_unique(); - EXPECT_TRUE(canvas != nullptr); -} - -TEST_F(DSCanvasTest, attachPolicyArea_Positive1) -{ - auto canvas = std::make_unique(); - EXPECT_TRUE(canvas != nullptr); - auto policyArea = std::make_shared(); - EXPECT_TRUE(policyArea != nullptr); - EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == true); -} - -TEST_F(DSCanvasTest, attachPolicyArea_Twice) -{ - auto canvas = std::make_unique(); - EXPECT_TRUE(canvas != nullptr); - auto policyArea = std::make_shared(); - EXPECT_TRUE(policyArea != nullptr); - EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == true); - - EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == false); -} - -TEST_F(DSCanvasTest, attachPolicyArea_N_DisplayArea) -{ - auto canvas = std::make_unique(); - EXPECT_TRUE(canvas != nullptr); - - auto policyArea = std::make_shared(); - EXPECT_TRUE(policyArea != nullptr); - EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == true); - - auto displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto output = std::make_shared(displayDeviceOutput); - EXPECT_TRUE(output != nullptr); - EXPECT_TRUE(output->applyResolutionAuto() == true); - auto displayArea = std::make_shared(output); - EXPECT_TRUE(displayArea != nullptr); - EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == true); - } -} - -TEST_F(DSCanvasTest, attachDisplayArea_Positive1) -{ - auto canvas = std::make_unique(); - EXPECT_TRUE(canvas != nullptr); - - auto displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto output = std::make_shared(displayDeviceOutput); - EXPECT_TRUE(output != nullptr); - EXPECT_TRUE(output->applyResolutionAuto() == true); - auto displayArea = std::make_shared(output); - EXPECT_TRUE(displayArea != nullptr); - EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == true); - } -} - -TEST_F(DSCanvasTest, attachDisplayArea_Twice) -{ - auto canvas = std::make_unique(); - EXPECT_TRUE(canvas != nullptr); - - auto displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto output = std::make_shared(displayDeviceOutput); - EXPECT_TRUE(output != nullptr); - EXPECT_TRUE(output->applyResolutionAuto() == true); - auto displayArea = std::make_shared(output); - EXPECT_TRUE(displayArea != nullptr); - EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == true); - - EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == false); - } -} - -TEST_F(DSCanvasTest, attachDisplayArea_N_PolicyArea) -{ - auto canvas = std::make_unique(); - EXPECT_TRUE(canvas != nullptr); - - auto displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto output = std::make_shared(displayDeviceOutput); - EXPECT_TRUE(output != nullptr); - EXPECT_TRUE(output->applyResolutionAuto() == true); - auto displayArea = std::make_shared(output); - EXPECT_TRUE(displayArea != nullptr); - EXPECT_TRUE(canvas->attachDisplayArea(displayArea) == true); - - auto policyArea = std::make_shared(); - EXPECT_TRUE(policyArea != nullptr); - EXPECT_TRUE(canvas->attachPolicyArea(policyArea) == true); - } -} diff --git a/tests/DSClient-test.cpp b/tests/DSClient-test.cpp deleted file mode 100644 index 0896cc8..0000000 --- a/tests/DSClient-test.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSObject.h" -#include "DSClient.h" -#include "DSCompositor.h" -#include "DSWaylandCompositor.h" -#include "DSWindow.h" -#include "DSWaylandClient.h" -#include - -using namespace display_server; - -class DSClientTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSClientTest, NewDSClientWithDSWaylandClient) -{ - DSWaylandCompositor *dswlComp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(dswlComp != nullptr); - - if (dswlComp) - { - /* client must be created with a valid wl_client ptr later. */ - DSWaylandClient *dswlClient = new DSWaylandClient(dswlComp, (wl_client *)nullptr); - EXPECT_TRUE(dswlClient != nullptr); - - if (dswlClient) - { - DSClient *client = new DSClient(nullptr, dswlClient); - EXPECT_TRUE(client != nullptr); - - if (client) - delete client; - - delete dswlClient; - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSClientTest, AddRemoveHasWindow) -{ - DSWindow *win = new DSWindow(); - EXPECT_TRUE(win != nullptr); - - if (win) - { - DSClient *client = new DSClient(nullptr); - EXPECT_TRUE(client != nullptr); - - if (client) - { - client->addWindow(win); - EXPECT_TRUE(client->hasWindow() == true); - - client->removeWindow(win); - EXPECT_TRUE(client->hasWindow() != true); - - delete client; - } - - delete win; - } -} - -TEST_F(DSClientTest, GetWindowsNumWindows) -{ - DSWindow *win1 = new DSWindow(); - EXPECT_TRUE(win1 != nullptr); - - DSWindow *win2 = new DSWindow(); - EXPECT_TRUE(win2 != nullptr); - - DSWindow *win3 = new DSWindow(); - EXPECT_TRUE(win3 != nullptr); - - if (win1 && win2 && win3) - { - DSClient *client = new DSClient(nullptr); - EXPECT_TRUE(client != nullptr); - - if (client) - { - client->addWindow(win1); - EXPECT_TRUE(client->numWindows() == 1); - client->addWindow(win2); - EXPECT_TRUE(client->numWindows() == 2); - client->addWindow(win3); - EXPECT_TRUE(client->numWindows() == 3); - - int cnt = 3; - std::list winList = client->getWindows(); - for (auto win : winList) - { - if (win == win1 || - win == win2 || - win == win3) - cnt--; - } - - EXPECT_TRUE(cnt == 0); - - client->removeWindow(win1); - EXPECT_TRUE(client->numWindows() == 2); - client->removeWindow(win2); - EXPECT_TRUE(client->numWindows() == 1); - client->removeWindow(win3); - EXPECT_TRUE(client->numWindows() == 0); - - delete client; - } - - delete win1; - delete win2; - delete win3; - } -} diff --git a/tests/DSCompositor-test.cpp b/tests/DSCompositor-test.cpp deleted file mode 100644 index 8de9fae..0000000 --- a/tests/DSCompositor-test.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSCompositor.h" -#include - -using namespace display_server; - -class DSCompositorTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - // for wl_display_add_socket(private_loop->wl_display, "tdm-socket") at tdm_server_init - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -class MockCompositor : public DSCompositor -{ -public: - MockCompositor() {} - ~MockCompositor() {} - - std::shared_ptr _onInitialized() override - { - auto canvas = std::make_shared(); - return canvas; - } - - void _onOutputAdded(std::shared_ptr output) override - {} - - void _onOutputRemoved(std::shared_ptr output) override - {} - - void _onInputAdded(std::shared_ptr input) override - {} - - void _onInputRemoved(std::shared_ptr input) override - {} -}; - -TEST_F(DSCompositorTest, NewDSCompositor) -{ - std::shared_ptr compositor = std::make_shared(); - EXPECT_TRUE(compositor != nullptr); -} - -TEST_F(DSCompositorTest, RunAndQuit) -{ - std::shared_ptr compositor = std::make_shared(); - EXPECT_TRUE(compositor != nullptr); - - Ecore_Timer *timer = nullptr; - double delayInSecond = 1.0; - auto cb = [](void *data) -> Eina_Bool { - MockCompositor *comp = (MockCompositor *)data; - EXPECT_TRUE(comp->quit() == true); - return EINA_FALSE; - }; - - timer = ecore_timer_loop_add(delayInSecond, cb, compositor.get()); - EXPECT_TRUE(timer != nullptr); - - if (timer != nullptr) { - EXPECT_TRUE(compositor->run() == true); - } -} diff --git a/tests/DSDebugLog-test.cpp b/tests/DSDebugLog-test.cpp deleted file mode 100644 index 179a620..0000000 --- a/tests/DSDebugLog-test.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSDebugLog.h" - -using namespace display_server; - -class DSDebugLogTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSDebugLogTest, GetInstance) -{ - DSDebugLog *log = DSDebugLog::GetInstance(); - EXPECT_TRUE(log->getLogLevel() == DSDebugLog::LOG_LEVEL_DEBUG); -} - -TEST_F(DSDebugLogTest, PrintLog) -{ - const char *str = "Hi world"; - DSDebugLog *log = DSDebugLog::GetInstance(); - - log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, "DSDebugLogTest", __func__, __LINE__, "Hello world"); - log->printLog(DSDebugLog::LOG_LEVEL_INFO, "DSDebugLogTest", __func__, __LINE__, "%s", str); - log->printLog(DSDebugLog::LOG_LEVEL_WARN, "DSDebugLogTest", __func__, __LINE__, "Greeting world"); - log->printLog(DSDebugLog::LOG_LEVEL_ERR, "DSDebugLogTest", __func__, __LINE__, "Hey world"); - - EXPECT_TRUE(true); -} - -TEST_F(DSDebugLogTest, LogMacros) -{ - const char *str = "Hi world"; - - DSLOG_DBG("DSTEST", "Hello world"); - DSLOG_INF("DSTEST", "%s", str); - DSLOG_WRN("DSTEST", "Greeting world"); - DSLOG_ERR("DSTEST", "Hey world"); - - EXPECT_TRUE(true); -} diff --git a/tests/DSDisplayArea-test.cpp b/tests/DSDisplayArea-test.cpp deleted file mode 100644 index ef97af1..0000000 --- a/tests/DSDisplayArea-test.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSDisplayArea.h" -#include "IDSOutput.h" -#include "DSOutputImpl.h" -#include "IDSDisplayDeviceOutput.h" -#include "DSDisplayDeviceTDMImpl.h" - -using namespace display_server; - -class DSDisplayAreaTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - // for wl_display_add_socket(private_loop->wl_display, "tdm-socket") at tdm_server_init - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSDisplayAreaTest, NewDSDisplayArea) -{ - auto displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto output = std::make_shared(displayDeviceOutput); - EXPECT_TRUE(output != nullptr); - EXPECT_TRUE(output->applyResolutionAuto() == true); - - auto displayArea = std::make_shared(output); - } -} - -TEST_F(DSDisplayAreaTest, BasicMethods) -{ - auto displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto output = std::make_shared(displayDeviceOutput); - EXPECT_TRUE(output != nullptr); - EXPECT_TRUE(output->applyResolutionAuto() == true); - - auto displayArea = std::make_shared(output); - EXPECT_TRUE(displayArea->getWidth() == output->getResolutionWidth()); - EXPECT_TRUE(displayArea->getHeight() == output->getResolutionHeight()); - EXPECT_TRUE(displayArea->getOutput() == output); - } -} diff --git a/tests/DSDisplayDeviceTDMImpl-test.cpp b/tests/DSDisplayDeviceTDMImpl-test.cpp deleted file mode 100644 index dfc8e94..0000000 --- a/tests/DSDisplayDeviceTDMImpl-test.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWindow.h" -#include "DSDisplayDeviceTDMImpl.h" -#include "DSDisplayDeviceOutputTDMImpl.h" - -using namespace display_server; - -class DSDisplayDeviceTDMImplTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -// DSDisplayDeviceTDMImpl -class MockDisplayDevice : public DSObject -{ -public: - MockDisplayDevice() - : flagOutputAdded(false), - flagOutputRemoved(false) - {} - ~MockDisplayDevice() - {} - - void outputAdded(std::shared_ptr output) { - flagOutputAdded = true; - } - - void outputRemoved(std::shared_ptr output) { - flagOutputRemoved = true; - } - - bool flagOutputAdded; - bool flagOutputRemoved; -}; - -TEST_F(DSDisplayDeviceTDMImplTest, Device_New) -{ - std::unique_ptr displayDevice = std::make_unique(); - EXPECT_TRUE(displayDevice != nullptr); -} - -TEST_F(DSDisplayDeviceTDMImplTest, Device_getOutputList) -{ - std::unique_ptr displayDevice = std::make_unique(); - EXPECT_TRUE(displayDevice != nullptr); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); -} - -TEST_F(DSDisplayDeviceTDMImplTest, Device_OutputAdded) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::shared_ptr mockDisplayDevice = std::make_shared(); - displayDevice->registerCallbackOutputAdded(mockDisplayDevice.get(), std::bind(&MockDisplayDevice::outputAdded, mockDisplayDevice, std::placeholders::_1)); - - std::unique_ptr displayDeviceTDM(static_cast(displayDevice.release())); // down-casting of std::unique_ptr - displayDeviceTDM->callCallbackOutputAdded(); - EXPECT_TRUE(mockDisplayDevice->flagOutputAdded); -} - -TEST_F(DSDisplayDeviceTDMImplTest, Device_OutputRemoved) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::shared_ptr mockDisplayDevice = std::make_shared(); - displayDevice->registerCallbackOutputRemoved(mockDisplayDevice.get(), std::bind(&MockDisplayDevice::outputRemoved, mockDisplayDevice, std::placeholders::_1)); - - std::unique_ptr displayDeviceTDM(static_cast(displayDevice.release())); // down-casting of std::unique_ptr - displayDeviceTDM->callCallbackOutputRemoved(); - EXPECT_TRUE(mockDisplayDevice->flagOutputRemoved); -} - -// DSDisplayDeviceTDMOutputImpl - -TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_getInitialValues) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) { - EXPECT_TRUE((output->getAvailableModes()).size() != 0); - EXPECT_TRUE(output->getResolutionWidth() == 0); - EXPECT_TRUE(output->getResolutionHeight() == 0); - EXPECT_TRUE(output->getPhysicalMMWidth() == 0); - EXPECT_TRUE(output->getPhysicalMMHeight() == 0); - EXPECT_TRUE(output->getMode() == nullptr); - EXPECT_TRUE(output->getDPMSMode() == IDSDisplayDeviceOutput::DPMS_OFF); - EXPECT_TRUE(output->getHWC() != nullptr); - } else { // IDSDisplayDeviceOutput::STATE_CONNECTED and IDSDisplayDeviceOutput::STATE_MODESET - EXPECT_TRUE((output->getAvailableModes()).size() != 0); - EXPECT_TRUE(output->getResolutionWidth() == 0); - EXPECT_TRUE(output->getResolutionHeight() == 0); - EXPECT_TRUE(output->getPhysicalMMWidth() > 0); - EXPECT_TRUE(output->getPhysicalMMHeight() > 0); - EXPECT_TRUE(output->getMode() == nullptr); - EXPECT_TRUE(output->getDPMSMode() == IDSDisplayDeviceOutput::DPMS_OFF); - EXPECT_TRUE(output->getHWC() != nullptr); - } - } -} - -TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_setModeBestResolution) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - auto bestMode = (output->getAvailableModes()).front(); - EXPECT_TRUE(output->setMode(bestMode) == true); - EXPECT_TRUE(output->getMode() == bestMode); - } -} - -class MockDisplayDeviceOutput : public DSObject -{ -public: - MockDisplayDeviceOutput() - : flagOutputConnected(false), - flagOutputDisconnected(false), - flagOutputResolutionSet(false) - {} - ~MockDisplayDeviceOutput() = default; - - void outputConnected(std::shared_ptr displayDeviceOuptut) { - flagOutputConnected = true; - } - - void outputDisconnected(std::shared_ptr displayDeviceOuptut) { - flagOutputDisconnected = true; - } - - void outputResolutionSet(std::shared_ptr displayDeviceOuptut) { - flagOutputResolutionSet = true; - } - - bool flagOutputConnected; - bool flagOutputDisconnected; - bool flagOutputResolutionSet; -}; - -TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_registerCallbackOutputConnected) -{ - std::unique_ptr displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto mockDisplayDeviceOutput = std::make_shared(); - displayDeviceOutput->registerCallbackOutputConnected(mockDisplayDeviceOutput.get(), std::bind(&MockDisplayDeviceOutput::outputConnected, mockDisplayDeviceOutput, std::placeholders::_1)); - - auto displayDeviceOutputTDM = std::dynamic_pointer_cast(displayDeviceOutput); // down-casting of std::shared_ptr - displayDeviceOutputTDM->callCallbackOutputConnected(); - EXPECT_TRUE(mockDisplayDeviceOutput->flagOutputConnected); - } -} - -TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_registerCallbackOutputDisconnected) -{ - std::unique_ptr displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto mockDisplayDeviceOutput = std::make_shared(); - displayDeviceOutput->registerCallbackOutputDisconnected(mockDisplayDeviceOutput.get(), std::bind(&MockDisplayDeviceOutput::outputDisconnected, mockDisplayDeviceOutput, std::placeholders::_1)); - - auto displayDeviceOutputTDM = std::dynamic_pointer_cast(displayDeviceOutput); // down-casting of std::shared_ptr - displayDeviceOutputTDM->callCallbackOutputDisconnected(); - EXPECT_TRUE(mockDisplayDeviceOutput->flagOutputDisconnected); - } -} - -TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_registerCallbackOutputResolutionSet) -{ - std::unique_ptr displayDevice = std::make_unique(); - auto outputList = displayDevice->getOutputList(); - for (auto displayDeviceOutput : outputList) { - auto mockDisplayDeviceOutput = std::make_shared(); - displayDeviceOutput->registerCallbackOutputResolutionSet(mockDisplayDeviceOutput.get(), std::bind(&MockDisplayDeviceOutput::outputResolutionSet, mockDisplayDeviceOutput, std::placeholders::_1)); - - auto displayDeviceOutputTDM = std::dynamic_pointer_cast(displayDeviceOutput); // down-casting of std::shared_ptr - displayDeviceOutputTDM->callCallbackOutputResolutionSet(); - EXPECT_TRUE(mockDisplayDeviceOutput->flagOutputResolutionSet); - } -} - -// DSDisplayDeviceTDMHWC - -TEST_F(DSDisplayDeviceTDMImplTest, DeviceOutput_makeHWCWindow) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - std::shared_ptr deviceHWC; - std::shared_ptr deviceHWCWindow; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - deviceHWC = output->getHWC(); - EXPECT_TRUE(deviceHWC != nullptr); - - deviceHWCWindow = deviceHWC->makeHWCWindow(); - EXPECT_TRUE(deviceHWC != nullptr); - } -} - -TEST_F(DSDisplayDeviceTDMImplTest, DeviceHWC_commit) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - std::shared_ptr deviceHWC; - std::shared_ptr deviceHWCWindow; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - auto bestMode = (output->getAvailableModes()).front(); - EXPECT_TRUE(output->setMode(bestMode) == true); - EXPECT_TRUE(output->getMode() == bestMode); - - deviceHWC = output->getHWC(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto bufferQueue = deviceHWC->getTargetBufferQueue(); - EXPECT_TRUE(deviceHWC != nullptr); - - deviceHWCWindow = deviceHWC->makeHWCWindow(); - EXPECT_TRUE(deviceHWC != nullptr); - EXPECT_TRUE(deviceHWC->addVisibleHWCWindow(deviceHWCWindow)); - - auto buffer = bufferQueue->dequeueBuffer(); - EXPECT_TRUE(buffer != nullptr); - EXPECT_TRUE(bufferQueue->enqueueBuffer(buffer)); - - // commit - EXPECT_TRUE(deviceHWC->commit()); - } -} diff --git a/tests/DSEventLoop-test.cpp b/tests/DSEventLoop-test.cpp deleted file mode 100644 index 40915e5..0000000 --- a/tests/DSEventLoop-test.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSEventLoop.h" -#include - -using namespace display_server; - -class DSEventLoopTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSEventLoopTest, NewDSEventLoop) -{ - DSEventLoop *eventLoop = DSEventLoop::getInstance(); - EXPECT_TRUE(eventLoop != nullptr); - DSEventLoop::releaseInstance(); -} - -TEST_F(DSEventLoopTest, RunAndQuit) -{ - DSEventLoop *eventLoop = DSEventLoop::getInstance(); - - Ecore_Timer *timer = nullptr; - double delayInSecond = 1.0; - auto cb = [](void *data) -> Eina_Bool { - DSEventLoop *loop = (DSEventLoop *)data; - EXPECT_TRUE(loop->quit() == true); - return EINA_FALSE; - }; - - timer = ecore_timer_loop_add(delayInSecond, cb, eventLoop); - EXPECT_TRUE(timer != nullptr); - - if (timer != nullptr) { - EXPECT_TRUE(eventLoop->run() == true); - } - - DSEventLoop::releaseInstance(); -} - -TEST_F(DSEventLoopTest, registerCallbackIdleEnterer) -{ - DSEventLoop *eventLoop = DSEventLoop::getInstance(); - - Ecore_Timer *timer = nullptr; - double delayInSecond = 1.0; - auto timerCb = [](void *data) -> Eina_Bool { - DSEventLoop *loop = (DSEventLoop *)data; - EXPECT_TRUE(loop->quit() == true); - return EINA_FALSE; - }; - - auto idleCb = [](void *data) -> Eina_Bool { - EXPECT_TRUE(true); - DSLOG_ERR("soolim", "idleCB"); - return EINA_TRUE; - }; - - timer = ecore_timer_loop_add(delayInSecond, timerCb, eventLoop); - EXPECT_TRUE(timer != nullptr); - - eventLoop->registerCallbackIdleEnterer(nullptr, idleCb); - - if (timer != nullptr) { - EXPECT_TRUE(eventLoop->run() == true); - } - - DSEventLoop::releaseInstance(); -} diff --git a/tests/DSInput-test.cpp b/tests/DSInput-test.cpp deleted file mode 100644 index 3090b30..0000000 --- a/tests/DSInput-test.cpp +++ /dev/null @@ -1,433 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSInput.h" -#include "DSSeat.h" -#include "DSInputEvent.h" - -using namespace display_server; - -class DSInputTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -class MockInput : public DSObject -{ -public: - MockInput() - : device(std::make_shared("None", "None", DSInput::NoneClass, DSInput::NoneSubclass)) - {} - ~MockInput() - {} - - void slotDeviceAdded(std::shared_ptr device) { - this->device.reset(); - this->device = device; - } - - void slotDeviceRemoved(std::shared_ptr device) { - this->device.reset(); - this->device = device; - } - - std::shared_ptr device; -}; - - -TEST_F(DSInputTest, NewDSInput) -{ - DSInput *input = new DSInput(); - EXPECT_TRUE(input != nullptr); - - if (input) - delete input; -} - -TEST_F(DSInputTest, DSInputInit) -{ - DSInput *input = new DSInput(); - EXPECT_TRUE(input != nullptr); - - if (input) - { - input->init(); - delete input; - } -} - -TEST_F(DSInputTest, DSInputDeviceAddedRemoved) -{ - DSInput *input = new DSInput(); - DSInputDevice *device = new DSInputDevice("MockTestDevice", "MockTest", DSInput::KeyboardClass, DSInput::NoneSubclass); - MockInput *mockInput = new MockInput; - MockInput *mockInput2 = new MockInput; - - EXPECT_TRUE(input != nullptr); - EXPECT_TRUE(device != nullptr); - EXPECT_TRUE(mockInput != nullptr); - EXPECT_TRUE(mockInput2 != nullptr); - - if (input) - { - input->init(); - - input->registerCallbackDeviceAdd(mockInput, std::bind(&MockInput::slotDeviceAdded, mockInput, std::placeholders::_1)); - input->deviceAdd(device->getName(), device->getIdentifier(), device->getClass(), device->getSubclass()); - EXPECT_TRUE(*(mockInput->device.get()) == *device); - - input->registerCallbackDeviceAdd(mockInput2, std::bind(&MockInput::slotDeviceAdded, mockInput2, std::placeholders::_1)); - input->deviceAdd(device->getName(), device->getIdentifier(), device->getClass(), device->getSubclass()); - EXPECT_FALSE(*(mockInput2->device.get()) == *device); - - input->registerCallbackDeviceRemove(mockInput, std::bind(&MockInput::slotDeviceRemoved, mockInput, std::placeholders::_1)); - input->deviceRemove(device->getName(), device->getIdentifier(), device->getClass(), device->getSubclass()); - EXPECT_TRUE(*(mockInput->device.get()) == *device); - - input->registerCallbackDeviceRemove(mockInput2, std::bind(&MockInput::slotDeviceRemoved, mockInput2, std::placeholders::_1)); - input->deviceRemove(device->getName(), device->getIdentifier(), device->getClass(), device->getSubclass()); - - EXPECT_FALSE(*(mockInput2->device.get()) == *device); - - delete mockInput2; - delete mockInput; - delete device; - delete input; - } -} - - -class DSInputDeviceTest : public ::testing::Test -{ -public: - void SetUp(void) override - {} - void TearDown(void) override - {} -}; - -TEST_F(DSInputDeviceTest, NewDSInputDevice) -{ - DSInputDevice *inputDevice = new DSInputDevice; - delete inputDevice; - inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); - delete inputDevice; - ASSERT_TRUE(true); -} - -TEST_F(DSInputDeviceTest, DSInputDeviceSetGetName) -{ - std::string tName = "TestDevice"; - DSInputDevice *inputDevice = new DSInputDevice; - inputDevice->setName(tName); - std::string name = inputDevice->getName(); - EXPECT_TRUE(name.compare(tName) == 0); - delete inputDevice; -} - -TEST_F(DSInputDeviceTest, DSInputDeviceSetGetIdentifier) -{ - std::string tIdentifier = "virtual-0"; - DSInputDevice *inputDevice = new DSInputDevice; - inputDevice->setIdentifier(tIdentifier); - std::string identifier = inputDevice->getIdentifier(); - EXPECT_TRUE(identifier.compare(tIdentifier) == 0); - delete inputDevice; -} - -TEST_F(DSInputDeviceTest, DSInputDeviceSetGetClass) -{ - DSInput::DeviceClass tDevClass; - DSInput::DeviceClass devClass; - DSInputDevice *inputDevice = new DSInputDevice; - - tDevClass = DSInput::PointerClass; - inputDevice->setClass(tDevClass); - devClass = inputDevice->getClass(); - EXPECT_TRUE(tDevClass == devClass); - - tDevClass = DSInput::KeyboardClass; - inputDevice->setClass(tDevClass); - devClass = inputDevice->getClass(); - EXPECT_TRUE(tDevClass == devClass); - - tDevClass = DSInput::TouchClass; - inputDevice->setClass(tDevClass); - devClass = inputDevice->getClass(); - EXPECT_TRUE(tDevClass == devClass); - - delete inputDevice; -} - -TEST_F(DSInputDeviceTest, DSInputDeviceSetGetSubclass) -{ - DSInput::DeviceSubclass tDevSubclass; - DSInputDevice *inputDevice = new DSInputDevice; - - tDevSubclass = DSInput::NoneSubclass; - inputDevice->setSubclass(tDevSubclass); - DSInput::DeviceSubclass devSubclass = inputDevice->getSubclass(); - EXPECT_TRUE(tDevSubclass == devSubclass); - - delete inputDevice; -} - -class DSInputEventTest : public ::testing::Test -{ -public: - void SetUp(void) override - {} - void TearDown(void) override - {} -}; - -TEST_F(DSInputEventTest, NewDSInputEvent) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); - DSInputEvent *inputEvent = new DSInputEvent(std::make_shared(*inputDevice), eventType, curTime); - - EXPECT_TRUE(inputEvent != nullptr); - - delete inputEvent; - delete inputDevice; -} - -TEST_F(DSInputEventTest, GetDevice) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); - DSInputEvent *inputEvent = new DSInputEvent(std::make_shared(*inputDevice), eventType, curTime); - - EXPECT_TRUE(*(inputEvent->getDevice().get()) == *inputDevice); - - delete inputEvent; - delete inputDevice; -} - -TEST_F(DSInputEventTest, GetType) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); - DSInputEvent *inputEvent = new DSInputEvent(std::make_shared(*inputDevice), eventType, curTime); - - EXPECT_TRUE(inputEvent->getType() == eventType); - - delete inputEvent; - delete inputDevice; -} - -TEST_F(DSInputEventTest, GetTimestamp) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass); - DSInputEvent *inputEvent = new DSInputEvent(std::make_shared(*inputDevice), eventType, curTime); - - EXPECT_TRUE((unsigned int)inputEvent->getTimestamp() == curTime); - - delete inputEvent; - delete inputDevice; -} - -class DSInputKeyboardEventTest : public ::testing::Test -{ -public: - void SetUp(void) override - {} - void TearDown(void) override - {} -}; - -TEST_F(DSInputKeyboardEventTest, NewDSInputKeyboardEvent) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int keycode = 166; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::KeyboardClass, DSInput::NoneSubclass); - DSInputKeyboardEvent *keyboardEvent = new DSInputKeyboardEvent(std::make_shared(*inputDevice), eventType, curTime, keycode); - - EXPECT_TRUE(keyboardEvent != nullptr); - - delete keyboardEvent; - delete inputDevice; -} - -TEST_F(DSInputKeyboardEventTest, GetKeycode) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int keycode = 166; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::KeyboardClass, DSInput::NoneSubclass); - DSInputKeyboardEvent *keyboardEvent = new DSInputKeyboardEvent(std::make_shared(*inputDevice), eventType, curTime, keycode); - - EXPECT_TRUE(keyboardEvent->getKeycode() == keycode); - - delete keyboardEvent; - delete inputDevice; -} - -TEST_F(DSInputKeyboardEventTest, GetSetKeyname) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int keycode = 166; - std::string keyname = "TestKey"; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::KeyboardClass, DSInput::NoneSubclass); - DSInputKeyboardEvent *keyboardEvent = new DSInputKeyboardEvent(std::make_shared(*inputDevice), eventType, curTime, keycode); - keyboardEvent->setKeyname(keyname); - - EXPECT_TRUE(keyboardEvent->getKeyname() == keyname); - - delete keyboardEvent; - delete inputDevice; -} - -class DSInputMouseEventTest : public ::testing::Test -{ -public: - void SetUp(void) override - {} - void TearDown(void) override - {} -}; - -TEST_F(DSInputMouseEventTest, NewDSInputMouseEvent) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int button = 1, x = 10, y = 20, z = 1; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::PointerClass, DSInput::NoneSubclass); - DSInputMouseEvent *mouseEvent = new DSInputMouseEvent(std::make_shared(*inputDevice), eventType, curTime, button, x, y, z); - - EXPECT_TRUE(mouseEvent != nullptr); - - delete mouseEvent; - delete inputDevice; -} - -TEST_F(DSInputMouseEventTest, GetAxis) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int button = 1, x = 10, y = 20, z = 1; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::PointerClass, DSInput::NoneSubclass); - DSInputMouseEvent *mouseEvent = new DSInputMouseEvent(std::make_shared(*inputDevice), eventType, curTime, button, x, y, z); - - EXPECT_TRUE(mouseEvent->getX() == x); - EXPECT_TRUE(mouseEvent->getY() == y); - EXPECT_TRUE(mouseEvent->getZ() == z); - - delete mouseEvent; - delete inputDevice; -} - -TEST_F(DSInputMouseEventTest, GetSetWinAxis) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int button = 1, x = 10, y = 20, z = 1; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::PointerClass, DSInput::NoneSubclass); - DSInputMouseEvent *mouseEvent = new DSInputMouseEvent(std::make_shared(*inputDevice), eventType, curTime, button, x, y, z); - - mouseEvent->setWinX(x); - mouseEvent->setWinY(y); - mouseEvent->setWinZ(z); - - EXPECT_TRUE(mouseEvent->getWinX() == x); - EXPECT_TRUE(mouseEvent->getWinY() == y); - EXPECT_TRUE(mouseEvent->getWinZ() == z); - - delete mouseEvent; - delete inputDevice; -} - -class DSInputTouchEventTest : public ::testing::Test -{ -public: - void SetUp(void) override - {} - void TearDown(void) override - {} -}; - -TEST_F(DSInputTouchEventTest, NewDSInputTouchEvent) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int index = 0, x = 10, y = 20; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::TouchClass, DSInput::NoneSubclass); - DSInputTouchEvent *touchEvent = new DSInputTouchEvent(std::make_shared(*inputDevice), eventType, curTime, index, x, y); - - EXPECT_TRUE(touchEvent != nullptr); - - delete touchEvent; - delete inputDevice; -} - -TEST_F(DSInputTouchEventTest, GetAxis) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int index = 0, x = 10, y = 20; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::TouchClass, DSInput::NoneSubclass); - DSInputTouchEvent *touchEvent = new DSInputTouchEvent(std::make_shared(*inputDevice), eventType, curTime, index, x, y); - - EXPECT_TRUE(touchEvent->getX() == x); - EXPECT_TRUE(touchEvent->getY() == y); - - delete touchEvent; - delete inputDevice; -} - -TEST_F(DSInputTouchEventTest, GetSetWinAxis) -{ - DSInputEvent::Type eventType = DSInputEvent::NoneEvent; - unsigned int curTime = 0; - int index = 0, x = 10, y = 20; - DSInputDevice *inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::TouchClass, DSInput::NoneSubclass); - DSInputTouchEvent *touchEvent = new DSInputTouchEvent(std::make_shared(*inputDevice), eventType, curTime, index, x, y); - - touchEvent->setWinX(x); - touchEvent->setWinY(y); - - EXPECT_TRUE(touchEvent->getWinX() == x); - EXPECT_TRUE(touchEvent->getWinY() == y); - - delete touchEvent; - delete inputDevice; -} - diff --git a/tests/DSKeyboard-test.cpp b/tests/DSKeyboard-test.cpp deleted file mode 100644 index fe08c28..0000000 --- a/tests/DSKeyboard-test.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSKeyboard.h" -#include "DSSeat.h" -#include "DSWaylandKeyboard.h" -#include "DSWaylandSeat.h" -#include "DSWaylandCompositor.h" -#include "DSWindow.h" -#include "DSWaylandSurface.h" - -using namespace display_server; - -class DSKeyboardTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSKeyboardTest, NewDSKeyboardWithDSSeat) -{ - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - auto keyboard = new DSKeyboard(seat); - EXPECT_TRUE(keyboard != nullptr); - } -} - -TEST_F(DSKeyboardTest, NewDSKeyboardWithDSWaylandKeyboard) -{ - auto waylandCompositor = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(waylandCompositor != nullptr); - - if (waylandCompositor) - { - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll); - EXPECT_TRUE(waylandSeat != nullptr); - - if (seat && waylandSeat) - { - auto waylandKeyboard = new DSWaylandKeyboard(waylandSeat); - EXPECT_TRUE(waylandKeyboard != nullptr); - - if (waylandKeyboard) - { - auto keyboard = new DSKeyboard(seat, waylandKeyboard); - EXPECT_TRUE(keyboard != nullptr); - } - } - - DSWaylandCompositor::releaseInstance(); - } - -} -TEST_F(DSKeyboardTest, BasicMethods) -{ - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - - auto waylandSurface = std::make_shared(); - EXPECT_TRUE(waylandSurface != nullptr); - - window->create(waylandSurface); - - if (seat && window) - { - auto keyboard = new DSKeyboard(seat); - EXPECT_TRUE(keyboard != nullptr); - - if (keyboard) - { - keyboard->setFocus(window); - EXPECT_TRUE(window == keyboard->getFocus()); - - keyboard->keyDown(100); - keyboard->keyUp(100); - - keyboard->setRepeatRate(25); - keyboard->setRepeatDelay(400); - } - } -} diff --git a/tests/DSObject-test.cpp b/tests/DSObject-test.cpp deleted file mode 100644 index 3f88433..0000000 --- a/tests/DSObject-test.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSCore.h" -#include "DSObject.h" - -using namespace display_server; - -class DSObjectTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Temporary classes for implemting PImpl Idiom based on DSObject/DSObjectPrivate classes */ -class TempObject; -class TempObjectPrivate : public DSObjectPrivate -{ - DS_PIMPL_USE_PUBLIC(TempObject); -public: - TempObjectPrivate() = delete; - TempObjectPrivate(TempObject *p_ptr); - ~TempObjectPrivate(); - - unsigned int funcMiddle(void); - -protected: - -private: -}; - -class TempObject : public DSObject -{ - DS_PIMPL_USE_PRIVATE(TempObject); -public: - explicit TempObject(); - virtual ~TempObject(); - - unsigned int funcEnter(unsigned int val); - unsigned int funcExit(); - -protected: - -private: - unsigned int __val = 0; -}; - -TempObjectPrivate::TempObjectPrivate(TempObject *p_ptr) - : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) -{ - ; -} - -TempObjectPrivate::~TempObjectPrivate() -{ - ; -} - -unsigned int TempObjectPrivate::funcMiddle(void) -{ - DS_GET_PUB(TempObject); - - return pub->funcExit(); -} - -TempObject::TempObject() - : DS_INIT_PRIVATE_PTR(TempObject) -{ - __val = 0; -} - -unsigned int TempObject::funcEnter(unsigned int val) -{ - DS_GET_PRIV(TempObject); - __val = val; - return priv->funcMiddle(); -} - -unsigned int TempObject::funcExit() -{ - return __val; -} - -TempObject::~TempObject() -{ - ; -} - -/* Test cases */ -TEST_F(DSObjectTest, NewDSObject) -{ - DSObject *obj = new DSObject; - EXPECT_TRUE(obj != nullptr); - - if (obj) - delete obj; -} - -TEST_F(DSObjectTest, DSObjectSetGetName) -{ - std::string gName; - - DSObject *obj = new DSObject(); - EXPECT_TRUE(obj != nullptr); - - if (obj) - { - obj->setName(std::string{"DSObject"}); - gName = obj->getName(); - EXPECT_TRUE(gName.empty() == false); - EXPECT_TRUE(gName.compare(std::string{"DSObject"}) == 0); - - if (!gName.empty()) - gName.clear(); - - delete obj; - } -} - -TEST_F(DSObjectTest, DSObjectSetGetProperty) -{ - DSObject *obj = new DSObject(); - ASSERT_NE(obj, nullptr) << "Failed to create DSObject"; - - obj->setProperty("testKey", "testValue", DSPropertyType::STRING); - - try - { - std::string data = std::get(obj->getProperty("testKey")); - EXPECT_EQ(data, "testValue") << "value mismatch"; - } - catch(const DSPropertyException &e) - { - ASSERT_TRUE(false) << "Exception catched! : " << e.what(); - } - - delete obj; -} - -TEST_F(DSObjectTest, NewDSObjecPrivate) -{ - DSObject *obj = nullptr; - DSObjectPrivate *objPrivate = nullptr; - - obj = new DSObject(); - EXPECT_TRUE(obj != nullptr); - - if (obj) - { - objPrivate = new DSObjectPrivate(obj); - EXPECT_TRUE(objPrivate != nullptr); - - if (objPrivate) - delete objPrivate; - - delete obj; - } -} - -TEST_F(DSObjectTest, NewTempObject) -{ - TempObject *obj = new TempObject(); - EXPECT_TRUE(obj != nullptr); - - if (obj) - delete obj; -} - -TEST_F(DSObjectTest, DerivedObjectSetGetName) -{ - std::string gName; - - TempObject *obj = new TempObject(); - EXPECT_TRUE(obj != nullptr); - - if (obj) - { - obj->setName(std::string{"TempObject"}); - gName = obj->getName(); - EXPECT_TRUE(gName.empty() == false); - EXPECT_TRUE(gName.compare(std::string{"TempObject"}) == 0); - - if (!gName.empty()) - gName.clear(); - - delete obj; - } -} - -TEST_F(DSObjectTest, DerivedObjectGetProperty) -{ - TempObject *obj = new TempObject(); - ASSERT_NE(obj, nullptr) << "Failed to create TempObject"; - - obj->setProperty("testKey", "testValue", DSPropertyType::STRING); - - try - { - std::string data = std::get(obj->getProperty("testKey")); - EXPECT_EQ(data, "testValue") << "value mismatch"; - } - catch(const DSPropertyException &e) - { - ASSERT_TRUE(false) << "Exception catched! : " << e.what(); - } - - delete obj; -} - -TEST_F(DSObjectTest, DerivedObjectPimpl) -{ - unsigned int vIn = 0xdeadbeaf; - unsigned int vOut = 0; - - TempObject *obj = new TempObject(); - EXPECT_TRUE(obj != nullptr); - - if (obj) - { - vOut = obj->funcEnter(vIn); - EXPECT_TRUE(vOut == vIn); - - delete obj; - } -} diff --git a/tests/DSOutputImpl-test.cpp b/tests/DSOutputImpl-test.cpp deleted file mode 100644 index 9f2d9df..0000000 --- a/tests/DSOutputImpl-test.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "IDSOutput.h" -#include "DSOutputImpl.h" -#include "IDSDisplayDeviceOutput.h" -#include "DSDisplayDeviceOutputTDMImpl.h" - -using namespace display_server; - -class DSOutputTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSOutputTest, NewDSOutput) -{ - auto displayDeviceOutput = std::make_shared(); - EXPECT_TRUE(displayDeviceOutput != nullptr); - auto output = std::make_shared(displayDeviceOutput); - EXPECT_TRUE(output != nullptr); -} - -TEST_F(DSOutputTest, BasicMethods) -{ - auto displayDeviceOutput = std::make_shared(); - EXPECT_TRUE(displayDeviceOutput != nullptr); - auto output = std::make_shared(displayDeviceOutput); - EXPECT_TRUE(output != nullptr); - - EXPECT_TRUE(output->getResolutionWidth() == 0); - EXPECT_TRUE(output->getResolutionHeight() == 0); - EXPECT_TRUE(output->applyResolutionAuto() == false); - EXPECT_TRUE(output->getDisplayDeviceOutput() == displayDeviceOutput); -} diff --git a/tests/DSPointer-test.cpp b/tests/DSPointer-test.cpp deleted file mode 100644 index 10b18dd..0000000 --- a/tests/DSPointer-test.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSPointer.h" -#include "DSSeat.h" -#include "DSWaylandPointer.h" -#include "DSWaylandSeat.h" -#include "DSWaylandCompositor.h" -#include "DSWindow.h" -#include "DSWaylandSurface.h" - -using namespace display_server; - -class DSPointerTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSPointerTest, NewDSPointerWithDSSeat) -{ - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - auto pointer = new DSPointer(seat); - EXPECT_TRUE(pointer != nullptr); - } -} - -TEST_F(DSPointerTest, NewDSPointerWithDSWaylandPointer) -{ - auto waylandCompositor = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(waylandCompositor != nullptr); - - if (waylandCompositor) - { - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll); - EXPECT_TRUE(waylandSeat != nullptr); - - if (seat && waylandSeat) - { - auto waylandPointer = new DSWaylandPointer(waylandSeat); - EXPECT_TRUE(waylandPointer != nullptr); - - if (waylandPointer) - { - auto pointer = new DSPointer(seat, waylandPointer); - EXPECT_TRUE(pointer != nullptr); - } - } - - DSWaylandCompositor::releaseInstance(); - } - -} -TEST_F(DSPointerTest, BasicMethods) -{ - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - - auto waylandSurface = std::make_shared(); - EXPECT_TRUE(waylandSurface != nullptr); - - window->create(waylandSurface); - - if (seat && window) - { - auto pointer = new DSPointer(seat); - EXPECT_TRUE(pointer != nullptr); - - if (pointer) - { - pointer->setFocus(window); - EXPECT_TRUE(window == pointer->getFocus()); - } - } -} diff --git a/tests/DSPolicyArea-test.cpp b/tests/DSPolicyArea-test.cpp deleted file mode 100644 index af945c9..0000000 --- a/tests/DSPolicyArea-test.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSPolicyArea.h" - -using namespace display_server; - -class DSPolicyAreaTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSPolicyAreaTest, NewDSPolicyArea) -{ - std::unique_ptr policyArea = std::make_unique(); - EXPECT_TRUE(policyArea != nullptr); -} - -TEST_F(DSPolicyAreaTest, BasicMethods) -{ - std::unique_ptr policyArea = std::make_unique(); - EXPECT_TRUE(policyArea != nullptr); - std::shared_ptr seat = std::make_shared(); - EXPECT_TRUE(seat != nullptr); - - EXPECT_TRUE(policyArea->setPosition(10, 10) == true); - EXPECT_TRUE(policyArea->setSize(100, 100) == true); - EXPECT_TRUE(policyArea->attachSeat(seat) == true); -} diff --git a/tests/DSProperty-test.cpp b/tests/DSProperty-test.cpp deleted file mode 100644 index 9f71eb8..0000000 --- a/tests/DSProperty-test.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSProperty.h" - -using namespace display_server; - -class DSPropertyTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSPropertyTest, NewDSProperty) -{ - /* DSProperty::DSProperty()*/ - DSProperty *pro = new DSProperty(); - ASSERT_NE(pro, nullptr) << "Failed to DSProperty()"; - delete pro; -} - -TEST_F(DSPropertyTest, SetGetProperty) -{ - /* DSProperty::DSProperty(std::__cxx11::string, const DSPropertyVariant&, DSPropertyType) */ - DSProperty *pro = new DSProperty("testProperty", 2020, DSPropertyType::INTEGER); - ASSERT_NE(pro, nullptr) << "Failed to DSProperty(key, data, type)"; - ASSERT_EQ(pro->getKey(), "testProperty") << "Key value mismatch!"; - ASSERT_EQ(pro->getType(), DSPropertyType::INTEGER) << "Type mistmatch!!"; - try { - int data = std::get(pro->getData()); - ASSERT_TRUE(data == 2020) << "data value mismatch!!"; - } catch (DSPropertyException &e) { - ASSERT_TRUE(false) << e.what(); - } - delete pro; -} - -TEST_F(DSPropertyTest, NewProperty2) -{ - /* DSProperty::DSProperty(DSProperty&) */ - DSProperty pro_s("testProperty2", 20.20, DSPropertyType::DOUBLE); - DSProperty *pro = new DSProperty(pro_s); - ASSERT_NE(pro, nullptr) << "Failed to DSProperty(const DSProperty&)"; - ASSERT_EQ(pro->getKey(), "testProperty2") << "Key value mismatch!"; - ASSERT_EQ(pro->getType(), DSPropertyType::DOUBLE) << "Type mistmatch!!"; - try { - double data = std::get(pro->getData()); - ASSERT_TRUE(data == 20.20) << "data value mismatch!!"; - } catch (DSPropertyException &e) { - ASSERT_TRUE(false) << e.what(); - } - delete pro; -} - -TEST_F(DSPropertyTest, CopyAssign) -{ - /* DSProperty::DSProperty(DSProperty&) */ - DSObject *obj = new DSObject(); - DSProperty pro_s("testProperty3", (void *)obj, DSPropertyType::POINTER); - DSProperty pro = pro_s; - ASSERT_EQ(pro.getKey(), "testProperty3") << "Key value mismatch!"; - ASSERT_EQ(pro.getType(), DSPropertyType::POINTER) << "Type mistmatch!!"; - try { - DSObject *data = (DSObject *)std::get(pro.getData()); - ASSERT_TRUE(data == obj) << "data value mismatch!!"; - } catch (DSPropertyException &e) { - ASSERT_TRUE(false) << e.what(); - } - - if (obj) delete obj; -} diff --git a/tests/DSRefBase-test.cpp b/tests/DSRefBase-test.cpp deleted file mode 100644 index f5198e9..0000000 --- a/tests/DSRefBase-test.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSRefBase.h" - -using namespace display_server; - -class DSRefBaseTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSRefBaseTest, CreateRefBase) -{ - DSRefBase *refBase = new DSRefBase(); - - int count1; - int count2; - - count1 = refBase->getref(); - refBase->ref(); - count2 = refBase->getref(); - refBase->unref(); - refBase->unref(); - - ASSERT_TRUE(count1 == 1); - ASSERT_TRUE(count2 == 2); -} diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp deleted file mode 100644 index 001fc8a..0000000 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ /dev/null @@ -1,531 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSRenderEngineDaliImpl.h" -#include "DSBufferQueueTBMImpl.h" -#include "DSBufferTBMImpl.h" -#include "DSEventLoop.h" -#include - -#include "DSDisplayDeviceTDMImpl.h" -#include "DSDisplayDeviceOutputTDMImpl.h" - -#include -#include - -#include - -using namespace display_server; - -class DSRenderEngineDaliTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - Ecore_Timer *timer = nullptr; - - DSWaylandCompositor::getInstance(); - __eventLoop = DSEventLoop::getInstance(); - double delayInSecond = 0.5; - auto timerCb = [](void *data) -> Eina_Bool { - DSEventLoop *loop = (DSEventLoop *)data; - EXPECT_TRUE(loop->quit() == true); - return EINA_FALSE; - }; - - timer = ecore_timer_loop_add(delayInSecond, timerCb, __eventLoop); - EXPECT_TRUE(timer != nullptr); - - __eventLoop->run(); - - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - setenv("TBM_DISPLAY_SERVER", "1", 1); - } - void TearDown(void) override - { - __eventLoop->quit(); - DSEventLoop::releaseInstance(); - DSWaylandCompositor::releaseInstance(); - - unsetenv("XDG_RUNTIME_DIR"); - unsetenv("TBM_DISPLAY_SERVER"); - } - - tbm_surface_h createTbmTexture(int w, int h, unsigned char r, unsigned char g, unsigned char b, unsigned char a) - { - tbm_surface_h tbmSurface; - tbm_surface_info_s tbmSurface_info; - - tbmSurface = tbm_surface_create(w, h, TBM_FORMAT_ARGB8888); - tbm_surface_map(tbmSurface, TBM_SURF_OPTION_WRITE | TBM_SURF_OPTION_READ, &tbmSurface_info); - - uint32_t stride = tbmSurface_info.planes[0].stride; - unsigned char *ptr = tbmSurface_info.planes[0].ptr; - - for (int j = 0; j < h; j++) - { - for (int i = 0; i < (int)stride/4; i++) - { - if (i < w) { - ptr[0] = b; - ptr[1] = g; - ptr[2] = r; - ptr[3] = a; - } - ptr += 4; - } - } - tbm_surface_unmap(tbmSurface); - - return tbmSurface; - } - -private: - DSEventLoop *__eventLoop; -}; - -TEST_F(DSRenderEngineDaliTest, RenderEngine_Create) -{ - auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue != nullptr); - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); -} - -TEST_F(DSRenderEngineDaliTest, RenderEngine_CreateRenderView) -{ - auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue != nullptr); - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - auto renderView = renderEngine->makeRenderView(); - EXPECT_TRUE(renderView != nullptr); -} - -TEST_F(DSRenderEngineDaliTest, RenderView_SetBuffer) -{ - auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue != nullptr); - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - auto renderView = renderEngine->makeRenderView(); - EXPECT_TRUE(renderView != nullptr); - auto buffer = std::make_shared(100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(renderView->setBuffer(buffer)); -} - -TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderFrame) -{ - auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue != nullptr); - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - auto renderView = renderEngine->makeRenderView(); - EXPECT_TRUE(renderView != nullptr); - auto buffer = std::make_shared (100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(renderView->setBuffer(buffer)); - EXPECT_TRUE(renderEngine->renderFrame()); -} - -TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - std::shared_ptr deviceHWC; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - auto bestMode = (output->getAvailableModes()).front(); - EXPECT_TRUE(output->setMode(bestMode) == true); - EXPECT_TRUE(output->getMode() == bestMode); - - deviceHWC = output->getHWC(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto bufferQueue = deviceHWC->getTargetBufferQueue(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - auto renderView = renderEngine->makeRenderView(); - EXPECT_TRUE(renderView != nullptr); - - int imgWidth = 500; - int imgHeight = 500; - - tbm_surface_h tbmTexture = DSRenderEngineDaliTest::createTbmTexture( - imgWidth, imgHeight, 255, 0, 0, 255); - EXPECT_TRUE(tbmTexture != nullptr); - - auto imageSourceBuffer = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTexture); - EXPECT_TRUE(renderView->setBuffer(imageSourceBuffer)); - EXPECT_TRUE(renderEngine->renderFrame()); - - usleep(1000000); - - EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); - - // commit - EXPECT_TRUE(deviceHWC->commit()); - - usleep(1000000); - } -} - -TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoRenderView) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - std::shared_ptr deviceHWC; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - auto bestMode = (output->getAvailableModes()).front(); - EXPECT_TRUE(output->setMode(bestMode) == true); - EXPECT_TRUE(output->getMode() == bestMode); - - deviceHWC = output->getHWC(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto bufferQueue = deviceHWC->getTargetBufferQueue(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - - int imgWidth = 500; - int imgHeight = 500; - - // for 1st renderView -- begin -- - auto renderViewA = renderEngine->makeRenderView(); - EXPECT_TRUE(renderViewA != nullptr); - - // create RED image buffer - tbm_surface_h tbmTextureA = DSRenderEngineDaliTest::createTbmTexture( - imgWidth, imgHeight, 255, 0, 0, 255); - EXPECT_TRUE(tbmTextureA != nullptr); - - auto imageSourceBufferA = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTextureA); - EXPECT_TRUE(renderViewA->setBuffer(imageSourceBufferA)); - // -- end -- - - // for 2nd renderView -- begin -- - auto renderViewB = renderEngine->makeRenderView(); - EXPECT_TRUE(renderViewB != nullptr); - - // The buffer size of the second renderView is half of the first. - // create BLUE image buffer - tbm_surface_h tbmTextureB = DSRenderEngineDaliTest::createTbmTexture( - imgWidth/2, imgHeight/2, 0, 0, 255, 255); - EXPECT_TRUE(tbmTextureB != nullptr); - - auto imageSourceBufferB = std::make_shared (imgWidth/2, imgHeight/2, IDSBuffer::FORMAT_ARGB8888, tbmTextureB); - EXPECT_TRUE(renderViewB->setBuffer(imageSourceBufferB)); - // -- end -- - - EXPECT_TRUE(renderEngine->renderFrame()); - - /* - * Since renderViewA was created and added before renderViewB, - * renderViewB should be drawn above and renderViewA below. - * - * ┌──────┬──────┐ - * │ B │ │ - * │ blue │ A │ - * ┣──────┘ │ - * │ red │ - * │   │ - * └─────────────┘ - */ - - usleep(1000000); - - EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); - - // commit - EXPECT_TRUE(deviceHWC->commit()); - - usleep(1000000); - } -} - -TEST_F(DSRenderEngineDaliTest, RenderEngine_RaiseToTop) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - std::shared_ptr deviceHWC; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - auto bestMode = (output->getAvailableModes()).front(); - EXPECT_TRUE(output->setMode(bestMode) == true); - EXPECT_TRUE(output->getMode() == bestMode); - - deviceHWC = output->getHWC(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto bufferQueue = deviceHWC->getTargetBufferQueue(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - - int imgWidth = 500; - int imgHeight = 500; - - // for 1st renderView -- begin -- - auto renderViewA = renderEngine->makeRenderView(); - EXPECT_TRUE(renderViewA != nullptr); - - // create RED image buffer - tbm_surface_h tbmTextureA = DSRenderEngineDaliTest::createTbmTexture( - imgWidth, imgHeight, 255, 0, 0, 255); - EXPECT_TRUE(tbmTextureA != nullptr); - - auto imageSourceBufferA = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTextureA); - EXPECT_TRUE(renderViewA->setBuffer(imageSourceBufferA)); - // -- end -- - - // for 2nd renderView -- begin -- - auto renderViewB = renderEngine->makeRenderView(); - EXPECT_TRUE(renderViewB != nullptr); - - // The buffer size of the second renderView is half of the first. - // create BLUE image buffer - tbm_surface_h tbmTextureB = DSRenderEngineDaliTest::createTbmTexture( - imgWidth/2, imgHeight/2, 0, 0, 255, 255); - EXPECT_TRUE(tbmTextureB != nullptr); - - auto imageSourceBufferB = std::make_shared (imgWidth/2, imgHeight/2, IDSBuffer::FORMAT_ARGB8888, tbmTextureB); - EXPECT_TRUE(renderViewB->setBuffer(imageSourceBufferB)); - // -- end -- - - // raise renderViewA to Top - renderViewA->raiseToTop(); - - EXPECT_TRUE(renderEngine->renderFrame()); - - /* - * Since renderViewA was created and added before renderViewB, - * renderViewB should be drawn above and renderViewA below. - * But because renderViewA called raiseToTop(), A rises up and covers B. - * - * ┌─────────────┐ - * │ │ - * │ A │ - * │ │ - * │ red │ - * │   │ - * └─────────────┘ - */ - - usleep(1000000); - - EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); - - // commit - EXPECT_TRUE(deviceHWC->commit()); - - usleep(1000000); - } -} - -TEST_F(DSRenderEngineDaliTest, RenderEngine_LowerToBottom) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - std::shared_ptr deviceHWC; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - auto bestMode = (output->getAvailableModes()).front(); - EXPECT_TRUE(output->setMode(bestMode) == true); - EXPECT_TRUE(output->getMode() == bestMode); - - deviceHWC = output->getHWC(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto bufferQueue = deviceHWC->getTargetBufferQueue(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - - int imgWidth = 500; - int imgHeight = 500; - - // for 1st renderView -- begin -- - auto renderViewA = renderEngine->makeRenderView(); - EXPECT_TRUE(renderViewA != nullptr); - - // create RED image buffer - tbm_surface_h tbmTextureA = DSRenderEngineDaliTest::createTbmTexture( - imgWidth, imgHeight, 255, 0, 0, 255); - EXPECT_TRUE(tbmTextureA != nullptr); - - auto imageSourceBufferA = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTextureA); - EXPECT_TRUE(renderViewA->setBuffer(imageSourceBufferA)); - // -- end -- - - // for 2nd renderView -- begin -- - auto renderViewB = renderEngine->makeRenderView(); - EXPECT_TRUE(renderViewB != nullptr); - - // The buffer size of the second renderView is half of the first. - // create BLUE image buffer - tbm_surface_h tbmTextureB = DSRenderEngineDaliTest::createTbmTexture( - imgWidth/2, imgHeight/2, 0, 0, 255, 255); - EXPECT_TRUE(tbmTextureB != nullptr); - - auto imageSourceBufferB = std::make_shared (imgWidth/2, imgHeight/2, IDSBuffer::FORMAT_ARGB8888, tbmTextureB); - EXPECT_TRUE(renderViewB->setBuffer(imageSourceBufferB)); - // -- end -- - - // raise renderViewA to Top - renderViewB->lowerToBottom(); - - EXPECT_TRUE(renderEngine->renderFrame()); - - /* - * Since renderViewA was created and added before renderViewB, - * renderViewB should be drawn above and renderViewA below. - * But because renderViewB called lowerToBottom(), B lower down and covered by A. - * - * ┌─────────────┐ - * │ │ - * │ A │ - * │ │ - * │ red │ - * │   │ - * └─────────────┘ - */ - - usleep(1000000); - - EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); - - // commit - EXPECT_TRUE(deviceHWC->commit()); - - usleep(1000000); - } -} - -TEST_F(DSRenderEngineDaliTest, RenderEngine_SetPosition) -{ - std::unique_ptr displayDevice = std::make_unique(); - std::list> outputList = displayDevice->getOutputList(); - EXPECT_TRUE(outputList.size() != 0); - - IDSDisplayDeviceOutput::ConnectorType connType; - IDSDisplayDeviceOutput::ConnectState connState; - std::shared_ptr deviceHWC; - - for (std::shared_ptr output : outputList) { - connType = output->getConnectType(); - EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); - connState = output->getConnectState(); - EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); - if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) - continue; - - auto bestMode = (output->getAvailableModes()).front(); - EXPECT_TRUE(output->setMode(bestMode) == true); - EXPECT_TRUE(output->getMode() == bestMode); - - deviceHWC = output->getHWC(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto bufferQueue = deviceHWC->getTargetBufferQueue(); - EXPECT_TRUE(deviceHWC != nullptr); - - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - auto renderView = renderEngine->makeRenderView(); - EXPECT_TRUE(renderView != nullptr); - - renderView->setPosition(200, 200); - - int imgWidth = 500; - int imgHeight = 500; - - tbm_surface_h tbmTexture = DSRenderEngineDaliTest::createTbmTexture( - imgWidth, imgHeight, 255, 0, 0, 255); - EXPECT_TRUE(tbmTexture != nullptr); - - auto imageSourceBuffer = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTexture); - EXPECT_TRUE(renderView->setBuffer(imageSourceBuffer)); - EXPECT_TRUE(renderEngine->renderFrame()); - - usleep(1000000); - - EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); - - // commit - EXPECT_TRUE(deviceHWC->commit()); - - usleep(1000000); - } -} diff --git a/tests/DSRenderEngineEcoreEvasImpl-test.cpp b/tests/DSRenderEngineEcoreEvasImpl-test.cpp deleted file mode 100644 index 4b93a28..0000000 --- a/tests/DSRenderEngineEcoreEvasImpl-test.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSRenderEngineEcoreEvasImpl.h" -#include "DSBufferQueueTBMImpl.h" -#include "DSBufferTBMImpl.h" - -using namespace display_server; - -class DSRenderEngineEcoreEvasTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSRenderEngineEcoreEvasTest, RenderEngine_Create) -{ - auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue != nullptr); - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); -} - -TEST_F(DSRenderEngineEcoreEvasTest, RenderEngine_MakeRenderView) -{ - auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue != nullptr); - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - auto renderView = renderEngine->makeRenderView(); - EXPECT_TRUE(renderView != nullptr); -} - -TEST_F(DSRenderEngineEcoreEvasTest, RenderView_SetBuffer) -{ - auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue != nullptr); - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - auto renderView = renderEngine->makeRenderView(); - EXPECT_TRUE(renderView != nullptr); - auto buffer = std::make_shared (100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(renderView->setBuffer(buffer)); -} - -TEST_F(DSRenderEngineEcoreEvasTest, RenderEngine_RenderFrame) -{ - auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(bufferQueue != nullptr); - auto renderEngine = std::make_unique(bufferQueue); - EXPECT_TRUE(renderEngine != nullptr); - auto renderView = renderEngine->makeRenderView(); - EXPECT_TRUE(renderView != nullptr); - auto buffer = std::make_shared (100, 100, IDSBuffer::FORMAT_ARGB8888); - EXPECT_TRUE(renderView->setBuffer(buffer)); - EXPECT_TRUE(renderEngine->renderFrame()); -} diff --git a/tests/DSSeat-test.cpp b/tests/DSSeat-test.cpp deleted file mode 100644 index 881a66c..0000000 --- a/tests/DSSeat-test.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSSeat.h" -#include "DSCompositor.h" -#include "DSZone.h" - -using namespace display_server; - -class DSSeatTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -class MockCompositor : public DSCompositor -{ -public: - MockCompositor() {} - ~MockCompositor() {} - - std::shared_ptr _onInitialized() override - { - auto canvas = std::make_shared(); - return canvas; - } - - void _onOutputAdded(std::shared_ptr output) override - {} - - void _onOutputRemoved(std::shared_ptr output) override - {} - - void _onInputAdded(std::shared_ptr input) override - {} - - void _onInputRemoved(std::shared_ptr input) override - {} -}; - -TEST_F(DSSeatTest, NewDSSeat) -{ - DSSeat *seat = new DSSeat(); - - EXPECT_TRUE(seat != nullptr); - - if (seat) - delete seat; -} - -TEST_F(DSSeatTest, GetName) -{ - std::string seatName{"default"}; - auto compositor = std::make_shared(); - EXPECT_TRUE(compositor != nullptr); - - if (compositor) - { - auto seat = std::make_shared(compositor.get(), seatName); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - EXPECT_TRUE(seat->getName().compare(seatName) == 0); - } - } -} - -TEST_F(DSSeatTest, HasPointerKeyboardTouch) -{ - std::string seatName{"default"}; - auto compositor = std::make_shared(); - EXPECT_TRUE(compositor != nullptr); - - if (compositor) - { - auto seat = std::make_shared(compositor.get(), seatName); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - seat->addPointer(); - seat->addKeyboard(); - seat->addTouch(); - - EXPECT_TRUE(seat->hasPointer() == true); - EXPECT_TRUE(seat->hasKeyboard() == true); - EXPECT_TRUE(seat->hasTouch() == true); - - seat->removePointer(); - seat->removeKeyboard(); - seat->removeTouch(); - } - } -} - -TEST_F(DSSeatTest, AttachGetDetachZone) -{ - std::string seatName{"default"}; - auto compositor = std::make_shared(); - EXPECT_TRUE(compositor != nullptr); - - if (compositor) - { - auto seat = std::make_shared(compositor.get(), seatName); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - if (zone) - { - EXPECT_TRUE(seat->attachZone(zone) == true); - EXPECT_TRUE(seat->getZone().get() == zone.get()); - EXPECT_TRUE(seat->detachZone() == true); - } - } - } -} - -TEST_F(DSSeatTest, GetXKB) -{ - std::string seatName{"default"}; - auto compositor = std::make_shared(); - EXPECT_TRUE(compositor != nullptr); - - if (compositor) - { - auto seat = std::make_shared(compositor.get(), seatName); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - EXPECT_TRUE(seat->getXkb() != nullptr); - } - } -} - -TEST_F(DSSeatTest, getTopWindow) -{ - std::string seatName{"default"}; - auto compositor = std::make_shared(); - EXPECT_TRUE(compositor != nullptr); - - if (compositor) - { - auto seat = std::make_shared(compositor.get(), seatName); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - if (zone) - { - EXPECT_TRUE(seat->attachZone(zone) == true); - - auto winTop = seat->getTopWindow(nullptr); - EXPECT_TRUE(winTop == nullptr); - - auto winTopOnPosition = seat->getTopWindowOnPosition(100, 100); - EXPECT_TRUE(winTopOnPosition == nullptr); - - EXPECT_TRUE(seat->detachZone() == true); - } - } - } -} - diff --git a/tests/DSSignal-test.cpp b/tests/DSSignal-test.cpp deleted file mode 100644 index 02db211..0000000 --- a/tests/DSSignal-test.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSSignal.h" -#include "DSDebugLog.h" - -using namespace display_server; - -class DSSignalTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -class SenderMock : public DSObject -{ -public: - SenderMock() - : signalA(std::make_unique>()), - signalB(std::make_unique>()) - {} - ~SenderMock() = default; - - void emitSignalA(int value) { - signalA->emit(value); - } - - void emitSignalB(double value) { - signalB->emit(value); - } - - std::unique_ptr> signalA; - std::unique_ptr> signalB; -}; - -class ReceiverMock : public DSObject -{ -public: - ReceiverMock(std::shared_ptr sender) - : __sender(sender) - { - sender->signalA->connect(this, std::bind(&ReceiverMock::slotA, this, std::placeholders::_1)); - sender->signalB->connect(this, std::bind(&ReceiverMock::slotB, this, std::placeholders::_1)); - } - ~ReceiverMock() = default; - - void slotA(int value) { - DSLOG_INF("DSTEST", "%s is invoked! : value, %d", __func__, value); - } - - void slotB(double value) { - DSLOG_INF("DSTEST", "%s is invoked! : value, %lf", __func__, value); - } - -private: - std::shared_ptr __sender; -}; - -TEST_F(DSSignalTest, CreateSignal) -{ - DSSignal *signal = new DSSignal(); - delete signal; - ASSERT_TRUE(true); -} - -TEST_F(DSSignalTest, ConnectSignal) -{ - auto sender1 = std::make_shared(); - auto receiver = std::make_unique(sender1); - - sender1->emitSignalA(30); - sender1->emitSignalB(3.0); -} diff --git a/tests/DSSignalBroker-test.cpp b/tests/DSSignalBroker-test.cpp deleted file mode 100644 index 644cc27..0000000 --- a/tests/DSSignalBroker-test.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include -#include "libds-tests.h" -#include "DSSignal.h" -#include "DSSignalBroker.h" -#include "DSDebugLog.h" - -using namespace display_server; - -struct stItem -{ - std::string str1; - std::string str2; -}; - -class MockSender : public DSObject -{ -public: - MockSender() {} - ~MockSender() {} - - bool registerSignal(std::string signalString) - { - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - bool res = false; - - if (sigbro == nullptr) - return false; - - res = sigbro->registerSignal(signalString, this); - - if (sigbro) - sigbro->releaseInstance(); - - return res; - } - - bool sendSignal1(std::string signalString, int data) - { - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - bool res = false; - - if (sigbro == nullptr) - return false; - - res = sigbro->emitSignal(signalString, this, data); - - if (sigbro) - sigbro->releaseInstance(); - - return res; - } - - bool sendSignal2(std::string signalString, double data) - { - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - bool res = false; - - if (sigbro == nullptr) - return false; - - res = sigbro->emitSignal(signalString, this, data); - - if (sigbro) - sigbro->releaseInstance(); - - return res; - } - - bool sendSignal3(std::string signalString, std::string data1, std::string data2, std::string data3) - { - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - bool res = false; - - if (sigbro == nullptr) - return false; - - struct stItem testItem = {data2, data3}; - - res = sigbro->emitSignal(signalString, this, data1, testItem); - - if (sigbro) - sigbro->releaseInstance(); - - return res; - } -}; - -class MockReceiver : public DSObject -{ -public: - MockReceiver() : - result1(0), - result2(0.0), - result3("") - { - } - ~MockReceiver() {} - -public: - int result1; - double result2; - std::string result3; - -public: - bool registerCallback1(std::string targetSignal) - { - bool res = false; - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - if (sigbro == nullptr) return false; - - std::function func = std::bind(&MockReceiver::UserCallback1, this, std::placeholders::_1); - res = sigbro->registerCallback(targetSignal, this, func); - - if (sigbro) - sigbro->releaseInstance(); - - return res; - } - - bool registerCallback2(std::string targetSignal) - { - bool res = false; - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - if (sigbro == nullptr) return false; - - std::function func = std::bind(&MockReceiver::UserCallback2, this, std::placeholders::_1); - res = sigbro->registerCallback(targetSignal, this, func); - - if (sigbro) - sigbro->releaseInstance(); - - return res; - } - - bool registerCallback3(std::string targetSignal) - { - bool res = false; - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - if (sigbro == nullptr) return false; - - std::function func = std::bind(&MockReceiver::UserCallback3, this, std::placeholders::_1, std::placeholders::_2); - res = sigbro->registerCallback(targetSignal, this, func); - - if (sigbro) - sigbro->releaseInstance(); - - return res; - } - - void UserCallback1(int arg) - { - DSLOG_INF("DSTEST", "%s is invoked!, arg: %d", __func__, arg); - result1 = arg; - } - - void UserCallback2(double arg) - { - DSLOG_INF("DSTEST", "%s is invoked!, arg: %d", __func__, arg); - result2 = arg; - } - - void UserCallback3(std::string arg1, struct stItem arg2) - { - DSLOG_INF("DSTEST", "%s is invoked!, arg1: %s, arg2{%s, %s}", __func__, arg1.c_str(), arg2.str1.c_str(), arg2.str2.c_str()); - result3 = arg1; - } -}; - -class DSSignalBrokerTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -std::shared_ptr __receiver; -std::shared_ptr __sender; - -TEST_F(DSSignalBrokerTest, getInstance) -{ - DSSignalBroker *sigbro = DSSignalBroker::getInstance(); - EXPECT_TRUE(sigbro != nullptr); - - if (sigbro) - sigbro->releaseInstance(); -} - -TEST_F(DSSignalBrokerTest, registerSignal) -{ - __sender = std::make_shared(); - ASSERT_TRUE(__sender != nullptr); - - __sender->registerSignal("SampleSignal1"); -} - -TEST_F(DSSignalBrokerTest, registerCallback) -{ - __receiver = std::make_shared(); - ASSERT_TRUE(__receiver != nullptr); - - __receiver->registerCallback1("SampleSignal1"); -} - -TEST_F(DSSignalBrokerTest, emitSignal) -{ - ASSERT_TRUE(__sender != nullptr); - ASSERT_TRUE(__receiver != nullptr); - - EXPECT_TRUE(__sender->sendSignal1("SampleSignal1", 1)); - EXPECT_TRUE(__receiver->result1 == 1); -} - -TEST_F(DSSignalBrokerTest, registerAndEmit1) -{ - auto sender1 = std::make_shared(); - auto sender2 = std::make_shared(); - - auto receiver1 = std::make_shared(); - auto receiver2 = std::make_shared(); - - ASSERT_TRUE(sender1 != nullptr && - sender2 != nullptr && - receiver1 != nullptr && - receiver2 != nullptr); - - // 1. register Signal - EXPECT_TRUE(sender1->registerSignal("SampleSignal1")); - EXPECT_TRUE(sender2->registerSignal("SampleSignal2")); - - // 2. register Callback - EXPECT_TRUE(receiver1->registerCallback1("SampleSignal1")); - EXPECT_TRUE(receiver2->registerCallback2("SampleSignal2")); - - // 3. emit Signal - EXPECT_TRUE(sender1->sendSignal1("SampleSignal1", 11)); - EXPECT_TRUE(sender2->sendSignal2("SampleSignal2", 10.10)); - - // 4. see Changes - EXPECT_TRUE(receiver1->result1 == 11); - EXPECT_TRUE(receiver2->result2 == 10.10); -} - -TEST_F(DSSignalBrokerTest, emitMultiItems) -{ - auto sender = std::make_shared(); - auto receiver = std::make_shared(); - - ASSERT_TRUE(sender != nullptr && - receiver != nullptr); - - // 1. register Signal - EXPECT_TRUE(sender->registerSignal("SampleSignal3")); - - // 2. register Callback - EXPECT_TRUE(receiver->registerCallback3("SampleSignal3")); - - // 3. emit Signal - EXPECT_TRUE(sender->sendSignal3("SampleSignal3", "Test", "Hello", "signal")); - - // 4. see Changes - EXPECT_TRUE(receiver->result3 == "Test"); -} diff --git a/tests/DSTextInput-test.cpp b/tests/DSTextInput-test.cpp deleted file mode 100644 index 55ba75d..0000000 --- a/tests/DSTextInput-test.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSTextInput.h" - -using namespace display_server; - -class DSTextInputTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSTextInputTest, NewDSTextInput) -{ - DSTextInput *textInput = new DSTextInput(); - EXPECT_TRUE(textInput != nullptr); - - delete textInput; -} - diff --git a/tests/DSTizenAppinfo-test.cpp b/tests/DSTizenAppinfo-test.cpp deleted file mode 100644 index ff9a6e9..0000000 --- a/tests/DSTizenAppinfo-test.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSTizenAppinfo.h" -#include "DSTizenAppinfoMgr.h" - -using namespace display_server; - -class DSTizenAppinfoTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSTizenAppinfoTest, NewTizenAppinfo) -{ - std::string appId1{"com.appinfo.first"}; - std::string appId2{"com.appinfo.second"}; - - DSTizenAppinfo *appinfo = new DSTizenAppinfo(appId1); - EXPECT_TRUE(appinfo != nullptr); - - if (appinfo) - { - pid_t pid = 1234; - appinfo->setPid(pid); - appinfo->setAppId(appId2); - EXPECT_TRUE(appinfo->getAppId().compare(appId2) == 0); - - EXPECT_TRUE(appinfo->getBaseOutputAvailable() == false); - EXPECT_TRUE(appinfo->getBaseOutputWidth() == 0); - EXPECT_TRUE(appinfo->getBaseOutputHeight() == 0); - - delete appinfo; - } -} - -TEST_F(DSTizenAppinfoTest, NewTizenAppinfoMgr) -{ - DSTizenAppinfoMgr *appinfoMgr = DSTizenAppinfoMgr::getInstance(); - EXPECT_TRUE(appinfoMgr != nullptr); - - if (appinfoMgr) - { - std::string appId1{"com.appinfo.first"}; - std::string appId2{"com.appinfo.second"}; - std::string appId3{"com.appinfo.third"}; - pid_t pid1 = 1234, pid2 = 4321; - int res_w = 0, res_h = 0; - - std::shared_ptr app1(nullptr), app2(nullptr), app3(nullptr), temp(nullptr); - - app1 = appinfoMgr->addTizenAppinfo(appId1); - EXPECT_TRUE(app1 != nullptr); - app2 = appinfoMgr->addTizenAppinfo(appId2); - EXPECT_TRUE(app2 != nullptr); - //FAIL to add a new appinfo using the existing appId - app3 = appinfoMgr->addTizenAppinfo(appId2); - EXPECT_TRUE(app3 == nullptr); - - temp = appinfoMgr->getTizenAppinfo(appId2); - EXPECT_TRUE(temp != nullptr); - - EXPECT_TRUE(appinfoMgr->removeTizenAppinfo(appId2) == true); - //FAIL to remove non-existing appinfo - EXPECT_TRUE(appinfoMgr->removeTizenAppinfo("com.appinfo.noname") == false); - - app1->setPid(pid1); //app1 - (appId1, 1234) - temp = nullptr; - temp = appinfoMgr->getTizenAppinfo(pid1); //temp = app1 - (appId1, 1234) - EXPECT_TRUE(temp != nullptr); - - appinfoMgr->updateTizenAppinfo(appId1, pid2); //app1 - (appId1, 4321) - appinfoMgr->updateTizenAppinfo(appId2, pid2); //no appinfo with appId2 - - EXPECT_TRUE(appinfoMgr->getBaseOutputResolution(pid1, &res_w, &res_h) == false); //no appinfo with pid1 - - app1->setBaseOutputAvailable(true); - app1->setBaseOutputWidth(720); - app1->setBaseOutputHeight(1280); - - EXPECT_TRUE(appinfoMgr->getBaseOutputResolution(pid2, &res_w, &res_h) == true); //app1 - EXPECT_TRUE(res_w == 720); - EXPECT_TRUE(res_h == 1280); - appinfoMgr->removeTizenAppinfo(app1->getAppId()); - - DSTizenAppinfoMgr::releaseInstance(); - } -} diff --git a/tests/DSTouch-test.cpp b/tests/DSTouch-test.cpp deleted file mode 100644 index a9b476e..0000000 --- a/tests/DSTouch-test.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSTouch.h" -#include "DSSeat.h" -#include "DSWaylandTouch.h" -#include "DSWaylandSeat.h" -#include "DSWaylandCompositor.h" -#include "DSWindow.h" -#include "DSWaylandSurface.h" - -using namespace display_server; - -class DSTouchTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSTouchTest, NewDSTouchWithDSSeat) -{ - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - auto touch = new DSTouch(seat); - EXPECT_TRUE(touch != nullptr); - } -} - -TEST_F(DSTouchTest, NewDSTouchWithDSWaylandTouch) -{ - auto waylandCompositor = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(waylandCompositor != nullptr); - - if (waylandCompositor) - { - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - auto waylandSeat = new DSWaylandSeat(waylandCompositor, DSWaylandSeat::capAll); - EXPECT_TRUE(waylandSeat != nullptr); - - if (seat && waylandSeat) - { - auto waylandTouch = new DSWaylandTouch(waylandSeat); - EXPECT_TRUE(waylandTouch != nullptr); - - if (waylandTouch) - { - auto touch = new DSTouch(seat, waylandTouch); - EXPECT_TRUE(touch != nullptr); - } - } - - DSWaylandCompositor::releaseInstance(); - } - -} -TEST_F(DSTouchTest, BasicMethods) -{ - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - - auto waylandSurface = std::make_shared(); - EXPECT_TRUE(waylandSurface != nullptr); - - window->create(waylandSurface); - - if (seat && window) - { - auto touch = new DSTouch(seat); - EXPECT_TRUE(touch != nullptr); - - if (touch) - { - touch->setFocus(window); - EXPECT_TRUE(window == touch->getFocus()); - } - } -} diff --git a/tests/DSTraceInfo-test.cpp b/tests/DSTraceInfo-test.cpp deleted file mode 100644 index 367a7f7..0000000 --- a/tests/DSTraceInfo-test.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSTraceInfo.h" - -using namespace display_server; - -class DSTraceInfoTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - Ecore_Timer *timer = nullptr; - - DSWaylandCompositor::getInstance(); - eventLoop = DSEventLoop::getInstance(); - double delayInSecond = 0.5; - auto timerCb = [](void *data) -> Eina_Bool { - DSEventLoop *loop = (DSEventLoop *)data; - EXPECT_TRUE(loop->quit() == true); - return EINA_FALSE; - }; - - timer = ecore_timer_loop_add(delayInSecond, timerCb, eventLoop); - EXPECT_TRUE(timer != nullptr); - - eventLoop->run(); - - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - eventLoop->quit(); - DSEventLoop::releaseInstance(); - DSWaylandCompositor::releaseInstance(); - - unsetenv("XDG_RUNTIME_DIR"); - } - DSEventLoop *eventLoop; -private: - -}; - -TEST_F(DSTraceInfoTest, NewTraceInfo) -{ - auto traceInfo = std::make_unique(); - EXPECT_TRUE(traceInfo != nullptr); -} - -TEST_F(DSTraceInfoTest, attachPolicyArea) -{ - auto traceInfo = std::make_unique(); - EXPECT_TRUE(traceInfo != nullptr); - auto policyArea = std::make_shared(); - EXPECT_TRUE(policyArea != nullptr); - EXPECT_TRUE(traceInfo->attachPolicyArea(policyArea) == true); -} - -TEST_F(DSTraceInfoTest, printWindowsInfo) -{ - std::shared_ptr zone(nullptr); - - auto traceInfo = std::make_unique(); - EXPECT_TRUE(traceInfo != nullptr); - auto policyArea = std::make_shared(); - EXPECT_TRUE(policyArea != nullptr); - if (traceInfo->attachPolicyArea(policyArea)) - { - std::string title1{"TestWindow1"}; - std::string title2{"TestWindow2"}; - zone = traceInfo->getZone(); - - auto dswlSurface1 = std::make_shared(); - EXPECT_TRUE(zone->testCreateWindow(dswlSurface1)); - - auto dswlSurface2 = std::make_shared(); - EXPECT_TRUE(zone->testCreateWindow(dswlSurface2)); - - usleep(100000); - eventLoop->testEmitIdleEntererFuncs(nullptr); - - zone->raiseWindow(dswlSurface1.get()); - eventLoop->testEmitIdleEntererFuncs(nullptr); - - EXPECT_TRUE(zone->testDestroyWindow(dswlSurface1)); - eventLoop->testEmitIdleEntererFuncs(nullptr); - - EXPECT_TRUE(zone->testDestroyWindow(dswlSurface2)); - eventLoop->testEmitIdleEntererFuncs(nullptr); - } -} - diff --git a/tests/DSWaylandBuffer-test.cpp b/tests/DSWaylandBuffer-test.cpp deleted file mode 100644 index e0e2fcd..0000000 --- a/tests/DSWaylandBuffer-test.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandBuffer.h" - -using namespace display_server; - -class DSWaylandBufferTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandBufferTest, NewDSWaylandBuffer) -{ - DSWaylandBuffer *buffer = new DSWaylandBuffer; - delete buffer; - EXPECT_TRUE(true); -} diff --git a/tests/DSWaylandCallback-test.cpp b/tests/DSWaylandCallback-test.cpp deleted file mode 100644 index 9c7a0e3..0000000 --- a/tests/DSWaylandCallback-test.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandCallback.h" - -using namespace display_server; - -class DSWaylandCallbackTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandCallbackTest, NewDSWaylandCallback) -{ - DSWaylandCallback *callback = new DSWaylandCallback; - delete callback; - EXPECT_TRUE(true); -} diff --git a/tests/DSWaylandClient-test.cpp b/tests/DSWaylandClient-test.cpp deleted file mode 100644 index 329cff9..0000000 --- a/tests/DSWaylandClient-test.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandClient.h" - -using namespace display_server; - -class DSWaylandClientTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandClientTest, NewDSWaylandClient) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - /* client must be created with a valid wl_client ptr later. */ - DSWaylandClient *client = new DSWaylandClient(comp, (wl_client *)nullptr); - EXPECT_TRUE(client != nullptr); - - if (client) - delete client; - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandClientTest, GetClientFromWlClient) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - /* client must be created with a valid wl_client ptr later. */ - auto client = new DSWaylandClient(comp, (wl_client *)nullptr); - EXPECT_TRUE(client != nullptr); - - if (client) - { - DSWaylandClient *client2 = client->fromWlClient((wl_client *)nullptr); - EXPECT_TRUE(client2 == nullptr); - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandClientTest, GetWlClient) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - /* client must be created with a valid wl_client ptr later. */ - auto client = new DSWaylandClient(comp, (wl_client *)nullptr); - EXPECT_TRUE(client != nullptr); - - if (client) - { - wl_client *wclient = client->wlClient(); - EXPECT_TRUE(wclient == nullptr); - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandClientTest, GetCompositor) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - /* client must be created with a valid wl_client ptr later. */ - DSWaylandClient *client = new DSWaylandClient(comp, (wl_client *)nullptr); - EXPECT_TRUE(client != nullptr); - - if (client) - { - DSWaylandCompositor *comp2 = client->getCompositor(); - EXPECT_TRUE(comp2 == comp); - - delete client; - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandClientTest, GetPidUidGid) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - /* client must be created with a valid wl_client ptr later. */ - auto client = new DSWaylandClient(comp, (wl_client *)nullptr); - EXPECT_TRUE(client != nullptr); - - if (client) - { - pid_t pID; - uid_t uID; - gid_t gID; - - pID = client->pid(); - uID = client->uid(); - gID = client->gid(); - - EXPECT_TRUE(pID == 0); - EXPECT_TRUE(uID == 0); - EXPECT_TRUE(gID == 0); - - delete client; - } - - DSWaylandCompositor::releaseInstance(); - } -} - diff --git a/tests/DSWaylandCompositor-test.cpp b/tests/DSWaylandCompositor-test.cpp deleted file mode 100644 index c2bf133..0000000 --- a/tests/DSWaylandCompositor-test.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandClient.h" -#include "DSWaylandSeat.h" - -using namespace display_server; - -class DSWaylandCompositorTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandCompositorTest, NewDSWaylandCompositor) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandCompositorTest, CreateTest) -{ - bool res; - - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - res = comp->create(); - EXPECT_TRUE(res == true); - - res = comp->isCreated(); - EXPECT_TRUE(res == true); - - std::string sockName = comp->socketName().substr(0, 8); - EXPECT_TRUE(sockName.compare(std::string{"wayland-"}) == 0); - - sockName.clear(); - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandCompositorTest, DisplayGet) -{ - bool res; - - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - res = comp->create(); - EXPECT_TRUE(res == true); - EXPECT_TRUE(comp->display() != nullptr); - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandCompositorTest, NextSerialGet) -{ - bool res; - uint32_t nSerial; - - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - res = comp->create(); - EXPECT_TRUE(res == true); - - nSerial = comp->nextSerial(); - EXPECT_TRUE((nSerial+1) == comp->nextSerial()); - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandCompositorTest, GetCurrentTime) -{ - bool res; - uint32_t currentTime; - - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - res = comp->create(); - EXPECT_TRUE(res == true); - - currentTime = comp->currentTime(); - EXPECT_TRUE(currentTime <= comp->currentTime()); - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandCompositorTest, AddRemoveClient) -{ - bool res; - std::list l; - - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - res = comp->create(); - EXPECT_TRUE(res == true); - - DSWaylandClient *client = new DSWaylandClient(comp, (wl_client *)nullptr); - EXPECT_TRUE(client != nullptr); - - if (client) - { - comp->addClient(client); - - l = comp->clients(); - EXPECT_TRUE(l.size() != 0); - - comp->removeClient(client); - - l = comp->clients(); - EXPECT_TRUE(l.size() == 0); - - delete client; - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandCompositorTest, GetDefaultSeat) -{ - bool res; - - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - res = comp->create(); - EXPECT_TRUE(res == true); - - DSWaylandSeat *seat = comp->addSeat((uint32_t)DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - EXPECT_TRUE(comp->defaultSeat() != nullptr); - - comp->removeSeat(seat); - EXPECT_TRUE(comp->defaultSeat() == nullptr); - } - - DSWaylandCompositor::releaseInstance(); - } -} - -static void -handle_global(void *data, struct wl_registry *registry, uint32_t name, - const char *interface, uint32_t version) -{ - struct TestClient *testClient = (struct TestClient *)data; - - if (strcmp(interface, "wl_compositor") == 0) { - testClient->compositor = (struct wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 1); - if (!testClient->compositor) - DSLOG_ERR("TEST", "wl_registry_bind compositor fails."); - } -} - -static void -handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) -{} - -static const struct wl_registry_listener registry_listener = { - handle_global, - handle_global_remove -}; - -TEST_F(DSWaylandCompositorTest, registerCallbackSurfaceCreated) -{ - auto mockWaylandCompositor = std::make_unique(); - - Ecore_Timer *serverQuitTimer = nullptr; - double severQuitTime = 1.0; - auto serverQuitFunc = [](void *data) -> Eina_Bool { - MockWaylandCompositor *comp = (MockWaylandCompositor *)data; - - // quit server - comp->quit(); - // check the emitting the surfaceCreated - EXPECT_TRUE(comp->surfaceCreated); - - return EINA_FALSE; - }; - serverQuitTimer = ecore_timer_loop_add(severQuitTime, serverQuitFunc, mockWaylandCompositor.get()); - EXPECT_TRUE(serverQuitTimer != nullptr); - - // create the wayland client which creates the wl_surface. - std::future clientThread = std::async(std::launch::async, []() -> bool { - std::this_thread::sleep_for(std::chrono::milliseconds(40)); - auto testClient = std::make_shared(); - - testClient->display = wl_display_connect(NULL); - EXPECT_TRUE(testClient->display != nullptr); - - testClient->registry = wl_display_get_registry(testClient->display); - wl_registry_add_listener(testClient->registry, ®istry_listener, testClient.get()); - wl_display_dispatch(testClient->display); - wl_display_roundtrip(testClient->display); - EXPECT_TRUE(testClient->compositor != nullptr); - - testClient->surface = wl_compositor_create_surface(testClient->compositor); - EXPECT_TRUE(testClient->surface != nullptr); - wl_display_roundtrip(testClient->display); - - wl_display_disconnect(testClient->display); - - return true; - } - ); - - mockWaylandCompositor->run(); - EXPECT_TRUE(clientThread.get()); // join(wait) and get the return value. -} - - diff --git a/tests/DSWaylandExtension-test.cpp b/tests/DSWaylandExtension-test.cpp deleted file mode 100644 index eb9388e..0000000 --- a/tests/DSWaylandExtension-test.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSObject.h" -#include "DSWaylandExtension.h" -#include "DSStruct.h" - -using namespace display_server; - -class DSWaylandExtensionTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandExtensionTest, NewWaylandExtension) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - auto wlExtension = std::make_shared(comp); - EXPECT_TRUE(wlExtension != nullptr); - - DSWaylandCompositor::releaseInstance(); -} diff --git a/tests/DSWaylandInputMethod-test.cpp b/tests/DSWaylandInputMethod-test.cpp deleted file mode 100644 index 98aeae4..0000000 --- a/tests/DSWaylandInputMethod-test.cpp +++ /dev/null @@ -1,657 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandInputMethod.h" - -using namespace display_server; - -class DSWaylandInputMethodTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandInputMethodTest, NewDSWaylandInputMethod) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ActivateDeactivate) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - bool activated = inputMethod->contextActivated(); - if (activated) - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ShowHideInputPanel) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->showInputPanel(0); - inputMethod->hideInputPanel(0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ResetTextInput) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->resetTextInput(); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, SetContentType) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->setContentType(10, 0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, SetPreferredLanguage) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->setPreferredLanguage("en_US"); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, CommitState) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->commitState(5); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, InvokeAction) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->invokeAction(1, 0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, SetReturnKeyType) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->setReturnKeyType(0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ReturnKeyDisabled) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->returnKeyDisabled(0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, SetInputPanelData) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->setInputPanelData("WILL_HIDE_ACK", 13); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, BidiDirection) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->bidiDirection(1); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, SetCursorPosition) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->setCursorPosition(0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ProcessInputDeviceEvent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->processInputDeviceEvent(0, "", 0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, FilterKeyEvent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->filterKeyEvent(1, 0, "A", 1, 1, "ime", 2, 12, 0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, SetCapitalMode) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->setCapitalMode(0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, PredictionHint) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->predictionHint(""); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, SetMimeType) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->setMimeType(""); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, FinalizeContent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->finalizeContent("", 0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, PredictionHintData) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->predictionHintData("appid", ""); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextCommitString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextCommitString(0, ""); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextPreeditString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextPreeditString(1, "", ""); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextPreeditStyling) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextPreeditStyling(1, 1, 1); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextPreeditCursor) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextPreeditCursor(0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextDeleteSurroundingText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextDeleteSurroundingText(1, 1); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextCursorPosition) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextCursorPosition(1, 1); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextModifiersMap) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextModifiersMap(""); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextKeysym) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextKeysym(1, 10, 65, 1, 1); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextLanguage) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextLanguage(1, "en_US"); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextTextDirection) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextTextDirection(1, 1); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextSelectionRegion) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextSelectionRegion(1, 10, 20); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextPrivateCommand) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextPrivateCommand(1, "CONFORMANT_RESET"); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextUpdateInputPanelData) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextUpdateInputPanelData(1, "", 0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextHideInputPanel) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextHideInputPanel(1); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextGetSelectionText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextGetSelectionText(5); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextGetSurroundingText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextGetSurroundingText(5, 10, 5); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextFilterKeyEventDone) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextFilterKeyEventDone(1, 0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextUpdateIseGeometry) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextUpdateIseGeometry(1, 0, 100, 200, 100); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextRecaptureString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextRecaptureString(1, 1, 0, "", "", ""); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextInputPanelEvent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextInputPanelEvent(1, 1, 0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextCommitContent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextCommitContent(1, "", "", ""); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextUpdateCandidateState) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextUpdateCandidateState(0); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, ContextReshowInputPanel) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->contextReshowInputPanel(); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodTest, SetGeometryUpdated) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - EXPECT_TRUE(inputMethod != nullptr); - - inputMethod->activate(0); - inputMethod->setGeometryUpdated(true); - inputMethod->deactivate(); - - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - diff --git a/tests/DSWaylandInputMethodContext-test.cpp b/tests/DSWaylandInputMethodContext-test.cpp deleted file mode 100644 index ec2d51b..0000000 --- a/tests/DSWaylandInputMethodContext-test.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandInputMethod.h" -#include "DSWaylandInputMethodContext.h" - -using namespace display_server; - -class DSWaylandInputMethodContextTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandInputMethodContextTest, NewDSWaylandInputMethodContext) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendReset) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendReset(nullptr); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendContentType) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendContentType(nullptr, 10, 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendPreferredLanguage) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendPreferredLanguage(nullptr, "en_US"); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendCommitState) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendCommitState(nullptr, 5); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendInvokeAction) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendInvokeAction(nullptr, 1, 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendReturnKeyType) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendReturnKeyType(nullptr, 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendReturnKeyDisabled) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendReturnKeyDisabled(nullptr, 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendInputPanelData) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendInputPanelData(nullptr, "WILL_HIDE_ACK", 13); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendBidiDirection) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendBidiDirection(nullptr, 1); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendCursorPosition) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendCursorPosition(nullptr, 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendProcessInputDeviceEvent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendProcessInputDeviceEvent(nullptr, 0, "", 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendFilterKeyEvent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendFilterKeyEvent(nullptr, 1, 0, "A", 1, 1, "ime", 2, 12, 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendCapitalMode) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendCapitalMode(nullptr, 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendPredictionHint) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendPredictionHint(nullptr, ""); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendMimeType) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendMimeType(nullptr, ""); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendFinalizedContent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendFinalizedContent(nullptr, "", 0); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputMethodContextTest, SendPredictionHintData) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); - DSWaylandInputMethodContext *inputMethodContext = new DSWaylandInputMethodContext(comp, inputMethod); - EXPECT_TRUE(inputMethodContext != nullptr); - - inputMethodContext->sendPredictionHintData(nullptr, "appid", ""); - - delete inputMethodContext; - delete inputMethod; - DSWaylandCompositor::releaseInstance(); -} - diff --git a/tests/DSWaylandInputPanel-test.cpp b/tests/DSWaylandInputPanel-test.cpp deleted file mode 100644 index b367486..0000000 --- a/tests/DSWaylandInputPanel-test.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandInputPanel.h" - -using namespace display_server; - -class DSWaylandInputPanelTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandInputPanelTest, NewDSWaylandInputPanel) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, CreateClearSurface) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->createSurface(nullptr, nullptr, 0, nullptr); - inputPanel->clearSurfaces(nullptr); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, GetSetWaitUpdate) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->setWaitUpdate(true); - bool waitUpdate = inputPanel->getWaitUpdate(); - - EXPECT_TRUE(waitUpdate == true); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, UpdateInputPanelState) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->updateInputPanelState(true); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, SetFloatingMovingRequest) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->setFloatingMovingRequest(true); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, GetSetRerunPanelShow) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->setRerunPanelShow(true); - EXPECT_TRUE(true == inputPanel->getRerunPanelShow()); - - inputPanel->setRerunPanelShow(false); - EXPECT_TRUE(false == inputPanel->getRerunPanelShow()); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, SetTransientFor) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->setTransientFor(nullptr); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, ChangeVisibility) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->changeVisibility(true); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, IsEffectRunning) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->isEffectRunning(nullptr); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, SetFloatingPosition) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->setFloatingPosition(0, 0); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, GetFloatingData) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - auto floatingData = inputPanel->getFloatingData(); - - EXPECT_TRUE(floatingData != nullptr); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, GetSurfaceGeometry) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->getSurfaceGeometry(nullptr); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, UpdateTextInputPanelState) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - inputPanel->updateTextInputPanelState(true); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelTest, GetTextInputSurface) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - EXPECT_TRUE(inputPanel != nullptr); - - (void)inputPanel->getTextInputSurface(); - - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - diff --git a/tests/DSWaylandInputPanelSurface-test.cpp b/tests/DSWaylandInputPanelSurface-test.cpp deleted file mode 100644 index 3de9fa2..0000000 --- a/tests/DSWaylandInputPanelSurface-test.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandInputPanelSurface.h" - -using namespace display_server; - -class DSWaylandInputPanelSurfaceTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandInputPanelSurfaceTest, NewDSWaylandInputPanelSurface) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelSurfaceTest, CreateClearGlobal) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - inputPanelSurface->createGlobal(nullptr, nullptr, 0, nullptr); - inputPanelSurface->clearGlobals(nullptr); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelSurfaceTest, FlushFrame) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - inputPanelSurface->flushFrame(); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelSurfaceTest, SetTransientForSurface) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - inputPanelSurface->setTransientForSurface(nullptr); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelSurfaceTest, UpdateSurfaceVisibility) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - inputPanelSurface->updateSurfaceVisibility(true); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelSurfaceTest, SsEffectRunning) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - inputPanelSurface->isEffectRunning(nullptr); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelSurfaceTest, SetPosition) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - inputPanelSurface->setPosition(nullptr, 0, 0); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelSurfaceTest, SetFloatingPosition) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - inputPanelSurface->setFloatingPosition(0, 0); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandInputPanelSurfaceTest, GetGeometry) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp); - DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel); - EXPECT_TRUE(inputPanelSurface != nullptr); - - inputPanelSurface->getGeometry(nullptr); - - delete inputPanelSurface; - delete inputPanel; - DSWaylandCompositor::releaseInstance(); -} - diff --git a/tests/DSWaylandKeyboard-test.cpp b/tests/DSWaylandKeyboard-test.cpp deleted file mode 100644 index 5a15f67..0000000 --- a/tests/DSWaylandKeyboard-test.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandKeyboard.h" -#include "DSWaylandSeat.h" -#include "DSWaylandSurface.h" - -using namespace display_server; - -class DSWaylandKeyboardTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandKeyboardTest, NewDSWaylandKeyboard) -{ - DSWaylandKeyboard *keyboard = new DSWaylandKeyboard(nullptr); - EXPECT_TRUE(keyboard != nullptr); - - if (keyboard) - delete keyboard; -} - -TEST_F(DSWaylandKeyboardTest, GetSeat) -{ - DSWaylandSeat *seat = new DSWaylandSeat(nullptr, DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - DSWaylandKeyboard *keyboard = new DSWaylandKeyboard(seat); - EXPECT_TRUE(keyboard != nullptr); - - if (keyboard) - { - EXPECT_TRUE(keyboard->seat() == seat); - - delete keyboard; - } - - delete seat; - } -} - -TEST_F(DSWaylandKeyboardTest, SetGetRepeatRateDelay) -{ - DSWaylandKeyboard *keyboard = new DSWaylandKeyboard(nullptr); - EXPECT_TRUE(keyboard != nullptr); - - if (keyboard) - { - uint32_t uRepeatRate = 25; - uint32_t uRepeatDelay = 400; - - keyboard->setRepeatRate(uRepeatRate); - EXPECT_TRUE(keyboard->repeatRate() == uRepeatRate); - - keyboard->setRepeatDelay(uRepeatDelay); - EXPECT_TRUE(keyboard->repeatDelay() == uRepeatDelay); - - delete keyboard; - } -} - -TEST_F(DSWaylandKeyboardTest, SetGetFocus) -{ - auto keyboard = new DSWaylandKeyboard(nullptr); - EXPECT_TRUE(keyboard != nullptr); - - if (keyboard) - { - auto waylandSurface = std::make_unique(); - EXPECT_TRUE(waylandSurface != nullptr); - - if (waylandSurface) - { - /* FIXME: currently we cannot create wl_surface so setFocus will be always set nullptr to focus - * so temporary I set nullptr to focus for test but this will be fixed - * keyboard->setFocus(waylandSurface.get()); - * EXPECT_TRUE(waylandSurface.get() == keyboard->getFocus()); - */ - keyboard->setFocus(nullptr); - EXPECT_TRUE(nullptr == keyboard->getFocus()); - } - } -} - -TEST_F(DSWaylandKeyboardTest, BasicMethods) -{ - auto keyboard = new DSWaylandKeyboard(nullptr); - EXPECT_TRUE(keyboard != nullptr); - - if (keyboard) - { - keyboard->sendKeyDown(100); - keyboard->sendKeyUp(100); - } -} - -TEST_F(DSWaylandKeyboardTest, ResetFocus) -{ - auto keyboard = new DSWaylandKeyboard(nullptr); - EXPECT_TRUE(keyboard != nullptr); - - if (keyboard) - { - keyboard->resetFocus(); - EXPECT_TRUE(nullptr == keyboard->getFocus()); - } -} - diff --git a/tests/DSWaylandOutput-test.cpp b/tests/DSWaylandOutput-test.cpp deleted file mode 100644 index 0009b60..0000000 --- a/tests/DSWaylandOutput-test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandOutput.h" - -using namespace display_server; - -class DSWaylandOutputTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandOutputTest, NewDSWaylandOutput) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandOutput *output = new DSWaylandOutput(comp, "unknown", "unknown", "unknown", 0, 0, 1280, 720, 100, 80, 30, 0, 0); - EXPECT_TRUE(output != nullptr); - - if (output) - delete output; - DSWaylandCompositor::releaseInstance(); -} diff --git a/tests/DSWaylandPointer-test.cpp b/tests/DSWaylandPointer-test.cpp deleted file mode 100644 index 0156b07..0000000 --- a/tests/DSWaylandPointer-test.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandPointer.h" -#include "DSWaylandSeat.h" -#include "DSWaylandSurface.h" - -using namespace display_server; - -class DSWaylandPointerTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandPointerTest, NewDSWaylandPointer) -{ - DSWaylandPointer *pointer = new DSWaylandPointer(nullptr); - EXPECT_TRUE(pointer != nullptr); - - if (pointer) - delete pointer; -} - -TEST_F(DSWaylandPointerTest, GetSeat) -{ - DSWaylandSeat *seat = new DSWaylandSeat(nullptr, DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - DSWaylandPointer *pointer = new DSWaylandPointer(seat); - EXPECT_TRUE(pointer != nullptr); - - if (pointer) - { - EXPECT_TRUE(pointer->seat() == seat); - - delete pointer; - } - - delete seat; - } -} - -TEST_F(DSWaylandPointerTest, SetGetFocus) -{ - auto pointer = new DSWaylandPointer(nullptr); - EXPECT_TRUE(pointer != nullptr); - - if (pointer) - { - auto waylandSurface = std::make_unique(); - EXPECT_TRUE(waylandSurface != nullptr); - - if (waylandSurface) - { - pointer->setFocus(waylandSurface.get()); - EXPECT_TRUE(waylandSurface.get() == pointer->getFocus()); - } - } -} - -TEST_F(DSWaylandPointerTest, ResetFocus) -{ - auto pointer = new DSWaylandPointer(nullptr); - EXPECT_TRUE(pointer != nullptr); - - if (pointer) - { - pointer->resetFocus(); - EXPECT_TRUE(nullptr == pointer->getFocus()); - } -} - diff --git a/tests/DSWaylandProtocolTrace-test.cpp b/tests/DSWaylandProtocolTrace-test.cpp deleted file mode 100644 index c5451ce..0000000 --- a/tests/DSWaylandProtocolTrace-test.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandProtocolTrace.h" - -using namespace display_server; - -class DSWaylandProtocolTraceTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - setenv("E_INFO_RULE_FILE", "/tmp/rule", 1); - setenv("E_INFO_TRACE_FILE", "/tmp/trace", 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - unsetenv("E_INFO_RULE_FILE"); - unsetenv("E_INFO_TRACE_FILE"); - } -}; - -TEST_F(DSWaylandProtocolTraceTest, NewDSWaylandProtocolTrace) -{ - DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); - EXPECT_TRUE(pTrace != nullptr); - - if(pTrace) - DSWaylandProtocolTrace::releaseInstance(); -} - -TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceInit) -{ - DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); - static FILE *rule_file = NULL; - - if(pTrace) - { - rule_file = fopen("/tmp/rule", "a"); - if(!rule_file) - { - EXPECT_TRUE(false); - DSWaylandProtocolTrace::releaseInstance(); - return; - } - - EXPECT_TRUE(pTrace->init() == true); - - if(rule_file != nullptr) - { - fclose(rule_file); - rule_file = nullptr; - } - DSWaylandProtocolTrace::releaseInstance(); - } -} - -TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceUpdateRule) -{ - DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); - - if(pTrace) - { - pTrace->init(); - - int argc = 3; - const char *argv[3]; - argv[0] = "add"; - argv[1] = "ALLOW"; - argv[2] = "all"; - EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); - - argc = 2; - argv[0] = "remove"; - argv[1] = "all"; - argv[2] = nullptr; - EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); - - argc = 1; - argv[0] = "print"; - argv[1] = nullptr; - argv[2] = nullptr; - EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); - - argc = 1; - argv[0] = "help"; - argv[1] = nullptr; - argv[2] = nullptr; - EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); - - argc = 1; - argv[0] = "command"; - argv[1] = nullptr; - argv[2] = nullptr; - EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); - DSWaylandProtocolTrace::releaseInstance(); - } - -} - -TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceEnableTraceFalse) -{ - DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); - bool trace_state = false; //disable - - if(pTrace) - { - pTrace->init(); - EXPECT_TRUE(pTrace->enableProtocolTrace(trace_state) == 0); - DSWaylandProtocolTrace::releaseInstance(); - } -} - -TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceEnableTraceTrue) -{ - DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); - bool trace_state = true; - - if(pTrace) - { - pTrace->init(); - EXPECT_TRUE(pTrace->enableProtocolTrace(trace_state) == 1); - DSWaylandProtocolTrace::releaseInstance(); - } -} diff --git a/tests/DSWaylandSeat-test.cpp b/tests/DSWaylandSeat-test.cpp deleted file mode 100644 index 06f67b7..0000000 --- a/tests/DSWaylandSeat-test.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandSeat.h" -#include "DSSeat.h" -#include "DSXkb.h" - -using namespace display_server; - -class DSWaylandSeatTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandSeatTest, NewDSWaylandSeat) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - DSWaylandSeat *seat = new DSWaylandSeat(comp, DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - if (seat) - delete seat; - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandSeatTest, SetUpdateGetCapabilities) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - DSWaylandSeat *seat = new DSWaylandSeat(comp, DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - EXPECT_TRUE(DSWaylandSeat::capDefault == seat->getCapability()); - - seat->setCapability(DSWaylandSeat::capKeyboard); - EXPECT_TRUE(DSWaylandSeat::capKeyboard == seat->getCapability()); - - seat->setCapability(DSWaylandSeat::capPointer); - EXPECT_TRUE(DSWaylandSeat::capPointer == seat->getCapability()); - - seat->setCapability(DSWaylandSeat::capTouch); - EXPECT_TRUE(DSWaylandSeat::capTouch == seat->getCapability()); - - delete seat; - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandSeatTest, SetGetName) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - DSWaylandSeat *seat = new DSWaylandSeat(comp, DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - std::string sName{"seat0"}; - std::string gName; - - seat->setName(sName); - gName = seat->getName(); - EXPECT_TRUE(gName.compare(std::string{"seat0"}) == 0); - - delete seat; - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandSeatTest, getKeyboardPointerTouch) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - DSWaylandSeat *seat = new DSWaylandSeat(comp, DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - EXPECT_TRUE(seat->getPointer () != nullptr); - EXPECT_TRUE(seat->getKeyboard () != nullptr); - EXPECT_TRUE(seat->getTouch () != nullptr); - - delete seat; - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandSeatTest, GetSetCurrentEventTime) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - auto seat = new DSWaylandSeat(comp, DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - uint32_t currentTime = comp->currentTime(); - seat->setCurrentEventTime(currentTime); - EXPECT_TRUE(currentTime == seat->getCurrentEventTime()); - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandSeatTest, GetSetXkb) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - if (comp) - { - auto seat = new DSSeat(); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - auto xkb = seat->getXkb(); - EXPECT_TRUE(xkb != nullptr); - - if (xkb) - { - auto waylandSeat = new DSWaylandSeat(comp, DSWaylandSeat::capDefault); - EXPECT_TRUE(waylandSeat != nullptr); - - waylandSeat->setXkb(xkb); - EXPECT_TRUE(xkb == waylandSeat->getXkb()); - } - } - - DSWaylandCompositor::releaseInstance(); - } -} - diff --git a/tests/DSWaylandSurface-test.cpp b/tests/DSWaylandSurface-test.cpp deleted file mode 100644 index d8db123..0000000 --- a/tests/DSWaylandSurface-test.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandSurface.h" - -using namespace display_server; - -class DSWaylandSurfaceTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -static void -handle_global(void *data, struct wl_registry *registry, uint32_t name, - const char *interface, uint32_t version) -{ - struct TestClient *testClient = (struct TestClient *)data; - - if (strcmp(interface, "wl_compositor") == 0) { - testClient->compositor = (struct wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 1); - if (!testClient->compositor) - DSLOG_ERR("TEST", "wl_registry_bind compositor fails."); - } -} - -static void -handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) -{} - -static const struct wl_registry_listener registry_listener = { - handle_global, - handle_global_remove -}; - -TEST_F(DSWaylandSurfaceTest, NewDSWaylandSurface) -{ - auto waylandSurface = std::make_unique(); - EXPECT_TRUE(waylandSurface != nullptr); -} - -TEST_F(DSWaylandSurfaceTest, NewDSWaylandSurfaceWithPrams) -{ - DSWaylandCompositor *waylandCompositor = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(waylandCompositor != nullptr); - - if (waylandCompositor) - { - DSWaylandClient *waylandClient = new DSWaylandClient(waylandCompositor, (wl_client *)nullptr); - EXPECT_TRUE(waylandClient != nullptr); - - if (waylandClient) - { - auto waylandSurface = std::make_unique(waylandClient, 0); - EXPECT_TRUE(waylandSurface != nullptr); - - delete waylandClient; - } - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandSurfaceTest, registerCallbackSurfaceCommitted) -{ - auto mockWaylandCompositor = std::make_unique(); - - Ecore_Timer *serverQuitTimer = nullptr; - double severQuitTime = 1.0; - auto serverQuitFunc = [](void *data) -> Eina_Bool { - MockWaylandCompositor *comp = (MockWaylandCompositor *)data; - - // quit server - comp->quit(); - // check the emitting the surfaceCommitted - EXPECT_TRUE(comp->surfaceCommitted); - - return EINA_FALSE; - }; - serverQuitTimer = ecore_timer_loop_add(severQuitTime, serverQuitFunc, mockWaylandCompositor.get()); - EXPECT_TRUE(serverQuitTimer != nullptr); - - // create the wayland client which creates the wl_surface. - std::future clientThread = std::async(std::launch::async, []() -> bool { - std::this_thread::sleep_for(std::chrono::milliseconds(40)); - auto testClient = std::make_shared(); - - testClient->display = wl_display_connect(NULL); - EXPECT_TRUE(testClient->display != nullptr); - - testClient->registry = wl_display_get_registry(testClient->display); - wl_registry_add_listener(testClient->registry, ®istry_listener, testClient.get()); - wl_display_dispatch(testClient->display); - wl_display_roundtrip(testClient->display); - EXPECT_TRUE(testClient->compositor != nullptr); - - testClient->surface = wl_compositor_create_surface(testClient->compositor); - EXPECT_TRUE(testClient->surface != nullptr); - wl_display_roundtrip(testClient->display); - - testClient->tbm_client = wayland_tbm_client_init(testClient->display); - EXPECT_TRUE(testClient->tbm_client != nullptr); - testClient->tbmBuffer = tbm_surface_create(720, 1280, TBM_FORMAT_ARGB8888); - EXPECT_TRUE(testClient->tbmBuffer != nullptr); - testClient->buffer = wayland_tbm_client_create_buffer(testClient->tbm_client, testClient->tbmBuffer); - EXPECT_TRUE(testClient->buffer != nullptr); - - wl_surface_attach(testClient->surface, testClient->buffer, 0, 0); - wl_surface_damage(testClient->surface, 0, 0, 100, 100); - wl_surface_set_buffer_transform(testClient->surface, 0); - wl_surface_set_buffer_scale(testClient->surface, 1); - wl_surface_damage_buffer(testClient->surface, 0, 0, 100, 100); - wl_surface_frame(testClient->surface); - wl_surface_commit(testClient->surface); - - wl_display_roundtrip(testClient->display); - - wayland_tbm_client_destroy_buffer(testClient->tbm_client, testClient->buffer); - tbm_surface_destroy(testClient->tbmBuffer); - wayland_tbm_client_deinit(testClient->tbm_client); - - wl_display_disconnect(testClient->display); - - return true; - } - ); - - mockWaylandCompositor->run(); - EXPECT_TRUE(clientThread.get()); // join(wait) and get the return value. -} diff --git a/tests/DSWaylandTextInput-test.cpp b/tests/DSWaylandTextInput-test.cpp deleted file mode 100644 index 4dd5414..0000000 --- a/tests/DSWaylandTextInput-test.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTextInput.h" -#include "DSWaylandTextInputManager.h" - -using namespace display_server; - -class DSWaylandTextInputTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandTextInputTest, NewDSWaylandTextInput) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, ShowInputPanel) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->showInputPanel(); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, HideInputPanel) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->hideInputPanel(); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendCommitString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendCommitString(0, ""); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendPreeditString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendPreeditString(1, "", ""); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendPreeditStyling) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendPreeditStyling(1, 1, 1); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendPreeditCursor) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendPreeditCursor(0); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendDeleteSurroundingText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendDeleteSurroundingText(1, 1); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendCursorPosition) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendCursorPosition(1, 1); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendModifiersMap) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendModifiersMap(""); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendKeysym) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendKeysym(1, 10, 65, 1, 1); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendLanguage) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendLanguage(1, "en_US"); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendTextDirection) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendTextDirection(1, 1); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendSelectionRegion) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendSelectionRegion(1, 10, 20); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendPrivateCommand) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendPrivateCommand(1, "CONFORMANT_RESET"); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendInputPanelData) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendInputPanelData(1, "", 0); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendGetSelectionText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendGetSelectionText(5); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendGetSurroundingText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendGetSurroundingText(5, 10, 5); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendFilterKeyEventDone) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendFilterKeyEventDone(1, 0); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendInputPanelGeometry) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendInputPanelGeometry(0, 100, 200, 100); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendRecaptureString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendRecaptureString(1, 1, 0, "", "", ""); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendInputPanelEvent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendInputPanelEvent(1, 1, 0); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SendCommitContent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->sendCommitContent(1, "", "", ""); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, UpdatePanelState) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->updatePanelState(true); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, SetGeometryUpdated) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - textInput->setGeometryUpdated(true); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputTest, GetClientSurface) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); - EXPECT_TRUE(textInput != nullptr); - - (void)textInput->getClientSurface(); - - delete textInput; - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - diff --git a/tests/DSWaylandTextInputManager-test.cpp b/tests/DSWaylandTextInputManager-test.cpp deleted file mode 100644 index 03e34dd..0000000 --- a/tests/DSWaylandTextInputManager-test.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTextInputManager.h" - -using namespace display_server; - -class DSWaylandTextInputManagerTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandTextInputManagerTest, NewDSWaylandTextInputManager) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextCommitString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextCommitString(0, ""); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextPreeditString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextPreeditString(1, "", ""); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextPreeditStyling) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextPreeditStyling(1, 1, 1); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextPreeditCursor) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextPreeditCursor(0); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextDeleteSurroundingText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextDeleteSurroundingText(1, 1); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextCursorPosition) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextCursorPosition(1, 1); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextModifiersMap) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextModifiersMap(""); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextKeysym) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextKeysym(1, 10, 65, 1, 1); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextLanguage) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextLanguage(1, "en_US"); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextTextDirection) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextTextDirection(1, 1); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextSelectionRegion) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextSelectionRegion(1, 10, 20); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextPrivateCommand) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextPrivateCommand(1, "CONFORMANT_RESET"); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextUpdateInputPanelData) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextUpdateInputPanelData(1, "", 0); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextShowInputPanel) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextShowInputPanel(); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextHideInputPanel) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextHideInputPanel(); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextGetSelectionText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextGetSelectionText(5); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextGetSurroundingText) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextGetSurroundingText(5, 10, 5); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextFilterKeyEventDone) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextFilterKeyEventDone(1, 0); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextUpdateIseGeometry) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextUpdateIseGeometry(0, 100, 200, 100); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextRecaptureString) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextRecaptureString(1, 1, 0, "", "", ""); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextInputPanelEvent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextInputPanelEvent(1, 1, 0); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, ContextCommitContent) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->contextCommitContent(1, "", "", ""); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, UpdateTextInputPanelState) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->updateTextInputPanelState(true); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, SetGeometryUpdated) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - textInputManager->setGeometryUpdated(true); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTextInputManagerTest, GetTextInputSurface) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); - EXPECT_TRUE(textInputManager != nullptr); - - (void)textInputManager->getTextInputSurface(); - - delete textInputManager; - DSWaylandCompositor::releaseInstance(); -} - diff --git a/tests/DSWaylandTizenAppinfo-test.cpp b/tests/DSWaylandTizenAppinfo-test.cpp deleted file mode 100644 index b77fe57..0000000 --- a/tests/DSWaylandTizenAppinfo-test.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include -#include "DSWaylandTizenAppinfo.h" -#include "DSTizenAppinfoMgr.h" - -using namespace display_server; - -class DSWaylandTizenAppinfoTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenAppinfoTest, New_Appinfo) -{ - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenAppinfo *tzAppinfo = new DSWaylandTizenAppinfo(compositor); - EXPECT_TRUE(tzAppinfo != nullptr); - - if (tzAppinfo) - delete tzAppinfo; - - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTizenAppinfoTest, New_Appinfo_with_AppinfoMgr) -{ - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSTizenAppinfoMgr *dsAppinfoMgr = DSTizenAppinfoMgr::getInstance(); - DSWaylandTizenAppinfo *tzAppinfo = new DSWaylandTizenAppinfo(compositor, dsAppinfoMgr); - EXPECT_TRUE(tzAppinfo != nullptr); - - if (tzAppinfo) - delete tzAppinfo; - - DSTizenAppinfoMgr::releaseInstance(); - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTizenAppinfoTest, Initialize_Appinfo) -{ - bool ret; - - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenAppinfo *tzAppinfo = new DSWaylandTizenAppinfo(compositor); - - ret = tzAppinfo->initialize(compositor); - EXPECT_TRUE(ret == true); - - if (tzAppinfo) - delete tzAppinfo; - - DSWaylandCompositor::releaseInstance(); -} - -static struct tizen_launch_appinfo *tz_appinfo = nullptr; - -static void -handle_global(void *data, struct wl_registry *registry, uint32_t name, - const char *interface, uint32_t version) -{ - struct TestClient *testClient = (struct TestClient *)data; - - if (strcmp(interface, "wl_compositor") == 0) { - testClient->compositor = (struct wl_compositor *)wl_registry_bind(registry, name, &wl_compositor_interface, 1); - if (!testClient->compositor) - DSLOG_ERR("TEST", "wl_registry_bind compositor fails."); - } - else if(strcmp(interface, "tizen_launch_appinfo") == 0) - { - const char * appId = "com.samsung.clocksetting"; - - tz_appinfo = (struct tizen_launch_appinfo *)wl_registry_bind(registry, name, &tizen_launch_appinfo_interface, 1); - - tizen_launch_appinfo_register_appid(tz_appinfo, appId); - tizen_launch_appinfo_set_pid(tz_appinfo, appId, 4077); - tizen_launch_appinfo_deregister_appid(tz_appinfo, appId); - } -} - -static void -handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) -{} - -static const struct wl_registry_listener registry_listener = { - handle_global, - handle_global_remove -}; -TEST_F(DSWaylandTizenAppinfoTest, testRequest_Appinfo) -{ - auto mockWaylandCompositor = std::make_unique(); - - Ecore_Timer *serverQuitTimer = nullptr; - double severQuitTime = 1.0; - auto serverQuitFunc = [](void *data) -> Eina_Bool { - MockWaylandCompositor *comp = (MockWaylandCompositor *)data; - - // quit server - comp->quit(); - // check the emitting the surfaceCreated - EXPECT_TRUE(tz_appinfo != nullptr); - - return EINA_FALSE; - }; - serverQuitTimer = ecore_timer_loop_add(severQuitTime, serverQuitFunc, mockWaylandCompositor.get()); - EXPECT_TRUE(serverQuitTimer != nullptr); - - // create the wayland client which creates the wl_surface. - std::future clientThread = std::async(std::launch::async, []() -> bool { - std::this_thread::sleep_for(std::chrono::milliseconds(40)); - auto testClient = std::make_shared(); - - testClient->display = wl_display_connect(NULL); - EXPECT_TRUE(testClient->display != nullptr); - - testClient->registry = wl_display_get_registry(testClient->display); - wl_registry_add_listener(testClient->registry, ®istry_listener, testClient.get()); - wl_display_dispatch(testClient->display); - wl_display_roundtrip(testClient->display); - EXPECT_TRUE(testClient->compositor != nullptr); - - wl_display_disconnect(testClient->display); - - return true; - } - ); - - mockWaylandCompositor->run(); - EXPECT_TRUE(clientThread.get()); // join(wait) and get the return value. -} diff --git a/tests/DSWaylandTizenIndicator-test.cpp b/tests/DSWaylandTizenIndicator-test.cpp deleted file mode 100644 index 2f3c4eb..0000000 --- a/tests/DSWaylandTizenIndicator-test.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTizenIndicator.h" - -using namespace display_server; - -class DSWaylandTizenIndicatorTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenIndicatorTest, NewDSWaylandTizenIndicator) -{ - DSWaylandTizenIndicator *tzInd = new DSWaylandTizenIndicator; - EXPECT_TRUE(tzInd != nullptr); - - if (tzInd) - delete tzInd; -} - -TEST_F(DSWaylandTizenIndicatorTest, VisibleTypeSetGet) -{ - DSWaylandTizenIndicator *tzInd = new DSWaylandTizenIndicator; - EXPECT_TRUE(tzInd != nullptr); - - tzInd->setVisibleType(DSWaylandTizenIndicator::DS_INDICATOR_VISIBLE_TYPE_SHOWN); - EXPECT_TRUE(tzInd->getVisibleType() == DSWaylandTizenIndicator::DS_INDICATOR_VISIBLE_TYPE_SHOWN); - - if (tzInd) - delete tzInd; -} diff --git a/tests/DSWaylandTizenInputDevice-test.cpp b/tests/DSWaylandTizenInputDevice-test.cpp deleted file mode 100644 index 8ca5d0a..0000000 --- a/tests/DSWaylandTizenInputDevice-test.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTizenInputDevice.h" - -using namespace display_server; - -class DSWaylandTizenInputDeviceTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenInputDeviceTest, NewDSWaylandTizenInputDevice) -{ - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(compositor != nullptr); - - if (compositor) - { - DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); - EXPECT_TRUE(inputDeviceManager != nullptr); - - if (inputDeviceManager) - { - DSWaylandTizenInputDevice *inputDevice = new DSWaylandTizenInputDevice(inputDeviceManager); - EXPECT_TRUE(inputDevice != nullptr); - - delete inputDevice; - delete inputDeviceManager; - } - - DSWaylandCompositor::releaseInstance(); - } -} - diff --git a/tests/DSWaylandTizenInputDeviceManager-test.cpp b/tests/DSWaylandTizenInputDeviceManager-test.cpp deleted file mode 100644 index 09836aa..0000000 --- a/tests/DSWaylandTizenInputDeviceManager-test.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTizenInputDeviceManager.h" - -using namespace display_server; - -class DSWaylandTizenInputDeviceManagerTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenInputDeviceManagerTest, NewDSWaylandTizenInputDeviceManager) -{ - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(compositor != nullptr); - - if (compositor) - { - DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); - EXPECT_TRUE(inputDeviceManager != nullptr); - - if (inputDeviceManager) - delete inputDeviceManager; - - DSWaylandCompositor::releaseInstance(); - } -} - -TEST_F(DSWaylandTizenInputDeviceManagerTest, getTizenInputDevice) -{ - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(compositor != nullptr); - - if (compositor) - { - DSWaylandTizenInputDeviceManager *inputDeviceManager = new DSWaylandTizenInputDeviceManager(compositor); - EXPECT_TRUE(inputDeviceManager != nullptr); - - if (inputDeviceManager) - { - EXPECT_TRUE(inputDeviceManager->getTizenInputDevice()); - - delete inputDeviceManager; - } - - DSWaylandCompositor::releaseInstance(); - } -} - diff --git a/tests/DSWaylandTizenLaunchEffect-test.cpp b/tests/DSWaylandTizenLaunchEffect-test.cpp deleted file mode 100644 index 14ed80a..0000000 --- a/tests/DSWaylandTizenLaunchEffect-test.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTizenLaunchEffect.h" - -using namespace display_server; - -class DSWaylandTizenLaunchEffectTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenLaunchEffectTest, New_LaunchEffect) -{ - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenLaunchEffect *tzLaunchEffect = new DSWaylandTizenLaunchEffect(compositor); - EXPECT_TRUE(tzLaunchEffect != nullptr); - - if (tzLaunchEffect) - delete tzLaunchEffect; - - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTizenLaunchEffectTest, Initialize_LaunchEffect) -{ - bool ret; - - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenLaunchEffect *tzLaunchEffect = new DSWaylandTizenLaunchEffect(compositor); - - ret = tzLaunchEffect->initialize(compositor); - EXPECT_TRUE(ret == true); - - if (tzLaunchEffect) - delete tzLaunchEffect; - - DSWaylandCompositor::releaseInstance(); -} diff --git a/tests/DSWaylandTizenPolicy-test.cpp b/tests/DSWaylandTizenPolicy-test.cpp deleted file mode 100644 index 27ab7df..0000000 --- a/tests/DSWaylandTizenPolicy-test.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandCompositor.h" -#include "DSWaylandTizenPolicy.h" - -using namespace display_server; - -class DSWaylandTizenPolicyTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenPolicyTest, new_P1) -{ - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(compositor); - delete tizenPolicy; - EXPECT_TRUE(true); - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTizenPolicyTest, initialize_P1) -{ - bool ret; - - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(compositor); - - ret = tizenPolicy->initialize(compositor); - EXPECT_TRUE(ret == true); - - delete tizenPolicy; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTizenPolicyTest, initialize_P2) -{ - bool ret; - - DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); - DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(nullptr); - - ret = tizenPolicy->initialize(compositor); - EXPECT_TRUE(ret == true); - - delete tizenPolicy; - DSWaylandCompositor::releaseInstance(); -} - -TEST_F(DSWaylandTizenPolicyTest, initialize_N1) -{ - bool ret; - DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(nullptr); - - ret = tizenPolicy->initialize(nullptr); - EXPECT_TRUE(ret == false); - - delete tizenPolicy; -} diff --git a/tests/DSWaylandTizenPolicyExt-test.cpp b/tests/DSWaylandTizenPolicyExt-test.cpp deleted file mode 100644 index 0f27e06..0000000 --- a/tests/DSWaylandTizenPolicyExt-test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTizenPolicyExt.h" - -using namespace display_server; - -class DSWaylandTizenPolicyExtTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenPolicyExtTest, NewDSWaylandTizenPolicyExt) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTizenPolicyExt *tizenPolicyExt = new DSWaylandTizenPolicyExt(comp); - EXPECT_TRUE(tizenPolicyExt != nullptr); - - if (tizenPolicyExt) - delete tizenPolicyExt; - DSWaylandCompositor::releaseInstance(); -} diff --git a/tests/DSWaylandTizenSurface-test.cpp b/tests/DSWaylandTizenSurface-test.cpp deleted file mode 100644 index ec979e4..0000000 --- a/tests/DSWaylandTizenSurface-test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTizenSurface.h" - -using namespace display_server; - -class DSWaylandTizenSurfaceTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenSurfaceTest, NewDSWaylandTizenSurface) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTizenSurface *tizenSurface = new DSWaylandTizenSurface(comp); - EXPECT_TRUE(tizenSurface != nullptr); - - if (tizenSurface) - delete tizenSurface; - DSWaylandCompositor::releaseInstance(); -} diff --git a/tests/DSWaylandTizenSurfaceShm-test.cpp b/tests/DSWaylandTizenSurfaceShm-test.cpp deleted file mode 100644 index 4579b4c..0000000 --- a/tests/DSWaylandTizenSurfaceShm-test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTizenSurfaceShm.h" - -using namespace display_server; - -class DSWaylandTizenSurfaceShmTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandTizenSurfaceShmTest, NewDSWaylandTizenSurfaceShm) -{ - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - DSWaylandTizenSurfaceShm *shm = new DSWaylandTizenSurfaceShm(comp); - EXPECT_TRUE(shm != nullptr); - - if (shm) - delete shm; - DSWaylandCompositor::releaseInstance(); -} diff --git a/tests/DSWaylandTouch-test.cpp b/tests/DSWaylandTouch-test.cpp deleted file mode 100644 index ee43b32..0000000 --- a/tests/DSWaylandTouch-test.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandTouch.h" -#include "DSWaylandSeat.h" -#include "DSWaylandSurface.h" - -using namespace display_server; - -class DSWaylandTouchTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -/* Test cases */ -TEST_F(DSWaylandTouchTest, NewDSWaylandTouch) -{ - DSWaylandTouch *touch = new DSWaylandTouch(nullptr); - EXPECT_TRUE(touch != nullptr); - - if (touch) - delete touch; -} - -TEST_F(DSWaylandTouchTest, GetSeat) -{ - DSWaylandSeat *seat = new DSWaylandSeat(nullptr, DSWaylandSeat::capDefault); - EXPECT_TRUE(seat != nullptr); - - if (seat) - { - DSWaylandTouch *touch = new DSWaylandTouch(seat); - EXPECT_TRUE(touch != nullptr); - - if (touch) - { - EXPECT_TRUE(touch->seat() == seat); - - delete touch; - } - - delete seat; - } -} - -TEST_F(DSWaylandTouchTest, SetGetFocus) -{ - auto touch = new DSWaylandTouch(nullptr); - EXPECT_TRUE(touch != nullptr); - - if (touch) - { - auto waylandSurface = std::make_unique(); - EXPECT_TRUE(waylandSurface != nullptr); - - if (waylandSurface) - { - touch->setFocus(waylandSurface.get()); - EXPECT_TRUE(waylandSurface.get() == touch->getFocus()); - } - } -} - -TEST_F(DSWaylandTouchTest, ResetFocus) -{ - auto touch = new DSWaylandTouch(nullptr); - EXPECT_TRUE(touch != nullptr); - - if (touch) - { - touch->resetFocus(); - EXPECT_TRUE(nullptr == touch->getFocus()); - } -} - diff --git a/tests/DSWaylandZxdgShellV6-test.cpp b/tests/DSWaylandZxdgShellV6-test.cpp deleted file mode 100644 index 593bbc0..0000000 --- a/tests/DSWaylandZxdgShellV6-test.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandZxdgShellV6.h" - -using namespace display_server; - -class DSWaylandZxdgShellV6Test : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgShellV6) -{ - DSWaylandZxdgShellV6 *zxdgShell = new DSWaylandZxdgShellV6; - EXPECT_TRUE(zxdgShell != nullptr); - - if (zxdgShell) - delete zxdgShell; -} - -TEST_F(DSWaylandZxdgShellV6Test, ShellAddSurface) -{ - DSWaylandZxdgShellV6 *zxdgShell = new DSWaylandZxdgShellV6; - DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(zxdgShell); - EXPECT_TRUE(zxdgShell != nullptr); - EXPECT_TRUE(zxdgSurface != nullptr); - - zxdgShell->addSurface(zxdgSurface); - EXPECT_TRUE(true); - - if (zxdgSurface) delete zxdgSurface; - if (zxdgShell) delete zxdgShell; -} - -TEST_F(DSWaylandZxdgShellV6Test, ShellGetSurfaceList) -{ - DSWaylandZxdgShellV6 *zxdgShell = new DSWaylandZxdgShellV6; - DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(zxdgShell); - 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 (zxdgSurface) delete zxdgSurface; - if (zxdgShell) delete zxdgShell; -} - -TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgPositionerV6) -{ - DSWaylandZxdgPositionerV6 *zxdgPositioner = new DSWaylandZxdgPositionerV6; - EXPECT_TRUE(zxdgPositioner != nullptr); - - if (zxdgPositioner) - delete zxdgPositioner; -} - -TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgSurfaceV6) -{ - DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(nullptr); - EXPECT_TRUE(zxdgSurface != nullptr); - - if (zxdgSurface) - delete zxdgSurface; -} - -TEST_F(DSWaylandZxdgShellV6Test, SetSurface) -{ - auto dsSurface = std::make_shared(); - EXPECT_TRUE(dsSurface != nullptr); - - auto zxdgSurface = std::make_shared(nullptr); - EXPECT_TRUE(zxdgSurface != nullptr); - - if (zxdgSurface && dsSurface) - { - DSWaylandSurface *ptrDsSurface = dsSurface.get(); - zxdgSurface->setSurface(ptrDsSurface); - - DSWaylandSurface *resultSurf = zxdgSurface->getSurface(); - EXPECT_TRUE(resultSurf == ptrDsSurface); - } -} - -TEST_F(DSWaylandZxdgShellV6Test, SurfaceSetWindowTitle) -{ - DSWaylandZxdgSurfaceV6 *zxdgSurface = new DSWaylandZxdgSurfaceV6(nullptr); - 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(nullptr); - 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; - EXPECT_TRUE(zxdgToplevel != nullptr); - - if (zxdgToplevel) - delete zxdgToplevel; -} - -TEST_F(DSWaylandZxdgShellV6Test, NewDSWaylandZxdgPopupV6) -{ - DSWaylandZxdgPopupV6 *zxdgPopup = new DSWaylandZxdgPopupV6; - EXPECT_TRUE(zxdgPopup != nullptr); - - if (zxdgPopup) - delete zxdgPopup; -} - diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp deleted file mode 100644 index 0cb0eaf..0000000 --- a/tests/DSWindow-test.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSObject.h" -#include "DSWindow.h" -#include "DSWindowShell.h" -#include "DSStruct.h" - -using namespace display_server; - -class DSWindowTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWindowTest, NewDSWindow) -{ - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); -} - -TEST_F(DSWindowTest, NewDSWindowWithDSWaylandSurface) -{ - auto waylandSurface = std::make_shared(); - EXPECT_TRUE(waylandSurface != nullptr); - auto window = std::make_shared(waylandSurface); - EXPECT_TRUE(window != nullptr); -} - -TEST_F(DSWindowTest, BasicMethods) -{ - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); - - EXPECT_TRUE(win->show() == true); - EXPECT_TRUE(win->hide(true) == true); - EXPECT_TRUE(win->showState() == 0); - - EXPECT_TRUE(win->setLayer(100) == true); - - EXPECT_TRUE(win->raise() == true); - EXPECT_TRUE(win->lower() == true); - - EXPECT_TRUE(win->hasFocus() == false); - EXPECT_TRUE(win->setFocus() == true); - EXPECT_TRUE(win->hasFocus() == true); - EXPECT_TRUE(win->unsetFocus() == true); - EXPECT_TRUE(win->hasFocus() != true); -} - -TEST_F(DSWindowTest, SizeTest) -{ - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); - - stSize size = win->getSize(); - EXPECT_TRUE(size.w == 0); - EXPECT_TRUE(size.h == 0); - - win->setSize(1280, 720); - size = win->getSize(); - EXPECT_TRUE(size.w == 1280); - EXPECT_TRUE(size.h == 720); - - stSize sSize; - sSize.w = 700; - sSize.h = 700; - win->setSize(sSize); - - size = win->getSize(); - EXPECT_TRUE(size.w == sSize.w); - EXPECT_TRUE(size.h == sSize.h); -} - -TEST_F(DSWindowTest, PositionTest) -{ - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); - - stPosition pos = win->getPosition(); - EXPECT_TRUE(pos.x == 0); - EXPECT_TRUE(pos.y == 0); - - win->setPosition(100, 200); - pos = win->getPosition(); - EXPECT_TRUE(pos.x == 100); - EXPECT_TRUE(pos.y == 200); -} - -TEST_F(DSWindowTest, WindowShellTest) -{ - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); - - auto winShell = std::make_shared(win.get()); - EXPECT_TRUE(winShell != nullptr); -} - -TEST_F(DSWindowTest, TitleTest) -{ - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); - - bool ret = false; - ret = win->setTitle("test title"); - EXPECT_TRUE(ret == true); - - std::string title = win->getTitle(); - EXPECT_TRUE(title.compare("test title") == 0); -} - -TEST_F(DSWindowTest, SkipFocusTest) -{ - bool ret; - bool skip; - - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); - - skip = win->getSkipFocus(); - EXPECT_TRUE(skip == false); - - ret = win->setSkipFocus(true); - EXPECT_TRUE(ret == true); - - skip = win->getSkipFocus(); - EXPECT_TRUE(skip == true); - - ret = win->setSkipFocus(false); - EXPECT_TRUE(ret == true); - - skip = win->getSkipFocus(); - EXPECT_TRUE(skip == false); -} - -TEST_F(DSWindowTest, ParentTest) -{ - auto parent = std::make_shared(); - EXPECT_TRUE(parent != nullptr); - EXPECT_TRUE(parent->getParent() == nullptr); - - auto child = std::make_shared(); - EXPECT_TRUE(child != nullptr); - EXPECT_TRUE(child->getParent() == nullptr); - - child->setParent(parent.get()); - EXPECT_TRUE(child->getParent() == parent.get()); - - child->setParent(nullptr); - EXPECT_TRUE(child->getParent() == nullptr); - - child->setParent(child.get()); - EXPECT_TRUE(child->getParent() == nullptr); -} - -TEST_F(DSWindowTest, UserGeometryTest) -{ - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); - - EXPECT_FALSE(win->isAllowUserGeometry()); - - win->allowUserGeometry(true); - EXPECT_TRUE(win->isAllowUserGeometry()); -} - -TEST_F(DSWindowTest, TypeTest) -{ - auto win = std::make_shared(); - EXPECT_TRUE(win != nullptr); - - int type; - type = win->getType(); - EXPECT_TRUE(type == 0); - - win->setType(3); - - type = win->getType(); - EXPECT_TRUE(type == 3); -} diff --git a/tests/DSWindowManager-test.cpp b/tests/DSWindowManager-test.cpp deleted file mode 100644 index 43f5d02..0000000 --- a/tests/DSWindowManager-test.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSWaylandCompositor.h" -#include "DSWindowManager.h" -#include "DSZone.h" -#include "DSWindow.h" -#include "DSWaylandSurface.h" - - -using namespace display_server; - -class DSWindowManagerTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWindowManagerTest, GetWindowManager) -{ - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - DSWindowManager::releaseInstance(); -} - -TEST_F(DSWindowManagerTest, RegisterWindow) -{ - bool ret = false; - DSZone *foundZone = nullptr; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto window = std::make_shared(); - EXPECT_TRUE(window != nullptr); - - foundZone = winMgr->getZone(window.get()); - EXPECT_TRUE(foundZone == nullptr); - - ret = winMgr->registerWindow(zone.get(), window.get()); - EXPECT_TRUE(ret == true); - - foundZone = winMgr->getZone(window.get()); - EXPECT_TRUE(foundZone == zone.get()); - - winMgr->unregisterWindow(zone.get(), window.get()); - - foundZone = winMgr->getZone(window.get()); - EXPECT_TRUE(foundZone == nullptr); - - DSWindowManager::releaseInstance(); -} - -TEST_F(DSWindowManagerTest, RegisterSurface) -{ - bool ret = false; - DSZone *foundZone = nullptr; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto surface = std::make_shared(); - EXPECT_TRUE(surface != nullptr); - - foundZone = winMgr->getZone(surface.get()); - EXPECT_TRUE(foundZone == nullptr); - - ret = winMgr->registerSurface(zone.get(), surface.get()); - EXPECT_TRUE(ret == true); - - foundZone = winMgr->getZone(surface.get()); - EXPECT_TRUE(foundZone == zone.get()); - - winMgr->unregisterSurface(zone.get(), surface.get()); - - foundZone = winMgr->getZone(surface.get()); - EXPECT_TRUE(foundZone == nullptr); - - DSWindowManager::releaseInstance(); -} - -TEST_F(DSWindowManagerTest, ParentTest_P1) -{ - bool ret = false; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto surface = std::make_shared(); - EXPECT_TRUE(surface != nullptr); - - auto surface2 = std::make_shared(); - EXPECT_TRUE(surface2 != nullptr); - - zone->testCreateWindow(surface); - zone->testCreateWindow(surface2); - - ret = winMgr->registerSurface(zone.get(), surface.get()); - EXPECT_TRUE(ret == true); - - ret = winMgr->registerSurface(zone.get(), surface2.get()); - EXPECT_TRUE(ret == true); - - ret = winMgr->setWindowParent(surface.get(), nullptr); - EXPECT_TRUE(ret == true); - - ret = winMgr->setWindowParent(surface.get(), surface2.get()); - EXPECT_TRUE(ret == true); - - DSWindowManager::releaseInstance(); -} - -TEST_F(DSWindowManagerTest, ParentTest_N1) -{ - bool ret = false; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto zone2 = std::make_shared(); - EXPECT_TRUE(zone2 != nullptr); - - auto surface = std::make_shared(); - EXPECT_TRUE(surface != nullptr); - - auto surface2 = std::make_shared(); - EXPECT_TRUE(surface2 != nullptr); - - // Not registered to DSZone - ret = winMgr->setWindowParent(surface.get(), surface2.get()); - EXPECT_TRUE(ret == false); - - winMgr->registerSurface(zone.get(), surface.get()); - winMgr->registerSurface(zone2.get(), surface2.get()); - - // Not SAME DSZone - ret = winMgr->setWindowParent(surface.get(), surface2.get()); - EXPECT_TRUE(ret == false); - - DSWindowManager::releaseInstance(); -} - -TEST_F(DSWindowManagerTest, PropertyTest) -{ - bool ret = false; - DSWindow *window = nullptr; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto surface = std::make_shared(); - EXPECT_TRUE(surface != nullptr); - - DSWaylandSurface *surface_ptr = surface.get(); - EXPECT_TRUE(surface_ptr != nullptr); - - zone->testCreateWindow(surface); - - ret = winMgr->registerSurface(zone.get(), surface_ptr); - EXPECT_TRUE(ret == true); - - std::list> winList = zone->getWindowList(); - for (auto w : winList) - { - if (w->surface() == surface_ptr) - { - window = w.get(); - } - } - EXPECT_TRUE(window != nullptr); - - winMgr->setWindowTitle(surface_ptr, "test"); - const std::string str = window->getTitle(); - EXPECT_TRUE(str == "test"); - - winMgr->setWindowType(surface_ptr, 3); - - winMgr->setWindowAllowUserGeometry(surface_ptr, true); - winMgr->setWindowGeometry(surface_ptr, 100, 200, 320, 480); - stGeometry geo = winMgr->getWindowGeometry(surface_ptr); - EXPECT_TRUE(geo.x == 100); - EXPECT_TRUE(geo.y == 200); - EXPECT_TRUE(geo.w == 320); - EXPECT_TRUE(geo.h == 480); - - winMgr->setWindowPosition(surface_ptr, 50, 100); - geo = winMgr->getWindowGeometry(surface_ptr); - EXPECT_TRUE(geo.x == 50); - EXPECT_TRUE(geo.y == 100); - - DSWindowManager::releaseInstance(); -} - -TEST_F(DSWindowManagerTest, AuxHintsTest) -{ - bool ret = false; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto surface = std::make_shared(); - EXPECT_TRUE(surface != nullptr); - - DSWaylandSurface *surface_ptr = surface.get(); - EXPECT_TRUE(surface_ptr != nullptr); - - zone->testCreateWindow(surface); - - ret = winMgr->registerSurface(zone.get(), surface_ptr); - EXPECT_TRUE(ret == true); - - std::list auxList = winMgr->getWindowSupportedAuxHints(surface_ptr); - EXPECT_TRUE(auxList.size() > 0); - - winMgr->addWindowAuxHint(surface_ptr, 1, "wm.policy.win.user.geometry", "1"); - winMgr->setWindowGeometry(surface_ptr, 100, 200, 320, 480); - stGeometry geo = winMgr->getWindowGeometry(surface_ptr); - EXPECT_TRUE(geo.x == 100); - EXPECT_TRUE(geo.y == 200); - EXPECT_TRUE(geo.w == 320); - EXPECT_TRUE(geo.h == 480); - - winMgr->changeWindowAuxHint(surface_ptr, 1, "0"); - geo = winMgr->getWindowGeometry(surface_ptr); - EXPECT_TRUE(geo.x == 0); - EXPECT_TRUE(geo.y == 0); - - winMgr->removeWindowAuxHint(surface_ptr, 1); - - DSWindowManager::releaseInstance(); -} - -TEST_F(DSWindowManagerTest, StackTest) -{ - bool ret = false; - DSWindow *resultWindow[3]; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto surface0 = std::make_shared(); - EXPECT_TRUE(surface0 != nullptr); - DSWaylandSurface *surface_ptr0 = surface0.get(); - EXPECT_TRUE(surface_ptr0 != nullptr); - - auto surface1 = std::make_shared(); - EXPECT_TRUE(surface1 != nullptr); - DSWaylandSurface *surface_ptr1 = surface1.get(); - EXPECT_TRUE(surface_ptr1 != nullptr); - - auto surface2 = std::make_shared(); - EXPECT_TRUE(surface2 != nullptr); - DSWaylandSurface *surface_ptr2 = surface2.get(); - EXPECT_TRUE(surface_ptr2 != nullptr); - - zone->testCreateWindow(surface0); - zone->testCreateWindow(surface1); - zone->testCreateWindow(surface2); - - ret = winMgr->registerSurface(zone.get(), surface_ptr0); - EXPECT_TRUE(ret == true); - ret = winMgr->registerSurface(zone.get(), surface_ptr1); - EXPECT_TRUE(ret == true); - ret = winMgr->registerSurface(zone.get(), surface_ptr2); - EXPECT_TRUE(ret == true); - - std::list> winList = zone->getWindowList(); - int id = 0; - for (auto w : winList) - { - resultWindow[id] = w.get(); - id++; - } - EXPECT_TRUE(resultWindow[0]->surface() == surface_ptr2); - EXPECT_TRUE(resultWindow[1]->surface() == surface_ptr1); - EXPECT_TRUE(resultWindow[2]->surface() == surface_ptr0); - - // ACTIVATE window - winMgr->activateWindow(surface_ptr0); - - winList = zone->getWindowList(); - id = 0; - for (auto w : winList) - { - resultWindow[id] = w.get(); - id++; - } - EXPECT_TRUE(resultWindow[0]->surface() == surface_ptr0); - EXPECT_TRUE(resultWindow[1]->surface() == surface_ptr2); - EXPECT_TRUE(resultWindow[2]->surface() == surface_ptr1); - - // LOWER window - winMgr->lowerWindow(surface_ptr2); - - winList = zone->getWindowList(); - id = 0; - for (auto w : winList) - { - resultWindow[id] = w.get(); - id++; - } - EXPECT_TRUE(resultWindow[0]->surface() == surface_ptr0); - EXPECT_TRUE(resultWindow[1]->surface() == surface_ptr1); - EXPECT_TRUE(resultWindow[2]->surface() == surface_ptr2); - - // RAISE window - winMgr->raiseWindow(surface_ptr2); - - winList = zone->getWindowList(); - id = 0; - for (auto w : winList) - { - resultWindow[id] = w.get(); - id++; - } - EXPECT_TRUE(resultWindow[0]->surface() == surface_ptr2); - EXPECT_TRUE(resultWindow[1]->surface() == surface_ptr0); - EXPECT_TRUE(resultWindow[2]->surface() == surface_ptr1); - - DSWindowManager::releaseInstance(); -} - -TEST_F(DSWindowManagerTest, FocusTest) -{ - bool ret = false; - DSWindow *window = nullptr; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto surface = std::make_shared(); - EXPECT_TRUE(surface != nullptr); - - DSWaylandSurface *surface_ptr = surface.get(); - EXPECT_TRUE(surface_ptr != nullptr); - - zone->testCreateWindow(surface); - - ret = winMgr->registerSurface(zone.get(), surface_ptr); - EXPECT_TRUE(ret == true); - - std::list> winList = zone->getWindowList(); - for (auto w : winList) - { - if (w->surface() == surface_ptr) - { - window = w.get(); - } - } - EXPECT_TRUE(window != nullptr); - - EXPECT_TRUE(window->getSkipFocus() == false); - - winMgr->setWindowSkipFocus(surface_ptr, true); - EXPECT_TRUE(window->getSkipFocus() == true); -} - -TEST_F(DSWindowManagerTest, KeyboardTest) -{ - bool ret = false; - - DSWindowManager *winMgr = DSWindowManager::getInstance(); - EXPECT_TRUE(winMgr != nullptr); - - auto zone = std::make_shared(); - EXPECT_TRUE(zone != nullptr); - - auto surface = std::make_shared(); - EXPECT_TRUE(surface != nullptr); - - DSWaylandSurface *surface_ptr = surface.get(); - EXPECT_TRUE(surface_ptr != nullptr); - - zone->testCreateWindow(surface); - - ret = winMgr->registerSurface(zone.get(), surface_ptr); - EXPECT_TRUE(ret == true); - - ret = winMgr->setWindowVkbdFloating(surface_ptr, true); - EXPECT_TRUE(ret == true); - - ret = winMgr->getWindowVkbdFloating(surface_ptr); - EXPECT_TRUE(ret == true); - - ret = winMgr->setWindowVkbdFloating(surface_ptr, false); - EXPECT_TRUE(ret == true); - - ret = winMgr->getWindowVkbdFloating(surface_ptr); - EXPECT_TRUE(ret == false); -} - diff --git a/tests/DSWindowShell-test.cpp b/tests/DSWindowShell-test.cpp deleted file mode 100644 index 0eae594..0000000 --- a/tests/DSWindowShell-test.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSObject.h" -#include "DSZone.h" -#include "DSWindow.h" -#include "DSWindowShell.h" -#include "IDSWaylandShell.h" -#include "DSWaylandZxdgShellV6.h" - -using namespace display_server; - -class DSWindowShellTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSWindowShellTest, NewDSWindowShell) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); -} - -TEST_F(DSWindowShellTest, create_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(nullptr) == true); -} - -TEST_F(DSWindowShellTest, create_P2) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); -} - -TEST_F(DSWindowShellTest, zone_P1) -{ - auto zone = std::make_shared(); - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->setZone(zone.get())); - - DSZone *tZone = winShell->getZone(); - EXPECT_TRUE(zone.get() == tZone); -} - -TEST_F(DSWindowShellTest, shellSurface_P1) -{ -/* - DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); - EXPECT_TRUE(comp != nullptr); - - auto zone = std::make_shared(); - auto window = std::make_shared(); - auto zxdgShell = std::make_shared(comp); - auto shellSurface = std::make_shared(zxdgShell.get()); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - winShell->setShellSurface(shellSurface.get()); - - DSWaylandZxdgSurfaceV6 *tShellSurface = (DSWaylandZxdgSurfaceV6*)winShell->getShellSurface(); - EXPECT_TRUE(shellSurface.get() == tShellSurface); - - DSWaylandCompositor::releaseInstance(); -*/ -} - -TEST_F(DSWindowShellTest, window_P1) -{ - auto zone = std::make_shared(); - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - DSWindow *tWindow = winShell->getWindow(); - EXPECT_TRUE(window.get() == tWindow); -} - -TEST_F(DSWindowShellTest, parent_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->getParent() == nullptr); - - auto childWindow = std::make_shared(); - std::unique_ptr childWinShell = std::make_unique(childWindow.get()); - EXPECT_TRUE(childWinShell != nullptr); - - EXPECT_TRUE(childWinShell->setParent(winShell.get()) == true); - EXPECT_TRUE(childWinShell->getParent() == winShell.get()); - - // test for set parent each other - EXPECT_TRUE(winShell->setParent(childWinShell.get()) == false); - - // test for set parent itself - EXPECT_TRUE(childWinShell->setParent(childWinShell.get()) == false); - - EXPECT_TRUE(childWinShell->setParent(nullptr) == true); - EXPECT_TRUE(childWinShell->getParent() == nullptr); -} - -TEST_F(DSWindowShellTest, child_P1) -{ - auto zone = std::make_shared(); - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - auto cWindow = std::make_shared(); - std::unique_ptr cShell = std::make_unique(cWindow.get()); - - EXPECT_TRUE(winShell->addChild(cShell.get())); - winShell->removeChild(cShell.get()); -} - -TEST_F(DSWindowShellTest, setTitle_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->setTitle("test setTitle") == true); -} - -TEST_F(DSWindowShellTest, setSkipFocus_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->setSkipFocus(true)); -} - -TEST_F(DSWindowShellTest, setPosition_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->setPosition(100, 150) == true); -} - -TEST_F(DSWindowShellTest, getPosition_P1) -{ - stPosition pos; - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->setPosition(100, 150) == true); - pos = winShell->getPosition(); - - EXPECT_TRUE(pos.x == 0); - EXPECT_TRUE(pos.y == 0); -} - -TEST_F(DSWindowShellTest, getPosition_P2) -{ - stPosition pos; - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - // set user geometry - winShell->addAuxHint(1, "wm.policy.win.user.geometry", "1"); - - EXPECT_TRUE(winShell->setPosition(100, 150) == true); - - pos = winShell->getPosition(); - - EXPECT_TRUE(pos.x == 100); - EXPECT_TRUE(pos.y == 150); -} - -TEST_F(DSWindowShellTest, setSize_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->setSize(720, 1280) == true); -} - -TEST_F(DSWindowShellTest, Geometry_P1) -{ - stGeometry geo; - - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - winShell->setGeometry(100, 150, 480, 800); - geo = winShell->getGeometry(); - - EXPECT_TRUE(geo.x == 0); - EXPECT_TRUE(geo.y == 0); - EXPECT_TRUE(geo.w == 0); - EXPECT_TRUE(geo.h == 0); -} - -TEST_F(DSWindowShellTest, Geometry_P2) -{ - stGeometry geo; - - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - // set user geometry - winShell->addAuxHint(1, "wm.policy.win.user.geometry", "1"); - - winShell->setGeometry(100, 150, 480, 800); - geo = winShell->getGeometry(); - - EXPECT_TRUE(geo.x == 100); - EXPECT_TRUE(geo.y == 150); - EXPECT_TRUE(geo.w == 480); - EXPECT_TRUE(geo.h == 800); -} - -TEST_F(DSWindowShellTest, auxHints_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - winShell->addAuxHint(1, "wm.policy.win.user.geometry", "1"); - winShell->changeAuxHint(1, "0"); - winShell->removeAuxHint(1); -} - -TEST_F(DSWindowShellTest, show_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->show() == true); -} - -TEST_F(DSWindowShellTest, hide_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->hide(true) == true); -} - -TEST_F(DSWindowShellTest, showState_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->showState() == 0); -} - -TEST_F(DSWindowShellTest, setLayer_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->setLayer(100) == true); -} - -TEST_F(DSWindowShellTest, getLayer_P1) -{ - int layer = -1; - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->setLayer(100) == true); - - layer = winShell->getLayer(); - EXPECT_TRUE(layer == 100); -} - -TEST_F(DSWindowShellTest, raise_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->raise() == true); -} - -TEST_F(DSWindowShellTest, lower_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->lower() == true); -} - -TEST_F(DSWindowShellTest, setFocus_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->setFocus() == true); -} - -TEST_F(DSWindowShellTest, isFocused_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->setFocus() == true); - - EXPECT_TRUE(winShell->isFocused() == true); -} - -TEST_F(DSWindowShellTest, unsetFocus) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->create(0, 0, 720, 1280, nullptr) == true); - EXPECT_TRUE(winShell->setFocus() == true); - EXPECT_TRUE(winShell->isFocused() == true); - EXPECT_TRUE(winShell->unsetFocus() == true); - EXPECT_TRUE(winShell->isFocused() == false); -} - -TEST_F(DSWindowShellTest, activate_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->activate()); -} - -TEST_F(DSWindowShellTest, activate_N1) -{ - std::unique_ptr winShell = std::make_unique(nullptr); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_FALSE(winShell->activate()); -} - -TEST_F(DSWindowShellTest, isActivated_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->isActivated()); -} - -TEST_F(DSWindowShellTest, iconify_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - bool ret = winShell->iconify(); - EXPECT_TRUE(ret == true); -} - -TEST_F(DSWindowShellTest, iconify_P2) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - bool ret = winShell->iconify(true); - EXPECT_TRUE(ret == true); -} - -TEST_F(DSWindowShellTest, uniconify_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - bool ret = winShell->uniconify(); - EXPECT_TRUE(ret == true); -} - -TEST_F(DSWindowShellTest, uniconify_P2) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - bool ret = winShell->uniconify(true); - EXPECT_TRUE(ret == true); -} - -TEST_F(DSWindowShellTest, getIconicState_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - int state = winShell->getIconicState(); - EXPECT_TRUE(state == 0); -} - -TEST_F(DSWindowShellTest, setType_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - bool ret = winShell->setType(1); - EXPECT_TRUE(ret == true); - - int type = winShell->getType(); - EXPECT_TRUE(type == 1); -} - -TEST_F(DSWindowShellTest, maximize_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - bool ret = winShell->maximize(); - EXPECT_TRUE(ret == true); - - bool maximized = winShell->isMaximized(); - EXPECT_TRUE(maximized == true); -} - -TEST_F(DSWindowShellTest, fullscreen_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - bool ret = winShell->fullscreen(); - EXPECT_TRUE(ret == true); - - bool fullscreen = winShell->isFullscreen(); - EXPECT_TRUE(fullscreen == true); -} - -TEST_F(DSWindowShellTest, setRole_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - const char *role = winShell->getRole(); - EXPECT_TRUE(role == nullptr); - - bool ret = winShell->setRole("quickpanel"); - EXPECT_TRUE(ret == true); -} - -TEST_F(DSWindowShellTest, vkbdFloating_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - EXPECT_TRUE(winShell->getVkbdFloating() == false); - - EXPECT_TRUE(winShell->setVkbdFloating(true)); - EXPECT_TRUE(winShell->getVkbdFloating()); - - EXPECT_TRUE(winShell->setVkbdFloating(false)); - EXPECT_TRUE(winShell->getVkbdFloating() == false); -} - -TEST_F(DSWindowShellTest, allowUserGeometry_P1) -{ - auto window = std::make_shared(); - std::unique_ptr winShell = std::make_unique(window.get()); - EXPECT_TRUE(winShell != nullptr); - - winShell->setAllowUserGeometry(true); - - // do something for checking this property -} - - diff --git a/tests/DSXkb-test.cpp b/tests/DSXkb-test.cpp deleted file mode 100644 index b28c036..0000000 --- a/tests/DSXkb-test.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSXkb.h" - -using namespace display_server; - -class DSXkbTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -TEST_F(DSXkbTest, NewDSXkb) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - EXPECT_TRUE(xkb != nullptr); - - delete xkb; - delete seat; -} - -TEST_F(DSXkbTest, GetKeyname) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - EXPECT_TRUE(xkb != nullptr); - - std::string keyname = xkb->getKeyname(166); - - EXPECT_TRUE(!keyname.empty()); - - delete xkb; - delete seat; -} - -TEST_F(DSXkbTest, GetKeycode) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - EXPECT_TRUE(xkb != nullptr); - - int keycode = xkb->getKeycode("XF86Back"); - - EXPECT_TRUE(keycode > 8); - - delete xkb; - delete seat; -} - -TEST_F(DSXkbTest, GetModifierDepressed) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - uint32_t depressed = xkb->getModifierDepressed(); - int keycode = xkb->getKeycode("Shift_L"); - - xkb->updateModifier(keycode, true); - - EXPECT_TRUE(depressed != xkb->getModifierDepressed()); - xkb->updateModifier(keycode, false); - - delete xkb; - delete seat; -} - -TEST_F(DSXkbTest, GetModifierLatched) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - - (void)xkb->getModifierLatched(); - - delete xkb; - delete seat; -} - -TEST_F(DSXkbTest, GetModifierLocked) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - uint32_t locked = xkb->getModifierLocked(); - int keycode = xkb->getKeycode("Caps_Lock"); - - xkb->updateModifier(keycode, true); - xkb->updateModifier(keycode, false); - - EXPECT_TRUE(locked != xkb->getModifierLocked()); - - xkb->updateModifier(keycode, true); - xkb->updateModifier(keycode, false); - - delete xkb; - delete seat; -} - -TEST_F(DSXkbTest, GetModifierGroup) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - - (void)xkb->getModifierGroup(); - - delete xkb; - delete seat; -} - -TEST_F(DSXkbTest, GetKeymapFd) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - int fd = xkb->getKeymapFd(); - - EXPECT_TRUE(fd >= 0); - - delete xkb; - delete seat; -} - -TEST_F(DSXkbTest, GetKeymapSize) -{ - DSSeat *seat = new DSSeat; - DSXkb *xkb = new DSXkb(seat); - int size = xkb->getKeymapSize(); - - EXPECT_TRUE(size > 0); - - delete xkb; - delete seat; -} - diff --git a/tests/DSZone-test.cpp b/tests/DSZone-test.cpp deleted file mode 100644 index e12b2ef..0000000 --- a/tests/DSZone-test.cpp +++ /dev/null @@ -1,396 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" -#include "DSZone.h" -#include "DSWaylandSurface.h" -#include "DSWindow.h" -#include "DSPolicyArea.h" -#include "DSPolicyAreaPrivate.h" - -using namespace display_server; - -class DSZoneTest : public ::testing::Test -{ -public: - void SetUp(void) override - { - char *xdir = getenv("DEFAULT_XDG_RUNTIME_DIR"); - setenv("XDG_RUNTIME_DIR", xdir, 1); - } - void TearDown(void) override - { - unsetenv("XDG_RUNTIME_DIR"); - } -}; - -class TestZone : public DSObject -{ -public: - TestZone(std::shared_ptr zone) - : __boolOnWindowCreated(false), - __boolOnWindowShellCreated(false) - { - zone->registerCallbackWindowCreated(this, std::bind(&TestZone::onWindowCreated, this, std::placeholders::_1)); - zone->registerCallbackWindowShellCreated(this, std::bind(&TestZone::onWindowShellCreated, this, std::placeholders::_1)); - __zone = zone; - - __countWindow = 0; - - for (int i=0; i<5; i++) - myWindow[i] = nullptr; - } - - ~TestZone() - {} - - void callOnWindowCreated() { - __zone->callCallbackWindowCreated(); - } - - bool getResultOnWindowCreated() { - return __boolOnWindowCreated; - } - - void onWindowCreated(std::shared_ptr window) { - __boolOnWindowCreated = true; - - myWindow[__countWindow] = window.get(); - __countWindow++; - } - - void callOnWindowShellCreated(std::shared_ptr winShell) { - __zone->callCallbackWindowShellCreated(winShell); - } - - bool getResultOnWindowShellCreated() { - return __boolOnWindowShellCreated; - } - - void onWindowShellCreated(std::shared_ptr windowShell) { - __boolOnWindowShellCreated = true; - } - - std::list> getWindowList() { - return __zone->getWindowList(); - } - - int getWindowCount() { - return __countWindow; - } - -public: - DSWindow* myWindow[5]; - -private: - bool __boolOnWindowCreated; - bool __boolOnWindowShellCreated; - std::shared_ptr __zone; - int __countWindow; -}; - -TEST_F(DSZoneTest, NewDSZone) -{ - auto zone = std::make_unique(); - EXPECT_TRUE(zone != nullptr); -} - -TEST_F(DSZoneTest, SetGetPosition) -{ - auto zone = std::make_unique(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - stPosition position1; - position1.x = 10; - position1.y = 10; - zone->setPosition(position1); - - stPosition position2; - position2 = zone->getPosition(); - EXPECT_TRUE(position1.x == position2.x) << "didn't match position X"; - EXPECT_TRUE(position1.y == position2.y) << "didn't match position Y"; -} - -TEST_F(DSZoneTest, SetGetSize) -{ - auto zone = std::make_unique(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - stSize size1; - size1.w = 100; - size1.h = 100; - zone->setSize(size1); - - stSize size2; - size2 = zone->getSize(); - EXPECT_TRUE(size1.w == size2.w) << "didn't match size W"; - EXPECT_TRUE(size1.h == size2.h) << "didn't match size H"; -} - -TEST_F(DSZoneTest, registerCallbackWindowCreated) -{ - auto zone = std::make_shared(); - ASSERT_TRUE(zone != nullptr); - - auto testZone = std::make_shared(zone); - ASSERT_TRUE(testZone != nullptr); - - testZone->callOnWindowCreated(); - EXPECT_TRUE(testZone->getResultOnWindowCreated()); -} - -TEST_F(DSZoneTest, registerCallbackWindowShellCreated) -{ - auto zone = std::make_shared(); - ASSERT_TRUE(zone != nullptr); - - auto testZone = std::make_shared(zone); - ASSERT_TRUE(testZone != nullptr); - - // before calling WindowShell created - EXPECT_FALSE(testZone->getResultOnWindowShellCreated()); - - testZone->callOnWindowShellCreated(nullptr); - - // after calling WindowShell created - EXPECT_TRUE(testZone->getResultOnWindowShellCreated()); -} - -TEST_F(DSZoneTest, stackChangedRaiseLower) -{ - int count; - - auto zone = std::make_shared(); - ASSERT_TRUE(zone != nullptr); - - auto testZone = std::make_shared(zone); - ASSERT_TRUE(testZone != nullptr); - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)); - - auto dswlSurface2 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface2)); - - count = testZone->getWindowCount(); - for (std::shared_ptr w : zone->getWindowList()) - { - EXPECT_TRUE(w.get() == testZone->myWindow[count-1]); - count--; - } - - zone->raiseWindow(dswlSurface1.get()); - - count = 0; - for (std::shared_ptr w : zone->getWindowList()) - { - EXPECT_TRUE(w.get() == testZone->myWindow[count]); - count++; - } - - zone->lowerWindow(dswlSurface1.get()); - - count = testZone->getWindowCount(); - for (std::shared_ptr w : zone->getWindowList()) - { - EXPECT_TRUE(w.get() == testZone->myWindow[count-1]); - count--; - } -} - -TEST_F(DSZoneTest, stackChangedActivate) -{ - int count; - - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)); - - auto dswlSurface2 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface2)); - - count = testZone->getWindowCount(); - for (std::shared_ptr w : zone->getWindowList()) - { - EXPECT_TRUE(w.get() == testZone->myWindow[count-1]); - count--; - } - - zone->activateWindow(dswlSurface1.get()); - - count = 0; - for (std::shared_ptr w : zone->getWindowList()) - { - EXPECT_TRUE(w.get() == testZone->myWindow[count]); - count++; - } -} - -TEST_F(DSZoneTest, SetWindowParent) -{ - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)) << "Failed to create test window1"; - - auto dswlSurface2 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface2)) << "Failed to create test window2"; - - EXPECT_TRUE(zone->setWindowParent(dswlSurface1.get(), dswlSurface2.get())) << "Failed to set window parent"; -} - -TEST_F(DSZoneTest, SetWindowType) -{ - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)) << "Failed to create test window1"; - - EXPECT_TRUE(zone->setWindowType(dswlSurface1.get(), 1)) << "Failed to set window type"; -} - -TEST_F(DSZoneTest, SetGetWindowGeometry) -{ - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)) << "Failed to create test window1"; - - // set window geometry - EXPECT_TRUE(zone->setWindowGeometry(dswlSurface1.get(), 11, 22, 33, 44)) << "Failed to set window type"; - - // get window geometry - stGeometry geom; - geom = zone->getWindowGeometry(dswlSurface1.get()); - EXPECT_NE(geom.x, 11) << "didn't match geometry X"; - EXPECT_NE(geom.y, 22) << "didn't match geometry Y"; - EXPECT_NE(geom.w, 33) << "didn't match geometry W"; - EXPECT_NE(geom.h, 44) << "didn't match geometry H"; -} - -TEST_F(DSZoneTest, SetWindowPosition) -{ - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)) << "Failed to create test window1"; - - // set window position - EXPECT_TRUE(zone->setWindowPosition(dswlSurface1.get(), 11, 22)) << "Failed to set window type"; - - // get window geometry - stGeometry geom; - geom = zone->getWindowGeometry(dswlSurface1.get()); - EXPECT_NE(geom.x, 11) << "didn't match geometry X"; - EXPECT_NE(geom.y, 22) << "didn't match geometry Y"; -} - -TEST_F(DSZoneTest, WindowAuxHint) -{ - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)) << "Failed to create test window1"; - - // TODO: need to add verity method - - // add test aux hint - zone->addWindowAuxHint(dswlSurface1.get(), 1, "test.aux.hint", "1"); - - // change aux hint value - zone->changeWindowAuxHint(dswlSurface1.get(), 1, "0"); - - // remove aux hint value - zone->removeWindowAuxHint(dswlSurface1.get(), 1); -} - -TEST_F(DSZoneTest, SetWindowSkipFocus) -{ - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)) << "Failed to create test window1"; - - // TODO: need to add verity method - zone->setWindowSkipFocus(dswlSurface1.get(), true); -} - -TEST_F(DSZoneTest, SetGetVkbdFloating) -{ - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)) << "Failed to create test window1"; - - EXPECT_TRUE(zone->setWindowVkbdFloating(dswlSurface1.get(), true)) << "Failed to set window vkbd floating"; - - EXPECT_TRUE(zone->getWindowVkbdFloating(dswlSurface1.get())) << "didn't matching vkbd floating value"; -} - -TEST_F(DSZoneTest, SetWindowAllowUserGeometry) -{ - auto zone = std::make_shared(); - ASSERT_NE(zone, nullptr) << "Failed to create DSZone"; - - auto testZone = std::make_shared(zone); - ASSERT_NE(testZone, nullptr) << "Failed to create TestZone"; - - auto dswlSurface1 = std::make_shared(); - ASSERT_TRUE(zone->testCreateWindow(dswlSurface1)) << "Failed to create test window1"; - - // TODO: need to add verity method - zone->setWindowAllowUserGeometry(dswlSurface1.get(), true); -} \ No newline at end of file diff --git a/tests/libds-mock.h b/tests/libds-mock.h deleted file mode 100644 index b473762..0000000 --- a/tests/libds-mock.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Contact: SooChan Lim -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __LIBDS_MOCK_H__ -#define __LIBDS_MOCK_H__ - -#include "DSWaylandCompositor.h" -#include "DSWaylandSurface.h" -#include "DSEventLoop.h" -#include "DSDebugLog.h" - -using namespace display_server; - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// wayland MockCompositor -///////////////////////////////////////////////////////////////////////////////////////////////////////// -class MockWaylandCompositor : public DSObject -{ -public: - MockWaylandCompositor() - : surfaceCreated(false), - surfaceCommitted(false), - __waylandSurface(nullptr) - { - __eventLoop = DSEventLoop::getInstance(); - - __waylandCompositor = DSWaylandCompositor::getInstance(); - - if (__waylandCompositor) - { - __waylandCompositor->create(); - __waylandCompositor->registerCallbackSurfaceCreated(this, std::bind(&MockWaylandCompositor::onSurfaceCreated, this, std::placeholders::_1)); - } - } - - ~MockWaylandCompositor() - { - __waylandSurface.reset(); - DSWaylandCompositor::releaseInstance(); - DSEventLoop::releaseInstance(); - } - - void onSurfaceCreated(std::shared_ptr waylandSurface) - { - surfaceCreated = true; - __waylandSurface = waylandSurface; - __waylandSurface->registerCallbackSurfaceCommitted(this, std::bind(&MockWaylandCompositor::onSurfaceCommitted, this, std::placeholders::_1)); - } - - void onSurfaceCommitted(std::shared_ptr waylandSurfaceCommitInfo) { - surfaceCommitted = true; - } - - void run() - { - __eventLoop->run(); - } - - void quit() - { - __eventLoop->quit(); - } - - bool surfaceCreated; // result of surfaceCreated - bool surfaceCommitted; // result of surfaceCommitted - -private: - DSWaylandCompositor *__waylandCompositor; - std::shared_ptr __waylandSurface; - DSEventLoop *__eventLoop; -}; - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// wayland Test Client -///////////////////////////////////////////////////////////////////////////////////////////////////////// -struct TestClient -{ - struct wl_display *display; - struct wl_compositor *compositor; - struct wl_registry *registry; - struct wl_surface *surface; - struct wl_buffer *buffer; - struct wayland_tbm_client *tbm_client; - tbm_surface_h tbmBuffer; - int dx, dy, dw, dh; // damage x,y,w,h - int ax, ay; // attach x,y -}; - -#endif // UT_H diff --git a/tests/libds-tests.cpp b/tests/libds-tests.cpp deleted file mode 100644 index 1fd6b75..0000000 --- a/tests/libds-tests.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Contact: SooChan Lim -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#include "libds-tests.h" - -int main(int argc, char **argv) -{ - char *strEnv = nullptr; - auto AllTestSuccess = false; - -#ifdef TIZEN_TEST_GCOV - setenv("GCOV_PREFIX", "/tmp", 1); -#endif - strEnv = getenv("DEFAULT_XDG_RUNTIME_DIR"); - if (!strEnv) { - setenv("DEFAULT_XDG_RUNTIME_DIR", "/tmp", 1); - } - - try { - ::testing::InitGoogleMock(&argc, argv); - ::testing::FLAGS_gtest_death_test_style = "fast"; - } catch ( ... ) { - std::cout << "error while trying to init google tests.\n"; - exit(EXIT_FAILURE); - } - - try { - AllTestSuccess = RUN_ALL_TESTS() == 0 ? true : false; - } catch (const ::testing::internal::GoogleTestFailureException & e) { - AllTestSuccess = false; - std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl; - std::cout << "\n"; - } - -#ifdef TIZEN_TEST_GCOV - __gcov_flush(); -#endif - return AllTestSuccess; -} diff --git a/tests/libds-tests.h b/tests/libds-tests.h deleted file mode 100644 index 312a732..0000000 --- a/tests/libds-tests.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. -* -* Contact: SooChan Lim -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice (including the next -* paragraph) shall be included in all copies or substantial portions of the -* Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -* DEALINGS IN THE SOFTWARE. -*/ - -#ifndef __LIBDS_TESTS_H__ -#define __LIBDS_TESTS_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libds-mock.h" - -#ifdef TIZEN_TEST_GCOV -extern "C" void __gcov_flush(void); -#endif - -using ::testing::TestWithParam; -using ::testing::Bool; -using ::testing::Values; -using ::testing::Combine; - -#endif // UT_H diff --git a/tests/meson.build b/tests/meson.build deleted file mode 100644 index 3331b77..0000000 --- a/tests/meson.build +++ /dev/null @@ -1,78 +0,0 @@ -libds_tests_srcs = [ - 'libds-tests.cpp', - 'DSRefBase-test.cpp', - 'DSProperty-test.cpp', - 'DSBufferTBMImpl-test.cpp', - 'DSBufferRef-test.cpp', - 'DSBufferManager-test.cpp', - 'DSRenderEngineEcoreEvasImpl-test.cpp', - 'DSRenderEngineDaliImpl-test.cpp', - 'DSCompositor-test.cpp', - 'DSOutputImpl-test.cpp', - 'DSInput-test.cpp', - 'DSCanvas-test.cpp', - 'DSSeat-test.cpp', - 'DSPolicyArea-test.cpp', - 'DSDisplayArea-test.cpp', - 'DSDebugLog-test.cpp', - 'DSDisplayDeviceTDMImpl-test.cpp', - 'DSSignal-test.cpp', - 'DSSignalBroker-test.cpp', - 'DSWindowManager-test.cpp', - 'DSWindow-test.cpp', - 'DSWindowShell-test.cpp', - 'DSWaylandCallback-test.cpp', - 'DSWaylandExtension-test.cpp', - 'DSWaylandOutput-test.cpp', - 'DSWaylandSurface-test.cpp', - 'DSWaylandTizenInputDeviceManager-test.cpp', - 'DSWaylandTizenInputDevice-test.cpp', - 'DSWaylandTizenPolicy-test.cpp', - 'DSWaylandTizenSurface-test.cpp', - 'DSWaylandTizenSurfaceShm-test.cpp', - 'DSWaylandTizenIndicator-test.cpp', - 'DSWaylandTizenAppinfo-test.cpp', - 'DSWaylandTizenLaunchEffect-test.cpp', - 'DSWaylandZxdgShellV6-test.cpp', - 'DSWaylandBuffer-test.cpp', - 'DSObject-test.cpp', - 'DSEventLoop-test.cpp', - 'DSWaylandCompositor-test.cpp', - 'DSWaylandSeat-test.cpp', - 'DSWaylandClient-test.cpp', - 'DSWaylandPointer-test.cpp', - 'DSWaylandKeyboard-test.cpp', - 'DSWaylandTouch-test.cpp', - 'DSZone-test.cpp', - 'DSClient-test.cpp', - 'DSTextInput-test.cpp', - 'DSWaylandInputMethod-test.cpp', - 'DSWaylandInputMethodContext-test.cpp', - 'DSWaylandTextInput-test.cpp', - 'DSWaylandTextInputManager-test.cpp', - 'DSWaylandInputPanel-test.cpp', - 'DSWaylandInputPanelSurface-test.cpp', - 'DSXkb-test.cpp', - 'DSPointer-test.cpp', - 'DSKeyboard-test.cpp', - 'DSTouch-test.cpp', - 'DSTizenAppinfo-test.cpp', - 'DSWaylandProtocolTrace-test.cpp', - 'DSTraceInfo-test.cpp', - 'DSWaylandTizenPolicyExt-test.cpp', - ] - -gmock_dep = dependency('gmock', method : 'pkg-config') -ecore_dep = dependency('ecore', method : 'pkg-config') -wl_client_dep = dependency('wayland-client', method : 'pkg-config') -wl_tbm_dep = dependency('wayland-tbm-client', method : 'pkg-config') -tizen_launch_client_dep = dependency('tizen-launch-client') - -executable( - 'libds-tests', - libds_tests_srcs, - dependencies : [libds_declared_dep, gmock_dep, ecore_dep, ecore_evas_dep, wl_client_dep, wl_tbm_dep, tizen_launch_client_dep], - install_dir : libds_prefix_bindir, - install : true - ) - -- 2.7.4 From a13f68ca0f6cfbf9acbd687adb1efcae68d4eceb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9E=84=EC=88=98=EC=B0=AC/Tizen=20Platform=20Lab=28SR=29/?= =?utf8?q?=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 3 Feb 2022 12:54:32 +0900 Subject: [PATCH 11/16] Initial commit Change-Id: I5cab00df22a871c6aa7ddcb111f0e8ca7f7731b2 --- .gitignore | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- README.md | 2 ++ 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 51ef652..c6127b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,52 @@ -.vscode -.TizenBuild +# Prerequisites +*.d +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf diff --git a/README.md b/README.md new file mode 100644 index 0000000..4c1f3c7 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# libds-c +libds with C -- 2.7.4 From 6b10214710c0c78c415aa43514d46785eb67db01 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Mon, 21 Feb 2022 13:58:09 +0900 Subject: [PATCH 12/16] Initial libds Change-Id: I60d7c170e7f0b918c17f2bf52c01018167dafe91 --- LICENSE | 21 + README.md | 16 +- TODO.md | 8 + examples/meson.build | 22 + examples/tinyds.c | 522 ++++++++++++++++++++ examples/wl-backend.c | 226 +++++++++ include/libds/allocator.h | 19 + include/libds/allocator/shm.h | 9 + include/libds/backend.h | 38 ++ include/libds/backend/wayland.h | 13 + include/libds/buffer.h | 74 +++ include/libds/compositor.h | 27 + include/libds/interfaces/allocator.h | 33 ++ include/libds/interfaces/backend.h | 36 ++ include/libds/interfaces/buffer.h | 48 ++ include/libds/interfaces/output.h | 76 +++ include/libds/log.h | 59 +++ include/libds/output.h | 30 ++ include/libds/presentation.h | 20 + include/libds/subsurface.h | 18 + include/libds/surface.h | 45 ++ include/libds/swapchain.h | 22 + include/libds/xdg_shell.h | 50 ++ include/meson.build | 3 + meson.build | 38 ++ packaging/libds.manifest | 5 + packaging/libds.spec | 56 +++ src/libds/addon.c | 60 +++ src/libds/addon.h | 42 ++ src/libds/allocator/allocator.c | 37 ++ src/libds/allocator/shm.c | 174 +++++++ src/libds/backend/backend.c | 55 +++ src/libds/backend/meson.build | 5 + src/libds/backend/wayland/backend.c | 281 +++++++++++ src/libds/backend/wayland/backend.h | 69 +++ src/libds/backend/wayland/meson.build | 26 + src/libds/backend/wayland/output.c | 309 ++++++++++++ src/libds/buffer.c | 149 ++++++ src/libds/buffer.h | 8 + src/libds/client_buffer.h | 31 ++ src/libds/client_buffer/shm_client_buffer.c | 157 ++++++ src/libds/compositor.c | 143 ++++++ src/libds/log.c | 96 ++++ src/libds/meson.build | 74 +++ src/libds/output.c | 116 +++++ src/libds/pixel_format.c | 15 + src/libds/pixel_format.h | 9 + src/libds/presentation.c | 114 +++++ src/libds/region.c | 196 ++++++++ src/libds/region.h | 24 + src/libds/subcompositor.c | 98 ++++ src/libds/subcompositor.h | 20 + src/libds/surface.h | 49 ++ src/libds/surface/subsurface.c | 333 +++++++++++++ src/libds/surface/surface-private.h | 109 ++++ src/libds/surface/surface.c | 740 ++++++++++++++++++++++++++++ src/libds/swapchain.c | 202 ++++++++ src/libds/util.h | 13 + src/libds/util/shm.c | 174 +++++++ src/libds/util/time.c | 8 + src/libds/xdg_shell/xdg_shell.c | 214 ++++++++ src/libds/xdg_shell/xdg_shell.h | 187 +++++++ src/libds/xdg_shell/xdg_surface.c | 485 ++++++++++++++++++ src/libds/xdg_shell/xdg_toplevel.c | 327 ++++++++++++ src/meson.build | 14 + src/tests/meson.build | 25 + src/tests/test-backend.c | 80 +++ src/tests/test-compositor.c | 63 +++ src/tests/test-subsurface.c | 211 ++++++++ src/tests/test-surface.c | 162 ++++++ 70 files changed, 7236 insertions(+), 2 deletions(-) create mode 100644 LICENSE create mode 100644 TODO.md create mode 100644 examples/meson.build create mode 100644 examples/tinyds.c create mode 100644 examples/wl-backend.c create mode 100644 include/libds/allocator.h create mode 100644 include/libds/allocator/shm.h create mode 100644 include/libds/backend.h create mode 100644 include/libds/backend/wayland.h create mode 100644 include/libds/buffer.h create mode 100644 include/libds/compositor.h create mode 100644 include/libds/interfaces/allocator.h create mode 100644 include/libds/interfaces/backend.h create mode 100644 include/libds/interfaces/buffer.h create mode 100644 include/libds/interfaces/output.h create mode 100644 include/libds/log.h create mode 100644 include/libds/output.h create mode 100644 include/libds/presentation.h create mode 100644 include/libds/subsurface.h create mode 100644 include/libds/surface.h create mode 100644 include/libds/swapchain.h create mode 100644 include/libds/xdg_shell.h create mode 100644 include/meson.build create mode 100644 meson.build create mode 100644 packaging/libds.manifest create mode 100644 packaging/libds.spec create mode 100644 src/libds/addon.c create mode 100644 src/libds/addon.h create mode 100644 src/libds/allocator/allocator.c create mode 100644 src/libds/allocator/shm.c create mode 100644 src/libds/backend/backend.c create mode 100644 src/libds/backend/meson.build create mode 100644 src/libds/backend/wayland/backend.c create mode 100644 src/libds/backend/wayland/backend.h create mode 100644 src/libds/backend/wayland/meson.build create mode 100644 src/libds/backend/wayland/output.c create mode 100644 src/libds/buffer.c create mode 100644 src/libds/buffer.h create mode 100644 src/libds/client_buffer.h create mode 100644 src/libds/client_buffer/shm_client_buffer.c create mode 100644 src/libds/compositor.c create mode 100644 src/libds/log.c create mode 100644 src/libds/meson.build create mode 100644 src/libds/output.c create mode 100644 src/libds/pixel_format.c create mode 100644 src/libds/pixel_format.h create mode 100644 src/libds/presentation.c create mode 100644 src/libds/region.c create mode 100644 src/libds/region.h create mode 100644 src/libds/subcompositor.c create mode 100644 src/libds/subcompositor.h create mode 100644 src/libds/surface.h create mode 100644 src/libds/surface/subsurface.c create mode 100644 src/libds/surface/surface-private.h create mode 100644 src/libds/surface/surface.c create mode 100644 src/libds/swapchain.c create mode 100644 src/libds/util.h create mode 100644 src/libds/util/shm.c create mode 100644 src/libds/util/time.c create mode 100644 src/libds/xdg_shell/xdg_shell.c create mode 100644 src/libds/xdg_shell/xdg_shell.h create mode 100644 src/libds/xdg_shell/xdg_surface.c create mode 100644 src/libds/xdg_shell/xdg_toplevel.c create mode 100644 src/meson.build create mode 100644 src/tests/meson.build create mode 100644 src/tests/test-backend.c create mode 100644 src/tests/test-compositor.c create mode 100644 src/tests/test-subsurface.c create mode 100644 src/tests/test-surface.c diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..54e4ef7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2022 Samsung Electronics co., Ltd. All Rights Reserved. +Copyright (c) 2017, 2018 Drew DeVault +Copyright (c) 2014 Jari Vetoniemi + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 4c1f3c7..c8dc588 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ -# libds-c -libds with C +libds +===== + +libds is a library that provides a building block which can be used for +building wayland compositors. It is heavily inspired, conceptually as well as +code-wise, by wlroots. + +libds initially aims to provide common set of functionality that users such as +Enlightenment compositor and Dali's compositor library expect. Such compositors +have its own renderer, so libds currently doesn't provide renderers. +However libds can provide renderers later on for general purposes, and this +renderers should stay decoupled with other objects of libds. + +WIP diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..f9681ed --- /dev/null +++ b/TODO.md @@ -0,0 +1,8 @@ +[] Implement a xdg shell +[] Implement a KMS/DRM backend +[] Implement a libinput backend +[] Implement an input +[] Implement a viewporter +[] Make up a ds output interface +[] Make up tests +[] Document APIs diff --git a/examples/meson.build b/examples/meson.build new file mode 100644 index 0000000..a107a77 --- /dev/null +++ b/examples/meson.build @@ -0,0 +1,22 @@ +project('libds-samples', 'c', + version : '0.1', + default_options : ['warning_level=3']) + +common_deps = [ + dependency('wayland-server', required: true), + dependency('libds', required: true), +] + +executable('wl-backend', + 'wl-backend.c', + dependencies: common_deps, + install : true) + +executable('tinyds', + 'tinyds.c', + dependencies: [ + common_deps, + dependency('pixman-1', required: true), + dependency('libdrm', required: true), + ], + install : true) diff --git a/examples/tinyds.c b/examples/tinyds.c new file mode 100644 index 0000000..3925014 --- /dev/null +++ b/examples/tinyds.c @@ -0,0 +1,522 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TINYDS_UNUSED __attribute__((unused)) + +#define OUTPUT_WIDTH 1280 +#define OUTPUT_HEIGHT 720 + +struct tinyds_output +{ + struct tinyds_server *server; + struct ds_output *ds_output; + struct ds_allocator *allocator; + struct ds_swapchain *swapchain; + struct ds_buffer *front_buffer; + + struct wl_listener output_destroy; + struct wl_listener output_frame; + struct wl_list link; // tinyds_server::outputs + + int width, height; + + bool drawable; + bool damaged; +}; + +struct tinyds_server +{ + struct wl_display *display; + + struct ds_backend *backend; + struct ds_compositor *compositor; + struct ds_xdg_shell *xdg_shell; + + struct tinyds_output primary_output; + + struct wl_list views; + struct wl_list outputs; + + struct wl_listener new_xdg_surface; +}; + +struct tinyds_view +{ + struct tinyds_server *server; + + struct ds_xdg_surface *xdg_surface; + + struct wl_listener xdg_surface_map; + struct wl_listener xdg_surface_unmap; + struct wl_listener xdg_surface_destroy; + struct wl_listener surface_commit; + struct wl_list link; // tinyds_server::views + + int x, y; + bool mapped; +}; + +struct tinyds_server _tinyds; + +static bool init_server(struct tinyds_server *server, struct wl_display *display); +static void fini_server(struct tinyds_server *server); +static bool init_output(struct tinyds_output *output, struct tinyds_server *server, + int width, int height); +static void fini_output(struct tinyds_output *output); +static void output_handle_destroy(struct wl_listener *listener, void *data); +static void output_handle_frame(struct wl_listener *listener, void *data); +static void draw_server(struct tinyds_server *server); +static void draw_server_with_damage(struct tinyds_server *server); +static void draw_output(struct tinyds_output *output); +static void draw_view(struct tinyds_view *view, pixman_image_t *dst_image); + +int +main(void) +{ + struct tinyds_server *server = &_tinyds; + struct wl_display *display; + const char *socket; + + ds_log_init(DS_DBG, NULL); + + display = wl_display_create(); + assert(display); + + assert(init_server(server, display) == true); + + assert(init_output(&server->primary_output, server, + OUTPUT_WIDTH, OUTPUT_HEIGHT) == true); + + socket = wl_display_add_socket_auto(display); + assert(socket); + + ds_backend_start(server->backend); + + draw_server(server); + + setenv("WAYLAND_DISPLAY", socket, true); + + ds_inf("Running Wayland compositor on WAYLAND_DISPLAY=%s", socket); + + wl_display_run(server->display); + + fini_output(&server->primary_output); + fini_server(server); + wl_display_destroy(display); + + return 0; +} + +static struct ds_backend * +tinyds_create_backend_auto(struct wl_display *display) +{ + struct ds_backend *backend = NULL; + char name[512]; + int i; + + for (i = 0; i < 5; i++) { + snprintf(name, sizeof name, "wayland-%d", i); + backend = ds_wl_backend_create(display, name); + if (backend) + break; + } + + return backend; +} + +static void +view_handle_xdg_surface_map(struct wl_listener *listener, + void *data TINYDS_UNUSED) +{ + struct tinyds_view *view; + + view = wl_container_of(listener, view, xdg_surface_map); + view->mapped = true; +} + +static void +view_handle_xdg_surface_unmap(struct wl_listener *listener, + void *data TINYDS_UNUSED) +{ + struct tinyds_view *view; + + view = wl_container_of(listener, view, xdg_surface_unmap); + view->mapped = false; +} + +static void +view_handle_xdg_surface_destroy(struct wl_listener *listener, + void *data TINYDS_UNUSED) +{ + struct tinyds_view *view; + + view = wl_container_of(listener, view, xdg_surface_destroy); + + draw_server_with_damage(view->server); + + wl_list_remove(&view->xdg_surface_destroy.link); + wl_list_remove(&view->xdg_surface_map.link); + wl_list_remove(&view->xdg_surface_unmap.link); + wl_list_remove(&view->surface_commit.link); + wl_list_remove(&view->link); + free(view); +} + +static void +view_handle_surface_commit(struct wl_listener *listener, + void *data TINYDS_UNUSED) +{ + struct tinyds_view *view; + + view = wl_container_of(listener, view, surface_commit); + draw_server_with_damage(view->server); +} + +static void +server_new_xdg_surface(struct wl_listener *listener, void *data) +{ + struct tinyds_server *server; + struct tinyds_view *view; + struct ds_xdg_surface *xdg_surface; + + server = wl_container_of(listener, server, new_xdg_surface); + xdg_surface = data; + + ds_inf("New xdg_surface(%p)", (void *)xdg_surface); + + view = calloc(1, sizeof *view); + view->server = server; + view->xdg_surface = xdg_surface; + + view->xdg_surface_map.notify = view_handle_xdg_surface_map; + ds_xdg_surface_add_map_listener(xdg_surface, + &view->xdg_surface_map); + + view->xdg_surface_unmap.notify = view_handle_xdg_surface_unmap; + ds_xdg_surface_add_unmap_listener(xdg_surface, + &view->xdg_surface_unmap); + + view->xdg_surface_destroy.notify = view_handle_xdg_surface_destroy; + ds_xdg_surface_add_destroy_listener(xdg_surface, + &view->xdg_surface_destroy); + + view->surface_commit.notify = view_handle_surface_commit; + ds_surface_add_commit_listener( + ds_xdg_surface_get_surface(xdg_surface), + &view->surface_commit); + + wl_list_insert(server->views.prev, &view->link); +} + +static bool +init_server(struct tinyds_server *server, struct wl_display *display) +{ + server->display = display; + + wl_list_init(&server->outputs); + wl_list_init(&server->views); + + if (wl_display_init_shm(display) != 0) + return false; + + server->backend = tinyds_create_backend_auto(display); + if (!server->backend) + return false; + + server->compositor = ds_compositor_create(display); + if (!server->compositor) { + ds_backend_destroy(server->backend); + return false; + } + + server->xdg_shell = ds_xdg_shell_create(display); + if (!server->xdg_shell) { + ds_backend_destroy(server->backend); + return false; + } + + server->new_xdg_surface.notify = server_new_xdg_surface; + ds_xdg_shell_add_new_surface_listener(server->xdg_shell, + &server->new_xdg_surface); + + return true; +} + +static void +fini_server(struct tinyds_server *server) +{ + wl_list_remove(&server->new_xdg_surface.link); +} + +static void +output_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED) +{ + struct tinyds_output *output = + wl_container_of(listener, output, output_destroy); + + wl_list_remove(&output->output_destroy.link); + wl_list_remove(&output->output_frame.link); + output->ds_output = NULL; + + wl_display_terminate(output->server->display); +} + +static void +output_handle_frame(struct wl_listener *listener, void *data TINYDS_UNUSED) +{ + struct tinyds_output *output = + wl_container_of(listener, output, output_frame); + + output->drawable = true; + draw_output(output); +} + +static bool +init_output(struct tinyds_output *output, struct tinyds_server *server, + int width, int height) +{ + output->server = server; + output->width = width; + output->height = height; + output->front_buffer = NULL; + output->drawable = true; + output->damaged = true; + + output->allocator = ds_shm_allocator_create(); + if (!output->allocator) + return false; + + output->swapchain = ds_swapchain_create(output->allocator, + width, height, DRM_FORMAT_XRGB8888); + if (!output->swapchain) + goto err_swapchain; + + output->ds_output = + ds_wl_backend_create_output(server->backend); + if (!output->ds_output) + goto err_output; + + output->output_destroy.notify = output_handle_destroy; + ds_output_add_destroy_listener(output->ds_output, &output->output_destroy); + + output->output_frame.notify = output_handle_frame; + ds_output_add_frame_listener(output->ds_output, &output->output_frame); + + wl_list_insert(&server->outputs, &output->link); + + return true; + +err_output: + ds_swapchain_destroy(output->swapchain); +err_swapchain: + ds_allocator_destroy(output->allocator); + + return false; +} + +static void +fini_output(struct tinyds_output *output) +{ + wl_list_remove(&output->link); + if (output->front_buffer) + ds_buffer_unlock(output->front_buffer); + if (output->ds_output) + ds_output_destroy(output->ds_output); + ds_swapchain_destroy(output->swapchain); + ds_allocator_destroy(output->allocator); +} + +static void +draw_server(struct tinyds_server *server) +{ + struct tinyds_output *output; + + wl_list_for_each(output, &server->outputs, link) + draw_output(output); +} + +static void +draw_server_with_damage(struct tinyds_server *server) +{ + struct tinyds_output *output; + + wl_list_for_each(output, &server->outputs, link) { + output->damaged = true; + draw_output(output); + } +} + +static void image_fill_color(pixman_image_t *image, + uint8_t r, uint8_t g, uint8_t b); +static pixman_image_t *image_from_buffer(struct ds_buffer *buffer, + enum ds_buffer_data_ptr_access_flag access_flag); +static void view_send_frame_done(struct tinyds_view *view); + +static void +draw_output(struct tinyds_output *output) +{ + struct ds_buffer *output_buffer; + pixman_image_t *output_image; + struct tinyds_view *view; + + if (!output->drawable || !output->damaged) + return; + + output_buffer = ds_swapchain_acquire(output->swapchain, NULL); + if (!output_buffer) + return; + + output_image = image_from_buffer(output_buffer, + DS_BUFFER_DATA_PTR_ACCESS_WRITE); + if (!output_image) { + ds_buffer_unlock(output_buffer); + return; + } + + image_fill_color(output_image, 80, 80, 80); + + wl_list_for_each(view, &output->server->views, link) { + if (!view->mapped) + continue; + draw_view(view, output_image); + } + pixman_image_unref(output_image); + + ds_output_attach_buffer(output->ds_output, output_buffer); + ds_output_commit(output->ds_output); + + if (output->front_buffer) + ds_buffer_unlock(output->front_buffer); + output->front_buffer = output_buffer; + + output->drawable = false; + output->damaged = false; +} + +static void +draw_view(struct tinyds_view *view, pixman_image_t *dst_image) +{ + struct ds_buffer *buffer; + pixman_image_t *src_image; + + buffer = ds_surface_get_buffer( + ds_xdg_surface_get_surface(view->xdg_surface)); + if (!buffer) + return; + + src_image = image_from_buffer(buffer, + DS_BUFFER_DATA_PTR_ACCESS_READ); + pixman_image_composite32(PIXMAN_OP_OVER, + src_image, + NULL, + dst_image, + 0, 0, 0, 0, 0, 0, + pixman_image_get_width(src_image), + pixman_image_get_height(src_image)); + pixman_image_unref(src_image); + + view_send_frame_done(view); +} + +static pixman_color_t * +color_rgb888(pixman_color_t *tmp, uint8_t r, uint8_t g, uint8_t b) +{ + tmp->alpha = 65535; + tmp->red = (r << 8) + r; + tmp->green = (g << 8) + g; + tmp->blue = (b << 8) +b; + + return tmp; +} + +static void +image_fill_color(pixman_image_t *image, uint8_t r, uint8_t g, uint8_t b) +{ + pixman_image_t *color_image; + pixman_color_t color; + + color_rgb888(&color, r, g, b); + color_image = pixman_image_create_solid_fill(&color); + pixman_image_composite32(PIXMAN_OP_SRC, + color_image, + NULL, + image, + 0, 0, 0, 0, 0, 0, + pixman_image_get_width(image), + pixman_image_get_height(image)); + pixman_image_unref(color_image); +} + +static void +destroy_pixman_image(pixman_image_t *image TINYDS_UNUSED, void *data) +{ + struct ds_buffer *buffer = data; + ds_buffer_end_data_ptr_access(buffer); + ds_buffer_unlock(buffer); +} + +static uint32_t +convert_drm_format_to_pixman(uint32_t fmt) +{ + switch (fmt) { + case DRM_FORMAT_XRGB8888: + return PIXMAN_x8r8g8b8; + case DRM_FORMAT_ARGB8888: + return PIXMAN_a8r8g8b8; + default: + assert(0 && "not reached"); + } +} + +static pixman_image_t * +image_from_buffer(struct ds_buffer *buffer, + enum ds_buffer_data_ptr_access_flag access_flag) +{ + pixman_image_t *image; + void *data; + uint32_t format; + size_t stride; + int width, height; + + ds_buffer_get_size(buffer, &width, &height); + + if (!ds_buffer_begin_data_ptr_access(buffer, + access_flag, &data, &format, &stride)) + return NULL; + + format = convert_drm_format_to_pixman(format); + image = pixman_image_create_bits(format, width, height, data, stride); + if (!image) { + ds_buffer_end_data_ptr_access(buffer); + return NULL; + } + + pixman_image_set_destroy_function(image, + destroy_pixman_image, ds_buffer_lock(buffer)); + + return image; +} + +static void +view_send_frame_done(struct tinyds_view *view) +{ + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + ds_surface_send_frame_done(ds_xdg_surface_get_surface(view->xdg_surface), + &now); +} diff --git a/examples/wl-backend.c b/examples/wl-backend.c new file mode 100644 index 0000000..38dea1b --- /dev/null +++ b/examples/wl-backend.c @@ -0,0 +1,226 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define WIDTH 700 +#define HEIGHT 400 + +struct server +{ + struct ds_backend *backend; + struct ds_output *output; + struct ds_allocator *allocator; + struct ds_swapchain *swapchain; + struct ds_buffer *front_buffer; + + struct wl_display *display; + + struct { + struct wl_listener output_destroy; + struct wl_listener output_frame; + } listener; + + int width, height; +}; + +struct server _server; + +static void init_server(struct server *server, struct wl_display *display); +static void fini_server(struct server *server); +static void output_handle_destroy(struct wl_listener *listener, void *data); +static void output_handle_frame(struct wl_listener *listener, void *data); +static void draw_output(struct server *server); + +int +main(void) +{ + struct server *server = &_server; + struct wl_display *display; + + ds_log_init(DS_DBG, NULL); + + display = wl_display_create(); + assert(display); + + server->width = WIDTH; + server->height = HEIGHT; + + init_server(server, display); + + server->listener.output_destroy.notify = output_handle_destroy; + ds_output_add_destroy_listener(server->output, + &server->listener.output_destroy); + + server->listener.output_frame.notify = output_handle_frame; + ds_output_add_frame_listener(server->output, + &server->listener.output_frame); + + ds_backend_start(server->backend); + + draw_output(server); + + wl_display_run(server->display); + + fini_server(server); + wl_display_destroy(display); + return 0; +} + +static struct ds_backend * +create_backend_auto(struct wl_display *display) +{ + struct ds_backend *backend = NULL; + char name[512]; + int i; + + for (i = 0; i < 5; i++) { + snprintf(name, sizeof name, "wayland-%d", i); + backend = ds_wl_backend_create(display, name); + if (backend) + break; + } + + return backend; +} + +static void +init_server(struct server *server, struct wl_display *display) +{ + server->display = display; + + server->backend = create_backend_auto(display); + assert(server->backend); + + server->allocator = ds_shm_allocator_create(); + assert(server->allocator); + + server->swapchain = ds_swapchain_create(server->allocator, + server->width, server->height, WL_SHM_FORMAT_XRGB8888); + assert(server->swapchain); + + server->output = + ds_wl_backend_create_output(server->backend); + assert(server->output); +} + +static void +fini_server(struct server *server) +{ + ds_buffer_unlock(server->front_buffer); + ds_swapchain_destroy(server->swapchain); + ds_allocator_destroy(server->allocator); +} + +static void +paint_pixels(void *image, int padding, int width, int height, uint32_t time) +{ + const int halfh = padding + (height - padding * 2) / 2; + const int halfw = padding + (width - padding * 2) / 2; + int ir, or; + uint32_t *pixel = image; + int y; + + /* squared radii thresholds */ + or = (halfw < halfh ? halfw : halfh) - 8; + ir = or - 32; + or *= or; + ir *= ir; + + pixel += padding * width; + for (y = padding; y < height - padding; y++) { + int x; + int y2 = (y - halfh) * (y - halfh); + + pixel += padding; + for (x = padding; x < width - padding; x++) { + uint32_t v; + + /* squared distance from center */ + int r2 = (x - halfw) * (x - halfw) + y2; + + if (r2 < ir) + v = (r2 / 32 + time / 64) * 0x0080401; + else if (r2 < or) + v = (y + time / 32) * 0x0080401; + else + v = (x + time / 16) * 0x0080401; + v &= 0x00ffffff; + + /* cross if compositor uses X from XRGB as alpha */ + if (abs(x - y) > 6 && abs(x + y - height) > 6) + v |= 0xff000000; + + *pixel++ = v; + } + + pixel += padding; + } +} + +static inline int64_t +timespec_to_msec(const struct timespec *a) +{ + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} + +static void +output_handle_destroy(struct wl_listener *listener, + void *data __attribute__((unused))) +{ + struct server *server = + wl_container_of(listener, server, listener.output_destroy); + wl_display_terminate(server->display); +} + +static void +output_handle_frame(struct wl_listener *listener, + void *data __attribute__((unused))) +{ + struct server *server = + wl_container_of(listener, server, listener.output_frame); + draw_output(server); +} + +static void +draw_output(struct server *server) +{ + struct ds_buffer *buffer; + void *data; + uint32_t format; + size_t stride; + struct timespec now; + uint32_t frame_time_msec; + + ds_dbg("Redraw output"); + + clock_gettime(CLOCK_MONOTONIC, &now); + frame_time_msec = timespec_to_msec(&now); + + buffer = ds_swapchain_acquire(server->swapchain, NULL); + assert(buffer); + + assert(ds_buffer_begin_data_ptr_access(buffer, + 0, &data, &format, &stride) == true); + + paint_pixels(data, 20, server->width, server->height, frame_time_msec); + + ds_buffer_end_data_ptr_access(buffer); + + ds_output_attach_buffer(server->output, buffer); + ds_output_commit(server->output); + + if (server->front_buffer) + ds_buffer_unlock(server->front_buffer); + + server->front_buffer = buffer; +} diff --git a/include/libds/allocator.h b/include/libds/allocator.h new file mode 100644 index 0000000..d4a6a80 --- /dev/null +++ b/include/libds/allocator.h @@ -0,0 +1,19 @@ +#ifndef LIBDS_ALLOCATOR_H +#define LIBDS_ALLOCATOR_H + +#include + +struct ds_allocator; + +void +ds_allocator_destroy(struct ds_allocator *alloc); + +struct ds_buffer * +ds_allocator_create_buffer(struct ds_allocator *alloc, int width, int height, + uint32_t format); + +void +ds_allocator_add_destroy_listener(struct ds_allocator *alloc, + struct wl_listener *listener); + +#endif diff --git a/include/libds/allocator/shm.h b/include/libds/allocator/shm.h new file mode 100644 index 0000000..1a02338 --- /dev/null +++ b/include/libds/allocator/shm.h @@ -0,0 +1,9 @@ +#ifndef LIBDS_ALLOCATOR_SHM_H +#define LIBDS_ALLOCATOR_SHM_H + +#include + +struct ds_allocator * +ds_shm_allocator_create(void); + +#endif diff --git a/include/libds/backend.h b/include/libds/backend.h new file mode 100644 index 0000000..71d9e63 --- /dev/null +++ b/include/libds/backend.h @@ -0,0 +1,38 @@ +#ifndef LIBDS_BACKEND_H +#define LIBDS_BACKEND_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ds_backend; + +bool +ds_backend_start(struct ds_backend *backend); + +void +ds_backend_destroy(struct ds_backend *backend); + +int +ds_backend_get_drm_fd(struct ds_backend *backend); + +ds_buffer_caps_t +ds_backend_get_buffer_caps(struct ds_backend *backend); + +void +ds_backend_add_destroy_listener(struct ds_backend *backend, + struct wl_listener *listener); + +void +ds_backend_add_new_output_listener(struct ds_backend *backend, + struct wl_listener *listener); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/backend/wayland.h b/include/libds/backend/wayland.h new file mode 100644 index 0000000..e7f233a --- /dev/null +++ b/include/libds/backend/wayland.h @@ -0,0 +1,13 @@ +#ifndef LIBDS_BACKEND_WAYLAND_H +#define LIBDS_BACKEND_WAYLAND_H + +#include +#include + +struct ds_backend * +ds_wl_backend_create(struct wl_display *display, const char *server_name); + +struct ds_output * +ds_wl_backend_create_output(struct ds_backend *backend); + +#endif diff --git a/include/libds/buffer.h b/include/libds/buffer.h new file mode 100644 index 0000000..eac5146 --- /dev/null +++ b/include/libds/buffer.h @@ -0,0 +1,74 @@ +#ifndef LIBDS_BUFFER_H +#define LIBDS_BUFFER_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ds_buffer; + +typedef enum +{ + DS_BUFFER_CAP_DATA_PTR = 1 << 0, + DS_BUFFER_CAP_DMABUF = 1 << 1, + DS_BUFFER_CAP_SHM = 1 << 2, +} ds_buffer_caps_t; + +enum ds_buffer_data_ptr_access_flag +{ + DS_BUFFER_DATA_PTR_ACCESS_READ = 1 << 0, + DS_BUFFER_DATA_PTR_ACCESS_WRITE = 1 << 1, +}; + +struct ds_shm_attributes +{ + int fd; + uint32_t format; + int width, height, stride; + off_t offset; +}; + +struct ds_buffer * +ds_buffer_from_resource(struct wl_resource *resource); + +void +ds_buffer_drop(struct ds_buffer *buffer); + +struct ds_buffer * +ds_buffer_lock(struct ds_buffer *buffer); + +void +ds_buffer_unlock(struct ds_buffer *buffer); + +bool +ds_buffer_get_shm(struct ds_buffer *buffer, struct ds_shm_attributes *attribs); + +void +ds_buffer_get_size(struct ds_buffer *buffer, int *out_width, int *out_height); + +void +ds_buffer_add_destroy_listener(struct ds_buffer *buffer, + struct wl_listener *listener); + +void +ds_buffer_add_release_listener(struct ds_buffer *buffer, + struct wl_listener *listener); + +bool +ds_buffer_begin_data_ptr_access(struct ds_buffer *buffer, + enum ds_buffer_data_ptr_access_flag flags, void **data, + uint32_t *format, size_t *stride); + +void +ds_buffer_end_data_ptr_access(struct ds_buffer *buffer); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/compositor.h b/include/libds/compositor.h new file mode 100644 index 0000000..343fa0c --- /dev/null +++ b/include/libds/compositor.h @@ -0,0 +1,27 @@ +#ifndef LIBDS_COMPOSITOR_H +#define LIBDS_COMPOSITOR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ds_compositor; + +struct ds_compositor * +ds_compositor_create(struct wl_display *display); + +void +ds_compositor_add_new_surface_listener(struct ds_compositor *compositor, + struct wl_listener *listener); + +void +ds_compositor_add_destroy_listener(struct ds_compositor *compositor, + struct wl_listener *listener); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/interfaces/allocator.h b/include/libds/interfaces/allocator.h new file mode 100644 index 0000000..1e60668 --- /dev/null +++ b/include/libds/interfaces/allocator.h @@ -0,0 +1,33 @@ +#ifndef LIBDS_INTERFACES_ALLOCATOR_H +#define LIBDS_INTERFACES_ALLOCATOR_H + +#include +#include + +struct ds_allocator; + +struct ds_allocator_interface { + struct ds_buffer *(*create_buffer)(struct ds_allocator *alloc, + int width, int height, uint32_t format); + void (*destroy)(struct ds_allocator *alloc); +}; + +struct ds_allocator +{ + const struct ds_allocator_interface *iface; + + uint32_t buffer_caps; + + struct { + struct wl_signal destroy; + } events; +}; + +void +ds_allocator_init(struct ds_allocator *alloc, + const struct ds_allocator_interface *iface, uint32_t buffer_caps); + +void +ds_allocator_destroy(struct ds_allocator *alloc); + +#endif diff --git a/include/libds/interfaces/backend.h b/include/libds/interfaces/backend.h new file mode 100644 index 0000000..e960ac4 --- /dev/null +++ b/include/libds/interfaces/backend.h @@ -0,0 +1,36 @@ +#ifndef LIBDS_INTERFACES_BACKEND_H +#define LIBDS_INTERFACES_BACKEND_H + +#include + +struct ds_backend; + +struct ds_backend_interface +{ + bool (*start)(struct ds_backend *backend); + void (*destroy)(struct ds_backend *backend); + int (*get_drm_fd)(struct ds_backend *backend); +}; + +struct ds_backend +{ + const struct ds_backend_interface *iface; + + struct wl_display *display; + + struct + { + struct wl_signal destroy; + struct wl_signal new_output; + } events; + + bool started; +}; + +void +ds_backend_init(struct ds_backend *backend, const struct ds_backend_interface *iface); + +void +ds_backend_finish(struct ds_backend *backend); + +#endif diff --git a/include/libds/interfaces/buffer.h b/include/libds/interfaces/buffer.h new file mode 100644 index 0000000..3e288aa --- /dev/null +++ b/include/libds/interfaces/buffer.h @@ -0,0 +1,48 @@ +#ifndef LIBDS_INTERFACES_BUFFER_H +#define LIBDS_INTERFACES_BUFFER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ds_buffer; + +struct ds_buffer_interface +{ + void (*destroy)(struct ds_buffer *buffer); + bool (*get_shm)(struct ds_buffer *buffer, + struct ds_shm_attributes *attribs); + bool (*begin_data_ptr_access)(struct ds_buffer *buffer, uint32_t flags, + void **data, uint32_t *format, size_t *stride); + void (*end_data_ptr_access)(struct ds_buffer *buffer); +}; + +struct ds_buffer +{ + const struct ds_buffer_interface *iface; + void *iface_data; + + int width, height; + size_t n_locks; + + bool dropped; + bool accessing_data_ptr; + + struct { + struct wl_signal destroy; + struct wl_signal release; + } events; +}; + +void +ds_buffer_init(struct ds_buffer *buffer, + const struct ds_buffer_interface *iface, int width, int height); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/interfaces/output.h b/include/libds/interfaces/output.h new file mode 100644 index 0000000..cacb927 --- /dev/null +++ b/include/libds/interfaces/output.h @@ -0,0 +1,76 @@ +#ifndef LIBDS_INTERFACES_OUTPUT_H +#define LIBDS_INTERFACES_OUTPUT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ds_output; + +enum ds_output_state_field +{ + DS_OUTPUT_STATE_BUFFER = 1 << 0, + DS_OUTPUT_STATE_DAMAGE = 1 << 1, + DS_OUTPUT_STATE_MODE = 1 << 2, + DS_OUTPUT_STATE_ENABLED = 1 << 3, + DS_OUTPUT_STATE_SCALE = 1 << 4, + DS_OUTPUT_STATE_TRANSFORM = 1 << 5, +}; + +struct ds_output_interface +{ + void (*destroy)(struct ds_output *output); + bool (*commit)(struct ds_output *output); +}; + +struct ds_output_mode { + struct wl_list link; + int32_t width, height; + int32_t refresh; + bool preferred; +}; + +struct ds_output_state +{ + enum ds_output_state_field committed; + struct ds_buffer *buffer; + struct ds_output_mode *mode; + + bool enabled; +}; + +struct ds_output +{ + const struct ds_output_interface *iface; + + struct ds_backend *backend; + + struct wl_display *display; + struct wl_global *global; + + struct ds_buffer *back_buffer, *front_buffer; + struct ds_output_state pending; + + struct wl_listener display_destroy; + + struct { + struct wl_signal destroy; + struct wl_signal frame; + struct wl_signal commit; + } events; +}; + +void +ds_output_init(struct ds_output *output, struct ds_backend *backend, + const struct ds_output_interface *iface, struct wl_display *display); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/log.h b/include/libds/log.h new file mode 100644 index 0000000..5296d89 --- /dev/null +++ b/include/libds/log.h @@ -0,0 +1,59 @@ +#ifndef LIBDS_LOG_H +#define LIBDS_LOG_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum ds_log_level { + DS_SILENT = 0, + DS_ERR = 1, + DS_INF = 2, + DS_DBG = 3, + DS_LOG_LEVEL_LAST, +}; + +typedef void (*ds_log_func_t)(enum ds_log_level level, + const char *fmt, va_list args); + +void ds_log_init(enum ds_log_level level, ds_log_func_t callback); + +enum ds_log_level ds_log_get_level(void); + +#ifdef __GNUC__ +#define _DS_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end))) +#else +#define _DS_ATTRIB_PRINTF(start, end) +#endif + +void _ds_log(enum ds_log_level level, const char *format, ...) _DS_ATTRIB_PRINTF(2, 3); +void _ds_vlog(enum ds_log_level level, const char *format, va_list args) _DS_ATTRIB_PRINTF(2, 0); + +#define ds_log(level, fmt, ...) \ + _ds_log(level, "[%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__) + +#define ds_vlog(level, fmt, args) \ + _ds_vlog(level, "[%s:%d] " fmt, __FILE__, __LINE__, args) + +#define ds_log_errno(level, fmt, ...) \ + ds_log(level, fmt ": %s", ##__VA_ARGS__, strerror(errno)) + +#define ds_err(fmt, ...) \ + ds_log(DS_ERR, fmt, ##__VA_ARGS__) + +#define ds_inf(fmt, ...) \ + ds_log(DS_INF, fmt, ##__VA_ARGS__) + +#define ds_dbg(fmt, ...) \ + ds_log(DS_DBG, fmt, ##__VA_ARGS__) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/output.h b/include/libds/output.h new file mode 100644 index 0000000..ea8e276 --- /dev/null +++ b/include/libds/output.h @@ -0,0 +1,30 @@ +#ifndef LIBDS_OUTPUT_H +#define LIBDS_OUTPUT_H + +#include +#include + +struct ds_output; + +void +ds_output_destroy(struct ds_output *output); + +bool +ds_output_commit(struct ds_output *output); + +void +ds_output_attach_buffer(struct ds_output *output, struct ds_buffer *buffer); + +void +ds_output_add_destroy_listener(struct ds_output *output, + struct wl_listener *listener); + +void +ds_output_add_frame_listener(struct ds_output *output, + struct wl_listener *listener); + +void +ds_output_add_commit_listener(struct ds_output *output, + struct wl_listener *listener); + +#endif diff --git a/include/libds/presentation.h b/include/libds/presentation.h new file mode 100644 index 0000000..2b496b4 --- /dev/null +++ b/include/libds/presentation.h @@ -0,0 +1,20 @@ +#ifndef LIBstruct ds_presentationIME_H +#define LIBstruct ds_presentationIME_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ds_presentation; + +struct ds_presentation * +ds_presentation_create(struct wl_display *display, + clockid_t clk_id); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/subsurface.h b/include/libds/subsurface.h new file mode 100644 index 0000000..72ed088 --- /dev/null +++ b/include/libds/subsurface.h @@ -0,0 +1,18 @@ +#ifndef LIBDS_SUBSURFACE_H +#define LIBDS_SUBSURFACE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ds_subsurface; + +bool ds_surface_is_subsurface(struct ds_surface *surface); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/surface.h b/include/libds/surface.h new file mode 100644 index 0000000..9c26cea --- /dev/null +++ b/include/libds/surface.h @@ -0,0 +1,45 @@ +#ifndef LIBDS_SURFACE_H +#define LIBDS_SURFACE_H + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ds_surface; + +typedef bool (*ds_surface_for_each_func_t)(struct ds_surface *surface, + int sx, int sy, void *data); + +void +ds_surface_add_destroy_listener(struct ds_surface *surface, + struct wl_listener *listener); + +void +ds_surface_add_commit_listener(struct ds_surface *surface, + struct wl_listener *listener); + +void +ds_surface_add_new_subsurface_listener(struct ds_surface *surface, + struct wl_listener *listener); + +struct ds_buffer * +ds_surface_get_buffer(struct ds_surface *surface); + +void +ds_surface_for_each(struct ds_surface *surface, + ds_surface_for_each_func_t iterator, void *data); + +void +ds_surface_send_frame_done(struct ds_surface *surface, + const struct timespec *when); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libds/swapchain.h b/include/libds/swapchain.h new file mode 100644 index 0000000..d78d428 --- /dev/null +++ b/include/libds/swapchain.h @@ -0,0 +1,22 @@ +#ifndef LIBDS_SWAPCHAIN_H +#define LIBDS_SWAPCHAIN_H + +#include + +struct ds_swapchain; + +struct ds_swapchain * +ds_swapchain_create(struct ds_allocator *alloc, int width, int height, + uint32_t format); + +void +ds_swapchain_destroy(struct ds_swapchain *swapchain); + +struct ds_buffer * +ds_swapchain_acquire(struct ds_swapchain *swapchain, int *age); + +void +ds_swapchain_set_buffer_submitted(struct ds_swapchain *swapchain, + struct ds_buffer *buffer); + +#endif diff --git a/include/libds/xdg_shell.h b/include/libds/xdg_shell.h new file mode 100644 index 0000000..e3b386f --- /dev/null +++ b/include/libds/xdg_shell.h @@ -0,0 +1,50 @@ +#ifndef LIBDS_XDG_SHELL_H +#define LIBDS_XDG_SHELL_H + +#include +#include + +#include "surface.h" + +struct ds_xdg_shell; + +struct ds_xdg_surface; + +struct ds_xdg_shell * +ds_xdg_shell_create(struct wl_display *display); + +void +ds_xdg_shell_add_destroy_listener(struct ds_xdg_shell *shell, + struct wl_listener *listener); + +void +ds_xdg_shell_add_new_surface_listener(struct ds_xdg_shell *shell, + struct wl_listener *listener); + +void +ds_xdg_surface_add_destroy_listener(struct ds_xdg_surface *surface, + struct wl_listener *listener); + +void +ds_xdg_surface_add_map_listener(struct ds_xdg_surface *surface, + struct wl_listener *listener); + +void +ds_xdg_surface_add_unmap_listener(struct ds_xdg_surface *surface, + struct wl_listener *listener); + +void +ds_xdg_surface_ping(struct ds_xdg_surface *surface); + +struct ds_surface * +ds_xdg_surface_get_surface(struct ds_xdg_surface *surface); + +uint32_t +ds_xdg_toplevel_set_size(struct ds_xdg_surface *surface, + uint32_t width, uint32_t height); + +uint32_t +ds_xdg_toplevel_set_activated(struct ds_xdg_surface *surface, + bool activated); + +#endif diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 0000000..731f7d3 --- /dev/null +++ b/include/meson.build @@ -0,0 +1,3 @@ +install_subdir('libds', + install_dir: get_option('includedir') +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..24506b6 --- /dev/null +++ b/meson.build @@ -0,0 +1,38 @@ +project('libds', 'c', + license: 'MIT', + version: '0.1.0', + default_options: [ + 'warning_level=1', + 'c_std=gnu99', + 'buildtype=debug' + ] +) + +libds_version = meson.project_version() +version_arr = libds_version.split('.') +libds_version_major = version_arr[0] +libds_version_minor = version_arr[1] +libds_version_patch = version_arr[2] + +dir_prefix = get_option('prefix') + +libds_inc = include_directories('include') +common_inc = [ include_directories('.'), libds_inc ] + +cdata = configuration_data() +cdata.set('LIBDS_VERSION_MAJOR', libds_version_major) +cdata.set('LIBDS_VERSION_MINOR', libds_version_minor) +cdata.set('LIBDS_VERSION_PATCH', libds_version_patch) + +subdir('include') +subdir('src') + +configure_file(output: 'config.h', install: false, configuration: cdata) + +pkgconfig = import('pkgconfig') +pkgconfig.generate(lib_libds, + version: meson.project_version(), + filebase: meson.project_name(), + name: meson.project_name(), + description: 'Wayland compositor library', +) diff --git a/packaging/libds.manifest b/packaging/libds.manifest new file mode 100644 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/libds.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libds.spec b/packaging/libds.spec new file mode 100644 index 0000000..8b7c5a7 --- /dev/null +++ b/packaging/libds.spec @@ -0,0 +1,56 @@ +Name: libds +Version: 0.0.1 +Release: 0 +Summary: Wayland Compositor Library +License: MIT +URL: http://www.tizen.org/ +Source: %name-%version.tar.xz +Source1001: %name.manifest + +BuildRequires: meson +BuildRequires: pkgconfig(wayland-server) +BuildRequires: pkgconfig(wayland-client) +BuildRequires: pkgconfig(wayland-protocols) +BuildRequires: pkgconfig(pixman-1) +BuildRequires: pkgconfig(libdrm) + +%description +Wayland Compositor Library + +%package devel +Summary: Wayland Compositor Library +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Development package of Wayland Compositor Library + +%prep +%setup -q +cp %{SOURCE1001} . + +%build +meson setup \ + --prefix /usr \ + --libdir %{_libdir} \ + --bindir %{_bindir} \ + builddir +ninja -C builddir all + +%install +export DESTDIR=%{buildroot} +ninja -C builddir install + +%files +%manifest %{name}.manifest +%defattr(-,root,root,-) +%license LICENSE +%{_libdir}/*.so.* + +%files devel +%manifest %{name}.manifest +%defattr(-,root,root,-) +%license LICENSE +%{_includedir}/* +%{_libdir}/pkgconfig/libds.pc +%{_libdir}/libds.so diff --git a/src/libds/addon.c b/src/libds/addon.c new file mode 100644 index 0000000..9b34b11 --- /dev/null +++ b/src/libds/addon.c @@ -0,0 +1,60 @@ +#include + +#include "addon.h" + +void +ds_addon_set_init(struct ds_addon_set *set) +{ + wl_list_init(&set->addons); +} + +void +ds_addon_set_finish(ds_addon_set_t *set) +{ + ds_addon_t *addon, *tmp; + + wl_list_for_each_safe(addon, tmp, &set->addons, link) { + ds_addon_finish(addon); + addon->impl->destroy(addon); + } +} + +void +ds_addon_init(ds_addon_t *addon, ds_addon_set_t *set, + const void *owner, const ds_addon_interface_t *impl) +{ + ds_addon_t *iter; + + assert(owner && impl); + + wl_list_for_each(iter, &set->addons, link) { + if (iter->owner == addon->owner && iter->impl == addon->impl) + assert(0 && "Can't have two addons of the same type with the same owner"); + } + + wl_list_insert(&set->addons, &addon->link); + + addon->owner = owner; + addon->impl = impl; +} + +void +ds_addon_finish(ds_addon_t *addon) +{ + wl_list_remove(&addon->link); + wl_list_init(&addon->link); +} + +ds_addon_t * +ds_addon_find(ds_addon_set_t *set, const void *owner, + const ds_addon_interface_t *impl) +{ + struct ds_addon *addon; + + wl_list_for_each(addon, &set->addons, link) { + if (addon->owner == owner && addon->impl == impl) + return addon; + } + + return NULL; +} diff --git a/src/libds/addon.h b/src/libds/addon.h new file mode 100644 index 0000000..bb04e7b --- /dev/null +++ b/src/libds/addon.h @@ -0,0 +1,42 @@ +#ifndef DS_ADDON_H +#define DS_ADDON_H + +#include + +typedef struct ds_addon_set ds_addon_set_t; +typedef struct ds_addon_interface ds_addon_interface_t; +typedef struct ds_addon ds_addon_t; + +struct ds_addon_set { + struct wl_list addons; +}; + +struct ds_addon_interface { + const char *name; + void (*destroy)(struct ds_addon *addon); +}; + +struct ds_addon { + const ds_addon_interface_t *impl; + const void *owner; + struct wl_list link; +}; + +void +ds_addon_set_init(ds_addon_set_t *set); + +void +ds_addon_set_finish(ds_addon_set_t *set); + +void +ds_addon_init(ds_addon_t *addon, ds_addon_set_t *set, + const void *owner, const ds_addon_interface_t *impl); + +void +ds_addon_finish(ds_addon_t *addon); + +ds_addon_t * +ds_addon_find(ds_addon_set_t *set, const void *owner, + const ds_addon_interface_t *impl); + +#endif diff --git a/src/libds/allocator/allocator.c b/src/libds/allocator/allocator.c new file mode 100644 index 0000000..34c0aa7 --- /dev/null +++ b/src/libds/allocator/allocator.c @@ -0,0 +1,37 @@ +#include +#include +#include + +#include "libds/log.h" +#include "libds/interfaces/allocator.h" + +WL_EXPORT void +ds_allocator_init(struct ds_allocator *alloc, + const struct ds_allocator_interface *iface, uint32_t buffer_caps) +{ + alloc->iface = iface; + alloc->buffer_caps = buffer_caps; + + wl_signal_init(&alloc->events.destroy); +} + +WL_EXPORT void +ds_allocator_destroy(struct ds_allocator *alloc) +{ + wl_signal_emit(&alloc->events.destroy, NULL); + alloc->iface->destroy(alloc); +} + +WL_EXPORT struct ds_buffer * +ds_allocator_create_buffer(struct ds_allocator *alloc, int width, int height, + uint32_t format) +{ + return alloc->iface->create_buffer(alloc, width, height, format); +} + +WL_EXPORT void +ds_allocator_add_destroy_listener(struct ds_allocator *alloc, + struct wl_listener *listener) +{ + wl_signal_add(&alloc->events.destroy, listener); +} diff --git a/src/libds/allocator/shm.c b/src/libds/allocator/shm.c new file mode 100644 index 0000000..3b9e219 --- /dev/null +++ b/src/libds/allocator/shm.c @@ -0,0 +1,174 @@ +#include +#include +#include +#include +#include +#include + +#include "libds/allocator/shm.h" +#include "libds/interfaces/allocator.h" +#include "libds/interfaces/buffer.h" +#include "libds/log.h" +#include "util.h" + +typedef struct ds_shm_allocator ds_shm_allocator_t; + +typedef struct ds_shm_buffer ds_shm_buffer_t; + +struct ds_shm_allocator +{ + struct ds_allocator base; +}; + +struct ds_shm_buffer +{ + struct ds_buffer base; + struct ds_shm_attributes shm; + void *data; + size_t size; +}; + +static const struct ds_allocator_interface shm_allocator_iface; + +WL_EXPORT struct ds_allocator * +ds_shm_allocator_create(void) +{ + ds_shm_allocator_t *alloc; + + alloc = calloc(1, sizeof *alloc); + if (!alloc) + return NULL; + + ds_allocator_init(&alloc->base, &shm_allocator_iface, + DS_BUFFER_CAP_DATA_PTR | DS_BUFFER_CAP_SHM); + + ds_dbg("Shm allocator(%p) created", alloc); + + return &alloc->base; +} + +static ds_shm_allocator_t * +shm_allocator_from_allocator(struct ds_allocator *ds_allocator) +{ + assert(ds_allocator->iface == &shm_allocator_iface); + return (ds_shm_allocator_t *)ds_allocator; +} + +static void +shm_allocator_destroy(struct ds_allocator *ds_allocator) +{ + ds_shm_allocator_t *alloc; + + alloc = shm_allocator_from_allocator(ds_allocator); + ds_dbg("Destroy Shm allocator(%p)", alloc); + free(alloc); +} + +static const struct ds_buffer_interface shm_buffer_interface; + +static ds_shm_buffer_t * +shm_buffer_from_buffer(struct ds_buffer *buffer) +{ + assert(buffer->iface == &shm_buffer_interface); + return (ds_shm_buffer_t *)buffer; +} + +static void +shm_buffer_destroy(struct ds_buffer *ds_buffer) +{ + ds_shm_buffer_t *buffer; + + buffer = shm_buffer_from_buffer(ds_buffer); + + ds_dbg("Destroy shm buffer(%p)", buffer); + + munmap(buffer->data, buffer->size); + close(buffer->shm.fd); + free(buffer); +} + +static bool +shm_buffer_get_shm(struct ds_buffer *ds_buffer, struct ds_shm_attributes *shm) +{ + ds_shm_buffer_t *buffer; + + buffer = shm_buffer_from_buffer(ds_buffer); + memcpy(shm, &buffer->shm, sizeof *shm); + return true; +} + +static bool +shm_buffer_begin_data_ptr_access(struct ds_buffer *ds_buffer, uint32_t flags, + void **data, uint32_t *format, size_t *stride) +{ + ds_shm_buffer_t *buffer; + + buffer = shm_buffer_from_buffer(ds_buffer); + *data = buffer->data; + *format = buffer->shm.format; + *stride = buffer->shm.stride; + return true; +} + +static void +shm_buffer_end_data_ptr_access(struct ds_buffer *buffer) +{ + (void) buffer; + + // This space is intentionally left blank +} + +static const struct ds_buffer_interface shm_buffer_interface = +{ + .destroy = shm_buffer_destroy, + .get_shm = shm_buffer_get_shm, + .begin_data_ptr_access = shm_buffer_begin_data_ptr_access, + .end_data_ptr_access = shm_buffer_end_data_ptr_access, +}; + +static struct ds_buffer * +shm_allocator_create_buffer(struct ds_allocator *ds_allocator, + int width, int height, uint32_t format) +{ + ds_shm_buffer_t *buffer; + + buffer = calloc(1, sizeof *buffer); + if (!buffer) + return NULL; + + ds_buffer_init(&buffer->base, &shm_buffer_interface, width, height); + + // FIXME + int bytes_per_pixel = 4; + int stride = width * bytes_per_pixel; + buffer->size = stride * height; + buffer->shm.fd = allocate_shm_file(buffer->size); + if (buffer->shm.fd < 0) { + free(buffer); + return NULL; + } + + buffer->shm.format = format; + buffer->shm.width = width; + buffer->shm.height = height; + buffer->shm.stride = stride; + buffer->shm.offset = 0; + + buffer->data = mmap(NULL, buffer->size, PROT_READ | PROT_WRITE, MAP_SHARED, + buffer->shm.fd, 0); + if (buffer->data == MAP_FAILED) { + ds_log_errno(DS_ERR, "mmap failed"); + close(buffer->shm.fd); + free(buffer); + return NULL; + } + + ds_dbg("Shm buffer(%p) created: size(%dx%d)", buffer, width, height); + + return &buffer->base; +} + +static const struct ds_allocator_interface shm_allocator_iface = { + .destroy = shm_allocator_destroy, + .create_buffer = shm_allocator_create_buffer, +}; diff --git a/src/libds/backend/backend.c b/src/libds/backend/backend.c new file mode 100644 index 0000000..d52a8d2 --- /dev/null +++ b/src/libds/backend/backend.c @@ -0,0 +1,55 @@ +#include +#include + +#include "libds/interfaces/backend.h" + +WL_EXPORT bool +ds_backend_start(struct ds_backend *backend) +{ + if (backend->iface->start) + return backend->iface->start(backend); + + backend->started = true; + + return true; +} + +WL_EXPORT void +ds_backend_destroy(struct ds_backend *backend) +{ + if (!backend) + return; + + if (backend->iface && backend->iface->destroy) + backend->iface->destroy(backend); + else + free(backend); +} + +WL_EXPORT void +ds_backend_add_destroy_listener(struct ds_backend *backend, + struct wl_listener *listener) +{ + wl_signal_add(&backend->events.destroy, listener); +} + +WL_EXPORT void +ds_backend_add_new_output_listener(struct ds_backend *backend, + struct wl_listener *listener) +{ + wl_signal_add(&backend->events.new_output, listener); +} + +void +ds_backend_init(struct ds_backend *backend, const struct ds_backend_interface *iface) +{ + backend->iface = iface; + wl_signal_init(&backend->events.destroy); + wl_signal_init(&backend->events.new_output); +} + +void +ds_backend_finish(struct ds_backend *backend) +{ + wl_signal_emit(&backend->events.destroy, backend); +} diff --git a/src/libds/backend/meson.build b/src/libds/backend/meson.build new file mode 100644 index 0000000..b135534 --- /dev/null +++ b/src/libds/backend/meson.build @@ -0,0 +1,5 @@ +libds_files += files( + 'backend.c', +) + +subdir('wayland') diff --git a/src/libds/backend/wayland/backend.c b/src/libds/backend/wayland/backend.c new file mode 100644 index 0000000..faa2c64 --- /dev/null +++ b/src/libds/backend/wayland/backend.c @@ -0,0 +1,281 @@ +#include +#include +#include +#include +#include + +#include "backend.h" +#include "libds/log.h" +#include "libds/output.h" + +#include "xdg-shell-client-protocol.h" + +static const struct ds_backend_interface wl_backend_interface; +static void wl_backend_handle_display_destroy(struct wl_listener *listener, + void *data); +static bool wl_backend_server_init(ds_wl_backend_server_t *server, + const char *name); +static void wl_backend_server_finish(ds_wl_backend_server_t *server); +static int wl_backend_handle_dispatch_events(int fd, uint32_t mask, + void *data); + +WL_EXPORT struct ds_backend * +ds_wl_backend_create(struct wl_display *display, const char *server_name) +{ + ds_wl_backend_t *wl_backend; + struct wl_event_loop *loop; + int fd; + + wl_backend = calloc(1, sizeof *wl_backend); + if (!wl_backend) { + ds_log_errno(DS_ERR, "Could not allocate memory"); + return NULL; + } + + ds_backend_init(&wl_backend->base, &wl_backend_interface); + + wl_backend->display = display; + wl_list_init(&wl_backend->buffers); + wl_list_init(&wl_backend->outputs); + + if (!wl_backend_server_init(&wl_backend->server, server_name)) { + ds_err("Failed to initialize Wayland Server"); + goto err_server; + } + + loop = wl_display_get_event_loop(wl_backend->display); + fd = wl_display_get_fd(wl_backend->server.display); + + wl_backend->server_event_source = + wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE, + wl_backend_handle_dispatch_events, wl_backend); + if (!wl_backend->server_event_source) { + ds_err("Failed to create event source"); + goto err_src; + } + + wl_backend->display_destroy.notify = wl_backend_handle_display_destroy; + wl_display_add_destroy_listener(display, &wl_backend->display_destroy); + + ds_inf("Wayland backend(%p) created: server name \"%s\"", + wl_backend, server_name); + + return &wl_backend->base; + +err_src: + wl_backend_server_finish(&wl_backend->server); +err_server: + ds_backend_finish(&wl_backend->base); + free(wl_backend); + + return NULL; +} + +ds_wl_backend_t * +wl_backend_from_backend(struct ds_backend *backend) +{ + assert(backend->iface == &wl_backend_interface); + return (ds_wl_backend_t *)backend; +} + +static void +wl_backend_destroy(ds_wl_backend_t *backend) +{ + ds_wl_output_t *output, *tmp_output; + ds_wl_buffer_t *buffer, *tmp_buffer; + + ds_dbg("Destroy wayland backend(%p)", backend); + + wl_list_for_each_safe(output, tmp_output, &backend->outputs, link) { + ds_output_destroy(&output->base); + } + + wl_list_for_each_safe(buffer, tmp_buffer, &backend->buffers, link) { + destroy_wl_buffer(buffer); + } + + ds_backend_finish(&backend->base); + + wl_list_remove(&backend->display_destroy.link); + + wl_event_source_remove(backend->server_event_source); + + wl_backend_server_finish(&backend->server); + + free(backend); +} + +static void +wl_backend_iface_destroy(struct ds_backend *backend) +{ + ds_wl_backend_t *wl_backend; + + if (!backend) + return; + + wl_backend = wl_backend_from_backend(backend); + + wl_backend_destroy(wl_backend); +} + +static const struct ds_backend_interface wl_backend_interface = { + .start = NULL, + .destroy = wl_backend_iface_destroy, + .get_drm_fd = NULL, +}; + +static void +wl_backend_handle_display_destroy(struct wl_listener *listener, void *data) +{ + ds_wl_backend_t *wl_backend; + + wl_backend = wl_container_of(listener, wl_backend, display_destroy); + wl_backend_destroy(wl_backend); +} + +static void +shm_handle_format(void *data, struct wl_shm *shm, uint32_t shm_format) +{ +} + +static const struct wl_shm_listener shm_listener = +{ + .format = shm_handle_format, +}; + +static void +xdg_wm_base_handle_ping(void *data, struct xdg_wm_base *base, uint32_t serial) +{ + xdg_wm_base_pong(base, serial); +} + +static const struct xdg_wm_base_listener xdg_wm_base_listener = +{ + .ping = xdg_wm_base_handle_ping, +}; + +static void +registry_handle_global(void *data, struct wl_registry *registry, + uint32_t name, const char *iface, uint32_t version) +{ + ds_wl_backend_server_t *server = data; + + ds_log(DS_DBG, "Wayland global: %s v%d", iface, version); + + if (strcmp(iface, wl_compositor_interface.name) == 0) { + server->compositor = wl_registry_bind(registry, name, + &wl_compositor_interface, 4); + } + else if (strcmp(iface, xdg_wm_base_interface.name) == 0) { + server->xdg_wm_base = wl_registry_bind(registry, name, + &xdg_wm_base_interface, 1); + xdg_wm_base_add_listener(server->xdg_wm_base, + &xdg_wm_base_listener, NULL); + } + else if (strcmp(iface, wl_shm_interface.name) == 0) { + server->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); + wl_shm_add_listener(server->shm, &shm_listener, server); + } +} + +static void +registry_handle_global_remove(void *data, struct wl_registry *registry, + uint32_t name) +{ + // TODO +} + +static const struct wl_registry_listener registry_listener = { + .global = registry_handle_global, + .global_remove = registry_handle_global_remove, +}; + +static bool +wl_backend_server_init(ds_wl_backend_server_t *server, const char *name) +{ + server->display = wl_display_connect(name); + if (!server->display) { + ds_log_errno(DS_ERR, "Could not connect to display: name \"%s\"", name); + return false; + } + + server->registry = wl_display_get_registry(server->display); + if (!server->registry) { + ds_log_errno(DS_ERR, "Could not get wl_registry"); + goto err_reg; + } + + wl_registry_add_listener(server->registry, ®istry_listener, server); + + wl_display_roundtrip(server->display); + + if (!server->compositor) { + ds_err("Wayland Server does not support wl_compositor"); + goto err_bind; + } + + if (!server->xdg_wm_base) { + ds_err("Wayland Server does not support xdg_wm_base"); + goto err_bind; + } + + return true; + +err_bind: + if (server->compositor) + wl_compositor_destroy(server->compositor); + + if (server->xdg_wm_base) + xdg_wm_base_destroy(server->xdg_wm_base); + + wl_registry_destroy(server->registry); +err_reg: + wl_display_disconnect(server->display); + + return false; +} + +static void +wl_backend_server_finish(ds_wl_backend_server_t *server) +{ + xdg_wm_base_destroy(server->xdg_wm_base); + wl_compositor_destroy(server->compositor); + wl_registry_destroy(server->registry); + wl_display_disconnect(server->display); +} + +static int +wl_backend_handle_dispatch_events(int fd, uint32_t mask, void *data) +{ + ds_wl_backend_t *wl_backend = data; + ds_wl_backend_server_t *server = &wl_backend->server; + int count = 0; + + if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) { + if (mask & WL_EVENT_ERROR) { + ds_err("Failed to read from Wayland Server"); + } + wl_display_terminate(wl_backend->display); + return 0; + } + + count = 0; + if (mask & WL_EVENT_READABLE) + count = wl_display_dispatch(server->display); + + if (mask & WL_EVENT_WRITABLE) + wl_display_flush(server->display); + + if (mask == 0) { + count = wl_display_dispatch_pending(server->display); + wl_display_flush(server->display); + } + + if (count < 0) { + ds_err("Failed to dispatch Wayland Server"); + wl_display_terminate(wl_backend->display); + return 0; + } + + return count; +} diff --git a/src/libds/backend/wayland/backend.h b/src/libds/backend/wayland/backend.h new file mode 100644 index 0000000..1c3cd5b --- /dev/null +++ b/src/libds/backend/wayland/backend.h @@ -0,0 +1,69 @@ +#ifndef DS_BACKEND_WAYLAND_H +#define DS_BACKEND_WAYLAND_H + +#include "libds/interfaces/backend.h" +#include "libds/interfaces/output.h" + +typedef struct ds_wl_backend_server ds_wl_backend_server_t; + +typedef struct ds_wl_backend ds_wl_backend_t; + +typedef struct ds_wl_buffer ds_wl_buffer_t; + +typedef struct ds_wl_output ds_wl_output_t; + +struct ds_wl_backend_server +{ + struct wl_display *display; + struct wl_registry *registry; + struct wl_compositor *compositor; + struct xdg_wm_base *xdg_wm_base; + struct wl_event_source *event_source; + struct wl_shm *shm; +}; + +struct ds_wl_backend +{ + struct ds_backend base; + + struct wl_display *display; + struct wl_listener display_destroy; + + struct wl_list outputs; // ds_wl_output.link + struct wl_list buffers; // ds_wl_buffer.link + + struct wl_event_source *server_event_source; + ds_wl_backend_server_t server; +}; + +struct ds_wl_buffer +{ + struct ds_buffer *buffer; + struct wl_buffer *wl_buffer; + struct wl_list link; // ds_wl_backend.buffers + struct wl_listener buffer_destroy; + + bool released; +}; + +struct ds_wl_output +{ + struct ds_output base; + + ds_wl_backend_t *backend; + + struct wl_surface *surface; + struct xdg_surface *xdg_surface; + struct xdg_toplevel *xdg_toplevel; + struct wl_callback *frame_callback; + + struct wl_list link; +}; + +ds_wl_backend_t * +wl_backend_from_backend(struct ds_backend *backend); + +void +destroy_wl_buffer(ds_wl_buffer_t *buffer); + +#endif diff --git a/src/libds/backend/wayland/meson.build b/src/libds/backend/wayland/meson.build new file mode 100644 index 0000000..db68fe9 --- /dev/null +++ b/src/libds/backend/wayland/meson.build @@ -0,0 +1,26 @@ +libds_files += files( + 'backend.c', + 'output.c', +) + +protocols = { + 'xdg-shell': wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml', +} + +protocols_code = {} +protocols_client_header = {} + +foreach name, path : protocols + client_header = custom_target( + name.underscorify() + '_client_h', + input: path, + output: '@BASENAME@-client-protocol.h', + command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'], + build_by_default: false, + ) + libds_files += client_header +endforeach + +libds_deps += [ + dependency('wayland-client', required: true), +] diff --git a/src/libds/backend/wayland/output.c b/src/libds/backend/wayland/output.c new file mode 100644 index 0000000..a995dbf --- /dev/null +++ b/src/libds/backend/wayland/output.c @@ -0,0 +1,309 @@ +#include +#include +#include + +#include "backend.h" +#include "libds/log.h" +#include "libds/output.h" + +#include "xdg-shell-client-protocol.h" + +const struct ds_output_interface wl_output_iface; +static const struct xdg_surface_listener wl_output_xdg_surface_listener; +static const struct xdg_toplevel_listener wl_output_xdg_toplevel_listener; + +struct ds_output * +ds_wl_backend_create_output(struct ds_backend *ds_backend) +{ + ds_wl_backend_t *backend; + ds_wl_output_t *output; + + backend = wl_backend_from_backend(ds_backend); + + output = calloc(1, sizeof *output); + if (!output) { + ds_log_errno(DS_ERR, "Could not allocate ds_wl_output"); + return NULL; + } + + ds_output_init(&output->base, &backend->base, &wl_output_iface, + backend->display); + + output->backend = backend; + + output->surface = wl_compositor_create_surface(backend->server.compositor); + if (!output->surface) { + ds_log_errno(DS_ERR, "Could not create output surface"); + goto err; + } + wl_surface_set_user_data(output->surface, output); + + output->xdg_surface = + xdg_wm_base_get_xdg_surface(backend->server.xdg_wm_base, + output->surface); + if (!output->xdg_surface) { + ds_log_errno(DS_ERR, "Could not get xdg_surface"); + goto err; + } + xdg_surface_add_listener(output->xdg_surface, + &wl_output_xdg_surface_listener, output); + + output->xdg_toplevel = + xdg_surface_get_toplevel(output->xdg_surface); + if (!output->xdg_toplevel) { + ds_log_errno(DS_ERR, "Could not get xdg_toplevel"); + goto err; + } + xdg_toplevel_add_listener(output->xdg_toplevel, + &wl_output_xdg_toplevel_listener, output); + + xdg_toplevel_set_app_id(output->xdg_toplevel, "libds"); + + wl_surface_commit(output->surface); + + wl_display_roundtrip(backend->server.display); + + wl_list_insert(&backend->outputs, &output->link); + + wl_signal_emit(&backend->base.events.new_output, &output->base); + + ds_dbg("Wayland output(%p) created", output); + + return &output->base; + +err: + ds_output_destroy(&output->base); + + return NULL; +} + +void +destroy_wl_buffer(ds_wl_buffer_t *buffer) +{ + if (buffer == NULL) + return; + + wl_list_remove(&buffer->buffer_destroy.link); + wl_list_remove(&buffer->link); + wl_buffer_destroy(buffer->wl_buffer); + free(buffer); +} + +static ds_wl_output_t * +wl_output_from_output(struct ds_output *ds_output) +{ + assert(ds_output->iface == &wl_output_iface); + return (ds_wl_output_t *)ds_output; +} + +static void +wl_output_iface_destroy(struct ds_output *ds_output) +{ + ds_wl_output_t *output; + + output = wl_output_from_output(ds_output); + + ds_dbg("Destroy wayland output(%p)", output); + + wl_list_remove(&output->link); + + if (output->frame_callback) + wl_callback_destroy(output->frame_callback); + + if (output->xdg_toplevel) + xdg_toplevel_destroy(output->xdg_toplevel); + + if (output->xdg_surface) + xdg_surface_destroy(output->xdg_surface); + + if (output->surface) + wl_surface_destroy(output->surface); + + wl_display_flush(output->backend->server.display); + + free(output); +} + +static struct wl_buffer * +import_shm(ds_wl_backend_t *backend, struct ds_shm_attributes *shm) +{ + enum wl_shm_format wl_shm_format = WL_SHM_FORMAT_XRGB8888; + struct wl_shm_pool *pool; + struct wl_buffer *wl_buffer; + uint32_t size; + + size = shm->stride * shm->height; + pool = wl_shm_create_pool(backend->server.shm, shm->fd, size); + if (!pool) + return NULL; + + wl_buffer = wl_shm_pool_create_buffer(pool, shm->offset, + shm->width, shm->height, shm->stride, wl_shm_format); + wl_shm_pool_destroy(pool); + + return wl_buffer; +} + +static void +buffer_handle_release(void *data, struct wl_buffer *wl_buffer) +{ + ds_wl_buffer_t *buffer = data; + + ds_dbg("Wayland output: Buffer(%p) released.", buffer->buffer); + buffer->released = true; + ds_buffer_unlock(buffer->buffer); +} + +static const struct wl_buffer_listener buffer_listener = { + .release = buffer_handle_release, +}; + +static void +buffer_handle_buffer_destroy(struct wl_listener *listener, void *data) +{ + ds_wl_buffer_t *buffer; + + buffer = wl_container_of(listener, buffer, buffer_destroy); + destroy_wl_buffer(buffer); +} + +static ds_wl_buffer_t * +create_wl_buffer(ds_wl_backend_t *backend, struct ds_buffer *ds_buffer) +{ + struct ds_shm_attributes shm; + ds_wl_buffer_t *buffer; + struct wl_buffer *wl_buffer; + + if (ds_buffer_get_shm(ds_buffer, &shm)) { + wl_buffer = import_shm(backend, &shm); + } + + buffer = calloc(1, sizeof *buffer); + if (!buffer) { + wl_buffer_destroy(wl_buffer); + return NULL; + } + + buffer->wl_buffer = wl_buffer; + buffer->buffer = ds_buffer_lock(ds_buffer); + wl_list_insert(&backend->buffers, &buffer->link); + + wl_buffer_add_listener(wl_buffer, &buffer_listener, buffer); + + buffer->buffer_destroy.notify = buffer_handle_buffer_destroy; + ds_buffer_add_destroy_listener(ds_buffer, &buffer->buffer_destroy); + + return buffer; +} + +static ds_wl_buffer_t * +get_or_create_wl_buffer(ds_wl_backend_t *backend, struct ds_buffer *ds_buffer) +{ + ds_wl_buffer_t *buffer; + + wl_list_for_each(buffer, &backend->buffers, link) { + if (buffer->buffer == ds_buffer && buffer->released) { + buffer->released = false; + ds_buffer_lock(buffer->buffer); + return buffer; + } + } + + return create_wl_buffer(backend, ds_buffer); +} + +static void +surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) +{ + ds_wl_output_t *output = data; + + wl_callback_destroy(cb); + output->frame_callback = NULL; + + wl_signal_emit(&output->base.events.frame, &output->base); +} + +static const struct wl_callback_listener frame_listener = { + .done = surface_frame_callback +}; + +static bool +wl_output_iface_commit(struct ds_output *ds_output) +{ + ds_wl_output_t *output; + ds_wl_buffer_t *buffer; + struct ds_buffer *ds_buffer; + + output = wl_output_from_output(ds_output); + + ds_buffer = ds_output->pending.buffer; + buffer = get_or_create_wl_buffer(output->backend, ds_buffer); + if (!buffer) + return NULL; + + if (ds_output->pending.committed & DS_OUTPUT_STATE_BUFFER) { + + if (output->frame_callback != NULL) { + ds_err("Skipping buffer swap"); + return false; + } + + output->frame_callback = wl_surface_frame(output->surface); + wl_callback_add_listener(output->frame_callback, &frame_listener, + output); + wl_surface_attach(output->surface, buffer->wl_buffer, 0, 0); + wl_surface_damage_buffer(output->surface, 0, 0, INT32_MAX, INT32_MAX); + wl_surface_commit(output->surface); + + ds_dbg("Swap Buffer!!!!!"); + } + + wl_display_flush(output->backend->server.display); + + return true; +} + +const struct ds_output_interface wl_output_iface = +{ + .destroy = wl_output_iface_destroy, + .commit = wl_output_iface_commit, +}; + +static void +wl_output_xdg_surface_handle_configure(void *data, + struct xdg_surface *xdg_surface, uint32_t serial) +{ + xdg_surface_ack_configure(xdg_surface, serial); +} + +static const struct xdg_surface_listener wl_output_xdg_surface_listener = +{ + .configure = wl_output_xdg_surface_handle_configure, +}; + +static void +wl_output_xdg_toplevel_handle_configure(void *data, + struct xdg_toplevel *xdg_toplevel, + int32_t width, int32_t height, struct wl_array *states) +{ + // TODO + // ds_wl_output_t *output = data; + + if (width == 0 || height == 0) + return; +} + +static void +wl_output_xdg_toplevel_handle_close(void *data, + struct xdg_toplevel *xdg_toplevel) +{ + ds_wl_output_t *output = data; + + ds_output_destroy(&output->base); +} + +static const struct xdg_toplevel_listener wl_output_xdg_toplevel_listener = +{ + .configure = wl_output_xdg_toplevel_handle_configure, + .close = wl_output_xdg_toplevel_handle_close, +}; diff --git a/src/libds/buffer.c b/src/libds/buffer.c new file mode 100644 index 0000000..96edec5 --- /dev/null +++ b/src/libds/buffer.c @@ -0,0 +1,149 @@ +#include +#include + +#include "buffer.h" +#include "client_buffer.h" +#include "libds/log.h" +#include "libds/interfaces/buffer.h" + +static void buffer_consider_destroy(struct ds_buffer *buffer); +static bool ds_resource_is_buffer(struct wl_resource *resource); + +WL_EXPORT void +ds_buffer_init(struct ds_buffer *buffer, const struct ds_buffer_interface *iface, + int width, int height) +{ + buffer->iface = iface; + buffer->width = width; + buffer->height = height; + + wl_signal_init(&buffer->events.destroy); + wl_signal_init(&buffer->events.release); +} + +WL_EXPORT struct ds_buffer * +ds_buffer_from_resource(struct wl_resource *resource) +{ + struct ds_buffer *buffer; + + assert(resource && ds_resource_is_buffer(resource)); + + if (wl_shm_buffer_get(resource) != NULL) { + ds_shm_client_buffer_t *shm_client_buffer = + ds_shm_client_buffer_get_or_create(resource); + if (!shm_client_buffer) { + ds_err("Failed to create shm client buffer"); + return NULL; + } + + buffer = ds_buffer_lock(&shm_client_buffer->base); + } + else { + // TODO; + buffer = NULL; + } + + return buffer; +} + +WL_EXPORT void +ds_buffer_drop(struct ds_buffer *buffer) +{ + assert(!buffer->dropped); + buffer->dropped = true; + ds_dbg("Buffer(%p) dropped: n_locks(%zu)", buffer, buffer->n_locks); + buffer_consider_destroy(buffer); +} + +WL_EXPORT struct ds_buffer * +ds_buffer_lock(struct ds_buffer *buffer) +{ + buffer->n_locks++; + ds_dbg("Buffer(%p) n_locks(%zu)", buffer, buffer->n_locks); + return buffer; +} + +WL_EXPORT void +ds_buffer_unlock(struct ds_buffer *buffer) +{ + assert(buffer->n_locks > 0); + buffer->n_locks--; + ds_dbg("Buffer(%p) n_locks(%zu)", buffer, buffer->n_locks); + + if (buffer->n_locks == 0) + wl_signal_emit(&buffer->events.release, NULL); + + buffer_consider_destroy(buffer); +} + +WL_EXPORT bool +ds_buffer_begin_data_ptr_access(struct ds_buffer *buffer, uint32_t flags, + void **data, uint32_t *format, size_t *stride) +{ + assert(!buffer->accessing_data_ptr); + if (!buffer->iface->begin_data_ptr_access) + return false; + if (!buffer->iface->begin_data_ptr_access(buffer, flags, data, format, stride)) + return false; + buffer->accessing_data_ptr = true; + return true; +} + +WL_EXPORT void +ds_buffer_end_data_ptr_access(struct ds_buffer *buffer) +{ + assert(buffer->accessing_data_ptr); + buffer->iface->end_data_ptr_access(buffer); + buffer->accessing_data_ptr = false; +} + +WL_EXPORT void +ds_buffer_add_destroy_listener(struct ds_buffer *buffer, + struct wl_listener *listener) +{ + wl_signal_add(&buffer->events.destroy, listener); +} + +void +ds_buffer_add_release_listener(struct ds_buffer *buffer, + struct wl_listener *listener) +{ + wl_signal_add(&buffer->events.release, listener); +} + +WL_EXPORT bool +ds_buffer_get_shm(struct ds_buffer *buffer, struct ds_shm_attributes *attribs) +{ + if (!buffer->iface->get_shm) + return false; + + return buffer->iface->get_shm(buffer, attribs); +} + +WL_EXPORT void +ds_buffer_get_size(struct ds_buffer *buffer, int *out_width, int *out_height) +{ + if (out_width) + *out_width = buffer->width; + if (out_height) + *out_height = buffer->height; +} + +static void +buffer_consider_destroy(struct ds_buffer *buffer) +{ + if (!buffer->dropped || buffer->n_locks > 0) + return; + + assert(!buffer->accessing_data_ptr); + + wl_signal_emit(&buffer->events.destroy, NULL); + buffer->iface->destroy(buffer); +} + +static bool +ds_resource_is_buffer(struct wl_resource *resource) +{ + return strcmp(wl_resource_get_class(resource), + wl_buffer_interface.name) == 0; +} diff --git a/src/libds/buffer.h b/src/libds/buffer.h new file mode 100644 index 0000000..08b4784 --- /dev/null +++ b/src/libds/buffer.h @@ -0,0 +1,8 @@ +#ifndef DS_BUFFER_H +#define DS_BUFFER_H + +#include + +#include "libds/buffer.h" + +#endif diff --git a/src/libds/client_buffer.h b/src/libds/client_buffer.h new file mode 100644 index 0000000..f21ea7c --- /dev/null +++ b/src/libds/client_buffer.h @@ -0,0 +1,31 @@ +#ifndef DS_CLIENT_BUFFER_H +#define DS_CLIENT_BUFFER_H + +#include + +#include "util.h" +#include "libds/buffer.h" +#include "libds/interfaces/buffer.h" + +typedef struct ds_shm_client_buffer ds_shm_client_buffer_t; + +struct ds_shm_client_buffer +{ + struct ds_buffer base; + + uint32_t format; + size_t stride; + + struct wl_resource *resource; + struct wl_shm_buffer *shm_buffer; + + struct { + struct wl_listener buffer_release; + struct wl_listener resource_destroy; + } listener; +}; + +ds_shm_client_buffer_t * +ds_shm_client_buffer_get_or_create(struct wl_resource *resource); + +#endif diff --git a/src/libds/client_buffer/shm_client_buffer.c b/src/libds/client_buffer/shm_client_buffer.c new file mode 100644 index 0000000..e2c4308 --- /dev/null +++ b/src/libds/client_buffer/shm_client_buffer.c @@ -0,0 +1,157 @@ +#include +#include +#include + +#include "pixel_format.h" +#include "buffer.h" +#include "libds/log.h" +#include "client_buffer.h" + +static void +shm_client_buffer_resource_handle_destroy(struct wl_listener *listener, + void *data); +static ds_shm_client_buffer_t * +shm_client_buffer_create(struct wl_resource *resource); + +ds_shm_client_buffer_t * +ds_shm_client_buffer_get_or_create(struct wl_resource *resource) +{ + ds_shm_client_buffer_t *buffer; + struct wl_listener *resource_destroy_listener; + + resource_destroy_listener = wl_resource_get_destroy_listener(resource, + shm_client_buffer_resource_handle_destroy); + if (resource_destroy_listener) { + buffer = wl_container_of(resource_destroy_listener, + buffer, listener.resource_destroy); + return buffer; + } + + return shm_client_buffer_create(resource); +} + +static void +shm_client_buffer_resource_handle_destroy(struct wl_listener *listener, + void *data) +{ + ds_shm_client_buffer_t *buffer; + + buffer = wl_container_of(listener, buffer, listener.resource_destroy); + + buffer->resource = NULL; + buffer->shm_buffer = NULL; + wl_list_remove(&buffer->listener.resource_destroy.link); + wl_list_init(&buffer->listener.resource_destroy.link); + + ds_buffer_drop(&buffer->base); +} + +static const struct ds_buffer_interface shm_client_buffer_iface; + +static ds_shm_client_buffer_t * +shm_client_buffer_from_buffer(struct ds_buffer *buffer) +{ + assert(buffer->iface == &shm_client_buffer_iface); + return (ds_shm_client_buffer_t *)buffer; +} + +static void +shm_client_buffer_destroy(struct ds_buffer *ds_buffer) +{ + ds_shm_client_buffer_t *buffer; + + buffer = shm_client_buffer_from_buffer(ds_buffer); + + ds_dbg("Destroy shm client buffer(%p)", buffer); + + wl_list_remove(&buffer->listener.resource_destroy.link); + wl_list_remove(&buffer->listener.buffer_release.link); + free(buffer); +} + +static bool +shm_client_buffer_begin_data_ptr_access(struct ds_buffer *ds_buffer, + enum ds_buffer_data_ptr_access_flag flags, void **data, + uint32_t *format, size_t *stride) +{ + ds_shm_client_buffer_t *buffer; + + buffer = shm_client_buffer_from_buffer(ds_buffer); + *format = buffer->format; + *stride = buffer->stride; + if (buffer->shm_buffer) { + *data = wl_shm_buffer_get_data(buffer->shm_buffer); + wl_shm_buffer_begin_access(buffer->shm_buffer); + } + else + return false; + + return true; +} + +static void +shm_client_buffer_end_data_ptr_access(struct ds_buffer *ds_buffer) +{ + ds_shm_client_buffer_t *buffer; + + buffer = shm_client_buffer_from_buffer(ds_buffer); + if (buffer->shm_buffer) + wl_shm_buffer_end_access(buffer->shm_buffer); +} + +static const struct ds_buffer_interface shm_client_buffer_iface = { + .destroy = shm_client_buffer_destroy, + .begin_data_ptr_access = shm_client_buffer_begin_data_ptr_access, + .end_data_ptr_access = shm_client_buffer_end_data_ptr_access, +}; + +static void +shm_client_buffer_handle_release(struct wl_listener *listener, void *data) +{ + ds_shm_client_buffer_t *buffer; + + buffer = wl_container_of(listener, buffer, listener.buffer_release); + if (buffer->resource) + wl_buffer_send_release(buffer->resource); +} + +static ds_shm_client_buffer_t * +shm_client_buffer_create(struct wl_resource *resource) +{ + ds_shm_client_buffer_t *buffer; + struct wl_shm_buffer *shm_buffer; + enum wl_shm_format wl_shm_format; + int32_t width; + int32_t height; + + shm_buffer = wl_shm_buffer_get(resource); + width = wl_shm_buffer_get_width(shm_buffer); + height = wl_shm_buffer_get_height(shm_buffer); + + buffer = calloc(1, sizeof(*buffer)); + if (!buffer) + return NULL; + + ds_buffer_init(&buffer->base, &shm_client_buffer_iface, width, height); + + buffer->resource = resource; + buffer->shm_buffer = shm_buffer; + + wl_shm_format = wl_shm_buffer_get_format(shm_buffer); + buffer->format = convert_wl_shm_format_to_drm(wl_shm_format); + buffer->stride = wl_shm_buffer_get_stride(shm_buffer); + + buffer->listener.buffer_release.notify = + shm_client_buffer_handle_release; + ds_buffer_add_release_listener(&buffer->base, + &buffer->listener.buffer_release); + + buffer->listener.resource_destroy.notify = + shm_client_buffer_resource_handle_destroy; + wl_resource_add_destroy_listener(resource, + &buffer->listener.resource_destroy); + + ds_dbg("Shm client buffer(%p) created", buffer); + + return buffer; +} diff --git a/src/libds/compositor.c b/src/libds/compositor.c new file mode 100644 index 0000000..a073405 --- /dev/null +++ b/src/libds/compositor.c @@ -0,0 +1,143 @@ +#include +#include + +#include "libds/log.h" +#include "subcompositor.h" +#include "surface.h" +#include "region.h" + +#define COMPOSITOR_VERSION 4 + +struct ds_compositor +{ + struct wl_global *global; + ds_subcompositor_t subcompositor; + + struct { + struct wl_signal new_surface; + struct wl_signal destroy; + } events; + + struct wl_listener display_destroy; +}; + +static void compositor_bind(struct wl_client *client, void *data, + uint32_t version, uint32_t id); +static void compositor_handle_display_destroy(struct wl_listener *listener, + void *data); + +WL_EXPORT struct ds_compositor * +ds_compositor_create(struct wl_display *display) +{ + struct ds_compositor *compositor; + + compositor = calloc(1, sizeof *compositor); + if (!compositor) { + ds_log_errno(DS_ERR, "Could not allocate memory"); + return NULL; + } + + compositor->global = wl_global_create(display, &wl_compositor_interface, + COMPOSITOR_VERSION, compositor, compositor_bind); + if (!compositor->global) { + ds_log_errno(DS_ERR, "Could not create global"); + goto err_global; + } + + if (!ds_subcompositor_init(&compositor->subcompositor, display)) { + ds_err("Could not initialize subcompositor"); + goto err_subcomp; + } + + wl_signal_init(&compositor->events.new_surface); + wl_signal_init(&compositor->events.destroy); + + compositor->display_destroy.notify = compositor_handle_display_destroy; + wl_display_add_destroy_listener(display, &compositor->display_destroy); + + ds_inf("Compositor(%p) created", compositor); + + return compositor; + +err_subcomp: + wl_global_destroy(compositor->global); +err_global: + free(compositor); + + return NULL; +} + +WL_EXPORT void +ds_compositor_add_new_surface_listener(struct ds_compositor *compositor, + struct wl_listener *listener) +{ + wl_signal_add(&compositor->events.new_surface, listener); +} + +WL_EXPORT void +ds_compositor_add_destroy_listener(struct ds_compositor *compositor, + struct wl_listener *listener) +{ + wl_signal_add(&compositor->events.destroy, listener); +} + +static void +compositor_handle_create_surface(struct wl_client *client, + struct wl_resource *resource, uint32_t id) +{ + struct ds_compositor *compositor = wl_resource_get_user_data(resource); + struct ds_surface *surface; + + surface = ds_surface_create(client, + wl_resource_get_version(resource), id); + if (!surface) { + ds_err("Could not create ds_surface"); + return; + } + + wl_signal_emit(&compositor->events.new_surface, surface); +} + +static void +compositor_handle_create_region(struct wl_client *client, + struct wl_resource *resource, uint32_t id) +{ + ds_region_add(client, wl_resource_get_version(resource), id); +} + +static const struct wl_compositor_interface compositor_impl = { + .create_surface = compositor_handle_create_surface, + .create_region = compositor_handle_create_region, +}; + +static void compositor_bind(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + struct ds_compositor *compositor = data; + struct wl_resource *resource; + + resource = wl_resource_create(client, &wl_compositor_interface, + version, id); + if (resource == NULL) { + wl_client_post_no_memory(client); + return; + } + + wl_resource_set_implementation(resource, &compositor_impl, + compositor, NULL); +} + +static void +compositor_handle_display_destroy(struct wl_listener *listener, void *data) +{ + struct ds_compositor *compositor = + wl_container_of(listener, compositor, display_destroy); + + ds_dbg("Destroy compositor(%p)", compositor); + + wl_signal_emit(&compositor->events.destroy, compositor); + + wl_list_remove(&compositor->display_destroy.link); + ds_subcompositor_finish(&compositor->subcompositor); + free(compositor); +} diff --git a/src/libds/log.c b/src/libds/log.c new file mode 100644 index 0000000..2777f9a --- /dev/null +++ b/src/libds/log.c @@ -0,0 +1,96 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "libds/log.h" + +static bool colored = true; +static enum ds_log_level log_level = DS_ERR; + +static const char *level_colors[] = { + [DS_SILENT] = "", + [DS_ERR] = "\x1B[1;31m", + [DS_INF] = "\x1B[1;34m", + [DS_DBG] = "\x1B[1;90m", +}; + +static const char *level_headers[] = { + [DS_SILENT] = "", + [DS_ERR] = "[ERROR]", + [DS_INF] = "[INFO]", + [DS_DBG] = "[DEBUG]", +}; + +static void log_stderr(enum ds_log_level level, const char *fmt, va_list args); +static void log_wl(const char *fmt, va_list args); + +static ds_log_func_t log_callback = log_stderr; + +WL_EXPORT void +ds_log_init(enum ds_log_level level, ds_log_func_t callback) +{ + if (level < DS_LOG_LEVEL_LAST) + log_level = level; + if (callback) + log_callback = callback; + + wl_log_set_handler_server(log_wl); +} + +WL_EXPORT void +_ds_vlog(enum ds_log_level level, const char *fmt, va_list args) +{ + log_callback(level, fmt, args); +} + +WL_EXPORT void +_ds_log(enum ds_log_level level, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + log_callback(level, fmt, args); + va_end(args); +} + +enum ds_log_level +ds_log_get_level(void) +{ + return log_level; +} + +static void +log_stderr(enum ds_log_level level, const char *fmt, va_list args) +{ + bool colored_tty = false; + + if (level > log_level) + return; + + unsigned c = (level < DS_LOG_LEVEL_LAST) ? level : DS_LOG_LEVEL_LAST - 1; + + colored_tty = colored && isatty(STDERR_FILENO); + if (colored_tty) + fprintf(stderr, "%s", level_colors[c]); + else + fprintf(stderr, "%s ", level_headers[c]); + + vfprintf(stderr, fmt, args); + + if (colored_tty) + fprintf(stderr, "\x1B[0m"); + fprintf(stderr, "\n"); +} + +static void +log_wl(const char *fmt, va_list args) +{ + static char ds_fmt[1024]; + int n = snprintf(ds_fmt, sizeof(ds_fmt), "[wayland] %s", fmt); + if (n > 0 && ds_fmt[n - 1] == '\n') + ds_fmt[n - 1] = '\0'; + _ds_vlog(DS_INF, ds_fmt, args); +} diff --git a/src/libds/meson.build b/src/libds/meson.build new file mode 100644 index 0000000..2d09a91 --- /dev/null +++ b/src/libds/meson.build @@ -0,0 +1,74 @@ +libds_files = [ + 'log.c', + 'addon.c', + 'buffer.c', + 'allocator/allocator.c', + 'allocator/shm.c', + 'swapchain.c', + 'output.c', + 'compositor.c', + 'subcompositor.c', + 'region.c', + 'util/time.c', + 'util/shm.c', + 'surface/surface.c', + 'surface/subsurface.c', + 'client_buffer/shm_client_buffer.c', + 'xdg_shell/xdg_shell.c', + 'xdg_shell/xdg_surface.c', + 'xdg_shell/xdg_toplevel.c', + 'pixel_format.c', +] + +protocols = { + 'xdg-shell': wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml', +} + +protocols_code = {} +protocols_server_header = {} + +foreach name, path : protocols + code = custom_target( + name.underscorify() + '_c', + input: path, + output: '@BASENAME@-protocol.c', + command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'], + ) + libds_files += code + + server_header = custom_target( + name.underscorify() + '_server_h', + input: path, + output: '@BASENAME@-server-protocol.h', + command: [wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@'], + build_by_default: false, + ) + libds_files += server_header +endforeach + +math = meson.get_compiler('c').find_library('m') +wayland_server = dependency('wayland-server', required: true) +pixman = dependency('pixman-1', required: true) +libdrm = dependency('libdrm', required: true) + +libds_deps = [ + math, + wayland_server, + pixman, + libdrm, +] + +subdir('backend') + +lib_libds = shared_library('ds', libds_files, + dependencies: libds_deps, + include_directories: [ common_inc, include_directories('.') ], + version: meson.project_version(), + install: true +) + +dep_libds = declare_dependency( + link_with: lib_libds, + dependencies: libds_deps, + include_directories: [ common_inc, include_directories('.') ], +) diff --git a/src/libds/output.c b/src/libds/output.c new file mode 100644 index 0000000..21d4ff8 --- /dev/null +++ b/src/libds/output.c @@ -0,0 +1,116 @@ +#include +#include + +#include "libds/log.h" +#include "libds/output.h" +#include "libds/interfaces/output.h" + +static void output_handle_display_destroy(struct wl_listener *listener, + void *data); +static void output_state_clear(struct ds_output_state *state); +static void output_state_clear_buffer(struct ds_output_state *state); + +WL_EXPORT void +ds_output_init(struct ds_output *output, struct ds_backend *backend, + const struct ds_output_interface *iface, struct wl_display *display) +{ + assert(iface->commit); + + output->backend = backend; + output->iface = iface; + output->display = display; + + wl_signal_init(&output->events.destroy); + wl_signal_init(&output->events.frame); + wl_signal_init(&output->events.commit); + + output->display_destroy.notify = output_handle_display_destroy; + wl_display_add_destroy_listener(display, &output->display_destroy); +} + +WL_EXPORT void +ds_output_destroy(struct ds_output *output) +{ + wl_list_remove(&output->display_destroy.link); + + wl_signal_emit(&output->events.destroy, output); + + if (output->iface && output->iface->destroy) + output->iface->destroy(output); + else + free(output); +} + +WL_EXPORT bool +ds_output_commit(struct ds_output *output) +{ + // TODO signal precommit + + if (!output->iface->commit(output)) { + return false; + } + + output_state_clear(&output->pending); + + // TODO signal commit + + return true; +} + +WL_EXPORT void +ds_output_attach_buffer(struct ds_output *output, struct ds_buffer *buffer) +{ + output_state_clear_buffer(&output->pending); + output->pending.committed |= DS_OUTPUT_STATE_BUFFER; + output->pending.buffer = ds_buffer_lock(buffer); +} + +WL_EXPORT void +ds_output_add_destroy_listener(struct ds_output *output, + struct wl_listener *listener) +{ + wl_signal_add(&output->events.destroy, listener); +} + +WL_EXPORT void +ds_output_add_frame_listener(struct ds_output *output, + struct wl_listener *listener) +{ + wl_signal_add(&output->events.frame, listener); +} + +WL_EXPORT void +ds_output_add_commit_listener(struct ds_output *output, + struct wl_listener *listener) +{ + wl_signal_add(&output->events.commit, listener); +} + +static void +output_handle_display_destroy(struct wl_listener *listener, void *data) +{ + struct ds_output *output; + + output = wl_container_of(listener, output, display_destroy); + // TODO + // destroy wl_global +} + +static void +output_state_clear(struct ds_output_state *state) +{ + output_state_clear_buffer(state); + state->committed = 0; +} + +static void +output_state_clear_buffer(struct ds_output_state *state) +{ + if (!(state->committed & DS_OUTPUT_STATE_BUFFER)) + return; + + ds_buffer_unlock(state->buffer); + state->buffer = NULL; + + state->committed &= ~DS_OUTPUT_STATE_BUFFER; +} diff --git a/src/libds/pixel_format.c b/src/libds/pixel_format.c new file mode 100644 index 0000000..29da532 --- /dev/null +++ b/src/libds/pixel_format.c @@ -0,0 +1,15 @@ +#include +#include "pixel_format.h" + +uint32_t +convert_wl_shm_format_to_drm(enum wl_shm_format fmt) +{ + switch (fmt) { + case WL_SHM_FORMAT_XRGB8888: + return DRM_FORMAT_XRGB8888; + case WL_SHM_FORMAT_ARGB8888: + return DRM_FORMAT_ARGB8888; + default: + return (uint32_t)fmt; + } +} diff --git a/src/libds/pixel_format.h b/src/libds/pixel_format.h new file mode 100644 index 0000000..21eb0a6 --- /dev/null +++ b/src/libds/pixel_format.h @@ -0,0 +1,9 @@ +#ifndef DS_PIXEL_FORMAT_H +#define DS_PIXEL_FORMAT_H + +#include +#include + +uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt); + +#endif diff --git a/src/libds/presentation.c b/src/libds/presentation.c new file mode 100644 index 0000000..d94ad04 --- /dev/null +++ b/src/libds/presentation.c @@ -0,0 +1,114 @@ +#include "libds-private.h" +#include "presentation-time-protocol.h" + +#define PRESENTATION_VERSION 1 + +struct ds_presentation +{ + struct wl_global *global; + + struct { + struct wl_signal destroy; + } events; +}; + +struct ds_presentation_feedback +{ + struct wl_list resources; + +} + +struct ds_presentation_surface_state +{ +}; + +struct ds_presentation_feedback +{ + struct wl_resource *resource; + struct wl_list link; + uint32_t psf_flags; +}; + + + +static void presentation_bind(struct wl_client *client, void *data, + uint32_t version, uint32_t id); +static void handle_display_destroy(struct wl_listener *listener, void *data); + +struct ds_presentation * +ds_presentation_create(struct wl_display *display, clockid_t clk_id) +{ + struct ds_presentation *presentation; + + presentation = calloc(1, sizeof *presentation); + if (!presentation) + return NULL; + + presentation->global = wl_global_create(display, &wp_presentation_interface, + PRESENTATION_VERSION, presentation, presentation_bind); + if (!presentation->global) { + free(presentation); + return NULL; + } + + presentation->clock = clk_id; + + wl_signal_init(&presentation->events.destroy); + + presentation->display_destroy.notify = handle_display_destroy; + wl_display_add_destroy_listener(display, &presentation->display_destroy); +} + +static void +presentation_handle_destroy(struct wl_client *client, struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +presentation_handle_feedback(struct wl_client *client, + struct wl_resource *presentation_resource, + struct wl_resource *surface_resource, uint32_t id) +{ + struct ds_presentation *presentation; + struct ds_surface *surface; + + presentation = wl_resource_get_user_data(presentation_resource); + surface = ds_surface_from_resource(surface_resource); +} + +static const struct wp_presentation_interface presentation_impl = { + .destroy = presentation_handle_destroy, + .feedback = presentation_handle_feedback, +}; + +static void +presentation_bind(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + struct ds_presentation *presentation = data; + struct wl_resource *resource; + + resource = wl_resource_create(client, &wp_presentation_interface, + version, id); + if (!resource) { + wl_client_post_no_memory(client); + return; + } + wl_resource_set_implementation(resource, &presentation_impl, + presentation, NULL); + + wp_presentation_send_clock_id(resource, (uint32_t)presentation->clock); +} + +static void +handle_display_destroy(struct wl_listener *listener, void *data) +{ + struct ds_presentation *presentation; + + presentation = wl_container_of(listener, presentation, display_destroy); + wl_signal_emit(&presentation->events.destroy, presentation); + wl_list_remove(&presentation->display_destroy.link); + wl_global_destroy(presentation->global); + free(presentation); +} diff --git a/src/libds/region.c b/src/libds/region.c new file mode 100644 index 0000000..27d30da --- /dev/null +++ b/src/libds/region.c @@ -0,0 +1,196 @@ +#include +#include +#include +#include + +#include "region.h" +#include "libds/log.h" + +static const struct wl_region_interface region_impl; + +static void region_handle_resource_destroy(struct wl_resource *resource); + +void +ds_region_add(struct wl_client *client, uint32_t version, uint32_t id) +{ + struct wl_resource *resource; + pixman_region32_t *region; + + region = calloc(1, sizeof *region); + if (!region) { + wl_client_post_no_memory(client); + return; + } + + pixman_region32_init(region); + + resource = wl_resource_create(client, &wl_region_interface, version, id); + if (!resource) { + free(region); + wl_client_post_no_memory(client); + return; + } + + wl_resource_set_implementation(resource, ®ion_impl, region, + region_handle_resource_destroy); +} + +pixman_region32_t * +ds_region_from_resource(struct wl_resource *resource) +{ + assert(wl_resource_instance_of(resource, &wl_region_interface, + ®ion_impl)); + return wl_resource_get_user_data(resource); +} + +void +ds_region_transform(pixman_region32_t *dst, pixman_region32_t *src, + enum wl_output_transform transform, int width, int height) +{ + pixman_box32_t *src_rects, *dst_rects; + int nrects, i; + + if (transform == WL_OUTPUT_TRANSFORM_NORMAL) { + pixman_region32_copy(dst, src); + return; + } + + src_rects = pixman_region32_rectangles(src, &nrects); + dst_rects = malloc(nrects * sizeof *dst_rects); + if (!dst_rects) + return; + + for (i = 0; i < nrects; i++) { + switch (transform) { + default: + ds_err("Unkown transform value(%d)", transform); + case WL_OUTPUT_TRANSFORM_NORMAL: + dst_rects[i].x1 = src_rects[i].x1; + dst_rects[i].y1 = src_rects[i].y1; + dst_rects[i].x2 = src_rects[i].x2; + dst_rects[i].y2 = src_rects[i].y2; + break; + case WL_OUTPUT_TRANSFORM_90: + dst_rects[i].x1 = height - src_rects[i].y2; + dst_rects[i].y1 = src_rects[i].x1; + dst_rects[i].x2 = height - src_rects[i].y1; + dst_rects[i].y2 = src_rects[i].x2; + break; + case WL_OUTPUT_TRANSFORM_180: + dst_rects[i].x1 = width - src_rects[i].x2; + dst_rects[i].y1 = height - src_rects[i].y2; + dst_rects[i].x2 = width - src_rects[i].x1; + dst_rects[i].y2 = height - src_rects[i].y1; + break; + case WL_OUTPUT_TRANSFORM_270: + dst_rects[i].x1 = src_rects[i].y1; + dst_rects[i].y1 = width - src_rects[i].x2; + dst_rects[i].x2 = src_rects[i].y2; + dst_rects[i].y2 = width - src_rects[i].x1; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED: + dst_rects[i].x1 = width - src_rects[i].x2; + dst_rects[i].y1 = src_rects[i].y1; + dst_rects[i].x2 = width - src_rects[i].x1; + dst_rects[i].y2 = src_rects[i].y2; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + dst_rects[i].x1 = src_rects[i].y1; + dst_rects[i].y1 = src_rects[i].x1; + dst_rects[i].x2 = src_rects[i].y2; + dst_rects[i].y2 = src_rects[i].x2; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_180: + dst_rects[i].x1 = src_rects[i].x1; + dst_rects[i].y1 = height - src_rects[i].y2; + dst_rects[i].x2 = src_rects[i].x2; + dst_rects[i].y2 = height - src_rects[i].y1; + break; + case WL_OUTPUT_TRANSFORM_FLIPPED_270: + dst_rects[i].x1 = height - src_rects[i].y2; + dst_rects[i].y1 = width - src_rects[i].x2; + dst_rects[i].x2 = height - src_rects[i].y1; + dst_rects[i].y2 = width - src_rects[i].x1; + break; + } + } + + pixman_region32_fini(dst); + pixman_region32_init_rects(dst, dst_rects, nrects); + free(dst_rects); +} + +void +ds_region_scale_xy(pixman_region32_t *dst, pixman_region32_t *src, + float scale_x, float scale_y) +{ + pixman_box32_t *src_rects, *dst_rects; + int nrects, i; + + if (scale_x == 1.0 && scale_y == 1.0) { + pixman_region32_copy(dst, src); + } + + src_rects = pixman_region32_rectangles(src, &nrects); + dst_rects = malloc(nrects * sizeof *dst_rects); + if (!dst_rects) + return; + + for (i = 0; i < nrects; i++) { + dst_rects[i].x1 = floor(src_rects[i].x1 * scale_x); + dst_rects[i].x2 = ceil(src_rects[i].x2 * scale_x); + dst_rects[i].y1 = floor(src_rects[i].y1 * scale_y); + dst_rects[i].y2 = ceil(src_rects[i].y2 * scale_y); + } + + pixman_region32_fini(dst); + pixman_region32_init_rects(dst, dst_rects, nrects); + free(dst_rects); +} + +void +ds_region_scale(pixman_region32_t *dst, pixman_region32_t *src, float scale) +{ + ds_region_scale_xy(dst, src, scale, scale); +} + +static void +region_destroy(struct wl_client *client, struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +region_add(struct wl_client *client, struct wl_resource *resource, + int32_t x, int32_t y, int32_t width, int32_t height) +{ + pixman_region32_t *region = wl_resource_get_user_data(resource); + pixman_region32_union_rect(region, region, x, y, width, height); +} + +static void +region_subtract(struct wl_client *client, struct wl_resource *resource, + int32_t x, int32_t y, int32_t width, int32_t height) +{ + pixman_region32_t *region = wl_resource_get_user_data(resource); + pixman_region32_t rect; + + pixman_region32_union_rect(region, region, x, y, width, height); + pixman_region32_init_rect(&rect, x, y, width, height); + pixman_region32_subtract(region, region, &rect); + pixman_region32_fini(&rect); +} + +static const struct wl_region_interface region_impl = { + .destroy = region_destroy, + .add = region_add, + .subtract = region_subtract, +}; + +static void +region_handle_resource_destroy(struct wl_resource *resource) +{ + pixman_region32_t *region = wl_resource_get_user_data(resource); + pixman_region32_fini(region); + free(region); +} diff --git a/src/libds/region.h b/src/libds/region.h new file mode 100644 index 0000000..b27963c --- /dev/null +++ b/src/libds/region.h @@ -0,0 +1,24 @@ +#ifndef DS_REGION_H +#define DS_REGION_H + +#include +#include + +void +ds_region_add(struct wl_client *client, uint32_t version, uint32_t id); + +pixman_region32_t * +ds_region_from_resource(struct wl_resource *resource); + +void +ds_region_transform(pixman_region32_t *dst, pixman_region32_t *src, + enum wl_output_transform transform, int width, int height); + +void +ds_region_scale_xy(pixman_region32_t *dst, pixman_region32_t *src, + float scale_x, float scale_y); + +void +ds_region_scale(pixman_region32_t *dst, pixman_region32_t *src, float scale); + +#endif diff --git a/src/libds/subcompositor.c b/src/libds/subcompositor.c new file mode 100644 index 0000000..483fefb --- /dev/null +++ b/src/libds/subcompositor.c @@ -0,0 +1,98 @@ +#include "subcompositor.h" +#include "surface.h" +#include "libds/log.h" + +#define SUBCOMPOSITOR_VERSION 1 + +static void subcompositor_bind(struct wl_client *client, void *data, + uint32_t version, uint32_t id); + +bool +ds_subcompositor_init(ds_subcompositor_t *subcomp, + struct wl_display *display) +{ + subcomp->global = wl_global_create(display, &wl_subcompositor_interface, + SUBCOMPOSITOR_VERSION, subcomp, subcompositor_bind); + if (!subcomp->global) { + ds_log_errno(DS_ERR, "Could not create global"); + return false; + } + + return true; +} + +void +ds_subcompositor_finish(ds_subcompositor_t *subcomp) +{ + wl_global_destroy(subcomp->global); +} + +static void +subcompositor_handle_destroy(struct wl_client *client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +subcompositor_handle_get_subsurface(struct wl_client *client, + struct wl_resource *resource, uint32_t id, + struct wl_resource *surface_resource, + struct wl_resource *parent_resource) +{ + struct ds_surface *surface = ds_surface_from_resource(surface_resource); + struct ds_surface *parent = ds_surface_from_resource(parent_resource); + + if (surface == parent) { + ds_inf("ds_surface(%p) cannot be its own parent", surface); + wl_resource_post_error(resource, + WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE, + "%d: wl_surface@%d cannot be its own parent", + id, wl_resource_get_id(surface_resource)); + return; + } + + if (ds_surface_is_subsurface(surface)) { + ds_inf("ds_surface(%p) is already a sub-surface", surface); + wl_resource_post_error(resource, + WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE, + "%d: wl_surface@%d is already a sub-surface", + id, wl_resource_get_id(surface_resource)); + return; + } + + if (ds_surface_is_ancestor_of(surface, parent)) { + ds_inf("ds_surface(%p) is an ancestor of given parent(%p)", + surface, parent); + wl_resource_post_error(resource, + WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE, + "%d: wl_surface@%d is an ancestor of parent", + id, wl_resource_get_id(surface_resource)); + return; + } + + ds_subsurface_create(resource, surface, parent, + wl_resource_get_version(resource), id); +} + +static const struct wl_subcompositor_interface subcompositor_impl = { + .destroy = subcompositor_handle_destroy, + .get_subsurface = subcompositor_handle_get_subsurface, +}; + +static void +subcompositor_bind(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + ds_subcompositor_t *subcomp = data; + struct wl_resource *resource; + + resource = wl_resource_create(client, &wl_subcompositor_interface, 1, id); + if (resource == NULL) { + wl_client_post_no_memory(client); + return; + } + + wl_resource_set_implementation(resource, &subcompositor_impl, + subcomp, NULL); +} diff --git a/src/libds/subcompositor.h b/src/libds/subcompositor.h new file mode 100644 index 0000000..362727e --- /dev/null +++ b/src/libds/subcompositor.h @@ -0,0 +1,20 @@ +#ifndef DS_SUBCOMPOSITOR_H +#define DS_SUBCOMPOSITOR_H + +#include + +typedef struct ds_subcompositor ds_subcompositor_t; + +struct ds_subcompositor +{ + struct wl_global *global; +}; + +bool +ds_subcompositor_init(ds_subcompositor_t *subcomp, + struct wl_display *display); + +void +ds_subcompositor_finish(ds_subcompositor_t *subcomp); + +#endif diff --git a/src/libds/surface.h b/src/libds/surface.h new file mode 100644 index 0000000..8f3ceac --- /dev/null +++ b/src/libds/surface.h @@ -0,0 +1,49 @@ +#ifndef DS_SURFACE_H +#define DS_SURFACE_H + +#include + +#include "libds/surface.h" + +struct ds_surface_role +{ + const char *name; + void (*commit)(struct ds_surface *surface); +}; + +struct ds_surface * +ds_surface_create(struct wl_client *client, uint32_t version, uint32_t id); + +struct ds_surface * +ds_surface_from_resource(struct wl_resource *resource); + +bool +ds_surface_set_role(struct ds_surface *surface, + const struct ds_surface_role *role, void *role_data, + struct wl_resource *error_resource, uint32_t error_code); + +const struct ds_surface_role * +ds_surface_get_role(struct ds_surface *surface); + +void * +ds_surface_get_role_data(struct ds_surface *surface); + +void +ds_surface_reset_role_data(struct ds_surface *surface); + +bool +ds_surface_has_buffer(struct ds_surface *surface); + +bool +ds_surface_is_ancestor_of(struct ds_surface *surface, + struct ds_surface *target_surface); + +bool +ds_surface_is_subsurface(struct ds_surface *surface); + +struct ds_subsurface * +ds_subsurface_create(struct wl_resource *subcomp_resource, + struct ds_surface *surface, struct ds_surface *parent, + uint32_t version, uint32_t id); + +#endif diff --git a/src/libds/surface/subsurface.c b/src/libds/surface/subsurface.c new file mode 100644 index 0000000..4cc1ad8 --- /dev/null +++ b/src/libds/surface/subsurface.c @@ -0,0 +1,333 @@ +#include +#include + +#include "libds/log.h" +#include "libds/surface.h" +#include "surface-private.h" + +static const struct wl_subsurface_interface subsurface_impl; +static const struct ds_surface_role subsurface_role; + +static void subsurface_handle_resource_destroy(struct wl_resource *resource); +static void subsurface_handle_surface_destroy(struct wl_listener *listener, + void *data); +static void subsurface_link_surface(struct ds_subsurface *subsurface, + struct ds_surface *surface); +static void subsurface_unlink_surface(struct ds_subsurface *subsurface); +static void subsurface_link_parent(struct ds_subsurface *subsurface, + struct ds_surface *parent); +static void subsurface_unlink_parent(struct ds_subsurface *subsurface); +static struct ds_subsurface *subsurface_find_sibling(struct ds_subsurface *subsurface, + struct ds_surface *surface); + +struct ds_subsurface * +ds_subsurface_create(struct wl_resource *subcomp_resource, + struct ds_surface *surface, struct ds_surface *parent, + uint32_t version, uint32_t id) +{ + struct wl_client *client; + struct ds_subsurface *subsurface; + + client = wl_resource_get_client(subcomp_resource); + + subsurface = calloc(1, sizeof *subsurface); + if (!subsurface) { + ds_log_errno(DS_ERR, "Could not allocate memory"); + wl_client_post_no_memory(client); + return NULL; + } + + if (!ds_surface_set_role(surface, &subsurface_role, subsurface, + subcomp_resource, WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE)) { + free(subsurface); + return NULL; + } + + subsurface->resource = wl_resource_create(client, &wl_subsurface_interface, + version, id); + if (!subsurface->resource) { + ds_log_errno(DS_ERR, "Could not create resource"); + free(subsurface); + wl_client_post_no_memory(client); + return NULL; + } + wl_resource_set_implementation(subsurface->resource, &subsurface_impl, + subsurface, subsurface_handle_resource_destroy); + + subsurface->synchronized = true; + + wl_signal_init(&subsurface->events.destroy); + + subsurface_link_surface(subsurface, surface); + subsurface_link_parent(subsurface, parent); + + ds_inf("New ds_subsurface %p: surface %p, parent surface %p", + subsurface, surface, parent); + + wl_signal_emit(&parent->events.new_subsurface, subsurface); + + return subsurface; +} + +bool +ds_surface_is_subsurface(struct ds_surface *surface) +{ + return ds_surface_get_role(surface) == &subsurface_role; +} + +struct ds_subsurface * +ds_subsurface_from_ds_surface(struct ds_surface *surface) +{ + assert(ds_surface_is_subsurface(surface)); + return (struct ds_subsurface *)surface->role_data; +} + +struct ds_surface * +ds_subsurface_get_parent(struct ds_subsurface *subsurface) +{ + return subsurface->parent; +} + +static const struct ds_surface_role subsurface_role = { + .name = "wl_subsurface", +}; + +static void +subsurface_handle_destroy(struct wl_client *client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +subsurface_handle_set_position(struct wl_client *client, + struct wl_resource *resource, int32_t x, int32_t y) +{ + struct ds_subsurface *subsurface; + + subsurface = wl_resource_get_user_data(resource); + if (!subsurface) + return; + + subsurface->pending.x = x; + subsurface->pending.y = y; +} + +static void +subsurface_handle_place_above(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *sibling_resource) +{ + struct ds_subsurface *subsurface, *sibling; + struct ds_surface *sibling_surface; + struct wl_list *node; + + subsurface = wl_resource_get_user_data(resource); + if (!subsurface) + return; + + sibling_surface = ds_surface_from_resource(sibling_resource); + if (sibling_surface == subsurface->parent) { + node = &subsurface->parent->pending.subsurfaces_above; + } + else { + sibling = subsurface_find_sibling(subsurface, sibling_surface); + if (!sibling) { + wl_resource_post_error(subsurface->resource, + WL_SUBSURFACE_ERROR_BAD_SURFACE, + "%s: wl_surface@%d is not a parent or sibling", + "place_above", wl_resource_get_id(sibling_resource)); + return; + } + node = &sibling->pending.link; + } + + wl_list_remove(&subsurface->pending.link); + wl_list_insert(node, &subsurface->pending.link); + + subsurface->reordered = true; +} + +static void +subsurface_handle_place_below(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *sibling_resource) +{ + struct ds_subsurface *subsurface, *sibling; + struct ds_surface *sibling_surface; + struct wl_list *node; + + subsurface = wl_resource_get_user_data(resource); + if (!subsurface) + return; + + sibling_surface = ds_surface_from_resource(sibling_resource); + if (sibling_surface == subsurface->parent) { + node = &subsurface->parent->pending.subsurfaces_below; + } + else { + sibling = subsurface_find_sibling(subsurface, sibling_surface); + if (!sibling) { + wl_resource_post_error(subsurface->resource, + WL_SUBSURFACE_ERROR_BAD_SURFACE, + "%s: wl_surface@%d is not a parent or sibling", + "place_below", wl_resource_get_id(sibling_resource)); + return; + } + node = &sibling->pending.link; + + } + + wl_list_remove(&subsurface->pending.link); + wl_list_insert(node->prev, &subsurface->pending.link); + + subsurface->reordered = true; +} + +static void +subsurface_handle_set_sync(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_subsurface *subsurface; + + subsurface = wl_resource_get_user_data(resource); + if (!subsurface) + return; + + subsurface->synchronized = true; +} + +static void +subsurface_handle_set_desync(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_subsurface *subsurface; + + subsurface = wl_resource_get_user_data(resource); + if (!subsurface) + return; + + if (subsurface->synchronized) { + subsurface->synchronized = false; + + // TODO: flush + } +} + +static const struct wl_subsurface_interface subsurface_impl = { + .destroy = subsurface_handle_destroy, + .set_position = subsurface_handle_set_position, + .place_above = subsurface_handle_place_above, + .place_below = subsurface_handle_place_below, + .set_sync = subsurface_handle_set_sync, + .set_desync = subsurface_handle_set_desync, +}; + +static void +subsurface_destroy(struct ds_subsurface *subsurface) +{ + wl_signal_emit(&subsurface->events.destroy, subsurface); + + if (subsurface->parent) + subsurface_unlink_parent(subsurface); + + if (subsurface->surface) + subsurface_unlink_surface(subsurface); + + wl_resource_set_user_data(subsurface->resource, NULL); + + free(subsurface); +} + +static void +subsurface_handle_resource_destroy(struct wl_resource *resource) +{ + struct ds_subsurface *subsurface; + + subsurface = wl_resource_get_user_data(resource); + if (!subsurface) + return; + + subsurface_destroy(subsurface); +} + +static +void subsurface_handle_surface_destroy(struct wl_listener *listener, + void *data) +{ + struct ds_subsurface *subsurface; + + subsurface = wl_container_of(listener, subsurface, + listener.surface_destroy); + subsurface_destroy(subsurface); +} + +static void +subsurface_handle_parent_destroy(struct wl_listener *listener, + void *data) +{ + struct ds_subsurface *subsurface; + + subsurface = wl_container_of(listener, subsurface, + listener.parent_destroy); + subsurface_unlink_parent(subsurface); +} + +static void +subsurface_link_surface(struct ds_subsurface *subsurface, struct ds_surface *surface) +{ + subsurface->surface = surface; + subsurface->listener.surface_destroy.notify = + subsurface_handle_surface_destroy; + ds_surface_add_destroy_listener(surface, + &subsurface->listener.surface_destroy); +} + +static void +subsurface_unlink_surface(struct ds_subsurface *subsurface) +{ + wl_list_remove(&subsurface->listener.surface_destroy.link); + subsurface->surface->role_data = NULL; + subsurface->surface = NULL; +} + +static void +subsurface_link_parent(struct ds_subsurface *subsurface, struct ds_surface *parent) +{ + subsurface->parent = parent; + subsurface->listener.parent_destroy.notify = + subsurface_handle_parent_destroy; + ds_surface_add_destroy_listener(parent, + &subsurface->listener.parent_destroy); + wl_list_insert(parent->current.subsurfaces_above.prev, + &subsurface->current.link); + wl_list_insert(parent->pending.subsurfaces_above.prev, + &subsurface->pending.link); +} + +static void +subsurface_unlink_parent(struct ds_subsurface *subsurface) +{ + wl_list_remove(&subsurface->current.link); + wl_list_remove(&subsurface->pending.link); + wl_list_remove(&subsurface->listener.parent_destroy.link); + subsurface->parent = NULL; +} + +static struct ds_subsurface * +subsurface_find_sibling(struct ds_subsurface *subsurface, struct ds_surface *surface) +{ + struct ds_surface *parent = subsurface->parent; + struct ds_subsurface *sibling; + + wl_list_for_each(sibling, &parent->pending.subsurfaces_below, pending.link) { + if (sibling->surface == surface && sibling != subsurface) + return sibling; + } + + wl_list_for_each(sibling, &parent->pending.subsurfaces_above, pending.link) { + if (sibling->surface == surface && sibling != subsurface) { + return sibling; + } + } + + return NULL; +} diff --git a/src/libds/surface/surface-private.h b/src/libds/surface/surface-private.h new file mode 100644 index 0000000..570dcc2 --- /dev/null +++ b/src/libds/surface/surface-private.h @@ -0,0 +1,109 @@ +#ifndef DS_SURFACE_PRIVATE_H +#define DS_SURFACE_PRIVATE_H + +#include +#include +#include + +#include "addon.h" +#include "buffer.h" +#include "surface.h" + +typedef enum +{ + DS_SURFACE_STATE_BUFFER = 1 << 0, + DS_SURFACE_STATE_SURFACE_DAMAGE = 1 << 1, + DS_SURFACE_STATE_BUFFER_DAMAGE = 1 << 2, + DS_SURFACE_STATE_OPAQUE_REGION = 1 << 3, + DS_SURFACE_STATE_INPUT_REGION = 1 << 4, + DS_SURFACE_STATE_TRANSFORM = 1 << 5, + DS_SURFACE_STATE_SCALE = 1 << 6, + DS_SURFACE_STATE_FRAME_CALLBACK_LIST = 1 << 7, + DS_SURFACE_STATE_VIEWPORT = 1 << 8, +} ds_surface_state_field_t; + +struct ds_surface_state +{ + ds_surface_state_field_t committed; + + struct ds_buffer *buffer; + int32_t dx, dy; + pixman_region32_t surface_damage, buffer_damage; + pixman_region32_t opaque, input; + enum wl_output_transform transform; + int32_t scale; + struct wl_list frame_callback_list; + + int width, height; + int buffer_width, buffer_height; + + struct wl_list subsurfaces_below; + struct wl_list subsurfaces_above; + + // TODO viewport +}; + +struct ds_surface +{ + struct wl_resource *resource; + + struct ds_buffer *buffer; + + pixman_region32_t buffer_damage; + pixman_region32_t opaque_region; + pixman_region32_t input_region; + + struct ds_surface_state current, pending; + + const struct ds_surface_role *role; + void *role_data; + + int sx, sy; + + struct { + struct wl_signal commit; + struct wl_signal new_subsurface; + struct wl_signal destroy; + } events; + + struct ds_addon_set addons; +}; + +struct ds_subsurface_parent_state +{ + int32_t x, y; + struct wl_list link; +}; + +struct ds_subsurface +{ + struct wl_resource *resource; + struct ds_surface *surface; + struct ds_surface *parent; + + struct ds_subsurface_parent_state current, pending; + + struct { + struct wl_signal destroy; + } events; + + struct { + struct wl_listener surface_destroy; + struct wl_listener parent_destroy; + } listener; + + bool synchronized; + bool reordered; + bool mapped; +}; + +struct ds_surface * +ds_surface_get_root_surface(struct ds_surface *surface); + +struct ds_subsurface * +ds_subsurface_from_ds_surface(struct ds_surface *surface); + +struct ds_surface * +ds_subsurface_get_parent(struct ds_subsurface *subsurface); + +#endif diff --git a/src/libds/surface/surface.c b/src/libds/surface/surface.c new file mode 100644 index 0000000..32ab232 --- /dev/null +++ b/src/libds/surface/surface.c @@ -0,0 +1,740 @@ +#include +#include + +#include "surface-private.h" +#include "region.h" +#include "util.h" + +#include "libds/log.h" +#include "libds/surface.h" + +#define CALLBACK_VERSION 1 + +static const struct wl_surface_interface surface_impl; + +static void surface_handle_resource_destroy(struct wl_resource *resource); +static void surface_state_init(struct ds_surface_state *state); +static void surface_state_finish(struct ds_surface_state *state); +static void surface_state_move(struct ds_surface_state *state, + struct ds_surface_state *next); +static void surface_finalize_pending(struct ds_surface *surface); +static void surface_commit_state(struct ds_surface *surface, + struct ds_surface_state *next); +static bool surface_for_each(struct ds_surface *surface, int x, int y, + ds_surface_for_each_func_t iterator, void *data); + +WL_EXPORT void +ds_surface_add_destroy_listener(struct ds_surface *surface, + struct wl_listener *listener) +{ + wl_signal_add(&surface->events.destroy, listener); +} + +WL_EXPORT void +ds_surface_add_commit_listener(struct ds_surface *surface, + struct wl_listener *listener) +{ + wl_signal_add(&surface->events.commit, listener); +} + +WL_EXPORT void +ds_surface_add_new_subsurface_listener(struct ds_surface *surface, + struct wl_listener *listener) +{ + wl_signal_add(&surface->events.new_subsurface, listener); +} + +WL_EXPORT struct ds_buffer * +ds_surface_get_buffer(struct ds_surface *surface) +{ + return surface->buffer; +} + +WL_EXPORT void +ds_surface_for_each(struct ds_surface *surface, + ds_surface_for_each_func_t iterator, void *data) +{ + surface_for_each(surface, 0, 0, iterator, data); +} + +WL_EXPORT void +ds_surface_send_frame_done(struct ds_surface *surface, + const struct timespec *when) +{ + struct wl_resource *resource, *tmp; + + wl_resource_for_each_safe(resource, tmp, + &surface->current.frame_callback_list) { + wl_callback_send_done(resource, timespec_to_msec(when)); + wl_resource_destroy(resource); + } +} + +struct ds_surface * +ds_surface_create(struct wl_client *client, uint32_t version, uint32_t id) +{ + struct ds_surface *surface; + + surface = calloc(1, sizeof *surface); + if (!surface) { + wl_client_post_no_memory(client); + return NULL; + } + + surface->resource = + wl_resource_create(client, &wl_surface_interface, version, id); + if (!surface->resource) { + free(surface); + wl_client_post_no_memory(client); + return NULL; + } + + wl_resource_set_implementation(surface->resource, &surface_impl, + surface, surface_handle_resource_destroy); + + surface_state_init(&surface->current); + surface_state_init(&surface->pending); + + wl_signal_init(&surface->events.commit); + wl_signal_init(&surface->events.destroy); + wl_signal_init(&surface->events.new_subsurface); + + pixman_region32_init(&surface->buffer_damage); + pixman_region32_init(&surface->opaque_region); + pixman_region32_init(&surface->input_region); + + ds_inf("New ds_surface %p (res %p)", surface, surface->resource); + + return surface; +} + +struct ds_surface * +ds_surface_from_resource(struct wl_resource *resource) +{ + assert(wl_resource_instance_of(resource, &wl_surface_interface, + &surface_impl)); + return wl_resource_get_user_data(resource); +} + +bool +ds_surface_set_role(struct ds_surface *surface, + const struct ds_surface_role *role, void *role_data, + struct wl_resource *error_resource, uint32_t error_code) +{ + assert(role != NULL); + + if (surface->role != NULL && surface->role != role) { + ds_err("Cannot assign role %s to ds_surface(%p) " + "already has role %s\n", + role->name, surface, surface->role->name); + if (error_resource != NULL) { + wl_resource_post_error(error_resource, error_code, + "Cannot assign role %s to wl_surface@%d " + "already has role %s\n", + role->name, wl_resource_get_id(surface->resource), + surface->role->name); + } + return false; + } + + if (surface->role_data != NULL && surface->role_data != role_data) { + ds_err("Cannot reassign role %s to ds_surface(%p), " + "role object still exists", role->name, surface); + wl_resource_post_error(error_resource, error_code, + "Cannot reassign role %s to wl_surface@%d, " + "role object still exists", role->name, + wl_resource_get_id(surface->resource)); + return false; + } + + surface->role = role; + surface->role_data = role_data; + + ds_inf("Set ds_surface(%p) role: %s", surface, role->name); + + return true; +} + +const struct ds_surface_role * +ds_surface_get_role(struct ds_surface *surface) +{ + return surface->role; +} + +void * +ds_surface_get_role_data(struct ds_surface *surface) +{ + return surface->role_data; +} + +void +ds_surface_reset_role_data(struct ds_surface *surface) +{ + surface->role_data = NULL; +} + +bool +ds_surface_is_ancestor_of(struct ds_surface *surface, + struct ds_surface *target_surface) +{ + struct ds_subsurface *target_subsurface; + struct ds_surface *parent_surface; + + while (target_surface && + ds_surface_is_subsurface(target_surface)) { + target_subsurface = ds_subsurface_from_ds_surface(target_surface); + if (!target_subsurface) + break; + + parent_surface = ds_subsurface_get_parent(target_subsurface); + if (surface == parent_surface) + return true; + + target_surface = parent_surface; + } + + return false; +} + +struct ds_surface * +ds_surface_get_root_surface(struct ds_surface *surface) +{ + struct ds_subsurface *subsurface; + + while (ds_surface_is_subsurface(surface)) { + subsurface = ds_subsurface_from_ds_surface(surface); + if (!subsurface) + break; + + surface = ds_subsurface_get_parent(subsurface); + if (!surface) + return NULL; + } + + return surface; +} + +bool +ds_surface_has_buffer(struct ds_surface *surface) +{ + return !!surface->buffer; +} + +static void +surface_handle_destroy(struct wl_client *client, struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +surface_handle_attach(struct wl_client *client, + struct wl_resource *resource, + struct wl_resource *buffer_resource, + int32_t dx, int32_t dy) +{ + struct ds_surface *surface; + struct ds_buffer *buffer = NULL; + + if (buffer_resource) { + buffer = ds_buffer_from_resource(buffer_resource); + if (!buffer) { + wl_resource_post_error(buffer_resource, 0, "unknown buffer type"); + return; + } + } + + surface = wl_resource_get_user_data(resource); + surface->pending.committed |= DS_SURFACE_STATE_BUFFER; + surface->pending.dx = dx; + surface->pending.dy = dy; + + if (surface->pending.buffer) + ds_buffer_unlock(surface->pending.buffer); + + surface->pending.buffer = buffer; + + ds_dbg("ds_surface(%p) attach buffer(%p)", surface, buffer); +} + +static void +surface_handle_damage(struct wl_client *client, + struct wl_resource *resource, + int32_t x, int32_t y, int32_t width, int32_t height) +{ + struct ds_surface *surface; + + surface = wl_resource_get_user_data(resource); + + ds_dbg("ds_surface(%p) damage: x %d y %d width %d height %d", + surface, x, y, width, height); + + if (width < 0 || height < 0) + return; + + surface->pending.committed |= DS_SURFACE_STATE_SURFACE_DAMAGE; + pixman_region32_union_rect(&surface->pending.surface_damage, + &surface->pending.surface_damage, + x, y, width, height); +} + +static void +callback_handle_resource_destroy(struct wl_resource *resource) +{ + wl_list_remove(wl_resource_get_link(resource)); +} + +static void +surface_handle_frame(struct wl_client *client, + struct wl_resource *resource, uint32_t callback) +{ + struct ds_surface *surface; + struct wl_resource *callback_resource; + + surface = wl_resource_get_user_data(resource); + + ds_dbg("ds_surface(%p) frame", surface); + + callback_resource = wl_resource_create(client, &wl_callback_interface, + CALLBACK_VERSION, callback); + if (!callback_resource) { + wl_resource_post_no_memory(resource); + return; + } + + wl_resource_set_implementation(callback_resource, NULL, NULL, + callback_handle_resource_destroy); + + wl_list_insert(surface->pending.frame_callback_list.prev, + wl_resource_get_link(callback_resource)); + + surface->pending.committed |= DS_SURFACE_STATE_FRAME_CALLBACK_LIST; +} + +static void +surface_handle_set_opaque_region(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *region_resource) +{ + struct ds_surface *surface; + pixman_region32_t *region; + + surface = wl_resource_get_user_data(resource); + + ds_dbg("ds_surface(%p) set opaque region", surface); + + surface->pending.committed |= DS_SURFACE_STATE_OPAQUE_REGION; + if (region_resource) { + region = ds_region_from_resource(region_resource); + pixman_region32_copy(&surface->pending.opaque, region); + } + else { + pixman_region32_clear(&surface->pending.opaque); + } +} + +static void +surface_handle_set_input_region(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *region_resource) +{ + struct ds_surface *surface = wl_resource_get_user_data(resource); + pixman_region32_t *region; + + ds_dbg("ds_surface(%p) set input region", surface); + + surface->pending.committed |= DS_SURFACE_STATE_INPUT_REGION; + if (region_resource) { + region = ds_region_from_resource(region_resource); + pixman_region32_copy(&surface->pending.input, region); + } + else { + pixman_region32_fini(&surface->pending.input); + pixman_region32_init_rect(&surface->pending.input, + INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX); + } +} + +static void +surface_handle_commit(struct wl_client *client, struct wl_resource *resource) +{ + struct ds_surface *surface; + + surface = wl_resource_get_user_data(resource); + + ds_dbg("ds_surface(%p) commit", surface); + + // TODO handle subsurface + + surface_finalize_pending(surface); + + surface_commit_state(surface, &surface->pending); + + // TODO handle subsurfaces of a given surface + + if (surface->role && surface->role->commit) + surface->role->commit(surface); + + wl_signal_emit(&surface->events.commit, surface); +} + +static void +surface_handle_set_buffer_transform(struct wl_client *client, + struct wl_resource *resource, int32_t transform) +{ + struct ds_surface *surface = wl_resource_get_user_data(resource); + + ds_dbg("ds_surface(%p) set buffer transform(%d)", surface, transform); + + if (transform < WL_OUTPUT_TRANSFORM_NORMAL || + transform > WL_OUTPUT_TRANSFORM_FLIPPED_270) { + ds_err("Specified transform value(%d) is invalid. ds_surface(%p)", + transform, surface); + wl_resource_post_error(resource, WL_SURFACE_ERROR_INVALID_TRANSFORM, + "Specified transform value(%d) is invalid", transform); + return; + } + + surface->pending.committed |= DS_SURFACE_STATE_TRANSFORM; + surface->pending.transform = transform; +} + +static void +surface_handle_set_buffer_scale(struct wl_client *client, + struct wl_resource *resource, int32_t scale) +{ + struct ds_surface *surface = wl_resource_get_user_data(resource); + + ds_dbg("ds_surface(%p) set buffer scale(%d)", surface, scale); + + if (scale <= 0) { + ds_err("Specified scale value(%d) is not positive. ds_surface(%p)", + scale, surface); + wl_resource_post_error(resource, WL_SURFACE_ERROR_INVALID_SCALE, + "Specified scale value(%d) is not positive", scale); + return; + } + + surface->pending.committed |= DS_SURFACE_STATE_SCALE; + surface->pending.scale = scale; +} + +static void +surface_handle_damage_buffer(struct wl_client *client, + struct wl_resource *resource, + int32_t x, int32_t y, int32_t width, int32_t height) +{ + struct ds_surface *surface = wl_resource_get_user_data(resource); + + ds_dbg("ds_surface(%p) damage: x %d y %d width %d height %d", + surface, x, y, width, height); + + if (width < 0 || height < 0) { + ds_err("Size cannot be less than zero. ds_surface(%p) " + "width %d height %d", surface, width, height); + return; + } + + surface->pending.committed |= DS_SURFACE_STATE_BUFFER_DAMAGE; + pixman_region32_union_rect(&surface->pending.buffer_damage, + &surface->pending.buffer_damage, + x, y, width, height); +} + +static const struct wl_surface_interface surface_impl = { + .destroy = surface_handle_destroy, + .attach = surface_handle_attach, + .damage = surface_handle_damage, + .frame = surface_handle_frame, + .set_opaque_region = surface_handle_set_opaque_region, + .set_input_region = surface_handle_set_input_region, + .commit = surface_handle_commit, + .set_buffer_transform = surface_handle_set_buffer_transform, + .set_buffer_scale = surface_handle_set_buffer_scale, + .damage_buffer = surface_handle_damage_buffer, +}; + +static void +surface_handle_resource_destroy(struct wl_resource *resource) +{ + struct ds_surface *surface = wl_resource_get_user_data(resource); + + ds_inf("Destroy ds_surface %p (res %p)", surface, surface->resource); + + wl_signal_emit(&surface->events.destroy, surface); + + if (surface->buffer) + ds_buffer_unlock(surface->buffer); + + surface_state_finish(&surface->pending); + surface_state_finish(&surface->current); + + pixman_region32_fini(&surface->buffer_damage); + pixman_region32_fini(&surface->opaque_region); + pixman_region32_fini(&surface->input_region); + + free(surface); +} + +static void +surface_state_init(struct ds_surface_state *state) +{ + state->scale = 1; + state->transform = WL_OUTPUT_TRANSFORM_NORMAL; + + wl_list_init(&state->subsurfaces_above); + wl_list_init(&state->subsurfaces_below); + + wl_list_init(&state->frame_callback_list); + + pixman_region32_init(&state->surface_damage); + pixman_region32_init(&state->buffer_damage); + pixman_region32_init(&state->opaque); + pixman_region32_init_rect(&state->input, + INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX); +} + +static void +surface_state_finish(struct ds_surface_state *state) +{ + struct wl_resource *resource, *tmp; + + if (state->buffer) + ds_buffer_unlock(state->buffer); + + wl_resource_for_each_safe(resource, tmp, &state->frame_callback_list) + wl_resource_destroy(resource); + + pixman_region32_fini(&state->surface_damage); + pixman_region32_fini(&state->buffer_damage); + pixman_region32_fini(&state->opaque); + pixman_region32_fini(&state->input); +} + +static void +surface_state_move(struct ds_surface_state *state, struct ds_surface_state *next) +{ + state->width = next->width; + state->height = next->height; + state->buffer_width = next->buffer_width; + state->buffer_height = next->buffer_height; + + if (next->committed & DS_SURFACE_STATE_SCALE) + state->scale = next->scale; + + if (next->committed & DS_SURFACE_STATE_TRANSFORM) + state->transform = next->transform; + + if (next->committed & DS_SURFACE_STATE_BUFFER) { + state->dx = next->dx; + state->dy = next->dy; + next->dx = next->dy = 0; + + if (state->buffer) { + ds_buffer_unlock(state->buffer); + state->buffer = NULL; + } + + if (next->buffer) { + state->buffer = ds_buffer_lock(next->buffer); + ds_buffer_unlock(next->buffer); + next->buffer = NULL; + } + } + else { + state->dx = state->dy = 0; + } + + if (next->committed & DS_SURFACE_STATE_SURFACE_DAMAGE) { + pixman_region32_copy(&state->surface_damage, &next->surface_damage); + pixman_region32_clear(&next->surface_damage); + } + else + pixman_region32_clear(&state->surface_damage); + + if (next->committed & DS_SURFACE_STATE_BUFFER_DAMAGE) { + pixman_region32_copy(&state->buffer_damage, &next->buffer_damage); + pixman_region32_clear(&next->buffer_damage); + } + else + pixman_region32_clear(&state->buffer_damage); + + if (next->committed & DS_SURFACE_STATE_OPAQUE_REGION) + pixman_region32_copy(&state->opaque, &next->opaque); + + if (next->committed & DS_SURFACE_STATE_INPUT_REGION) + pixman_region32_copy(&state->input, &next->input); + + if (next->committed & DS_SURFACE_STATE_FRAME_CALLBACK_LIST) { + wl_list_insert_list(&state->frame_callback_list, + &next->frame_callback_list); + wl_list_init(&next->frame_callback_list); + } + + // FIXME + // state->committed |= next->committed; ?? + state->committed = next->committed; + next->committed = 0; +} + +static void +surface_state_viewport_src_size(struct ds_surface_state *state, + int *out_width, int *out_height) +{ + int width, height, tmp; + + if (state->buffer_width == 0 && state->buffer_height == 0) { + *out_width = 0; + *out_height = 0; + return; + } + + width = state->buffer_width / state->scale; + height = state->buffer_height / state->scale; + if ((state->transform & WL_OUTPUT_TRANSFORM_90) != 0) { + tmp = width; + width = height; + height = tmp; + } + + *out_width = width; + *out_height = height; +} + +static void +surface_finalize_pending(struct ds_surface *surface) +{ + struct ds_surface_state *pending = &surface->pending; + + if ((pending->committed & DS_SURFACE_STATE_BUFFER)) { + if (pending->buffer) { + ds_buffer_get_size(pending->buffer, + &pending->buffer_width, &pending->buffer_height); + } + else { + pending->buffer_width = 0; + pending->buffer_height = 0; + } + } + + surface_state_viewport_src_size(pending, + &pending->width, &pending->height); + + pixman_region32_intersect_rect(&pending->surface_damage, + &pending->surface_damage, + 0, 0, pending->width, pending->height); + + pixman_region32_intersect_rect(&pending->buffer_damage, + &pending->buffer_damage, + 0, 0, pending->buffer_width, pending->buffer_height); +} + +// FIXME +static enum wl_output_transform +ds_output_transform_invert(enum wl_output_transform tr) +{ + if ((tr & WL_OUTPUT_TRANSFORM_90) && !(tr & WL_OUTPUT_TRANSFORM_FLIPPED)) { + tr ^= WL_OUTPUT_TRANSFORM_180; + } + return tr; +} + +static void +surface_update_damage(pixman_region32_t *buffer_damage, + struct ds_surface_state *current, struct ds_surface_state *pending) +{ + pixman_region32_clear(buffer_damage); + + if (pending->width != current->width || + pending->height != current->height) { + pixman_region32_union_rect(buffer_damage, buffer_damage, + 0, 0, pending->buffer_width, pending->buffer_height); + } + else { + pixman_region32_t surface_damage; + + pixman_region32_init(&surface_damage); + pixman_region32_copy(&surface_damage, &pending->surface_damage); + + // TODO viewport + + ds_region_transform(&surface_damage, &surface_damage, + ds_output_transform_invert(pending->transform), + pending->width, pending->height); + ds_region_scale(&surface_damage, &surface_damage, pending->scale); + + pixman_region32_union(buffer_damage, + &pending->buffer_damage, &surface_damage); + + pixman_region32_fini(&surface_damage); + } +} + +static void +surface_update_buffer(struct ds_surface *surface) +{ + if (!surface->current.buffer) { + if (surface->buffer) { + ds_buffer_unlock(surface->buffer); + surface->buffer = NULL; + } + return; + } + + if (surface->buffer) { + ds_buffer_unlock(surface->buffer); + surface->buffer = NULL; + } + + if (surface->current.buffer) { + surface->buffer = ds_buffer_lock(surface->current.buffer); + ds_buffer_unlock(surface->current.buffer); + surface->current.buffer = NULL; + } +} + +static void +surface_commit_state(struct ds_surface *surface, struct ds_surface_state *next) +{ + surface->sx += next->dx; + surface->sy += next->dy; + surface_update_damage(&surface->buffer_damage, &surface->current, next); + + surface_state_move(&surface->current, next); + + // FIXME no need? + if (surface->current.committed & DS_SURFACE_STATE_BUFFER) + surface_update_buffer(surface); + + wl_signal_emit(&surface->events.commit, surface); +} + +static bool +surface_for_each(struct ds_surface *surface, int x, int y, + ds_surface_for_each_func_t iterator, void *data) +{ + struct ds_subsurface *subsurface; + struct ds_subsurface_parent_state *state; + bool stop = false; + + wl_list_for_each(subsurface, + &surface->current.subsurfaces_below, current.link) { + state = &subsurface->current; + stop = surface_for_each(subsurface->surface, + x + state->x, y + state->y, iterator, data); + if (stop) + return true; + } + + stop = iterator(surface, x, y, data); + if (stop) + return true; + + wl_list_for_each(subsurface, + &surface->current.subsurfaces_above, current.link) { + state = &subsurface->current; + stop = surface_for_each(subsurface->surface, + x + state->x, y + state->y, iterator, data); + if (stop) + return true; + } + + return false; +} diff --git a/src/libds/swapchain.c b/src/libds/swapchain.c new file mode 100644 index 0000000..54e64cf --- /dev/null +++ b/src/libds/swapchain.c @@ -0,0 +1,202 @@ +#include +#include +#include + +#include "libds/log.h" +#include "libds/allocator.h" + +#define DS_SWAPCHAIN_CAP 4 + +struct ds_swapchain_slot +{ + struct ds_buffer *buffer; + + struct wl_listener buffer_release; + + int age; + bool acquired; +}; + +struct ds_swapchain +{ + struct ds_allocator *allocator; + + struct ds_swapchain_slot slots[DS_SWAPCHAIN_CAP]; + + struct wl_listener allocator_destroy; + + int width, height; + uint32_t format; +}; + +static void swapchain_handle_allocator_destroy(struct wl_listener *listener, + void *data); +static bool swapchain_has_buffer(struct ds_swapchain *swapchain, + struct ds_buffer *buffer); +static struct ds_buffer *swapchain_slot_acquire(struct ds_swapchain *swapchain, + struct ds_swapchain_slot *slot, int *age); +static void swapchain_slot_reset(struct ds_swapchain_slot *slot); + +struct ds_swapchain * +ds_swapchain_create(struct ds_allocator *alloc, int width, int height, + uint32_t format) +{ + struct ds_swapchain *swapchain = NULL; + + swapchain = calloc(1, sizeof *swapchain); + if (!swapchain) + return NULL; + + swapchain->allocator = alloc; + swapchain->width = width; + swapchain->height = height; + swapchain->format = format; + + swapchain->allocator_destroy.notify = + swapchain_handle_allocator_destroy; + ds_allocator_add_destroy_listener(alloc, + &swapchain->allocator_destroy); + + ds_inf("Swapchain(%p) created", swapchain); + + return swapchain; +} + +void +ds_swapchain_destroy(struct ds_swapchain *swapchain) +{ + size_t i; + + ds_dbg("Destroy swapchain(%p)", swapchain); + + for (i = 0; i < DS_SWAPCHAIN_CAP; i++) + swapchain_slot_reset(&swapchain->slots[i]); + + wl_list_remove(&swapchain->allocator_destroy.link); + free(swapchain); +} + +struct ds_buffer * +ds_swapchain_acquire(struct ds_swapchain *swapchain, int *age) +{ + struct ds_swapchain_slot *slot, *free_slot = NULL; + size_t i; + + for (i = 0; i < DS_SWAPCHAIN_CAP; i++) { + slot = &swapchain->slots[i]; + if (slot->acquired) + continue; + + if (slot->buffer != NULL) + return swapchain_slot_acquire(swapchain, slot, age); + + free_slot = slot; + } + + if (free_slot == NULL) { + ds_err("No free output buffer slot"); + return NULL; + } + + if (!swapchain->allocator) + return NULL; + + free_slot->buffer = ds_allocator_create_buffer(swapchain->allocator, + swapchain->width, swapchain->height, swapchain->format); + if (!free_slot->buffer) { + ds_err("Failed to allocate buffer"); + return NULL; + } + + ds_dbg("Allocating new swapchain buffer(%p)", free_slot->buffer); + + return swapchain_slot_acquire(swapchain, free_slot, age); +} + +void +ds_swapchain_set_buffer_submitted(struct ds_swapchain *swapchain, + struct ds_buffer *buffer) +{ + struct ds_swapchain_slot *slot; + size_t i; + + assert(buffer); + + if (!swapchain_has_buffer(swapchain, buffer)) + return; + + for (i = 0; i < DS_SWAPCHAIN_CAP; i++) { + slot = &swapchain->slots[i]; + if (slot->buffer == buffer) + slot->age = 1; + else if (slot->age > 0) + slot->age++; + } +} + +static void +swapchain_handle_allocator_destroy(struct wl_listener *listener, void *data) +{ + struct ds_swapchain *swapchain; + + swapchain = wl_container_of(listener, swapchain, allocator_destroy); + swapchain->allocator = NULL; +} + +static bool swapchain_has_buffer(struct ds_swapchain *swapchain, + struct ds_buffer *buffer) +{ + struct ds_swapchain_slot *slot; + size_t i; + + for (i = 0; i < DS_SWAPCHAIN_CAP; i++) { + slot = &swapchain->slots[i]; + if (slot->buffer == buffer) + return true; + } + + return false; +} + +static void +swapchain_slot_handle_buffer_release(struct wl_listener *listener, void *data) +{ + struct ds_swapchain_slot *slot; + + slot = wl_container_of(listener, slot, buffer_release); + + ds_dbg("Buffer(%p) released.", slot->buffer); + + wl_list_remove(&slot->buffer_release.link); + slot->acquired = false; +} + +static struct ds_buffer * +swapchain_slot_acquire(struct ds_swapchain *swapchain, struct ds_swapchain_slot *slot, + int *age) +{ + assert(!slot->acquired); + assert(slot->buffer); + + slot->acquired = true; + + slot->buffer_release.notify = swapchain_slot_handle_buffer_release; + ds_buffer_add_release_listener(slot->buffer, &slot->buffer_release); + + if (age != NULL) + *age = slot->age; + + return ds_buffer_lock(slot->buffer); +} + +static void +swapchain_slot_reset(struct ds_swapchain_slot *slot) +{ + if (slot->acquired) + wl_list_remove(&slot->buffer_release.link); + + if (slot->buffer) + ds_buffer_drop(slot->buffer); + + memset(slot, 0, sizeof *slot); +} diff --git a/src/libds/util.h b/src/libds/util.h new file mode 100644 index 0000000..3b7448b --- /dev/null +++ b/src/libds/util.h @@ -0,0 +1,13 @@ +#ifndef DS_UTIL_H +#define DS_UTIL_H + +#include +#include + +int64_t +timespec_to_msec(const struct timespec *a); + +int +allocate_shm_file(size_t size); + +#endif diff --git a/src/libds/util/shm.c b/src/libds/util/shm.c new file mode 100644 index 0000000..c8c84e3 --- /dev/null +++ b/src/libds/util/shm.c @@ -0,0 +1,174 @@ +/* + * Copyright © 2012 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define _POSIX_C_SOURCE 200809L + +#include +#include +#include +#include +#include +#include + +int +os_fd_set_cloexec(int fd) +{ + long flags; + + if (fd == -1) + return -1; + + flags = fcntl(fd, F_GETFD); + if (flags == -1) + return -1; + + if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) + return -1; + + return 0; +} + +static int +set_cloexec_or_close(int fd) +{ + if (os_fd_set_cloexec(fd) != 0) { + close(fd); + return -1; + } + return fd; +} + +static int +create_tmpfile_cloexec(char *tmpname) +{ + int fd; + +#ifdef HAVE_MKOSTEMP + fd = mkostemp(tmpname, O_CLOEXEC); + if (fd >= 0) + unlink(tmpname); +#else + fd = mkstemp(tmpname); + if (fd >= 0) { + fd = set_cloexec_or_close(fd); + unlink(tmpname); + } +#endif + + return fd; +} + +/* + * Create a new, unique, anonymous file of the given size, and + * return the file descriptor for it. The file descriptor is set + * CLOEXEC. The file is immediately suitable for mmap()'ing + * the given size at offset zero. + * + * The file should not have a permanent backing store like a disk, + * but may have if XDG_RUNTIME_DIR is not properly implemented in OS. + * + * The file name is deleted from the file system. + * + * The file is suitable for buffer sharing between processes by + * transmitting the file descriptor over Unix sockets using the + * SCM_RIGHTS methods. + * + * If the C library implements posix_fallocate(), it is used to + * guarantee that disk space is available for the file at the + * given size. If disk space is insufficient, errno is set to ENOSPC. + * If posix_fallocate() is not supported, program may receive + * SIGBUS on accessing mmap()'ed file contents instead. + * + * If the C library implements memfd_create(), it is used to create the + * file purely in memory, without any backing file name on the file + * system, and then sealing off the possibility of shrinking it. This + * can then be checked before accessing mmap()'ed file contents, to + * make sure SIGBUS can't happen. It also avoids requiring + * XDG_RUNTIME_DIR. + */ +int +allocate_shm_file(off_t size) +{ + static const char template[] = "/weston-shared-XXXXXX"; + const char *path; + char *name; + int fd; + int ret; + +#ifdef HAVE_MEMFD_CREATE + fd = memfd_create("weston-shared", MFD_CLOEXEC | MFD_ALLOW_SEALING); + if (fd >= 0) { + /* We can add this seal before calling posix_fallocate(), as + * the file is currently zero-sized anyway. + * + * There is also no need to check for the return value, we + * couldn't do anything with it anyway. + */ + fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK); + } else +#endif + { + path = getenv("XDG_RUNTIME_DIR"); + if (!path) { + errno = ENOENT; + return -1; + } + + name = malloc(strlen(path) + sizeof(template)); + if (!name) + return -1; + + strcpy(name, path); + strcat(name, template); + + fd = create_tmpfile_cloexec(name); + + free(name); + + if (fd < 0) + return -1; + } + +#ifdef HAVE_POSIX_FALLOCATE + do { + ret = posix_fallocate(fd, 0, size); + } while (ret == EINTR); + if (ret != 0) { + close(fd); + errno = ret; + return -1; + } +#else + do { + ret = ftruncate(fd, size); + } while (ret < 0 && errno == EINTR); + if (ret < 0) { + close(fd); + return -1; + } +#endif + + return fd; +} diff --git a/src/libds/util/time.c b/src/libds/util/time.c new file mode 100644 index 0000000..1b17516 --- /dev/null +++ b/src/libds/util/time.c @@ -0,0 +1,8 @@ +#define _POSIX_C_SOURCE 200809L + +#include +#include + +int64_t timespec_to_msec(const struct timespec *a) { + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} diff --git a/src/libds/xdg_shell/xdg_shell.c b/src/libds/xdg_shell/xdg_shell.c new file mode 100644 index 0000000..b7cc8ff --- /dev/null +++ b/src/libds/xdg_shell/xdg_shell.c @@ -0,0 +1,214 @@ +#include +#include +#include + +#include "xdg_shell.h" +#include "libds/log.h" +#include "libds/xdg_shell.h" + +#define XDG_WM_BASE_VERSION 2 +#define XDG_SHELL_PING_TIMEOUT 10000 + +static void xdg_shell_handle_display_destroy(struct wl_listener *listener, void *data); +static void xdg_shell_bind(struct wl_client *wl_client, void *data, + uint32_t verison, uint32_t id); + +WL_EXPORT struct ds_xdg_shell * +ds_xdg_shell_create(struct wl_display *display) +{ + struct ds_xdg_shell *shell; + + shell = calloc(1, sizeof *shell); + if (!shell) { + return NULL; + } + + shell->ping_timeout = XDG_SHELL_PING_TIMEOUT; + + wl_list_init(&shell->clients); + + shell->global = wl_global_create(display, &xdg_wm_base_interface, + XDG_WM_BASE_VERSION, shell, xdg_shell_bind); + if (!shell->global) { + free(shell); + return NULL; + } + + wl_signal_init(&shell->events.destroy); + wl_signal_init(&shell->events.new_surface); + + shell->display_destroy.notify = xdg_shell_handle_display_destroy; + wl_display_add_destroy_listener(display, &shell->display_destroy); + + ds_inf("Global created: xdg_wm_base shell(%p)", shell); + + return shell; +} + +WL_EXPORT void +ds_xdg_shell_add_destroy_listener(struct ds_xdg_shell *shell, + struct wl_listener *listener) +{ + wl_signal_add(&shell->events.destroy, listener); +} + +void +ds_xdg_shell_add_new_surface_listener(struct ds_xdg_shell *shell, + struct wl_listener *listener) +{ + wl_signal_add(&shell->events.new_surface, listener); +} + +static void +xdg_shell_handle_display_destroy(struct wl_listener *listener, void *data) +{ + struct ds_xdg_shell *shell; + + shell = wl_container_of(listener, shell, display_destroy); + + ds_inf("Global destroy: xdg_wm_base shell(%p)", shell); + + wl_signal_emit(&shell->events.destroy, shell); + wl_list_remove(&shell->display_destroy.link); + wl_global_destroy(shell->global); + free(shell); +} + +static void +xdg_shell_handle_destroy(struct wl_client *wl_client, + struct wl_resource *resource) +{ + struct ds_xdg_client *client; + + client = wl_resource_get_user_data(resource); + + if (!wl_list_empty(&client->surfaces)) { + wl_resource_post_error(client->resource, + XDG_WM_BASE_ERROR_DEFUNCT_SURFACES, + "xdg_wm_base was destroyed before children"); + return; + } + + wl_resource_destroy(resource); +} + +static void +xdg_shell_handle_create_positioner(struct wl_client *wl_client, + struct wl_resource *resource, uint32_t id) +{ + // TODO +} + +static void +xdg_shell_handle_get_xdg_surface(struct wl_client *wl_client, + struct wl_resource *resource, uint32_t id, + struct wl_resource *surface_resource) +{ + struct ds_xdg_client *client; + struct ds_surface *surface; + + client = wl_resource_get_user_data(resource); + surface = ds_surface_from_resource(surface_resource); + create_xdg_surface(client, surface, id); +} + +static void +xdg_shell_handle_pong(struct wl_client *wl_client, + struct wl_resource *resource, uint32_t serial) +{ + struct ds_xdg_client *client; + + client = wl_resource_get_user_data(resource); + if (client->ping_serial != serial) + return; + + wl_event_source_timer_update(client->ping_timer, 0); + client->ping_serial = 0; +} + +static const struct xdg_wm_base_interface xdg_shell_impl = { + .destroy = xdg_shell_handle_destroy, + .create_positioner = xdg_shell_handle_create_positioner, + .get_xdg_surface = xdg_shell_handle_get_xdg_surface, + .pong = xdg_shell_handle_pong, +}; + +static void +xdg_client_handle_resource_destroy(struct wl_resource *resource) +{ + struct ds_xdg_client *client; + + client = wl_resource_get_user_data(resource); + + if (client->ping_timer != NULL) + wl_event_source_remove(client->ping_timer); + + wl_list_remove(&client->link); + free(client); +} + +static int +xdg_client_handle_ping_timeout(void *user_data) +{ + struct ds_xdg_client *client; + struct ds_xdg_surface *surface; + + client = user_data; + + wl_list_for_each(surface, &client->surfaces, link) + wl_signal_emit(&surface->events.ping_timeout, surface); + + client->ping_serial = 0; + + return 1; +} + +static void +xdg_client_init_ping_timer(struct ds_xdg_client *client) +{ + struct wl_display *display; + struct wl_event_loop *loop; + + display = wl_client_get_display(client->wl_client); + loop = wl_display_get_event_loop(display); + client->ping_timer = wl_event_loop_add_timer(loop, + xdg_client_handle_ping_timeout, client); + if (client->ping_timer == NULL) + wl_client_post_no_memory(client->wl_client); +} + +static void +xdg_shell_bind(struct wl_client *wl_client, void *data, uint32_t version, + uint32_t id) +{ + struct ds_xdg_shell *shell; + struct ds_xdg_client *client; + + shell = data; + + client = calloc(1, sizeof *client); + if (client == NULL) { + wl_client_post_no_memory(wl_client); + return; + } + + client->wl_client = wl_client; + client->shell = shell; + + wl_list_init(&client->surfaces); + + client->resource = + wl_resource_create(wl_client, &xdg_wm_base_interface, version, id); + if (client->resource == NULL) { + free(client); + wl_client_post_no_memory(wl_client); + return; + } + + wl_resource_set_implementation(client->resource, &xdg_shell_impl, client, + xdg_client_handle_resource_destroy); + + wl_list_insert(&shell->clients, &client->link); + + xdg_client_init_ping_timer(client); +} diff --git a/src/libds/xdg_shell/xdg_shell.h b/src/libds/xdg_shell/xdg_shell.h new file mode 100644 index 0000000..0f99d6d --- /dev/null +++ b/src/libds/xdg_shell/xdg_shell.h @@ -0,0 +1,187 @@ +#ifndef DS_XDG_SHELL_H +#define DS_XDG_SHELL_H + +#include + +#include "xdg-shell-server-protocol.h" + +#include "surface.h" +#include "libds/output.h" + +typedef enum +{ + DS_XDG_SURFACE_ROLE_NONE, + DS_XDG_SURFACE_ROLE_TOPLEVEL, + DS_XDG_SURFACE_ROLE_POPUP, +} ds_xdg_surface_role_t; + +struct ds_xdg_shell +{ + struct wl_global *global; + + struct wl_list clients; + + struct wl_listener display_destroy; + + struct { + struct wl_signal destroy; + struct wl_signal new_surface; + } events; + + uint32_t ping_timeout; +}; + +struct ds_xdg_client +{ + struct ds_xdg_shell *shell; + + struct wl_resource *resource; + struct wl_client *wl_client; + struct wl_event_source *ping_timer; + + struct wl_list surfaces; + + struct wl_list link; // ds_xdg_shell::clients + + uint32_t ping_serial; +}; + +struct ds_xdg_toplevel_state +{ + bool maximized, fullscreen, resizing, activated; + uint32_t tiled; + uint32_t width, height; + uint32_t max_width, max_height; + uint32_t min_width, min_height; +}; + +struct ds_xdg_toplevel_configure +{ + bool maximized, fullscreen, resizing, activated; + uint32_t tiled; + uint32_t width, height; +}; + +struct ds_xdg_toplevel_requested +{ + bool maximized, minimized, fullscreen; + struct ds_output *fullscreen_output; + struct wl_listener fullscreen_output_destroy; +}; + +struct ds_xdg_toplevel +{ + struct wl_resource *resource; + struct ds_xdg_surface *base; + bool added; + + struct ds_xdg_surface *parent; + struct wl_listener parent_unmap; + + struct ds_xdg_toplevel_state current, pending; + struct ds_xdg_toplevel_configure scheduled; + struct ds_xdg_toplevel_requested requested; + + char *title; + char *app_id; + + struct { + struct wl_signal request_maximize; + struct wl_signal request_fullscreen; + struct wl_signal request_minimize; + struct wl_signal request_move; + struct wl_signal request_resize; + struct wl_signal request_show_window_menu; + struct wl_signal set_parent; + struct wl_signal set_title; + struct wl_signal set_app_id; + } events; +}; + +struct ds_xdg_popup +{ + +}; + +struct ds_xdg_surface_state +{ + uint32_t configure_serial; + struct { + int x, y; + int width, height; + } geometry; +}; + +struct ds_xdg_surface +{ + struct ds_xdg_client *client; + struct ds_surface *ds_surface; + + ds_xdg_surface_role_t role; + + union { + struct ds_xdg_toplevel *toplevel; + struct ds_xdg_popup *popup; + }; + + struct wl_resource *resource; + + struct wl_event_source *configure_idle; + uint32_t scheduled_serial; + struct wl_list configure_list; + + struct ds_xdg_surface_state current, pending; + + struct wl_list link; // ds_xdg_client::surfaces + + struct { + struct wl_listener surface_destroy; + struct wl_listener surface_commit; + } listener; + + struct { + struct wl_signal destroy; + struct wl_signal ping_timeout; + struct wl_signal new_popup; + struct wl_signal map; + struct wl_signal unmap; + struct wl_signal configure; + struct wl_signal ack_configure; + } events; + + bool added, configured, mapped; +}; + +struct ds_xdg_surface_configure +{ + struct ds_xdg_surface *surface; + struct wl_list link; + uint32_t serial; + + struct ds_xdg_toplevel_configure *toplevel_configure; +}; + +uint32_t +ds_xdg_surface_schedule_configure(struct ds_xdg_surface *surface); + +struct ds_xdg_surface * +create_xdg_surface(struct ds_xdg_client *client, struct ds_surface *surface, + uint32_t id); + +void +reset_xdg_surface(struct ds_xdg_surface *surface); + +void +create_xdg_toplevel(struct ds_xdg_surface *surface, uint32_t id); + +void +handle_xdg_surface_commit(struct ds_surface *ds_surface); + +void +handle_xdg_surface_toplevel_committed(struct ds_xdg_surface *surface); + +void +send_xdg_toplevel_configure(struct ds_xdg_surface *surface, + struct ds_xdg_surface_configure *configure); + +#endif diff --git a/src/libds/xdg_shell/xdg_surface.c b/src/libds/xdg_shell/xdg_surface.c new file mode 100644 index 0000000..523438d --- /dev/null +++ b/src/libds/xdg_shell/xdg_surface.c @@ -0,0 +1,485 @@ +#include +#include + +#include "xdg_shell.h" +#include "libds/log.h" + +static const struct xdg_surface_interface xdg_surface_impl; +static void xdg_surface_handle_surface_destroy(struct wl_listener *listener, + void *data); +static void xdg_surface_handle_surface_commit(struct wl_listener *listener, + void *data); +static void xdg_surface_handle_resource_destroy(struct wl_resource *resource); +static void xdg_surface_configure_destroy(struct ds_xdg_surface_configure *configure); +static void surface_send_configure(void *user_data); + +void +ds_xdg_surface_add_destroy_listener(struct ds_xdg_surface *surface, + struct wl_listener *listener) +{ + wl_signal_add(&surface->events.destroy, listener); +} + +WL_EXPORT void +ds_xdg_surface_add_map_listener(struct ds_xdg_surface *surface, + struct wl_listener *listener) +{ + wl_signal_add(&surface->events.map, listener); +} + +WL_EXPORT void +ds_xdg_surface_add_unmap_listener(struct ds_xdg_surface *surface, + struct wl_listener *listener) +{ + wl_signal_add(&surface->events.unmap, listener); +} + +struct ds_surface * +ds_xdg_surface_get_surface(struct ds_xdg_surface *surface) +{ + return surface->ds_surface; +} + +struct ds_xdg_surface * +create_xdg_surface(struct ds_xdg_client *client, struct ds_surface *ds_surface, + uint32_t id) +{ + struct ds_xdg_surface *surface; + + surface = calloc(1, sizeof *surface); + if (!surface) { + wl_client_post_no_memory(client->wl_client); + return NULL; + } + + surface->client = client; + surface->role = DS_XDG_SURFACE_ROLE_NONE; + surface->ds_surface = ds_surface; + surface->resource = wl_resource_create(client->wl_client, + &xdg_surface_interface, wl_resource_get_version(client->resource), + id); + if (!surface->resource) { + free(surface); + wl_client_post_no_memory(client->wl_client); + return NULL; + } + + if (ds_surface_has_buffer(surface->ds_surface)) { + wl_resource_destroy(surface->resource); + free(surface); + wl_resource_post_error(client->resource, + XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER, + "xdg_surface must not have a buffer at creation"); + return NULL; + } + + wl_list_init(&surface->configure_list); + + wl_signal_init(&surface->events.destroy); + wl_signal_init(&surface->events.ping_timeout); + wl_signal_init(&surface->events.new_popup); + wl_signal_init(&surface->events.map); + wl_signal_init(&surface->events.unmap); + wl_signal_init(&surface->events.configure); + wl_signal_init(&surface->events.ack_configure); + + surface->listener.surface_destroy.notify = + xdg_surface_handle_surface_destroy; + ds_surface_add_destroy_listener(ds_surface, + &surface->listener.surface_destroy); + + surface->listener.surface_commit.notify = + xdg_surface_handle_surface_commit; + ds_surface_add_commit_listener(ds_surface, + &surface->listener.surface_commit); + + wl_resource_set_implementation(surface->resource, &xdg_surface_impl, + surface, xdg_surface_handle_resource_destroy); + + wl_list_insert(&client->surfaces, &surface->link); + + ds_inf("New xdg_surface %p (res %p)", surface, surface->resource); + + return surface; +} + +void +unmap_xdg_surface(struct ds_xdg_surface *surface) +{ + struct ds_xdg_surface_configure *configure, *tmp; + + // TODO handle popup + + if (surface->mapped) + wl_signal_emit(&surface->events.unmap, surface); + + switch (surface->role) { + case DS_XDG_SURFACE_ROLE_TOPLEVEL: + if (surface->toplevel->parent) { + wl_list_remove(&surface->toplevel->parent_unmap.link); + surface->toplevel->parent = NULL; + } + free(surface->toplevel->title); + surface->toplevel->title = NULL; + free(surface->toplevel->app_id); + surface->toplevel->app_id = NULL; + break; + case DS_XDG_SURFACE_ROLE_POPUP: + // TODO + break; + case DS_XDG_SURFACE_ROLE_NONE: + assert(false && "not reached"); + } + + wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) + xdg_surface_configure_destroy(configure); + + if (surface->configure_idle) { + wl_event_source_remove(surface->configure_idle); + surface->configure_idle = NULL; + } + + surface->configured = false; + surface->mapped = false; +} + +void +reset_xdg_surface(struct ds_xdg_surface *surface) +{ + struct ds_xdg_toplevel_requested *req; + + if (surface->role != DS_XDG_SURFACE_ROLE_NONE) + unmap_xdg_surface(surface); + + if (surface->added) { + wl_signal_emit(&surface->events.destroy, surface); + surface->added = false; + } + + switch (surface->role) { + case DS_XDG_SURFACE_ROLE_TOPLEVEL: + wl_resource_set_user_data(surface->toplevel->resource, NULL); + surface->toplevel->resource = NULL; + req = &surface->toplevel->requested; + if (req->fullscreen_output) + wl_list_remove(&req->fullscreen_output_destroy.link); + free(surface->toplevel); + surface->toplevel = NULL; + break; + case DS_XDG_SURFACE_ROLE_POPUP: + // TODO + break; + case DS_XDG_SURFACE_ROLE_NONE: + // This space is intentionally left blank + break; + } + + surface->role = DS_XDG_SURFACE_ROLE_NONE; +} + +void +destroy_xdg_surface(struct ds_xdg_surface *surface) +{ + reset_xdg_surface(surface); + + wl_resource_set_user_data(surface->resource, NULL); + + ds_surface_reset_role_data(surface->ds_surface); + + wl_list_remove(&surface->link); + wl_list_remove(&surface->listener.surface_destroy.link); + wl_list_remove(&surface->listener.surface_commit.link); + + free(surface); +} + +void +handle_xdg_surface_commit(struct ds_surface *ds_surface) +{ + struct ds_xdg_surface *surface; + + surface = ds_surface_get_role_data(ds_surface); + surface->current = surface->pending; + + switch (surface->role) { + case DS_XDG_SURFACE_ROLE_NONE: + // inert toplevel or popup + break; + case DS_XDG_SURFACE_ROLE_TOPLEVEL: + handle_xdg_surface_toplevel_committed(surface); + // TODO + break; + case DS_XDG_SURFACE_ROLE_POPUP: + // TODO + break; + } + + if (!surface->added) { + surface->added = true; + wl_signal_emit(&surface->client->shell->events.new_surface, surface); + } + + if (surface->configured && + ds_surface_has_buffer(surface->ds_surface) && + !surface->mapped) { + surface->mapped = true; + wl_signal_emit(&surface->events.map, surface); + } +} + +void handle_xdg_surface_precommit(struct ds_surface *ds_surface) +{ + struct ds_xdg_surface *surface; + + surface = ds_surface_get_role_data(ds_surface); + + // TODO + (void)surface; +} + +uint32_t +ds_xdg_surface_schedule_configure(struct ds_xdg_surface *surface) +{ + struct wl_display *display; + struct wl_event_loop *loop; + + display = wl_client_get_display(surface->client->wl_client); + loop = wl_display_get_event_loop(display); + + if (!surface->configure_idle) { + surface->scheduled_serial = wl_display_next_serial(display); + surface->configure_idle = wl_event_loop_add_idle(loop, + surface_send_configure, surface); + if (!surface->configure_idle) + wl_client_post_no_memory(surface->client->wl_client); + } + + return surface->scheduled_serial; +} + +void +ds_xdg_surface_ping(struct ds_xdg_surface *surface) +{ +} + +static void +xdg_surface_handle_surface_destroy(struct wl_listener *listener, void *data) +{ + struct ds_xdg_surface *surface; + + surface = wl_container_of(listener, surface, listener.surface_destroy); + destroy_xdg_surface(surface); +} + +static void +xdg_surface_handle_surface_commit(struct wl_listener *listener, void *data) +{ + struct ds_xdg_surface *surface; + + surface = wl_container_of(listener, surface, listener.surface_commit); + + if (ds_surface_has_buffer(surface->ds_surface) && + !surface->configured) { + wl_resource_post_error(surface->resource, + XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER, + "xdg_surface has never been configured"); + return; + } + + if (!ds_surface_get_role(surface->ds_surface)) { + wl_resource_post_error(surface->resource, + XDG_SURFACE_ERROR_NOT_CONSTRUCTED, + "xdg_surface must have a role"); + return; + } +} + +static void +xdg_surface_handle_resource_destroy(struct wl_resource *resource) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + if (!surface) + return; + + destroy_xdg_surface(surface); +} + +static void +xdg_surface_configure_destroy(struct ds_xdg_surface_configure *configure) +{ + wl_list_remove(&configure->link); + free(configure->toplevel_configure); + free(configure); +} + +static void +xdg_surface_handle_destroy(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + + if (surface->role != DS_XDG_SURFACE_ROLE_NONE) { + ds_err("Tried to destroy an xdg_surface before its role object"); + return; + } + + wl_resource_destroy(resource); +} + +static void +xdg_surface_handle_get_toplevel(struct wl_client *client, + struct wl_resource *resource, uint32_t id) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + create_xdg_toplevel(surface, id); +} + +static void +xdg_surface_handle_get_popup(struct wl_client *client, + struct wl_resource *resource, uint32_t id, + struct wl_resource *parent_resource, + struct wl_resource *positioner_resource) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + + // TODO + (void)surface; +} + +static void +xdg_surface_handle_ack_configure(struct wl_client *client, + struct wl_resource *resource, uint32_t serial) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + + if (surface->role == DS_XDG_SURFACE_ROLE_NONE) { + wl_resource_post_error(surface->resource, + XDG_SURFACE_ERROR_NOT_CONSTRUCTED, + "xdg_surface must have a role"); + return; + } + + bool found = false; + struct ds_xdg_surface_configure *configure, *tmp; + wl_list_for_each(configure, &surface->configure_list, link) { + if (configure->serial == serial) { + found = true; + break; + } + } + + if (!found) { + wl_resource_post_error(surface->client->resource, + XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE, + "wrong configure serial: %u", serial); + return; + } + + wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) { + if (configure->serial == serial) + break; + + wl_signal_emit(&surface->events.ack_configure, configure); + xdg_surface_configure_destroy(configure); + } + + switch (surface->role) { + case DS_XDG_SURFACE_ROLE_NONE: + assert(0 && "not reached"); + break; + case DS_XDG_SURFACE_ROLE_TOPLEVEL: + // TODO + break; + case DS_XDG_SURFACE_ROLE_POPUP: + break; + } + + surface->configured = true; + surface->pending.configure_serial = serial; + + wl_signal_emit(&surface->events.ack_configure, configure); + xdg_surface_configure_destroy(configure); +} + +static void +xdg_surface_handle_set_window_geometry(struct wl_client *client, + struct wl_resource *resource, + int32_t x, int32_t y, int32_t width, int32_t height) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + + if (surface->role == DS_XDG_SURFACE_ROLE_NONE) { + wl_resource_post_error(surface->resource, + XDG_SURFACE_ERROR_NOT_CONSTRUCTED, + "xdg_surface must have a role"); + return; + } + + if (width <= 0 || height <= 0) { + ds_err("Client tried to set invalid geometry"); + wl_resource_post_error(resource, -1, + "Tried to set invalid xdg_surface geometry"); + return; + } + + surface->pending.geometry.x = x; + surface->pending.geometry.y = y; + surface->pending.geometry.width = width; + surface->pending.geometry.height = height; +} + +static const struct xdg_surface_interface xdg_surface_impl = +{ + .destroy = xdg_surface_handle_destroy, + .get_toplevel = xdg_surface_handle_get_toplevel, + .get_popup = xdg_surface_handle_get_popup, + .ack_configure = xdg_surface_handle_ack_configure, + .set_window_geometry = xdg_surface_handle_set_window_geometry, +}; + +static void +surface_send_configure(void *user_data) +{ + struct ds_xdg_surface *surface; + struct ds_xdg_surface_configure *configure; + + surface = user_data; + surface->configure_idle = NULL; + + configure = calloc(1, sizeof *configure); + if (!configure) { + wl_client_post_no_memory(surface->client->wl_client); + return; + } + + wl_list_insert(surface->configure_list.prev, &configure->link); + configure->serial = surface->scheduled_serial; + configure->surface = surface; + + switch (surface->role) { + case DS_XDG_SURFACE_ROLE_NONE: + assert(0 && "not reached"); + break; + case DS_XDG_SURFACE_ROLE_TOPLEVEL: + send_xdg_toplevel_configure(surface, configure); + break; + case DS_XDG_SURFACE_ROLE_POPUP: + break; + } + + wl_signal_emit(&surface->events.configure, configure); + + xdg_surface_send_configure(surface->resource, configure->serial); +} diff --git a/src/libds/xdg_shell/xdg_toplevel.c b/src/libds/xdg_shell/xdg_toplevel.c new file mode 100644 index 0000000..8e78fe7 --- /dev/null +++ b/src/libds/xdg_shell/xdg_toplevel.c @@ -0,0 +1,327 @@ +#include +#include +#include + +#include "xdg_shell.h" + +const struct ds_surface_role xdg_toplevel_surface_role = { + .name = "xdg_toplevel", + .commit = handle_xdg_surface_commit, +}; + +static const struct xdg_toplevel_interface xdg_toplevel_impl; + +static void xdg_toplevel_handle_resource_destroy(struct wl_resource *resource); + +void +create_xdg_toplevel(struct ds_xdg_surface *surface, uint32_t id) +{ + if (!ds_surface_set_role(surface->ds_surface, &xdg_toplevel_surface_role, + surface, surface->resource, XDG_WM_BASE_ERROR_ROLE)) { + return; + } + + if (surface->role != DS_XDG_SURFACE_ROLE_NONE) { + wl_resource_post_error(surface->resource, + XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED, + "xdg_surface has already been constructed"); + return; + } + + assert(surface->toplevel == NULL); + + surface->toplevel = calloc(1, sizeof *surface->toplevel); + if (!surface->toplevel) { + wl_resource_post_no_memory(surface->resource); + return; + } + + surface->toplevel->base = surface; + + wl_signal_init(&surface->toplevel->events.request_maximize); + wl_signal_init(&surface->toplevel->events.request_fullscreen); + wl_signal_init(&surface->toplevel->events.request_minimize); + wl_signal_init(&surface->toplevel->events.request_move); + wl_signal_init(&surface->toplevel->events.request_resize); + wl_signal_init(&surface->toplevel->events.request_show_window_menu); + wl_signal_init(&surface->toplevel->events.set_parent); + wl_signal_init(&surface->toplevel->events.set_title); + wl_signal_init(&surface->toplevel->events.set_app_id); + + surface->toplevel->resource = wl_resource_create( + surface->client->wl_client, &xdg_toplevel_interface, + wl_resource_get_version(surface->resource), id); + if (!surface->toplevel->resource) { + free(surface->toplevel); + wl_resource_post_no_memory(surface->resource); + return; + } + + wl_resource_set_implementation(surface->toplevel->resource, + &xdg_toplevel_impl, surface, + xdg_toplevel_handle_resource_destroy); + + surface->role = DS_XDG_SURFACE_ROLE_TOPLEVEL; +} + +void +handle_xdg_surface_toplevel_committed(struct ds_xdg_surface *surface) +{ + if (!surface->toplevel->added) { + ds_xdg_surface_schedule_configure(surface); + surface->toplevel->added = true; + return; + } + + surface->toplevel->current = surface->toplevel->pending; +} + +void +send_xdg_toplevel_configure(struct ds_xdg_surface *surface, + struct ds_xdg_surface_configure *configure) +{ + struct wl_array states; + + configure->toplevel_configure = + malloc(sizeof *configure->toplevel_configure); + if (!configure->toplevel_configure) { + wl_resource_post_no_memory(surface->toplevel->resource); + return; + } + + *configure->toplevel_configure = surface->toplevel->scheduled; + + wl_array_init(&states); + if (surface->toplevel->scheduled.maximized) { + uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); + if (!s) + goto error_out; + *s = XDG_TOPLEVEL_STATE_MAXIMIZED; + } + + if (surface->toplevel->scheduled.fullscreen) { + uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); + if (!s) + goto error_out; + *s = XDG_TOPLEVEL_STATE_FULLSCREEN; + } + + if (surface->toplevel->scheduled.resizing) { + uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); + if (!s) + goto error_out; + *s = XDG_TOPLEVEL_STATE_RESIZING; + } + + if (surface->toplevel->scheduled.activated) { + uint32_t *s = wl_array_add(&states, sizeof(uint32_t)); + if (!s) + goto error_out; + *s = XDG_TOPLEVEL_STATE_ACTIVATED; + } + + if (surface->toplevel->scheduled.tiled) { + ;;; + // TODO + } + + uint32_t width = surface->toplevel->scheduled.width; + uint32_t height = surface->toplevel->scheduled.height; + + xdg_toplevel_send_configure(surface->toplevel->resource, width, height, + &states); + wl_array_release(&states); + + return; + +error_out: + wl_array_release(&states); + wl_resource_post_no_memory(surface->toplevel->resource); +} + +void +destroy_xdg_toplevel(struct ds_xdg_surface *xdg_surface) +{ + reset_xdg_surface(xdg_surface); +} + +static void +xdg_toplevel_handle_destroy(struct wl_client *client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +xdg_toplevel_handle_set_parent(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *parent_resource) +{ + // TODO +} + +static void +xdg_toplevel_handle_set_title(struct wl_client *client, + struct wl_resource *resource, const char *title) +{ + struct ds_xdg_surface *surface; + char *tmp; + + surface = wl_resource_get_user_data(resource); + tmp = strdup(title); + if (!tmp) { + wl_resource_post_no_memory(resource); + return; + } + + if (surface->toplevel->title) + free(surface->toplevel->title); + + surface->toplevel->title = tmp; + wl_signal_emit(&surface->toplevel->events.set_title, surface); +} + +static void +xdg_toplevel_handle_set_app_id(struct wl_client *client, + struct wl_resource *resource, const char *app_id) +{ + struct ds_xdg_surface *surface; + char *tmp; + + surface = wl_resource_get_user_data(resource); + tmp = strdup(app_id); + if (!tmp) { + wl_resource_post_no_memory(resource); + return; + } + + if (surface->toplevel->app_id) + free(surface->toplevel->app_id); + + surface->toplevel->app_id= tmp; + wl_signal_emit(&surface->toplevel->events.set_app_id, surface); + +} + +static void +xdg_toplevel_handle_show_window_menu(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *seat_resource, + uint32_t serial, int32_t x, int32_t y) +{ + // TODO +} + +static void +xdg_toplevel_handle_move(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *seat_resource, + uint32_t serial) +{ + // TODO +} + +static void +xdg_toplevel_handle_resize(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *seat_resource, + uint32_t serial, uint32_t edges) +{ + // TODO +} + +static void +xdg_toplevel_handle_set_max_size(struct wl_client *client, + struct wl_resource *resource, int32_t width, int32_t height) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + surface->toplevel->pending.max_width = width; + surface->toplevel->pending.max_height = height; +} + +static void +xdg_toplevel_handle_set_min_size(struct wl_client *client, + struct wl_resource *resource, int32_t width, int32_t height) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + surface->toplevel->pending.min_width = width; + surface->toplevel->pending.min_height = height; +} + +static void +xdg_toplevel_handle_set_maximized(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + surface->toplevel->requested.maximized = true; + wl_signal_emit(&surface->toplevel->events.request_maximize, surface); + ds_xdg_surface_schedule_configure(surface); +} + +static void +xdg_toplevel_handle_unset_maximized(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + surface->toplevel->requested.maximized = false; + wl_signal_emit(&surface->toplevel->events.request_maximize, surface); + ds_xdg_surface_schedule_configure(surface); +} + +static void +xdg_toplevel_handle_set_fullscreen(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *output_resource) +{ + // TODO +} + +static void +xdg_toplevel_handle_unset_fullscreen(struct wl_client *client, + struct wl_resource *resource) +{ + // TODO +} + +static void +xdg_toplevel_handle_set_minimized(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + surface->toplevel->requested.minimized = true; + wl_signal_emit(&surface->toplevel->events.request_maximize, surface); +} + +static const struct xdg_toplevel_interface xdg_toplevel_impl = { + xdg_toplevel_handle_destroy, + xdg_toplevel_handle_set_parent, + xdg_toplevel_handle_set_title, + xdg_toplevel_handle_set_app_id, + xdg_toplevel_handle_show_window_menu, + xdg_toplevel_handle_move, + xdg_toplevel_handle_resize, + xdg_toplevel_handle_set_max_size, + xdg_toplevel_handle_set_min_size, + xdg_toplevel_handle_set_maximized, + xdg_toplevel_handle_unset_maximized, + xdg_toplevel_handle_set_fullscreen, + xdg_toplevel_handle_unset_fullscreen, + xdg_toplevel_handle_set_minimized, +}; + +static void +xdg_toplevel_handle_resource_destroy(struct wl_resource *resource) +{ + struct ds_xdg_surface *surface; + + surface = wl_resource_get_user_data(resource); + if (!surface) + return; + + destroy_xdg_toplevel(surface); +} diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..2a6ba37 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,14 @@ +wayland_protos = dependency('wayland-protocols', + fallback: ['wayland-protocols', 'wayland_protocols'], + default_options: ['tests=false'], +) +wl_protocol_dir = wayland_protos.get_variable('pkgdatadir') + +wayland_scanner_dep = dependency('wayland-scanner', native: true) +wayland_scanner = find_program( + wayland_scanner_dep.get_variable('wayland_scanner'), + native: true, +) + +subdir('libds') +subdir('tests') diff --git a/src/tests/meson.build b/src/tests/meson.build new file mode 100644 index 0000000..dd52176 --- /dev/null +++ b/src/tests/meson.build @@ -0,0 +1,25 @@ +tests = [ + { 'name': 'test-compositor' }, + { 'name': 'test-backend' }, + { + 'name': 'test-surface', + 'deps': [ dependency('wayland-client') ], + }, + { + 'name': 'test-subsurface', + 'deps': [ dependency('wayland-client') ], + }, +] + +foreach t : tests + t_deps = [ dep_libds ] + t_deps += t.get('deps', []) + + test('libds-' + t.get('name'), + executable('libds-' + t.get('name'), t.get('name') + '.c', + dependencies: t_deps , + include_directories: common_inc, + install: false + ) + ) +endforeach diff --git a/src/tests/test-backend.c b/src/tests/test-backend.c new file mode 100644 index 0000000..69417b6 --- /dev/null +++ b/src/tests/test-backend.c @@ -0,0 +1,80 @@ +#include +#include +#include + +#include +#include + +static struct ds_backend * +create_possible_wl_backend(struct wl_display *display) +{ + struct ds_backend *backend; + char wl_name[512]; + + for (int i = 0; i < 5; i++) { + snprintf(wl_name, sizeof wl_name, "wayland-%d", i); + backend = ds_wl_backend_create(display, wl_name); + if (backend) + break; + } + + return backend; +} + +static void +test_wl_backend_create(void) +{ + struct wl_display *display; + struct ds_backend *backend; + + display = wl_display_create(); + + backend = create_possible_wl_backend(display); + assert(backend); + + ds_backend_destroy(backend); +} + +struct test +{ + struct wl_listener backend_destroy; + bool cb_called; +}; + +static void +cb_backend_destroy(struct wl_listener *listener, void *data) +{ + struct test *test; + + test = wl_container_of(listener, test, backend_destroy); + test->cb_called = true; +} + +static void +test_wl_backend_destroy_signal(void) +{ + struct wl_display *display; + struct ds_backend *backend; + struct test test; + + display = wl_display_create(); + + backend = create_possible_wl_backend(display); + assert(backend); + + test.cb_called = false; + test.backend_destroy.notify = cb_backend_destroy; + ds_backend_add_destroy_listener(backend, &test.backend_destroy); + + wl_display_destroy(display); + assert(test.cb_called); +} + +int +main(void) +{ + test_wl_backend_create(); + test_wl_backend_destroy_signal(); + + return 0; +} diff --git a/src/tests/test-compositor.c b/src/tests/test-compositor.c new file mode 100644 index 0000000..b5883a5 --- /dev/null +++ b/src/tests/test-compositor.c @@ -0,0 +1,63 @@ +#include +#include + +#include +#include +#include + +static void +test_compositor_create(void) +{ + struct wl_display *display; + struct ds_compositor *compositor; + + display = wl_display_create(); + compositor = ds_compositor_create(display); + assert(compositor); + + wl_display_destroy(display); +} + +struct test +{ + struct wl_listener compositor_destroy; + bool destroyed; +}; + +static void +cb_compositor_destroy(struct wl_listener *listener, void *data) +{ + struct test *test; + + test = wl_container_of(listener, test, compositor_destroy); + test->destroyed = true; +} + +static void +test_compositor_destroy_signal(void) +{ + struct wl_display *display; + struct ds_compositor *compositor; + struct test test; + + display = wl_display_create(); + compositor = ds_compositor_create(display); + assert(compositor); + + test.destroyed = false; + test.compositor_destroy.notify = cb_compositor_destroy; + ds_compositor_add_destroy_listener(compositor, + &test.compositor_destroy); + + wl_display_destroy(display); + assert(test.destroyed == true); +} + +int +main(void) +{ + test_compositor_create(); + test_compositor_destroy_signal(); + + return 0; +} diff --git a/src/tests/test-subsurface.c b/src/tests/test-subsurface.c new file mode 100644 index 0000000..98e830d --- /dev/null +++ b/src/tests/test-subsurface.c @@ -0,0 +1,211 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +struct server_base +{ + struct wl_display *display; + struct ds_compositor *compositor; + const char *socket; +}; + +const char * +test_server_init(struct server_base *server) +{ + server->display = wl_display_create(); + assert(server->display); + server->compositor = ds_compositor_create(server->display); + assert(server->compositor); + server->socket = wl_display_add_socket_auto(server->display); + assert(server->socket); + + return server->socket; +} + +void +test_server_finish(struct server_base *server) +{ + wl_display_destroy(server->display); +} + +struct client +{ + struct wl_display *display; + struct wl_registry *registry; + struct wl_compositor *compositor; + struct wl_subcompositor *subcompositor; + struct wl_surface *surface; + struct wl_subsurface *subsurface; +}; + +static void +handle_global(void *data, struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) +{ + struct client *client = data; + + if (strcmp(interface, "wl_compositor") == 0) { + client->compositor = + wl_registry_bind(registry, id, &wl_compositor_interface, version); + } + else if (strcmp(interface, "wl_subcompositor") == 0) { + client->subcompositor = + wl_registry_bind(registry, id, &wl_subcompositor_interface, version); + } +} + +static const struct wl_registry_listener registry_listener = { + .global = handle_global, +}; + +void +test_client_init(struct client *client, const char *name) +{ + client->display = wl_display_connect(name); + assert(client->display); + client->registry = wl_display_get_registry(client->display); + assert(client->registry); + + wl_registry_add_listener(client->registry, ®istry_listener, client); + + wl_display_roundtrip(client->display); + + assert(client->compositor); + assert(client->subcompositor); +} + +void +test_client_finish(struct client *client) +{ + wl_subcompositor_destroy(client->subcompositor); + wl_compositor_destroy(client->compositor); + wl_registry_destroy(client->registry); + wl_display_disconnect(client->display); +} + +struct test_server +{ + struct server_base base; + bool cb_called; + + struct wl_listener new_surface; + struct wl_listener new_subsurface1; + struct wl_listener new_subsurface2; +}; + +static void +cb_new_subsurface1(struct wl_listener *listener, void *data) +{ + struct ds_subsurface *subsurface = data; + struct test_server *server; + + assert(subsurface); + + server = wl_container_of(listener, server, new_subsurface1); + server->cb_called = true; + wl_display_terminate(server->base.display); +} + +static void +cb_new_subsurface2(struct wl_listener *listener, void *data) +{ + struct ds_subsurface *subsurface = data; + struct test_server *server; + + assert(subsurface); + + server = wl_container_of(listener, server, new_subsurface2); + server->cb_called = true; + wl_display_terminate(server->base.display); +} + +static void +cb_new_surface(struct wl_listener *listener, void *data) +{ + struct ds_surface *surface = data; + struct test_server *server; + + server = wl_container_of(listener, server, new_surface); + if (!server->new_subsurface1.notify) { + server->new_subsurface1.notify = cb_new_subsurface1; + ds_surface_add_new_subsurface_listener(surface, + &server->new_subsurface1); + } + else { + server->new_subsurface2.notify = cb_new_subsurface2; + ds_surface_add_new_subsurface_listener(surface, + &server->new_subsurface2); + } +} + +static void +run_client(const char *name) +{ + struct client client; + + test_client_init(&client, name); + + struct wl_surface *surface = + wl_compositor_create_surface(client.compositor); + + struct wl_surface *child_surface = + wl_compositor_create_surface(client.compositor); + + struct wl_subsurface *subsurface = + wl_subcompositor_get_subsurface(client.subcompositor, + child_surface, surface); + + wl_display_roundtrip(client.display); + + wl_subsurface_destroy(subsurface); + wl_surface_destroy(child_surface); + wl_surface_destroy(surface); + + test_client_finish(&client); +} + +static void +test_subsurface_create(void) +{ + struct test_server server = { + .new_subsurface1 = { .notify = NULL }, + .cb_called = false + }; + pid_t pid; + + const char *socket_name = test_server_init(&server.base); + + pid = fork(); + assert(pid != -1); + + if (pid == 0) { + run_client(socket_name); + exit(0); + } + + server.new_surface.notify = cb_new_surface; + ds_compositor_add_new_surface_listener(server.base.compositor, + &server.new_surface); + + wl_display_run(server.base.display); + + assert(server.cb_called); + + test_server_finish(&server.base); +} + +int +main(void) +{ + test_subsurface_create(); + return 0; +} diff --git a/src/tests/test-surface.c b/src/tests/test-surface.c new file mode 100644 index 0000000..eab2b77 --- /dev/null +++ b/src/tests/test-surface.c @@ -0,0 +1,162 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +struct server_base +{ + struct wl_display *display; + struct ds_compositor *compositor; + const char *socket; +}; + +void +test_server_init(struct server_base *server) +{ + server->display = wl_display_create(); + assert(server->display); + server->compositor = ds_compositor_create(server->display); + assert(server->compositor); + server->socket = wl_display_add_socket_auto(server->display); + assert(server->socket); +} + +void +test_server_finish(struct server_base *server) +{ + wl_display_destroy(server->display); +} + +struct client +{ + struct wl_display *display; + struct wl_registry *registry; + struct wl_compositor *compositor; + struct wl_surface *surface; +}; + +static void +handle_global(void *data, struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) +{ + struct client *client = data; + + if (strcmp(interface, "wl_compositor") == 0) { + client->compositor = + wl_registry_bind(registry, id, &wl_compositor_interface, version); + } +} + +static const struct wl_registry_listener registry_listener = { + .global = handle_global, +}; + +void +test_client_init(struct client *client, const char *name) +{ + client->display = wl_display_connect(name); + assert(client->display); + client->registry = wl_display_get_registry(client->display); + assert(client->registry); + + wl_registry_add_listener(client->registry, ®istry_listener, client); + + wl_display_roundtrip(client->display); + + assert(client->compositor); +} + +void +test_client_finish(struct client *client) +{ + wl_compositor_destroy(client->compositor); + wl_registry_destroy(client->registry); + wl_display_disconnect(client->display); +} + +struct test_server { + struct server_base base; + bool cb_called; + + struct wl_listener new_surface; + struct wl_listener surface_destroy; +}; + +static void +cb_surface_destroy(struct wl_listener *listener, void *data) +{ + struct test_server *server; + + server = wl_container_of(listener, server, surface_destroy); + server->cb_called = true; + wl_display_terminate(server->base.display); +} + +static void +cb_new_surface(struct wl_listener *listener, void *data) +{ + struct ds_surface *surface = data; + struct test_server *server; + + server = wl_container_of(listener, server, new_surface); + server->surface_destroy.notify = cb_surface_destroy; + ds_surface_add_destroy_listener(surface, &server->surface_destroy); +} + +static void +run_client(const char *name) +{ + struct client client; + + test_client_init(&client, name); + + struct wl_surface *surface = + wl_compositor_create_surface(client.compositor); + + wl_display_roundtrip(client.display); + + wl_surface_destroy(surface); + + test_client_finish(&client); +} + +static void +test_surface_create_and_destroy(void) +{ + struct test_server server = { .cb_called = false }; + pid_t pid; + + test_server_init(&server.base); + + pid = fork(); + assert(pid != -1); + + if (pid == 0) { + run_client(server.base.socket); + exit(0); + } + + server.new_surface.notify = cb_new_surface; + ds_compositor_add_new_surface_listener(server.base.compositor, + &server.new_surface); + + wl_display_run(server.base.display); + + assert(server.cb_called); + + test_server_finish(&server.base); +} + +int +main(void) +{ + test_surface_create_and_destroy(); + return 0; +} -- 2.7.4 From f7f8b1639f5de938bdcaace2e6996200002ade4a Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 2 Mar 2022 11:03:37 +0900 Subject: [PATCH 13/16] Remove _t suffix from struct Change-Id: I166e2fc310f3bf6ee2ae5986c85b06a74314d468 --- include/libds/backend.h | 2 +- include/libds/buffer.h | 4 +-- src/libds/addon.c | 18 ++++++------- src/libds/addon.h | 32 ++++++++++------------- src/libds/allocator/shm.c | 24 ++++++++--------- src/libds/backend/wayland/backend.c | 30 +++++++++++----------- src/libds/backend/wayland/backend.h | 16 +++--------- src/libds/backend/wayland/output.c | 40 ++++++++++++++--------------- src/libds/buffer.c | 2 +- src/libds/client_buffer.h | 4 +-- src/libds/client_buffer/shm_client_buffer.c | 24 ++++++++--------- src/libds/compositor.c | 2 +- src/libds/subcompositor.c | 6 ++--- src/libds/subcompositor.h | 6 ++--- src/libds/surface/surface-private.h | 6 ++--- src/libds/xdg_shell/xdg_shell.h | 6 ++--- 16 files changed, 101 insertions(+), 121 deletions(-) diff --git a/include/libds/backend.h b/include/libds/backend.h index 71d9e63..6b587d2 100644 --- a/include/libds/backend.h +++ b/include/libds/backend.h @@ -20,7 +20,7 @@ ds_backend_destroy(struct ds_backend *backend); int ds_backend_get_drm_fd(struct ds_backend *backend); -ds_buffer_caps_t +enum ds_buffer_caps ds_backend_get_buffer_caps(struct ds_backend *backend); void diff --git a/include/libds/buffer.h b/include/libds/buffer.h index eac5146..c91cba7 100644 --- a/include/libds/buffer.h +++ b/include/libds/buffer.h @@ -12,12 +12,12 @@ extern "C" { struct ds_buffer; -typedef enum +enum ds_buffer_caps { DS_BUFFER_CAP_DATA_PTR = 1 << 0, DS_BUFFER_CAP_DMABUF = 1 << 1, DS_BUFFER_CAP_SHM = 1 << 2, -} ds_buffer_caps_t; +}; enum ds_buffer_data_ptr_access_flag { diff --git a/src/libds/addon.c b/src/libds/addon.c index 9b34b11..e1858ff 100644 --- a/src/libds/addon.c +++ b/src/libds/addon.c @@ -9,9 +9,9 @@ ds_addon_set_init(struct ds_addon_set *set) } void -ds_addon_set_finish(ds_addon_set_t *set) +ds_addon_set_finish(struct ds_addon_set *set) { - ds_addon_t *addon, *tmp; + struct ds_addon *addon, *tmp; wl_list_for_each_safe(addon, tmp, &set->addons, link) { ds_addon_finish(addon); @@ -20,10 +20,10 @@ ds_addon_set_finish(ds_addon_set_t *set) } void -ds_addon_init(ds_addon_t *addon, ds_addon_set_t *set, - const void *owner, const ds_addon_interface_t *impl) +ds_addon_init(struct ds_addon *addon, struct ds_addon_set *set, + const void *owner, const struct ds_addon_interface *impl) { - ds_addon_t *iter; + struct ds_addon *iter; assert(owner && impl); @@ -39,15 +39,15 @@ ds_addon_init(ds_addon_t *addon, ds_addon_set_t *set, } void -ds_addon_finish(ds_addon_t *addon) +ds_addon_finish(struct ds_addon *addon) { wl_list_remove(&addon->link); wl_list_init(&addon->link); } -ds_addon_t * -ds_addon_find(ds_addon_set_t *set, const void *owner, - const ds_addon_interface_t *impl) +struct ds_addon * +ds_addon_find(struct ds_addon_set *set, const void *owner, + const struct ds_addon_interface *impl) { struct ds_addon *addon; diff --git a/src/libds/addon.h b/src/libds/addon.h index bb04e7b..2e7b0e1 100644 --- a/src/libds/addon.h +++ b/src/libds/addon.h @@ -3,40 +3,36 @@ #include -typedef struct ds_addon_set ds_addon_set_t; -typedef struct ds_addon_interface ds_addon_interface_t; -typedef struct ds_addon ds_addon_t; - struct ds_addon_set { struct wl_list addons; }; -struct ds_addon_interface { - const char *name; - void (*destroy)(struct ds_addon *addon); -}; - struct ds_addon { - const ds_addon_interface_t *impl; + const struct ds_addon_interface *impl; const void *owner; struct wl_list link; }; +struct ds_addon_interface { + const char *name; + void (*destroy)(struct ds_addon *addon); +}; + void -ds_addon_set_init(ds_addon_set_t *set); +ds_addon_set_init(struct ds_addon_set *set); void -ds_addon_set_finish(ds_addon_set_t *set); +ds_addon_set_finish(struct ds_addon_set *set); void -ds_addon_init(ds_addon_t *addon, ds_addon_set_t *set, - const void *owner, const ds_addon_interface_t *impl); +ds_addon_init(struct ds_addon *addon, struct ds_addon_set *set, + const void *owner, const struct ds_addon_interface *impl); void -ds_addon_finish(ds_addon_t *addon); +ds_addon_finish(struct ds_addon *addon); -ds_addon_t * -ds_addon_find(ds_addon_set_t *set, const void *owner, - const ds_addon_interface_t *impl); +struct ds_addon * +ds_addon_find(struct ds_addon_set *set, const void *owner, + const struct ds_addon_interface *impl); #endif diff --git a/src/libds/allocator/shm.c b/src/libds/allocator/shm.c index 3b9e219..a0acd0c 100644 --- a/src/libds/allocator/shm.c +++ b/src/libds/allocator/shm.c @@ -11,10 +11,6 @@ #include "libds/log.h" #include "util.h" -typedef struct ds_shm_allocator ds_shm_allocator_t; - -typedef struct ds_shm_buffer ds_shm_buffer_t; - struct ds_shm_allocator { struct ds_allocator base; @@ -33,7 +29,7 @@ static const struct ds_allocator_interface shm_allocator_iface; WL_EXPORT struct ds_allocator * ds_shm_allocator_create(void) { - ds_shm_allocator_t *alloc; + struct ds_shm_allocator *alloc; alloc = calloc(1, sizeof *alloc); if (!alloc) @@ -47,17 +43,17 @@ ds_shm_allocator_create(void) return &alloc->base; } -static ds_shm_allocator_t * +static struct ds_shm_allocator * shm_allocator_from_allocator(struct ds_allocator *ds_allocator) { assert(ds_allocator->iface == &shm_allocator_iface); - return (ds_shm_allocator_t *)ds_allocator; + return (struct ds_shm_allocator *)ds_allocator; } static void shm_allocator_destroy(struct ds_allocator *ds_allocator) { - ds_shm_allocator_t *alloc; + struct ds_shm_allocator *alloc; alloc = shm_allocator_from_allocator(ds_allocator); ds_dbg("Destroy Shm allocator(%p)", alloc); @@ -66,17 +62,17 @@ shm_allocator_destroy(struct ds_allocator *ds_allocator) static const struct ds_buffer_interface shm_buffer_interface; -static ds_shm_buffer_t * +static struct ds_shm_buffer * shm_buffer_from_buffer(struct ds_buffer *buffer) { assert(buffer->iface == &shm_buffer_interface); - return (ds_shm_buffer_t *)buffer; + return (struct ds_shm_buffer *)buffer; } static void shm_buffer_destroy(struct ds_buffer *ds_buffer) { - ds_shm_buffer_t *buffer; + struct ds_shm_buffer *buffer; buffer = shm_buffer_from_buffer(ds_buffer); @@ -90,7 +86,7 @@ shm_buffer_destroy(struct ds_buffer *ds_buffer) static bool shm_buffer_get_shm(struct ds_buffer *ds_buffer, struct ds_shm_attributes *shm) { - ds_shm_buffer_t *buffer; + struct ds_shm_buffer *buffer; buffer = shm_buffer_from_buffer(ds_buffer); memcpy(shm, &buffer->shm, sizeof *shm); @@ -101,7 +97,7 @@ static bool shm_buffer_begin_data_ptr_access(struct ds_buffer *ds_buffer, uint32_t flags, void **data, uint32_t *format, size_t *stride) { - ds_shm_buffer_t *buffer; + struct ds_shm_buffer *buffer; buffer = shm_buffer_from_buffer(ds_buffer); *data = buffer->data; @@ -130,7 +126,7 @@ static struct ds_buffer * shm_allocator_create_buffer(struct ds_allocator *ds_allocator, int width, int height, uint32_t format) { - ds_shm_buffer_t *buffer; + struct ds_shm_buffer *buffer; buffer = calloc(1, sizeof *buffer); if (!buffer) diff --git a/src/libds/backend/wayland/backend.c b/src/libds/backend/wayland/backend.c index faa2c64..9b6cd3a 100644 --- a/src/libds/backend/wayland/backend.c +++ b/src/libds/backend/wayland/backend.c @@ -13,16 +13,16 @@ static const struct ds_backend_interface wl_backend_interface; static void wl_backend_handle_display_destroy(struct wl_listener *listener, void *data); -static bool wl_backend_server_init(ds_wl_backend_server_t *server, +static bool wl_backend_server_init(struct ds_wl_backend_server *server, const char *name); -static void wl_backend_server_finish(ds_wl_backend_server_t *server); +static void wl_backend_server_finish(struct ds_wl_backend_server *server); static int wl_backend_handle_dispatch_events(int fd, uint32_t mask, void *data); WL_EXPORT struct ds_backend * ds_wl_backend_create(struct wl_display *display, const char *server_name) { - ds_wl_backend_t *wl_backend; + struct ds_wl_backend *wl_backend; struct wl_event_loop *loop; int fd; @@ -71,18 +71,18 @@ err_server: return NULL; } -ds_wl_backend_t * +struct ds_wl_backend * wl_backend_from_backend(struct ds_backend *backend) { assert(backend->iface == &wl_backend_interface); - return (ds_wl_backend_t *)backend; + return (struct ds_wl_backend *)backend; } static void -wl_backend_destroy(ds_wl_backend_t *backend) +wl_backend_destroy(struct ds_wl_backend *backend) { - ds_wl_output_t *output, *tmp_output; - ds_wl_buffer_t *buffer, *tmp_buffer; + struct ds_wl_output *output, *tmp_output; + struct ds_wl_buffer *buffer, *tmp_buffer; ds_dbg("Destroy wayland backend(%p)", backend); @@ -108,7 +108,7 @@ wl_backend_destroy(ds_wl_backend_t *backend) static void wl_backend_iface_destroy(struct ds_backend *backend) { - ds_wl_backend_t *wl_backend; + struct ds_wl_backend *wl_backend; if (!backend) return; @@ -127,7 +127,7 @@ static const struct ds_backend_interface wl_backend_interface = { static void wl_backend_handle_display_destroy(struct wl_listener *listener, void *data) { - ds_wl_backend_t *wl_backend; + struct ds_wl_backend *wl_backend; wl_backend = wl_container_of(listener, wl_backend, display_destroy); wl_backend_destroy(wl_backend); @@ -158,7 +158,7 @@ static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *iface, uint32_t version) { - ds_wl_backend_server_t *server = data; + struct ds_wl_backend_server *server = data; ds_log(DS_DBG, "Wayland global: %s v%d", iface, version); @@ -191,7 +191,7 @@ static const struct wl_registry_listener registry_listener = { }; static bool -wl_backend_server_init(ds_wl_backend_server_t *server, const char *name) +wl_backend_server_init(struct ds_wl_backend_server *server, const char *name) { server->display = wl_display_connect(name); if (!server->display) { @@ -236,7 +236,7 @@ err_reg: } static void -wl_backend_server_finish(ds_wl_backend_server_t *server) +wl_backend_server_finish(struct ds_wl_backend_server *server) { xdg_wm_base_destroy(server->xdg_wm_base); wl_compositor_destroy(server->compositor); @@ -247,8 +247,8 @@ wl_backend_server_finish(ds_wl_backend_server_t *server) static int wl_backend_handle_dispatch_events(int fd, uint32_t mask, void *data) { - ds_wl_backend_t *wl_backend = data; - ds_wl_backend_server_t *server = &wl_backend->server; + struct ds_wl_backend *wl_backend = data; + struct ds_wl_backend_server *server = &wl_backend->server; int count = 0; if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) { diff --git a/src/libds/backend/wayland/backend.h b/src/libds/backend/wayland/backend.h index 1c3cd5b..ab37ec0 100644 --- a/src/libds/backend/wayland/backend.h +++ b/src/libds/backend/wayland/backend.h @@ -4,14 +4,6 @@ #include "libds/interfaces/backend.h" #include "libds/interfaces/output.h" -typedef struct ds_wl_backend_server ds_wl_backend_server_t; - -typedef struct ds_wl_backend ds_wl_backend_t; - -typedef struct ds_wl_buffer ds_wl_buffer_t; - -typedef struct ds_wl_output ds_wl_output_t; - struct ds_wl_backend_server { struct wl_display *display; @@ -33,7 +25,7 @@ struct ds_wl_backend struct wl_list buffers; // ds_wl_buffer.link struct wl_event_source *server_event_source; - ds_wl_backend_server_t server; + struct ds_wl_backend_server server; }; struct ds_wl_buffer @@ -50,7 +42,7 @@ struct ds_wl_output { struct ds_output base; - ds_wl_backend_t *backend; + struct ds_wl_backend *backend; struct wl_surface *surface; struct xdg_surface *xdg_surface; @@ -60,10 +52,10 @@ struct ds_wl_output struct wl_list link; }; -ds_wl_backend_t * +struct ds_wl_backend * wl_backend_from_backend(struct ds_backend *backend); void -destroy_wl_buffer(ds_wl_buffer_t *buffer); +destroy_wl_buffer(struct ds_wl_buffer *buffer); #endif diff --git a/src/libds/backend/wayland/output.c b/src/libds/backend/wayland/output.c index a995dbf..b411dad 100644 --- a/src/libds/backend/wayland/output.c +++ b/src/libds/backend/wayland/output.c @@ -15,8 +15,8 @@ static const struct xdg_toplevel_listener wl_output_xdg_toplevel_listener; struct ds_output * ds_wl_backend_create_output(struct ds_backend *ds_backend) { - ds_wl_backend_t *backend; - ds_wl_output_t *output; + struct ds_wl_backend *backend; + struct ds_wl_output *output; backend = wl_backend_from_backend(ds_backend); @@ -78,7 +78,7 @@ err: } void -destroy_wl_buffer(ds_wl_buffer_t *buffer) +destroy_wl_buffer(struct ds_wl_buffer *buffer) { if (buffer == NULL) return; @@ -89,17 +89,17 @@ destroy_wl_buffer(ds_wl_buffer_t *buffer) free(buffer); } -static ds_wl_output_t * +static struct ds_wl_output * wl_output_from_output(struct ds_output *ds_output) { assert(ds_output->iface == &wl_output_iface); - return (ds_wl_output_t *)ds_output; + return (struct ds_wl_output *)ds_output; } static void wl_output_iface_destroy(struct ds_output *ds_output) { - ds_wl_output_t *output; + struct ds_wl_output *output; output = wl_output_from_output(ds_output); @@ -125,7 +125,7 @@ wl_output_iface_destroy(struct ds_output *ds_output) } static struct wl_buffer * -import_shm(ds_wl_backend_t *backend, struct ds_shm_attributes *shm) +import_shm(struct ds_wl_backend *backend, struct ds_shm_attributes *shm) { enum wl_shm_format wl_shm_format = WL_SHM_FORMAT_XRGB8888; struct wl_shm_pool *pool; @@ -147,7 +147,7 @@ import_shm(ds_wl_backend_t *backend, struct ds_shm_attributes *shm) static void buffer_handle_release(void *data, struct wl_buffer *wl_buffer) { - ds_wl_buffer_t *buffer = data; + struct ds_wl_buffer *buffer = data; ds_dbg("Wayland output: Buffer(%p) released.", buffer->buffer); buffer->released = true; @@ -161,17 +161,17 @@ static const struct wl_buffer_listener buffer_listener = { static void buffer_handle_buffer_destroy(struct wl_listener *listener, void *data) { - ds_wl_buffer_t *buffer; + struct ds_wl_buffer *buffer; buffer = wl_container_of(listener, buffer, buffer_destroy); destroy_wl_buffer(buffer); } -static ds_wl_buffer_t * -create_wl_buffer(ds_wl_backend_t *backend, struct ds_buffer *ds_buffer) +static struct ds_wl_buffer * +create_wl_buffer(struct ds_wl_backend *backend, struct ds_buffer *ds_buffer) { struct ds_shm_attributes shm; - ds_wl_buffer_t *buffer; + struct ds_wl_buffer *buffer; struct wl_buffer *wl_buffer; if (ds_buffer_get_shm(ds_buffer, &shm)) { @@ -196,10 +196,10 @@ create_wl_buffer(ds_wl_backend_t *backend, struct ds_buffer *ds_buffer) return buffer; } -static ds_wl_buffer_t * -get_or_create_wl_buffer(ds_wl_backend_t *backend, struct ds_buffer *ds_buffer) +static struct ds_wl_buffer * +get_or_create_wl_buffer(struct ds_wl_backend *backend, struct ds_buffer *ds_buffer) { - ds_wl_buffer_t *buffer; + struct ds_wl_buffer *buffer; wl_list_for_each(buffer, &backend->buffers, link) { if (buffer->buffer == ds_buffer && buffer->released) { @@ -215,7 +215,7 @@ get_or_create_wl_buffer(ds_wl_backend_t *backend, struct ds_buffer *ds_buffer) static void surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) { - ds_wl_output_t *output = data; + struct ds_wl_output *output = data; wl_callback_destroy(cb); output->frame_callback = NULL; @@ -230,8 +230,8 @@ static const struct wl_callback_listener frame_listener = { static bool wl_output_iface_commit(struct ds_output *ds_output) { - ds_wl_output_t *output; - ds_wl_buffer_t *buffer; + struct ds_wl_output *output; + struct ds_wl_buffer *buffer; struct ds_buffer *ds_buffer; output = wl_output_from_output(ds_output); @@ -287,7 +287,7 @@ wl_output_xdg_toplevel_handle_configure(void *data, int32_t width, int32_t height, struct wl_array *states) { // TODO - // ds_wl_output_t *output = data; + // struct ds_wl_output *output = data; if (width == 0 || height == 0) return; @@ -297,7 +297,7 @@ static void wl_output_xdg_toplevel_handle_close(void *data, struct xdg_toplevel *xdg_toplevel) { - ds_wl_output_t *output = data; + struct ds_wl_output *output = data; ds_output_destroy(&output->base); } diff --git a/src/libds/buffer.c b/src/libds/buffer.c index 96edec5..70de23f 100644 --- a/src/libds/buffer.c +++ b/src/libds/buffer.c @@ -29,7 +29,7 @@ ds_buffer_from_resource(struct wl_resource *resource) assert(resource && ds_resource_is_buffer(resource)); if (wl_shm_buffer_get(resource) != NULL) { - ds_shm_client_buffer_t *shm_client_buffer = + struct ds_shm_client_buffer *shm_client_buffer = ds_shm_client_buffer_get_or_create(resource); if (!shm_client_buffer) { ds_err("Failed to create shm client buffer"); diff --git a/src/libds/client_buffer.h b/src/libds/client_buffer.h index f21ea7c..cf390aa 100644 --- a/src/libds/client_buffer.h +++ b/src/libds/client_buffer.h @@ -7,8 +7,6 @@ #include "libds/buffer.h" #include "libds/interfaces/buffer.h" -typedef struct ds_shm_client_buffer ds_shm_client_buffer_t; - struct ds_shm_client_buffer { struct ds_buffer base; @@ -25,7 +23,7 @@ struct ds_shm_client_buffer } listener; }; -ds_shm_client_buffer_t * +struct ds_shm_client_buffer * ds_shm_client_buffer_get_or_create(struct wl_resource *resource); #endif diff --git a/src/libds/client_buffer/shm_client_buffer.c b/src/libds/client_buffer/shm_client_buffer.c index e2c4308..14bb745 100644 --- a/src/libds/client_buffer/shm_client_buffer.c +++ b/src/libds/client_buffer/shm_client_buffer.c @@ -10,13 +10,13 @@ static void shm_client_buffer_resource_handle_destroy(struct wl_listener *listener, void *data); -static ds_shm_client_buffer_t * +static struct ds_shm_client_buffer * shm_client_buffer_create(struct wl_resource *resource); -ds_shm_client_buffer_t * +struct ds_shm_client_buffer * ds_shm_client_buffer_get_or_create(struct wl_resource *resource) { - ds_shm_client_buffer_t *buffer; + struct ds_shm_client_buffer *buffer; struct wl_listener *resource_destroy_listener; resource_destroy_listener = wl_resource_get_destroy_listener(resource, @@ -34,7 +34,7 @@ static void shm_client_buffer_resource_handle_destroy(struct wl_listener *listener, void *data) { - ds_shm_client_buffer_t *buffer; + struct ds_shm_client_buffer *buffer; buffer = wl_container_of(listener, buffer, listener.resource_destroy); @@ -48,17 +48,17 @@ shm_client_buffer_resource_handle_destroy(struct wl_listener *listener, static const struct ds_buffer_interface shm_client_buffer_iface; -static ds_shm_client_buffer_t * +static struct ds_shm_client_buffer * shm_client_buffer_from_buffer(struct ds_buffer *buffer) { assert(buffer->iface == &shm_client_buffer_iface); - return (ds_shm_client_buffer_t *)buffer; + return (struct ds_shm_client_buffer *)buffer; } static void shm_client_buffer_destroy(struct ds_buffer *ds_buffer) { - ds_shm_client_buffer_t *buffer; + struct ds_shm_client_buffer *buffer; buffer = shm_client_buffer_from_buffer(ds_buffer); @@ -74,7 +74,7 @@ shm_client_buffer_begin_data_ptr_access(struct ds_buffer *ds_buffer, enum ds_buffer_data_ptr_access_flag flags, void **data, uint32_t *format, size_t *stride) { - ds_shm_client_buffer_t *buffer; + struct ds_shm_client_buffer *buffer; buffer = shm_client_buffer_from_buffer(ds_buffer); *format = buffer->format; @@ -92,7 +92,7 @@ shm_client_buffer_begin_data_ptr_access(struct ds_buffer *ds_buffer, static void shm_client_buffer_end_data_ptr_access(struct ds_buffer *ds_buffer) { - ds_shm_client_buffer_t *buffer; + struct ds_shm_client_buffer *buffer; buffer = shm_client_buffer_from_buffer(ds_buffer); if (buffer->shm_buffer) @@ -108,17 +108,17 @@ static const struct ds_buffer_interface shm_client_buffer_iface = { static void shm_client_buffer_handle_release(struct wl_listener *listener, void *data) { - ds_shm_client_buffer_t *buffer; + struct ds_shm_client_buffer *buffer; buffer = wl_container_of(listener, buffer, listener.buffer_release); if (buffer->resource) wl_buffer_send_release(buffer->resource); } -static ds_shm_client_buffer_t * +static struct ds_shm_client_buffer * shm_client_buffer_create(struct wl_resource *resource) { - ds_shm_client_buffer_t *buffer; + struct ds_shm_client_buffer *buffer; struct wl_shm_buffer *shm_buffer; enum wl_shm_format wl_shm_format; int32_t width; diff --git a/src/libds/compositor.c b/src/libds/compositor.c index a073405..64dd363 100644 --- a/src/libds/compositor.c +++ b/src/libds/compositor.c @@ -11,7 +11,7 @@ struct ds_compositor { struct wl_global *global; - ds_subcompositor_t subcompositor; + struct ds_subcompositor subcompositor; struct { struct wl_signal new_surface; diff --git a/src/libds/subcompositor.c b/src/libds/subcompositor.c index 483fefb..717fd33 100644 --- a/src/libds/subcompositor.c +++ b/src/libds/subcompositor.c @@ -8,7 +8,7 @@ static void subcompositor_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id); bool -ds_subcompositor_init(ds_subcompositor_t *subcomp, +ds_subcompositor_init(struct ds_subcompositor *subcomp, struct wl_display *display) { subcomp->global = wl_global_create(display, &wl_subcompositor_interface, @@ -22,7 +22,7 @@ ds_subcompositor_init(ds_subcompositor_t *subcomp, } void -ds_subcompositor_finish(ds_subcompositor_t *subcomp) +ds_subcompositor_finish(struct ds_subcompositor *subcomp) { wl_global_destroy(subcomp->global); } @@ -84,7 +84,7 @@ static void subcompositor_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) { - ds_subcompositor_t *subcomp = data; + struct ds_subcompositor *subcomp = data; struct wl_resource *resource; resource = wl_resource_create(client, &wl_subcompositor_interface, 1, id); diff --git a/src/libds/subcompositor.h b/src/libds/subcompositor.h index 362727e..71265d0 100644 --- a/src/libds/subcompositor.h +++ b/src/libds/subcompositor.h @@ -3,18 +3,16 @@ #include -typedef struct ds_subcompositor ds_subcompositor_t; - struct ds_subcompositor { struct wl_global *global; }; bool -ds_subcompositor_init(ds_subcompositor_t *subcomp, +ds_subcompositor_init(struct ds_subcompositor *subcomp, struct wl_display *display); void -ds_subcompositor_finish(ds_subcompositor_t *subcomp); +ds_subcompositor_finish(struct ds_subcompositor *subcomp); #endif diff --git a/src/libds/surface/surface-private.h b/src/libds/surface/surface-private.h index 570dcc2..78b2900 100644 --- a/src/libds/surface/surface-private.h +++ b/src/libds/surface/surface-private.h @@ -9,7 +9,7 @@ #include "buffer.h" #include "surface.h" -typedef enum +enum ds_surface_state_field { DS_SURFACE_STATE_BUFFER = 1 << 0, DS_SURFACE_STATE_SURFACE_DAMAGE = 1 << 1, @@ -20,11 +20,11 @@ typedef enum DS_SURFACE_STATE_SCALE = 1 << 6, DS_SURFACE_STATE_FRAME_CALLBACK_LIST = 1 << 7, DS_SURFACE_STATE_VIEWPORT = 1 << 8, -} ds_surface_state_field_t; +}; struct ds_surface_state { - ds_surface_state_field_t committed; + enum ds_surface_state_field committed; struct ds_buffer *buffer; int32_t dx, dy; diff --git a/src/libds/xdg_shell/xdg_shell.h b/src/libds/xdg_shell/xdg_shell.h index 0f99d6d..6596ea2 100644 --- a/src/libds/xdg_shell/xdg_shell.h +++ b/src/libds/xdg_shell/xdg_shell.h @@ -8,12 +8,12 @@ #include "surface.h" #include "libds/output.h" -typedef enum +enum ds_xdg_surface_role { DS_XDG_SURFACE_ROLE_NONE, DS_XDG_SURFACE_ROLE_TOPLEVEL, DS_XDG_SURFACE_ROLE_POPUP, -} ds_xdg_surface_role_t; +}; struct ds_xdg_shell { @@ -117,7 +117,7 @@ struct ds_xdg_surface struct ds_xdg_client *client; struct ds_surface *ds_surface; - ds_xdg_surface_role_t role; + enum ds_xdg_surface_role role; union { struct ds_xdg_toplevel *toplevel; -- 2.7.4 From 2b3fdf8ff1139724a5e4c6a9b35a34bd13728738 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 23 Feb 2022 13:39:35 +0900 Subject: [PATCH 14/16] First draft for tdm backend Change-Id: I5d73b20242a1e865713834f785a7fa0ff1f3ed11 --- include/libds/interfaces/output.h | 13 ++- include/libds/output.h | 14 ++++ packaging/libds.spec | 2 + src/libds/backend/meson.build | 1 + src/libds/backend/tdm/backend.c | 162 ++++++++++++++++++++++++++++++++++++++ src/libds/backend/tdm/meson.build | 8 ++ src/libds/backend/tdm/output.c | 145 ++++++++++++++++++++++++++++++++++ src/libds/backend/tdm/tdm.h | 53 +++++++++++++ src/libds/output.c | 33 ++++++++ 9 files changed, 423 insertions(+), 8 deletions(-) create mode 100644 src/libds/backend/tdm/backend.c create mode 100644 src/libds/backend/tdm/meson.build create mode 100644 src/libds/backend/tdm/output.c create mode 100644 src/libds/backend/tdm/tdm.h diff --git a/include/libds/interfaces/output.h b/include/libds/interfaces/output.h index cacb927..9b95db1 100644 --- a/include/libds/interfaces/output.h +++ b/include/libds/interfaces/output.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -28,18 +29,11 @@ struct ds_output_interface bool (*commit)(struct ds_output *output); }; -struct ds_output_mode { - struct wl_list link; - int32_t width, height; - int32_t refresh; - bool preferred; -}; - struct ds_output_state { enum ds_output_state_field committed; struct ds_buffer *buffer; - struct ds_output_mode *mode; + const struct ds_output_mode *mode; bool enabled; }; @@ -54,8 +48,11 @@ struct ds_output struct wl_global *global; struct ds_buffer *back_buffer, *front_buffer; + const struct ds_output_mode *current_mode; struct ds_output_state pending; + struct wl_list modes; + struct wl_listener display_destroy; struct { diff --git a/include/libds/output.h b/include/libds/output.h index ea8e276..d2454fc 100644 --- a/include/libds/output.h +++ b/include/libds/output.h @@ -6,6 +6,13 @@ struct ds_output; +struct ds_output_mode { + int32_t width, height; + int32_t refresh; + bool preferred; + struct wl_list link; +}; + void ds_output_destroy(struct ds_output *output); @@ -15,6 +22,13 @@ ds_output_commit(struct ds_output *output); void ds_output_attach_buffer(struct ds_output *output, struct ds_buffer *buffer); +const struct ds_output_mode * +ds_output_preferred_mode(struct ds_output *output); + +void +ds_output_set_mode(struct ds_output *output, + const struct ds_output_mode *mode); + void ds_output_add_destroy_listener(struct ds_output *output, struct wl_listener *listener); diff --git a/packaging/libds.spec b/packaging/libds.spec index 8b7c5a7..f68b266 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -14,6 +14,8 @@ BuildRequires: pkgconfig(wayland-protocols) BuildRequires: pkgconfig(pixman-1) BuildRequires: pkgconfig(libdrm) +BuildRequires: pkgconfig(libtdm) + %description Wayland Compositor Library diff --git a/src/libds/backend/meson.build b/src/libds/backend/meson.build index b135534..e095efd 100644 --- a/src/libds/backend/meson.build +++ b/src/libds/backend/meson.build @@ -3,3 +3,4 @@ libds_files += files( ) subdir('wayland') +subdir('tdm') diff --git a/src/libds/backend/tdm/backend.c b/src/libds/backend/tdm/backend.c new file mode 100644 index 0000000..582fe62 --- /dev/null +++ b/src/libds/backend/tdm/backend.c @@ -0,0 +1,162 @@ +#include +#include + +#include "libds/log.h" +#include "tdm.h" + +static const struct ds_backend_interface tdm_backend_iface; +static void tdm_backend_handle_display_destroy(struct wl_listener *listener, + void *data); +static void tdm_backend_destroy(struct ds_tdm_backend *tdm); +static int tdm_backend_handle_tdm_event(int fd, uint32_t mask, void *data); + +WL_EXPORT struct ds_backend * +ds_tdm_backend_create(struct wl_display *display) +{ + struct ds_tdm_backend *tdm; + struct wl_event_loop *loop; + tdm_error err; + + ds_inf("Initializing TDM backend"); + + tdm = calloc(1, sizeof *tdm); + if (!tdm) + return NULL; + + ds_backend_init(&tdm->base, &tdm_backend_iface); + + tdm->wl_display = display; + tdm->clock = CLOCK_MONOTONIC; // FIXME + wl_list_init(&tdm->outputs); + + tdm->tdm_display = tdm_display_init(&err); + if (err != TDM_ERROR_NONE) { + ds_err("Could not initialize tdm_display"); + goto err_display; + } + + err = tdm_display_get_fd(tdm->tdm_display, &tdm->fd); + if (err != TDM_ERROR_NONE || tdm->fd < 0) { + ds_err("Could not get fd from tdm_display: err(%d)", err); + goto err_fd; + } + + loop = wl_display_get_event_loop(display); + tdm->tdm_event = wl_event_loop_add_fd(loop, tdm->fd, WL_EVENT_READABLE, + tdm_backend_handle_tdm_event, tdm); + if (!tdm->tdm_event) { + ds_err("could not add fd event handler for tdm event"); + goto err_event; + } + + tdm->display_destroy.notify = tdm_backend_handle_display_destroy; + wl_display_add_destroy_listener(display, &tdm->display_destroy); + + return &tdm->base; + +err_event: + close(tdm->fd); +err_fd: + tdm_display_deinit(tdm->tdm_display); +err_display: + free(tdm); + + return NULL; +} + +struct ds_tdm_backend * +tdm_backend_from_backend(struct ds_backend *backend) +{ + assert(backend->iface == &tdm_backend_iface); + return (struct ds_tdm_backend *)backend; +} + +static void +tdm_backend_destroy(struct ds_tdm_backend *tdm) +{ + wl_list_remove(&tdm->display_destroy.link); + wl_event_source_remove(tdm->tdm_event); + close(tdm->fd); + tdm_display_deinit(tdm->tdm_display); + free(tdm); +} + +static bool +tdm_backend_scan_outputs(struct ds_tdm_backend *tdm) +{ + struct ds_tdm_output *output; + tdm_output *tdm_output; + tdm_error err; + int num_outputs, i; + + err = tdm_display_get_output_count(tdm->tdm_display, &num_outputs); + if (err != TDM_ERROR_NONE) { + ds_err("Could not get number of outputs: err(%d)", err); + return false; + } + + for (i = 0; i < num_outputs; i++) { + tdm_output = tdm_display_get_output(tdm->tdm_display, i, &err); + if (err != TDM_ERROR_NONE || !tdm_output) { + ds_err("Could not get output from tdm_display: index(%d) err(%d)", + i, err); + continue; + } + + output = create_tdm_output(tdm, tdm_output); + if (!output) { + ds_err("Could not create output: index(%d)", i); + continue; + } + + wl_list_insert(&tdm->outputs, &output->link); + + wl_signal_emit(&tdm->base.events.new_output, &output->base); + } + + return true; +} + +static bool +tdm_backend_iface_start(struct ds_backend *backend) +{ + struct ds_tdm_backend *tdm; + + tdm = tdm_backend_from_backend(backend); + return tdm_backend_scan_outputs(tdm); +} + +static void +tdm_backend_iface_destroy(struct ds_backend *backend) +{ + struct ds_tdm_backend *tdm; + + tdm = tdm_backend_from_backend(backend); + tdm_backend_destroy(tdm); +} + +static const struct ds_backend_interface tdm_backend_iface = { + .start = tdm_backend_iface_start, + .destroy = tdm_backend_iface_destroy, + .get_drm_fd = NULL, +}; + +static void +tdm_backend_handle_display_destroy(struct wl_listener *listener, void *data) +{ + struct ds_tdm_backend *tdm; + + tdm = wl_container_of(listener, tdm, display_destroy); + tdm_backend_destroy(tdm); +} + +static int +tdm_backend_handle_tdm_event(int fd, uint32_t mask, void *data) +{ + struct ds_tdm_backend *tdm; + + tdm = data; + tdm_display_handle_events(tdm->tdm_display); + + return 0; +} diff --git a/src/libds/backend/tdm/meson.build b/src/libds/backend/tdm/meson.build new file mode 100644 index 0000000..9a0b041 --- /dev/null +++ b/src/libds/backend/tdm/meson.build @@ -0,0 +1,8 @@ +libds_files += files( + 'backend.c', + 'output.c', +) + +libds_deps += [ + dependency('libtdm', required: true), +] diff --git a/src/libds/backend/tdm/output.c b/src/libds/backend/tdm/output.c new file mode 100644 index 0000000..74a0e29 --- /dev/null +++ b/src/libds/backend/tdm/output.c @@ -0,0 +1,145 @@ +#include +#include + +#include "libds/log.h" +#include "tdm.h" + +static const struct ds_output_interface tdm_output_iface; +static bool tdm_output_init_modes(struct ds_tdm_output *output); +static void tdm_output_destroy(struct ds_tdm_output *output); + +struct ds_tdm_output * +create_tdm_output(struct ds_tdm_backend *tdm, tdm_output *tdm_output) +{ + struct ds_tdm_output *output; + tdm_output_conn_status conn; + tdm_error err; + + output = calloc(1, sizeof *output); + if (!output) + return NULL; + + ds_output_init(&output->base, &tdm->base, &tdm_output_iface, + tdm->wl_display); + + output->tdm = tdm; + output->tdm_output = tdm_output; + + err = tdm_output_get_conn_status(tdm_output, &conn); + if (err != TDM_ERROR_NONE) { + ds_err("Could not get connection status of tdm output(%p): err(%d)", + tdm_output, err); + goto err_status; + } + + if (conn == TDM_OUTPUT_CONN_STATUS_CONNECTED) { + output->status = DS_TDM_OUTPUT_CONNECTED; + + if (!tdm_output_init_modes(output)) { + ds_err("Could not initialize modes of tdm output(%p)", + tdm_output); + goto err_status; + } + } + else if (conn == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) { + output->status = DS_TDM_OUTPUT_DISCONNECTED; + } + + ds_inf("TDM output(%p) created.", output); + + return output; + +err_status: + free(output); + + return NULL; +} + +static struct ds_tdm_output * +tdm_output_from_output(struct ds_output *ds_output) +{ + assert(ds_output->iface == &tdm_output_iface); + return (struct ds_tdm_output *)ds_output; +} + +static void +tdm_output_iface_destroy(struct ds_output *ds_output) +{ + struct ds_tdm_output *output; + + output = tdm_output_from_output(ds_output); + tdm_output_destroy(output); +} + +static bool +tdm_output_iface_commit(struct ds_output *ds_output) +{ + // TODO + return true; +} + +static const struct ds_output_interface tdm_output_iface = +{ + .destroy = tdm_output_iface_destroy, + .commit = tdm_output_iface_commit, +}; + +static void +tdm_output_destroy(struct ds_tdm_output *output) +{ + struct ds_tdm_output_mode *mode, *mode_tmp; + + wl_list_for_each_safe(mode, mode_tmp, &output->base.modes, base.link) { + wl_list_remove(&mode->base.link); + free(mode); + } + + free(output); +} + +static bool +tdm_output_init_modes(struct ds_tdm_output *output) +{ + struct ds_tdm_output_mode *mode; + const tdm_output_mode *tdm_modes, *tdm_mode; + tdm_error err; + int num_modes, i; + + err = tdm_output_get_available_modes(output->tdm_output, &tdm_modes, + &num_modes); + if (err != TDM_ERROR_NONE) { + ds_err("Could not get available modes: output(%p)", output); + return false; + } + + ds_inf("Detected modes:"); + + for (i = 0; i < num_modes; i++) { + tdm_mode = &tdm_modes[i]; + + mode = calloc(1, sizeof *mode); + if (!mode) { + ds_err("Could not allocate memory"); + continue; + } + + mode->tdm_mode = tdm_mode; + mode->base.width = tdm_mode->hdisplay; + mode->base.height = tdm_mode->vdisplay; + mode->base.refresh = (int32_t)tdm_mode->vrefresh; // FIXME + + if (tdm_mode->type & TDM_OUTPUT_MODE_TYPE_PREFERRED) + mode->base.preferred = true; + + ds_inf(" %dx%d@%d %s", mode->base.width, mode->base.height, + mode->base.refresh, + mode->base.preferred ? "(preferred)" : ""); + + if (tdm_mode->type & TDM_OUTPUT_MODE_TYPE_DEFAULT) + wl_list_insert(&output->base.modes, &mode->base.link); + else + wl_list_insert(output->base.modes.prev, &mode->base.link); + } + + return true; +} diff --git a/src/libds/backend/tdm/tdm.h b/src/libds/backend/tdm/tdm.h new file mode 100644 index 0000000..3a8990b --- /dev/null +++ b/src/libds/backend/tdm/tdm.h @@ -0,0 +1,53 @@ +#ifndef DS_BACKEND_TDM_H +#define DS_BACKEND_TDM_H + +#include +#include + +#include "libds/interfaces/backend.h" +#include "libds/interfaces/output.h" + +enum ds_tdm_output_status { + DS_TDM_OUTPUT_DISCONNECTED, + DS_TDM_OUTPUT_CONNECTED, +}; + +struct ds_tdm_output_mode { + struct ds_output_mode base; + const tdm_output_mode *tdm_mode; +}; + +struct ds_tdm_backend +{ + struct ds_backend base; + + tdm_display *tdm_display; + struct wl_display *wl_display; + struct wl_event_source *tdm_event; + + struct wl_list outputs; // ds_tdm_output.link + + struct wl_listener display_destroy; + + clockid_t clock; + int fd; +}; + +struct ds_tdm_output +{ + struct ds_output base; + + struct ds_tdm_backend *tdm; + tdm_output *tdm_output; + + struct wl_list link; + + enum ds_tdm_output_status status; +}; + +struct ds_tdm_backend *tdm_backend_from_backend(struct ds_backend *backend); + +struct ds_tdm_output *create_tdm_output(struct ds_tdm_backend *tdm, + tdm_output *tdm_output); + +#endif diff --git a/src/libds/output.c b/src/libds/output.c index 21d4ff8..f5cd356 100644 --- a/src/libds/output.c +++ b/src/libds/output.c @@ -20,6 +20,8 @@ ds_output_init(struct ds_output *output, struct ds_backend *backend, output->iface = iface; output->display = display; + wl_list_init(&output->modes); + wl_signal_init(&output->events.destroy); wl_signal_init(&output->events.frame); wl_signal_init(&output->events.commit); @@ -65,6 +67,37 @@ ds_output_attach_buffer(struct ds_output *output, struct ds_buffer *buffer) output->pending.buffer = ds_buffer_lock(buffer); } +WL_EXPORT const struct ds_output_mode * +ds_output_preferred_mode(struct ds_output *output) +{ + struct ds_output_mode *mode; + + if (wl_list_empty(&output->modes)) + return NULL; + + wl_list_for_each(mode, &output->modes, link) { + if (mode->preferred) + return mode; + } + + // No preferred mode, choose the first one + return wl_container_of(output->modes.next, mode, link); +} + +WL_EXPORT void +ds_output_set_mode(struct ds_output *output, const struct ds_output_mode *mode) +{ + output->pending.mode = NULL; + output->pending.committed &= ~DS_OUTPUT_STATE_MODE; + + if (output->current_mode == mode) { + return; + } + + output->pending.committed |= DS_OUTPUT_STATE_MODE; + output->pending.mode = mode; +} + WL_EXPORT void ds_output_add_destroy_listener(struct ds_output *output, struct wl_listener *listener) -- 2.7.4 From 3da1a3c47568a3b35c194f1ff5045162264a7a77 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 24 Feb 2022 14:58:44 +0900 Subject: [PATCH 15/16] Add tbm allocator Change-Id: Iab7cb52148134b46ff2c12c945c3746c38146da0 --- include/libds/allocator/tbm.h | 12 +++ packaging/libds.spec | 1 + src/libds/allocator/tbm.c | 177 ++++++++++++++++++++++++++++++++++++++++++ src/libds/meson.build | 2 + 4 files changed, 192 insertions(+) create mode 100644 include/libds/allocator/tbm.h create mode 100644 src/libds/allocator/tbm.c diff --git a/include/libds/allocator/tbm.h b/include/libds/allocator/tbm.h new file mode 100644 index 0000000..1457e3f --- /dev/null +++ b/include/libds/allocator/tbm.h @@ -0,0 +1,12 @@ +#ifndef LIBDS_ALLOCATOR_TBM_H +#define LIBDS_ALLOCATOR_TBM_H + +#include + +struct ds_allocator * +ds_tbm_allocator_create(void); + +WL_EXPORT void * +ds_tbm_buffer_get_surface(struct ds_buffer *ds_buffer); + +#endif diff --git a/packaging/libds.spec b/packaging/libds.spec index f68b266..aaf79b3 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -15,6 +15,7 @@ BuildRequires: pkgconfig(pixman-1) BuildRequires: pkgconfig(libdrm) BuildRequires: pkgconfig(libtdm) +BuildRequires: pkgconfig(libtbm) %description Wayland Compositor Library diff --git a/src/libds/allocator/tbm.c b/src/libds/allocator/tbm.c new file mode 100644 index 0000000..f4d0702 --- /dev/null +++ b/src/libds/allocator/tbm.c @@ -0,0 +1,177 @@ +#include +#include +#include +#include + +#include +#include + +#include "libds/interfaces/allocator.h" +#include "libds/interfaces/buffer.h" +#include "libds/log.h" + +struct ds_tbm_allocator +{ + struct ds_allocator base; + tbm_bufmgr bufmgr; +}; + +struct ds_tbm_buffer +{ + struct ds_buffer base; + tbm_surface_h surface; +}; + +static const struct ds_allocator_interface tbm_allocator_iface; +static struct ds_tbm_buffer *tbm_buffer_from_buffer(struct ds_buffer *buffer); + +WL_EXPORT struct ds_allocator * +ds_tbm_allocator_create(void) +{ + struct ds_tbm_allocator *alloc; + + alloc = calloc(1, sizeof *alloc); + if (!alloc) + return NULL; + + alloc->bufmgr = tbm_bufmgr_init(-1); + if (!alloc->bufmgr) { + ds_err("Could not initialize tbm_bufmgr"); + free(alloc); + return NULL; + } + + ds_allocator_init(&alloc->base, &tbm_allocator_iface, + DS_BUFFER_CAP_DATA_PTR); + + ds_inf("TBM allocator(%p) created", alloc); + + return &alloc->base; +} + +WL_EXPORT void * +ds_tbm_buffer_get_surface(struct ds_buffer *ds_buffer) +{ + struct ds_tbm_buffer *buffer; + + buffer = tbm_buffer_from_buffer(ds_buffer); + if (!buffer) + return NULL; + + return buffer->surface; +} + +static struct ds_tbm_allocator * +tbm_allocator_from_allocator(struct ds_allocator *ds_allocator) +{ + assert(ds_allocator->iface == &tbm_allocator_iface); + return (struct ds_tbm_allocator *)ds_allocator; +} + +static const struct ds_buffer_interface tbm_buffer_iface; + +static struct ds_tbm_buffer * +tbm_buffer_from_buffer(struct ds_buffer *buffer) +{ + assert(buffer->iface == &tbm_buffer_iface); + return (struct ds_tbm_buffer *)buffer; +} + +static void +tbm_buffer_destroy(struct ds_buffer *ds_buffer) +{ + struct ds_tbm_buffer *buffer; + + buffer = tbm_buffer_from_buffer(ds_buffer); + + ds_dbg("Destroy tbm buffer(%p)", buffer); + + tbm_surface_destroy(buffer->surface); + free(buffer); +} + +static bool +tbm_buffer_begin_data_ptr_access(struct ds_buffer *ds_buffer, uint32_t flags, + void **data, uint32_t *format, size_t *stride) +{ + struct ds_tbm_buffer *buffer; + tbm_surface_info_s info; + int tbm_access_flags = 0; + int ret; + + buffer = tbm_buffer_from_buffer(ds_buffer); + + if (flags & DS_BUFFER_DATA_PTR_ACCESS_READ) + tbm_access_flags |= TBM_OPTION_READ; + else if (flags & DS_BUFFER_DATA_PTR_ACCESS_WRITE) + tbm_access_flags |= TBM_OPTION_WRITE; + + ret = tbm_surface_map(buffer->surface, tbm_access_flags, &info); + if (ret != TBM_SURFACE_ERROR_NONE) { + ds_err("Could not map tbm_surface of buffer(%p)", buffer); + return false; + } + + *data = info.planes[0].ptr; + *format = info.format; + *stride = info.planes[0].stride; + + return true; +} + +static void +tbm_buffer_end_data_ptr_access(struct ds_buffer *ds_buffer) +{ + struct ds_tbm_buffer *buffer; + + buffer = tbm_buffer_from_buffer(ds_buffer); + + tbm_surface_unmap(buffer->surface); +} + +static const struct ds_buffer_interface tbm_buffer_iface = +{ + .destroy = tbm_buffer_destroy, + .begin_data_ptr_access = tbm_buffer_begin_data_ptr_access, + .end_data_ptr_access = tbm_buffer_end_data_ptr_access, +}; + + +static void +tbm_allocator_destroy(struct ds_allocator *ds_allocator) +{ + struct ds_tbm_allocator *alloc; + + alloc = tbm_allocator_from_allocator(ds_allocator); + + ds_inf("Destroy TBM allocator(%p)", alloc); + + tbm_bufmgr_deinit(alloc->bufmgr); + free(alloc); +} + +static struct ds_buffer * +tbm_allocator_create_buffer(struct ds_allocator *ds_allocator, + int width, int height, uint32_t format) +{ + static int num_buffers = 0; + struct ds_tbm_buffer *buffer; + + buffer = calloc(1, sizeof *buffer); + if (!buffer) + return NULL; + + ds_buffer_init(&buffer->base, &tbm_buffer_iface, width, height); + + buffer->surface = tbm_surface_create(width, height, TBM_FORMAT_XRGB8888); + + ds_dbg("tbm buffer(%p) created: size(%dx%d) number of buffers: %d", + buffer, width, height, ++num_buffers); + + return &buffer->base; +} + +static const struct ds_allocator_interface tbm_allocator_iface = { + .destroy = tbm_allocator_destroy, + .create_buffer = tbm_allocator_create_buffer, +}; diff --git a/src/libds/meson.build b/src/libds/meson.build index 2d09a91..8a88b62 100644 --- a/src/libds/meson.build +++ b/src/libds/meson.build @@ -4,6 +4,7 @@ libds_files = [ 'buffer.c', 'allocator/allocator.c', 'allocator/shm.c', + 'allocator/tbm.c', 'swapchain.c', 'output.c', 'compositor.c', @@ -50,6 +51,7 @@ math = meson.get_compiler('c').find_library('m') wayland_server = dependency('wayland-server', required: true) pixman = dependency('pixman-1', required: true) libdrm = dependency('libdrm', required: true) +libtbm = dependency('libtbm', required: true) libds_deps = [ math, -- 2.7.4 From 3d1640a24ba168cc20dba6625c9e499aa1f4aa40 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 24 Feb 2022 15:01:07 +0900 Subject: [PATCH 16/16] Flesh out tdm backend Change-Id: Ibb9557cca0f764ee7721563ce86def7164e58555 --- include/libds/backend/tdm.h | 9 ++ src/libds/backend/tdm/backend.c | 13 +++ src/libds/backend/tdm/output.c | 180 ++++++++++++++++++++++++++++++++++++++-- src/libds/backend/tdm/tdm.h | 23 ++++- 4 files changed, 218 insertions(+), 7 deletions(-) create mode 100644 include/libds/backend/tdm.h diff --git a/include/libds/backend/tdm.h b/include/libds/backend/tdm.h new file mode 100644 index 0000000..ec5f9cc --- /dev/null +++ b/include/libds/backend/tdm.h @@ -0,0 +1,9 @@ +#ifndef LIBDS_BACKEND_TDM_H +#define LIBDS_BACKEND_TDM_H + +#include + +struct ds_backend * +ds_tdm_backend_create(struct wl_display *display); + +#endif diff --git a/src/libds/backend/tdm/backend.c b/src/libds/backend/tdm/backend.c index 582fe62..2772f84 100644 --- a/src/libds/backend/tdm/backend.c +++ b/src/libds/backend/tdm/backend.c @@ -27,7 +27,9 @@ ds_tdm_backend_create(struct wl_display *display) tdm->wl_display = display; tdm->clock = CLOCK_MONOTONIC; // FIXME + wl_list_init(&tdm->outputs); + wl_list_init(&tdm->buffers); tdm->tdm_display = tdm_display_init(&err); if (err != TDM_ERROR_NONE) { @@ -74,6 +76,17 @@ tdm_backend_from_backend(struct ds_backend *backend) static void tdm_backend_destroy(struct ds_tdm_backend *tdm) { + struct ds_tdm_output *output, *tmp_output; + struct ds_tdm_buffer *buffer, *tmp_buffer; + + wl_list_for_each_safe(output, tmp_output, &tdm->outputs, link) { + ds_output_destroy(&output->base); + } + + wl_list_for_each_safe(buffer, tmp_buffer, &tdm->buffers, link) { + destroy_tdm_buffer(buffer); + } + wl_list_remove(&tdm->display_destroy.link); wl_event_source_remove(tdm->tdm_event); close(tdm->fd); diff --git a/src/libds/backend/tdm/output.c b/src/libds/backend/tdm/output.c index 74a0e29..08b56b5 100644 --- a/src/libds/backend/tdm/output.c +++ b/src/libds/backend/tdm/output.c @@ -2,11 +2,14 @@ #include #include "libds/log.h" +#include "libds/allocator/tbm.h" #include "tdm.h" +#include static const struct ds_output_interface tdm_output_iface; static bool tdm_output_init_modes(struct ds_tdm_output *output); static void tdm_output_destroy(struct ds_tdm_output *output); +static void tdm_output_init_hwc(struct ds_tdm_output *output); struct ds_tdm_output * create_tdm_output(struct ds_tdm_backend *tdm, tdm_output *tdm_output) @@ -22,8 +25,8 @@ create_tdm_output(struct ds_tdm_backend *tdm, tdm_output *tdm_output) ds_output_init(&output->base, &tdm->base, &tdm_output_iface, tdm->wl_display); - output->tdm = tdm; - output->tdm_output = tdm_output; + output->backend = tdm; + output->tdm.output = tdm_output; err = tdm_output_get_conn_status(tdm_output, &conn); if (err != TDM_ERROR_NONE) { @@ -45,7 +48,10 @@ create_tdm_output(struct ds_tdm_backend *tdm, tdm_output *tdm_output) output->status = DS_TDM_OUTPUT_DISCONNECTED; } - ds_inf("TDM output(%p) created.", output); + if (tdm_output_get_hwc(output->tdm.output, NULL) != NULL) + tdm_output_init_hwc(output); + + ds_inf("TDM output(%p) created: hwc(%p)", output, output->tdm.hwc); return output; @@ -71,10 +77,148 @@ tdm_output_iface_destroy(struct ds_output *ds_output) tdm_output_destroy(output); } +void +destroy_tdm_buffer(struct ds_tdm_buffer *buffer) +{ + if (buffer == NULL) + return; + + wl_list_remove(&buffer->buffer_destroy.link); + wl_list_remove(&buffer->link); + free(buffer); +} + +static void +buffer_handle_buffer_destroy(struct wl_listener *listener, void *data) +{ + struct ds_tdm_buffer *buffer; + + buffer = wl_container_of(listener, buffer, buffer_destroy); + destroy_tdm_buffer(buffer); +} + +static struct ds_tdm_buffer * +create_tdm_buffer(struct ds_tdm_backend *backend, struct ds_buffer *ds_buffer) +{ + struct ds_tdm_buffer *buffer; + tbm_surface_h surface; + + surface = ds_tbm_buffer_get_surface(ds_buffer); + if (!surface) { + ds_err("Could not get tbm_surface_h"); + return NULL; + } + + buffer = calloc(1, sizeof *buffer); + if (!buffer) { + return NULL; + } + + buffer->surface = surface; + buffer->buffer = ds_buffer_lock(ds_buffer); + wl_list_insert(&backend->buffers, &buffer->link); + + buffer->buffer_destroy.notify = buffer_handle_buffer_destroy; + ds_buffer_add_destroy_listener(ds_buffer, &buffer->buffer_destroy); + + return buffer; +} + +static struct ds_tdm_buffer * +get_or_create_tdm_buffer(struct ds_tdm_backend *backend, + struct ds_buffer *ds_buffer) +{ + struct ds_tdm_buffer *buffer; + + wl_list_for_each(buffer, &backend->buffers, link) { + if (buffer->buffer == ds_buffer && buffer->released) { + buffer->released = false; + ds_buffer_lock(buffer->buffer); + return buffer; + } + } + + return create_tdm_buffer(backend, ds_buffer); +} + +static void +tdm_output_hwc_commit_handler(tdm_hwc *hwc, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, void *user_data) +{ + struct ds_tdm_output *output; + + output = user_data; + + if (output->front_buffer) { + output->front_buffer->released = true; + ds_buffer_unlock(output->front_buffer->buffer); + } + + output->front_buffer = output->back_buffer; + output->back_buffer = NULL; + + wl_signal_emit(&output->base.events.frame, &output->base); +} + static bool tdm_output_iface_commit(struct ds_output *ds_output) { - // TODO + struct ds_tdm_output *output; + struct ds_tdm_buffer *buffer; + struct ds_buffer *ds_buffer; + + output = tdm_output_from_output(ds_output); + + ds_buffer = ds_output->pending.buffer; + buffer = get_or_create_tdm_buffer(output->backend, ds_buffer); + if (!buffer) + return false; + + if (ds_output->pending.committed & DS_OUTPUT_STATE_BUFFER) { + tdm_region fb_damage; + tdm_error err; + uint32_t num_changes; + + memset(&fb_damage, 0, sizeof(fb_damage)); + err = tdm_hwc_set_client_target_buffer(output->tdm.hwc, + buffer->surface, fb_damage); + if (err != TDM_ERROR_NONE) { + ds_err("Could not set hwc client target buffer"); + ds_buffer_unlock(buffer->buffer); + return false; + } + + err = tdm_hwc_validate(output->tdm.hwc, NULL, 0, &num_changes); + if (err != TDM_ERROR_NONE) { + ds_err("Could not hwc validate"); + ds_buffer_unlock(buffer->buffer); + return false; + } + + err = tdm_hwc_accept_validation(output->tdm.hwc); + if (err != TDM_ERROR_NONE) { + ds_err("Could not hwc accept validation"); + ds_buffer_unlock(buffer->buffer); + return false; + } + + err = tdm_hwc_commit(output->tdm.hwc, 0, tdm_output_hwc_commit_handler, output); + if (err != TDM_ERROR_NONE) { + ds_err("Could not hwc commit"); + ds_buffer_unlock(buffer->buffer); + return false; + } + + if (output->back_buffer) { + output->back_buffer->released = true; + ds_buffer_unlock(output->back_buffer->buffer); + } + + output->back_buffer = buffer; + + ds_dbg("Swap Buffer!!!!!"); + } + return true; } @@ -94,6 +238,12 @@ tdm_output_destroy(struct ds_tdm_output *output) free(mode); } + if (output->back_buffer) + ds_buffer_unlock(output->back_buffer->buffer); + + if (output->front_buffer) + ds_buffer_unlock(output->front_buffer->buffer); + free(output); } @@ -105,7 +255,7 @@ tdm_output_init_modes(struct ds_tdm_output *output) tdm_error err; int num_modes, i; - err = tdm_output_get_available_modes(output->tdm_output, &tdm_modes, + err = tdm_output_get_available_modes(output->tdm.output, &tdm_modes, &num_modes); if (err != TDM_ERROR_NONE) { ds_err("Could not get available modes: output(%p)", output); @@ -139,7 +289,27 @@ tdm_output_init_modes(struct ds_tdm_output *output) wl_list_insert(&output->base.modes, &mode->base.link); else wl_list_insert(output->base.modes.prev, &mode->base.link); + + // FIXME + if (mode->base.preferred) { + err = tdm_output_set_mode(output->tdm.output, tdm_mode); + if (err != TDM_ERROR_NONE) { + ds_err("Could not set mode"); + } + } } return true; } + +static void +tdm_output_init_hwc(struct ds_tdm_output *output) +{ + tdm_error err; + + output->tdm.hwc = tdm_output_get_hwc(output->tdm.output, &err); + if (err != TDM_ERROR_NONE || !output->tdm.hwc) { + ds_err("Could not get tdm_hwc: output(%p)", output); + return; + } +} diff --git a/src/libds/backend/tdm/tdm.h b/src/libds/backend/tdm/tdm.h index 3a8990b..2b1c1e4 100644 --- a/src/libds/backend/tdm/tdm.h +++ b/src/libds/backend/tdm/tdm.h @@ -26,6 +26,7 @@ struct ds_tdm_backend struct wl_event_source *tdm_event; struct wl_list outputs; // ds_tdm_output.link + struct wl_list buffers; // ds_tdm_buffer.link struct wl_listener display_destroy; @@ -37,17 +38,35 @@ struct ds_tdm_output { struct ds_output base; - struct ds_tdm_backend *tdm; - tdm_output *tdm_output; + struct ds_tdm_backend *backend; + struct ds_tdm_buffer *front_buffer, *back_buffer; + + struct { + tdm_output *output; + tdm_hwc *hwc; + } tdm; struct wl_list link; enum ds_tdm_output_status status; }; +struct ds_tdm_buffer +{ + struct ds_buffer *buffer; + tbm_surface_h surface; + struct wl_list link; // ds_wl_backend.buffers + struct wl_listener buffer_destroy; + + bool released; +}; + struct ds_tdm_backend *tdm_backend_from_backend(struct ds_backend *backend); struct ds_tdm_output *create_tdm_output(struct ds_tdm_backend *tdm, tdm_output *tdm_output); +void destroy_tdm_buffer(struct ds_tdm_buffer *buffer); + + #endif -- 2.7.4