* DEALINGS IN THE SOFTWARE.
*/
+#include "DSWindowManager.h"
#include "DSWaylandZxdgShellV6.h"
#include "DSWaylandZxdgShellV6Private.h"
#include "DSWaylandCompositor.h"
void DSWaylandZxdgSurfaceV6Private::setWindowTitle(const std::string &title)
{
// TODO: needs DSWindow title set method
- //__window->setTitle(title);
__title = title;
+
+ DSWindowManager *wm = DSWindowManager::getInstance();
+ wm->setWindowTitle(__dsSurface, __title);
+ DSWindowManager::releaseInstance();
}
void DSWaylandZxdgSurfaceV6Private::setAppID(const std::string &appId)
__hasFocus(false),
__waylandSurface(nullptr),
__winShell(nullptr),
- __firstCommit(true)
+ __firstCommit(true),
+ __title("")
{
}
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::setLayer(int layer)
{
return true;
return priv->showState();
}
+bool DSWindow::setTitle(const std::string &title)
+{
+ DSLOG_DBG("DSWindow", "title:%s", title.c_str());
+
+ DS_GET_PRIV(DSWindow);
+ return priv->setTitle(title);
+}
+
+const std::string DSWindow::getTitle(void)
+{
+ DS_GET_PRIV(DSWindow);
+ return priv->getTitle();
+}
bool DSWindow::setLayer(int layer)
{
bool hide(bool autoFocus = true);
int showState(void);
+ bool setTitle(const std::string &title);
+ const std::string getTitle(void);
+
bool setLayer(int layer);
bool raise(void);
bool lower(void);
bool hide(bool autoFocus);
int showState(void);
+ bool setTitle(const std::string &title);
+ const std::string getTitle(void);
+
bool setLayer(int layer);
bool raise(void);
bool lower(void);
std::shared_ptr<DSWaylandSurface> __waylandSurface;
DSWindowShell *__winShell;
bool __firstCommit;
+ std::string __title;
};
}
}
+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
+ }
+}
+
DSWindowManager::DSWindowManager(DSObject *parent)
: DS_INIT_PRIVATE_PTR(DSWindowManager)
return priv->getZone(surface);
}
+void DSWindowManager::setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title)
+{
+ DS_GET_PRIV(DSWindowManager);
+ priv->setWindowTitle(dsSurface, title);
+}
+
} // namespace display_server
void unregisterSurface(DSZone *zone, DSWaylandSurface *surface);
DSZone *getZone(DSWaylandSurface *surface);
+ void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title);
+
protected:
private:
void unregisterSurface(DSZone *zone, DSWaylandSurface *surface);
DSZone *getZone(DSWaylandSurface *surface);
+ void setWindowTitle(DSWaylandSurface *dsSurface, const std::string &title);
+
private:
DSZone *__getZone(DSWindow *window);
DSZone *__getZone(DSWaylandSurface *surface);
}
}
+bool DSZone::setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title)
+{
+ std::shared_ptr<DSWindow> window = __findWindow(dswSurface);
+ return window->setTitle(title);
+}
+
} // namespace display_server
void callCallbackWindowCreated();
void callCallbackWindowShellCreated();
+ // for window property
+ bool setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title);
+
std::list<std::shared_ptr<DSWindow>> getWindowList();
std::list<std::shared_ptr<DSWindowShell>> getWindowShellList();
TEST_F(DSWindowTest, NewDSWindow)
{
- DSWindow *win = new DSWindow();
+ auto win = std::make_shared<DSWindow>();
EXPECT_TRUE(win != nullptr);
}
TEST_F(DSWindowTest, BasicMethods)
{
- auto win = new DSWindow();
+ auto win = std::make_shared<DSWindow>();
EXPECT_TRUE(win != nullptr);
EXPECT_TRUE(win->show() == 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);
}
TEST_F(DSWindowTest, SizeTest)
{
- auto win = new DSWindow();
+ auto win = std::make_shared<DSWindow>();
EXPECT_TRUE(win != nullptr);
stSize size = win->getSize();
TEST_F(DSWindowTest, PositionTest)
{
- auto win = new DSWindow();
+ auto win = std::make_shared<DSWindow>();
EXPECT_TRUE(win != nullptr);
stPosition pos = win->getPosition();
TEST_F(DSWindowTest, WindowShellTest)
{
- auto win = new DSWindow();
+ auto win = std::make_shared<DSWindow>();
EXPECT_TRUE(win != nullptr);
- auto winShell = new DSWindowShell(win);
+ auto winShell = std::make_shared<DSWindowShell>(win.get());
EXPECT_TRUE(winShell != nullptr);
- EXPECT_TRUE(win->setWindowShell(winShell) == true);
+ EXPECT_TRUE(win->setWindowShell(winShell.get()) == true);
DSWindowShell *getWinShell = nullptr;
getWinShell = win->getWindowShell();
- EXPECT_TRUE(winShell == getWinShell);
+ EXPECT_TRUE(winShell.get() == getWinShell);
}
+
+TEST_F(DSWindowTest, TitleTest)
+{
+ auto win = std::make_shared<DSWindow>();
+ 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);
+}
+