From: Doyoun Kang Date: Thu, 20 Aug 2020 10:36:21 +0000 (+0900) Subject: add code to handle focus_skip_set X-Git-Tag: accepted/tizen/unified/20200826.133051~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bcbd03934f49081790e63a7203b1282875efc545;p=platform%2Fcore%2Fuifw%2Flibds.git add code to handle focus_skip_set Change-Id: I9dfa518f7916681b13534be2d08152026e2fd637 --- diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index 52f19e3..33e47b0 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -129,12 +129,22 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_lower_by_res_id(Resource *resourc void DSWaylandTizenPolicyPrivate::tizen_policy_set_focus_skip(Resource *resource, struct ::wl_resource *surface) { - DSLOG_DBG("TizenPolicyPriv", ""); + 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", ""); + 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) diff --git a/src/DSWindow/DSWindow.cpp b/src/DSWindow/DSWindow.cpp index 3306276..8c10913 100644 --- a/src/DSWindow/DSWindow.cpp +++ b/src/DSWindow/DSWindow.cpp @@ -44,6 +44,7 @@ DSWindowPrivate::DSWindowPrivate(DSWindow *p_ptr) __winShell(nullptr), __firstCommit(true), __changedGeometry(false), + __acceptsFocus(true), __title("") { } @@ -92,6 +93,20 @@ 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; +} + bool DSWindowPrivate::setLayer(int layer) { return true; @@ -253,6 +268,18 @@ const std::string DSWindow::getTitle(void) 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(); +} + bool DSWindow::setLayer(int layer) { DS_GET_PRIV(DSWindow); diff --git a/src/DSWindow/DSWindow.h b/src/DSWindow/DSWindow.h index 04bfa9f..10fb3b8 100644 --- a/src/DSWindow/DSWindow.h +++ b/src/DSWindow/DSWindow.h @@ -56,6 +56,9 @@ public: bool setTitle(const std::string &title); const std::string getTitle(void); + bool setSkipFocus(bool set); + bool getSkipFocus(void); + bool setLayer(int layer); bool raise(void); bool lower(void); diff --git a/src/DSWindow/DSWindowPrivate.h b/src/DSWindow/DSWindowPrivate.h index df18827..b5a36f4 100644 --- a/src/DSWindow/DSWindowPrivate.h +++ b/src/DSWindow/DSWindowPrivate.h @@ -53,6 +53,9 @@ public: bool setTitle(const std::string &title); const std::string getTitle(void); + bool setSkipFocus(bool set); + bool getSkipFocus(void); + bool setLayer(int layer); bool raise(void); bool lower(void); @@ -78,6 +81,7 @@ private: DSWindowShell *__winShell; bool __firstCommit; bool __changedGeometry; + bool __acceptsFocus; std::string __title; }; diff --git a/src/DSWindowManager/DSWindowManager.cpp b/src/DSWindowManager/DSWindowManager.cpp index 4137305..818fd33 100644 --- a/src/DSWindowManager/DSWindowManager.cpp +++ b/src/DSWindowManager/DSWindowManager.cpp @@ -288,6 +288,17 @@ void DSWindowManagerPrivate::lowerWindow(DSWaylandSurface *dswlSurface) } } +void DSWindowManagerPrivate::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) +{ + // find dswlSurface's window + DSZone *zone = __getZone(dswlSurface); + if (zone) + { + zone->setWindowSkipFocus(dswlSurface, set); + } +} + + DSWindowManager::DSWindowManager(DSObject *parent) : DS_INIT_PRIVATE_PTR(DSWindowManager) { @@ -428,5 +439,11 @@ void DSWindowManager::lowerWindow(DSWaylandSurface *dswlSurface) priv->lowerWindow(dswlSurface); } +void DSWindowManager::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) +{ + DS_GET_PRIV(DSWindowManager); + priv->setWindowSkipFocus(dswlSurface, set); +} + } // namespace display_server diff --git a/src/DSWindowManager/DSWindowManager.h b/src/DSWindowManager/DSWindowManager.h index 6b6ce69..ed69080 100644 --- a/src/DSWindowManager/DSWindowManager.h +++ b/src/DSWindowManager/DSWindowManager.h @@ -64,6 +64,8 @@ public: void raiseWindow(DSWaylandSurface *dswlSurface); void lowerWindow(DSWaylandSurface *dswlSurface); + void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + protected: private: diff --git a/src/DSWindowManager/DSWindowManagerPrivate.h b/src/DSWindowManager/DSWindowManagerPrivate.h index b42ad84..f1066a0 100644 --- a/src/DSWindowManager/DSWindowManagerPrivate.h +++ b/src/DSWindowManager/DSWindowManagerPrivate.h @@ -59,6 +59,8 @@ public: void raiseWindow(DSWaylandSurface *dswlSurface); void lowerWindow(DSWaylandSurface *dswlSurface); + void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + private: DSZone *__getZone(DSWindow *window); DSZone *__getZone(DSWaylandSurface *surface); diff --git a/src/DSWindowShell/DSWindowShell.cpp b/src/DSWindowShell/DSWindowShell.cpp index d6291b5..94029b0 100644 --- a/src/DSWindowShell/DSWindowShell.cpp +++ b/src/DSWindowShell/DSWindowShell.cpp @@ -73,6 +73,12 @@ bool DSWindowShell::setTitle(const std::string &title) return priv->setTitle(title); } +bool DSWindowShell::setSkipFocus(bool set) +{ + DS_GET_PRIV(DSWindowShell); + return priv->setSkipFocus(set); +} + bool DSWindowShell::setPosition(int x, int y) { DS_GET_PRIV(DSWindowShell); diff --git a/src/DSWindowShell/DSWindowShell.h b/src/DSWindowShell/DSWindowShell.h index d9ac09c..53d2bcb 100644 --- a/src/DSWindowShell/DSWindowShell.h +++ b/src/DSWindowShell/DSWindowShell.h @@ -52,6 +52,8 @@ public: bool setTitle(const std::string &title); + bool setSkipFocus(bool set); + bool setPosition(int x, int y); stPosition getPosition(void); diff --git a/src/DSWindowShell/DSWindowShellPrivate.cpp b/src/DSWindowShell/DSWindowShellPrivate.cpp index e4a1e2a..56eee9b 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.cpp +++ b/src/DSWindowShell/DSWindowShellPrivate.cpp @@ -97,6 +97,17 @@ bool DSWindowShellPrivate::setTitle(const std::string &title) return false; } +bool DSWindowShellPrivate::setSkipFocus(bool set) +{ + if (__window) + { + __window->setSkipFocus(set); + return true; + } + else + return false; +} + bool DSWindowShellPrivate::setPosition(int x, int y) { __x = x; diff --git a/src/DSWindowShell/DSWindowShellPrivate.h b/src/DSWindowShell/DSWindowShellPrivate.h index 809324a..8cebc66 100644 --- a/src/DSWindowShell/DSWindowShellPrivate.h +++ b/src/DSWindowShell/DSWindowShellPrivate.h @@ -48,6 +48,8 @@ public: bool setTitle(const std::string &title); + bool setSkipFocus(bool set); + bool setPosition(int x, int y); stPosition getPosition(void); diff --git a/src/DSZone/DSZone.cpp b/src/DSZone/DSZone.cpp index 39ceafa..7ce4399 100644 --- a/src/DSZone/DSZone.cpp +++ b/src/DSZone/DSZone.cpp @@ -412,5 +412,12 @@ void DSZone::lowerWindow(DSWaylandSurface* dswlSurface) wShell->lower(); } +void DSZone::setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set) +{ + DSWindowShell *wShell = __findWindowShell(dswlSurface); + if (!wShell) return; + + wShell->setSkipFocus(set); +} } // namespace display_server diff --git a/src/DSZone/DSZone.h b/src/DSZone/DSZone.h index e115978..01a8c9b 100644 --- a/src/DSZone/DSZone.h +++ b/src/DSZone/DSZone.h @@ -72,6 +72,8 @@ public: void raiseWindow(DSWaylandSurface* dswlSurface); void lowerWindow(DSWaylandSurface* dswlSurface); + void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set); + std::list> getWindowList(); std::list> getWindowShellList(); diff --git a/tests/DSWindow-test.cpp b/tests/DSWindow-test.cpp index 7f33bd3..8ee7f19 100644 --- a/tests/DSWindow-test.cpp +++ b/tests/DSWindow-test.cpp @@ -76,8 +76,8 @@ TEST_F(DSWindowTest, SizeTest) EXPECT_TRUE(win != nullptr); stSize size = win->getSize(); - EXPECT_TRUE(size.w == 1); - EXPECT_TRUE(size.h == 1); + EXPECT_TRUE(size.w == 0); + EXPECT_TRUE(size.h == 0); win->setSize(1280, 720); size = win->getSize(); @@ -137,3 +137,27 @@ TEST_F(DSWindowTest, TitleTest) 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); +} +