From d1ac4461961a5ab3959aa266c122468c6623763a Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Thu, 13 Aug 2020 13:56:06 +0900 Subject: [PATCH] DSWaylandOutput: add getBaseResolutionFromAppinfo() func to get resolution information from DSTizenAppinfo Change-Id: Ibc07c1a65af07c8bc4c528cf1d3b65412245ecb6 --- samples/exampleClient.c | 5 +++ src/DSWaylandServer/DSWaylandOutput.cpp | 60 +++++++++++++++++++++++++++- src/DSWaylandServer/DSWaylandOutputPrivate.h | 3 ++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/samples/exampleClient.c b/samples/exampleClient.c index a8c262d..929f72b 100644 --- a/samples/exampleClient.c +++ b/samples/exampleClient.c @@ -45,6 +45,7 @@ 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; @@ -478,6 +479,10 @@ global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, 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); + } } static void diff --git a/src/DSWaylandServer/DSWaylandOutput.cpp b/src/DSWaylandServer/DSWaylandOutput.cpp index a3b1ae7..067f353 100644 --- a/src/DSWaylandServer/DSWaylandOutput.cpp +++ b/src/DSWaylandServer/DSWaylandOutput.cpp @@ -23,6 +23,8 @@ #include "DSWaylandOutput.h" #include "DSWaylandOutputPrivate.h" +#include "DSWaylandClient.h" +#include "DSTizenAppinfoMgr.h" namespace display_server { @@ -42,7 +44,22 @@ DSWaylandOutputPrivate::~DSWaylandOutputPrivate() void DSWaylandOutputPrivate::output_bind_resource(wl_output::Resource *resource) { - sendWaylandOutputInfo(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) @@ -55,12 +72,53 @@ 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; +} + void DSWaylandOutputPrivate::sendWaylandOutputInfo(void) { std::multimap::iterator iter; diff --git a/src/DSWaylandServer/DSWaylandOutputPrivate.h b/src/DSWaylandServer/DSWaylandOutputPrivate.h index f6e916c..7320781 100644 --- a/src/DSWaylandServer/DSWaylandOutputPrivate.h +++ b/src/DSWaylandServer/DSWaylandOutputPrivate.h @@ -45,6 +45,7 @@ protected: 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); @@ -56,6 +57,8 @@ protected: void setWaylandOutputSubpixel(unsigned int subpixel); void setWaylandOutputTransform(unsigned int transform); + bool getBaseResolutionFromAppinfo(Resource *resource, int *w, int *h); + private: stRect __outputRect; int __phyWidth; -- 2.7.4