add code to handle focus_skip_set 10/241910/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Thu, 20 Aug 2020 10:36:21 +0000 (19:36 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 23:58:45 +0000 (08:58 +0900)
Change-Id: I9dfa518f7916681b13534be2d08152026e2fd637

14 files changed:
src/DSWaylandServer/DSWaylandTizenPolicy.cpp
src/DSWindow/DSWindow.cpp
src/DSWindow/DSWindow.h
src/DSWindow/DSWindowPrivate.h
src/DSWindowManager/DSWindowManager.cpp
src/DSWindowManager/DSWindowManager.h
src/DSWindowManager/DSWindowManagerPrivate.h
src/DSWindowShell/DSWindowShell.cpp
src/DSWindowShell/DSWindowShell.h
src/DSWindowShell/DSWindowShellPrivate.cpp
src/DSWindowShell/DSWindowShellPrivate.h
src/DSZone/DSZone.cpp
src/DSZone/DSZone.h
tests/DSWindow-test.cpp

index 52f19e3..33e47b0 100644 (file)
@@ -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)
index 3306276..8c10913 100644 (file)
@@ -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);
index 04bfa9f..10fb3b8 100644 (file)
@@ -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);
index df18827..b5a36f4 100644 (file)
@@ -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;
 };
 
index 4137305..818fd33 100644 (file)
@@ -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
index 6b6ce69..ed69080 100644 (file)
@@ -64,6 +64,8 @@ public:
        void raiseWindow(DSWaylandSurface *dswlSurface);
        void lowerWindow(DSWaylandSurface *dswlSurface);
 
+       void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set);
+
 protected:
 
 private:
index b42ad84..f1066a0 100644 (file)
@@ -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);
index d6291b5..94029b0 100644 (file)
@@ -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);
index d9ac09c..53d2bcb 100644 (file)
@@ -52,6 +52,8 @@ public:
 
        bool setTitle(const std::string &title);
 
+       bool setSkipFocus(bool set);
+
        bool setPosition(int x, int y);
        stPosition getPosition(void);
 
index e4a1e2a..56eee9b 100644 (file)
@@ -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;
index 809324a..8cebc66 100644 (file)
@@ -48,6 +48,8 @@ public:
 
        bool setTitle(const std::string &title);
 
+       bool setSkipFocus(bool set);
+
        bool setPosition(int x, int y);
        stPosition getPosition(void);
 
index 39ceafa..7ce4399 100644 (file)
@@ -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
index e115978..01a8c9b 100644 (file)
@@ -72,6 +72,8 @@ public:
        void raiseWindow(DSWaylandSurface* dswlSurface);
        void lowerWindow(DSWaylandSurface* dswlSurface);
 
+       void setWindowSkipFocus(DSWaylandSurface *dswlSurface, bool set);
+
        std::list<std::shared_ptr<DSWindow>> getWindowList();
        std::list<std::shared_ptr<DSWindowShell>> getWindowShellList();
 
index 7f33bd3..8ee7f19 100644 (file)
@@ -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<DSWindow>();
+       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);
+}
+