#include <wayland-client.h>
#include <wayland-client-protocol.h>
#include <wayland-extension/tizen-extension-client-protocol.h>
+#include <wayland-extension/tizen-launch-client-protocol.h>
struct wl_display *display = NULL;
struct wl_compositor *compositor = 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;
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)
{
};
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)\n", interface, id);
+ printf("Registry event : global added (interface:%s, id:%d, version:%d)\n", interface, id, version);
if (strcmp(interface, "wl_compositor") == 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, "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);
+ }
}
static void
# exampleClient written for testing exampleCompositor
wayland_client_dep = dependency('wayland-client')
tizen_extension_client_dep = dependency('tizen-extension-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, libxkbcommon_dep],
+ dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, libxkbcommon_dep, tizen_launch_client_dep],
install_dir : libds_prefix_bindir,
install : true
)
--- /dev/null
+#include <DSTizenAppinfo.h>
+
+namespace display_server
+{
+DSTizenAppinfo::DSTizenAppinfo()
+ : __pid(-1),
+ __base_output_available(false),
+ __base_output_width(0),
+ __base_output_height(0)
+{
+}
+
+DSTizenAppinfo::DSTizenAppinfo(std::string appid)
+ : __pid(-1),
+ __base_output_available(false),
+ __base_output_width(0),
+ __base_output_height(0)
+{
+ __appId = appid;
+}
+
+void DSTizenAppinfo::setAppId(std::string appId)
+{
+ __appId = appId;
+}
+
+void DSTizenAppinfo::setPid(pid_t pid)
+{
+ __pid = pid;
+}
+
+DSTizenAppinfo::~DSTizenAppinfo()
+{
+}
+
+pid_t DSTizenAppinfo::pid()
+{
+ return __pid;
+}
+
+std::string DSTizenAppinfo::appId()
+{
+ return __appId;
+}
+
+bool DSTizenAppinfo::base_output_available()
+{
+ return __base_output_available;
+}
+
+int DSTizenAppinfo::base_output_width()
+{
+ return __base_output_width;
+}
+
+int DSTizenAppinfo::base_output_height()
+{
+ return __base_output_height;
+}
+
+}
\ No newline at end of file
--- /dev/null
+#ifndef _DS_TIZENAPPINFO_H_
+#define _DS_TIZENAPPINFO_H_
+
+#include <DSWaylandTizenAppinfo.h>
+
+namespace display_server
+{
+
+class DSTizenAppinfo : public DSObject
+{
+public:
+ DSTizenAppinfo();
+ DSTizenAppinfo(std::string appid);
+ virtual ~DSTizenAppinfo();
+
+ void setAppId(std::string appId);
+ void setPid(pid_t pid);
+ pid_t pid(void);
+ std::string appId(void);
+ bool base_output_available(void);
+ int base_output_width(void);
+ int base_output_height(void);
+
+private:
+ std::string __appId;
+ pid_t __pid;
+ bool __base_output_available;
+ int __base_output_width;
+ int __base_output_height;
+};
+
+}
+#endif
\ No newline at end of file
--- /dev/null
+#include "DSTizenAppinfoMgr.h"
+#include "DSWaylandTizenAppinfo.h"
+#include "DSDebugLog.h"
+
+namespace display_server
+{
+
+DSTizenAppinfoMgr::DSTizenAppinfoMgr()
+ :__numAppinfo(0)
+{
+ __wlCompositor = DSWaylandCompositor::getInstance();
+ __wlAppinfo = new DSWaylandTizenAppinfo(__wlCompositor, this);
+}
+
+DSTizenAppinfoMgr::~DSTizenAppinfoMgr()
+{
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::getTizenAppinfo(std::string appId)
+{
+ auto it = __appIdMap.find(appId);
+ if (it != __appIdMap.end())
+ {
+ DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) returned by appId:%s", appId);
+ return it->second;
+ }
+ return nullptr;
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::getTizenAppinfo(pid_t pid)
+{
+ std::unordered_map <std::string, std::shared_ptr<DSTizenAppinfo>>::iterator it;
+ for (it = __appIdMap.begin(); it != __appIdMap.end(); it++) {
+ std::shared_ptr<DSTizenAppinfo> ptr_appinfo = it->second;
+ DSTizenAppinfo * appinfo;
+ appinfo = ptr_appinfo.get() ;
+ if (appinfo->pid() == pid) {
+ DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo returned by pid:%d", pid);
+ return ptr_appinfo;
+ }
+ }
+ return nullptr;
+}
+
+std::shared_ptr<DSTizenAppinfo> DSTizenAppinfoMgr::addTizenAppinfo(std::string appId)
+{
+ std::shared_ptr<DSTizenAppinfo> appinfo = getTizenAppinfo(appId);
+ if (appinfo == nullptr) {
+ appinfo = std::make_shared<DSTizenAppinfo>(appId);
+ if (appinfo != nullptr)
+ {
+ __appIdMap.emplace(appId, appinfo);
+ __numAppinfo++;
+ DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) added", appId);
+ return appinfo;
+ }
+ }
+ DSLOG_INF("DSTizenAppinfoMgr", "No TizenAppinfo added by apppId:%s", appId);
+ return appinfo;
+}
+
+void DSTizenAppinfoMgr::removeTizenAppinfo(std::string appId)
+{
+ auto it = __appIdMap.find(appId);
+ if (it != __appIdMap.end()) {
+ __appIdMap.erase(it);
+ --__numAppinfo;
+ DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) removed", appId);
+ }
+ return;
+}
+
+void DSTizenAppinfoMgr::updateTizenAppinfo(std::string appId, pid_t pid)
+{
+ std::shared_ptr<DSTizenAppinfo> ptr_appinfo = getTizenAppinfo(appId);
+ DSTizenAppinfo * appinfo;
+ appinfo = ptr_appinfo.get();
+ if (appinfo != nullptr)
+ {
+ appinfo->setPid(pid);
+ DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) set to pid:%d", appId, pid);
+ }
+}
+}
\ No newline at end of file
--- /dev/null
+#ifndef _DS_TIZENAPPINFO_MGR_H_
+#define _DS_TIZENAPPINFO_MGR_H_
+
+#include <DSTizenAppinfo.h>
+#include "DSWaylandCompositor.h"
+
+namespace display_server
+{
+
+class DSTizenAppinfoMgr : public DSObject
+{
+public:
+ DSTizenAppinfoMgr();
+ virtual ~DSTizenAppinfoMgr();
+
+ std::shared_ptr<DSTizenAppinfo> getTizenAppinfo(std::string appId);
+ std::shared_ptr<DSTizenAppinfo> getTizenAppinfo(pid_t pid);
+
+ std::shared_ptr<DSTizenAppinfo> addTizenAppinfo(std::string appId);
+
+ void removeTizenAppinfo(std::string appId);
+
+ void updateTizenAppinfo(std::string appId, pid_t pid);
+
+ int numAppinfo()
+ {
+ return __numAppinfo;
+ };
+
+private:
+ DSWaylandCompositor *__wlCompositor;
+ DSWaylandTizenAppinfo *__wlAppinfo;
+ std::unordered_map <std::string, std::shared_ptr<DSTizenAppinfo>> __appIdMap;
+ int __numAppinfo;
+};
+
+}
+
+#endif
\ No newline at end of file
#include "DSWaylandCompositor.h"
#include "DSWaylandZxdgShellV6.h"
#include "DSWaylandTizenPolicy.h"
+#include "DSTizenAppinfoMgr.h"
namespace display_server
{
__initZxdgShellV6();
__initTizenPolicy();
+ __initTizenAppinfoMgr();
}
catch(const std::runtime_error& e)
{
return true;
}
+bool DSWaylandExtensionPrivate::__initTizenAppinfoMgr(void)
+{
+ __tzAppinfoMgr = std::make_shared<DSTizenAppinfoMgr>();
+ if (__tzAppinfoMgr == nullptr)
+ {
+ throw std::runtime_error(__func__);
+ return false;
+ }
+
+ return true;
+}
+
DSWaylandExtension::DSWaylandExtension(DSWaylandCompositor *compositor)
: DS_INIT_PRIVATE_PTR(DSWaylandExtension)
{
class DSWaylandZxdgShellV6;
class DSWaylandTizenPolicy;
+class DSTizenAppinfoMgr;
class DSWaylandExtensionPrivate : public DSObjectPrivate
{
private:
bool __initZxdgShellV6(void);
bool __initTizenPolicy(void);
+ bool __initTizenAppinfoMgr(void);
private:
DSWaylandCompositor *__compositor;
std::shared_ptr<DSWaylandZxdgShellV6> __zxdgShell;
std::shared_ptr<DSWaylandTizenPolicy> __tzPolicy;
+ std::shared_ptr<DSTizenAppinfoMgr> __tzAppinfoMgr;
};
#include "DSWaylandTizenAppinfo.h"
#include "DSWaylandTizenAppinfoPrivate.h"
+#include "DSTizenAppinfoMgr.h"
+
+const int TIZEN_APPINFO_VERSION = 1;
namespace display_server
{
-
-DSWaylandTizenAppinfo::DSWaylandTizenAppinfo()
- : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo)
+DSWaylandTizenAppinfoPrivate::DSWaylandTizenAppinfoPrivate(DSWaylandTizenAppinfo *p_ptr)
+ : DSObjectPrivate(p_ptr),
+ __p_ptr(p_ptr)
{
}
-DSWaylandTizenAppinfo::~DSWaylandTizenAppinfo()
+DSWaylandTizenAppinfoPrivate::~DSWaylandTizenAppinfoPrivate()
{
}
-DSWaylandTizenAppinfoPrivate::DSWaylandTizenAppinfoPrivate(DSWaylandTizenAppinfo *p_ptr)
- : DSObjectPrivate(p_ptr),
- __p_ptr(p_ptr)
+void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_initialize(DSWaylandCompositor *wlCompositor)
{
-}
+ ::wl_display *display;
+ display = wlCompositor->display();
-DSWaylandTizenAppinfoPrivate::~DSWaylandTizenAppinfoPrivate()
+ 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", "");
}
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);
+ if (pub->__dsAppinfoMgr == nullptr)
+ return;
+
+ std::shared_ptr<DSTizenAppinfo> ptr_appinfo = pub->__dsAppinfoMgr->getTizenAppinfo(pid);
+ DSTizenAppinfo *appinfo = ptr_appinfo.get();
+ send_base_output_resolution_done(pid, appinfo->base_output_width(), appinfo->base_output_height());
+ DSLOG_DBG("TizenAppinfoPriv", "SEND base_output_resolution_done event with width(%d), height(%d)", appinfo->base_output_width(), appinfo->base_output_height());
}
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", "");
+}
+
+DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor)
+ : DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo),
+ __wlCompositor(wlCompositor),
+ __isCreated(false),
+ __dsAppinfoMgr(nullptr)
+{
+ this->initialize(__wlCompositor);
+}
+
+DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor, DSTizenAppinfoMgr *dsAppinfoMgr)
+ : DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo),
+ __wlCompositor(wlCompositor),
+ __isCreated(false),
+ __dsAppinfoMgr(dsAppinfoMgr)
+{
+ this->initialize(__wlCompositor);
+}
+
+DSWaylandTizenAppinfo::~DSWaylandTizenAppinfo()
+{
+ 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;
}
}
#include <DSObject.h>
#include <DSCore.h>
+#include "DSWaylandCompositor.h"
namespace display_server
{
class DSWaylandTizenAppinfoPrivate;
+class DSTizenAppinfoMgr;
class DSWaylandTizenAppinfo : public DSObject
{
DS_PIMPL_USE_PRIVATE(DSWaylandTizenAppinfo);
public:
- DSWaylandTizenAppinfo();
+ 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;
+ DSTizenAppinfoMgr *__dsAppinfoMgr;
+
};
}
#define __DS_WAYLAND_TIZEN_APPINFO_PRIVATE_H__
#include "dswayland-server-tizen-launch.h"
+
#include "DSWaylandTizenAppinfo.h"
namespace display_server
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;
'DSCore/DSStruct.h',
'DSCore/DSCore.h',
'DSWaylandExtension/DSWaylandExtension.cpp',
+ 'DSWaylandExtension/DSTizenAppinfo.h',
+ 'DSWaylandExtension/DSTizenAppinfo.cpp',
+ 'DSWaylandExtension/DSTizenAppinfoMgr.h',
+ 'DSWaylandExtension/DSTizenAppinfoMgr.cpp',
'DSWindow/DSWindow.h',
'DSWindow/DSWindowPrivate.h',
'DSWindow/DSWindow.cpp',
--- /dev/null
+#include "libds-tests.h"
+#include "DSTizenAppinfo.h"
+#include "DSTizenAppinfoMgr.h"
+
+using namespace display_server;
+
+class DSTizenAppinfoTest : public ::testing::Test
+{
+public:
+ void SetUp(void) override
+ {
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
+ }
+ void TearDown(void) override
+ {
+ unsetenv("XDG_RUNTIME_DIR");
+ }
+};
+
+TEST_F(DSTizenAppinfoTest, NewTizenAppinfo)
+{
+ DSTizenAppinfo *appinfo = new DSTizenAppinfo();
+ EXPECT_TRUE(appinfo != nullptr);
+
+ if (appinfo)
+ delete appinfo;
+}
+
+TEST_F(DSTizenAppinfoTest, NewTizenAppinfoMgr)
+{
+ DSTizenAppinfoMgr *appinfoMgr = new DSTizenAppinfoMgr();
+ EXPECT_TRUE(appinfoMgr != nullptr);
+
+ if (appinfoMgr)
+ {
+ std::string appId1{"com.appinfo.first"};
+ std::string appId2{"com.appinfo.econd"};
+
+ std::shared_ptr<DSTizenAppinfo> app1 = appinfoMgr->addTizenAppinfo(appId1);
+ EXPECT_TRUE(app1 != nullptr);
+ std::shared_ptr<DSTizenAppinfo> app2 = appinfoMgr->addTizenAppinfo(appId2);
+ EXPECT_TRUE(app2 != nullptr);
+ EXPECT_TRUE(appinfoMgr->numAppinfo() == 2);
+
+ std::shared_ptr<DSTizenAppinfo> temp = appinfoMgr->getTizenAppinfo(appId2);
+ EXPECT_TRUE(temp != nullptr);
+ appinfoMgr->removeTizenAppinfo(appId2);
+
+ pid_t pid = 1234;
+ app1->setPid(pid);
+ temp = appinfoMgr->getTizenAppinfo(pid);
+ appinfoMgr->removeTizenAppinfo(temp->appId());
+
+ EXPECT_TRUE(appinfoMgr->numAppinfo() == 0);
+
+ delete appinfoMgr;
+ }
+}
\ No newline at end of file
{}
};
-TEST_F(DSWaylandTizenAppinfoTest, NewDSWaylandTizenAppinfo)
+TEST_F(DSWaylandTizenAppinfoTest, New_Appinfo)
{
- DSWaylandTizenAppinfo *tzAppinfo = new DSWaylandTizenAppinfo;
+ DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance();
+ DSWaylandTizenAppinfo *tzAppinfo = new DSWaylandTizenAppinfo(compositor);
EXPECT_TRUE(tzAppinfo != nullptr);
if (tzAppinfo)
delete tzAppinfo;
+
+ 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();
+}
\ No newline at end of file
'DSWaylandTizenPolicy-test.cpp',
'DSWaylandTizenSurface-test.cpp',
'DSWaylandTizenIndicator-test.cpp',
+ 'DSWaylandTizenAppinfo-test.cpp',
'DSWaylandZxdgShellV6-test.cpp',
'DSWaylandBuffer-test.cpp',
'DSObject-test.cpp',
'DSPointer-test.cpp',
'DSKeyboard-test.cpp',
'DSTouch-test.cpp',
+ 'DSTizenAppinfo-test.cpp',
]
gmock_dep = dependency('gmock', method : 'pkg-config')