__p_ptr(p_ptr)
{
DSLOG_DBG("TizenPolicyPriv", "");
+ __wm = DSWindowManager::getInstance();
}
DSWaylandTizenPolicyPrivate::~DSWaylandTizenPolicyPrivate()
{
DSLOG_DBG("TizenPolicyPriv", "");
+ if (__wm)
+ DSWindowManager::releaseInstance();
}
void DSWaylandTizenPolicyPrivate::tizen_policy_initialize(DSWaylandCompositor *wlCompositor)
void DSWaylandTizenPolicyPrivate::tizen_policy_activate(Resource *resource, struct ::wl_resource *surface)
{
- DSLOG_DBG("TizenPolicyPriv", "");
+ DSLOG_DBG("TizenPolicyPriv", "Request to activate. resource:%p, wl_surface:%p", resource, surface);
+ DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface);
+ if (!dswlSurface) return;
+ if (!__wm) return;
+
+ __wm->activateWindow(dswlSurface);
}
void DSWaylandTizenPolicyPrivate::tizen_policy_activate_below_by_res_id(Resource *resource, uint32_t res_id, uint32_t below_res_id)
void DSWaylandTizenPolicyPrivate::tizen_policy_raise(Resource *resource, struct ::wl_resource *surface)
{
- DSLOG_DBG("TizenPolicyPriv", "");
+ DSLOG_DBG("TizenPolicyPriv", "Request to raise. resource:%p, wl_surface:%p", resource, surface);
+ DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface);
+ if (!dswlSurface) return;
+ if (!__wm) return;
+
+ __wm->raiseWindow(dswlSurface);
}
void DSWaylandTizenPolicyPrivate::tizen_policy_lower(Resource *resource, struct ::wl_resource *surface)
{
- DSLOG_DBG("TizenPolicyPriv", "");
+ DSLOG_DBG("TizenPolicyPriv", "Request to lower. resource:%p, wl_surface:%p", resource, surface);
+ DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface);
+ if (!dswlSurface) return;
+ if (!__wm) return;
+
+ __wm->lowerWindow(dswlSurface);
}
void DSWaylandTizenPolicyPrivate::tizen_policy_lower_by_res_id(Resource *resource, uint32_t res_id)
#define _DS_WAYLAND_TIZEN_POLICY_PRIVATE_H_
#include "dswayland-server-tizen-extension.h"
+#include "DSWindowManager.h"
#include "DSWaylandTizenPolicy.h"
namespace display_server
void tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid) override;
private:
+ DSWindowManager *__wm;
std::list<std::shared_ptr<DSWaylandTizenPosition>> __tzPosList;
};
}
}
+void DSWindowManagerPrivate::activateWindow(DSWaylandSurface *dswlSurface)
+{
+ // find dswlSurface's window
+ DSZone *zone = __getZone(dswlSurface);
+ if (zone)
+ {
+ zone->activateWindow(dswlSurface);
+ }
+}
+
+void DSWindowManagerPrivate::raiseWindow(DSWaylandSurface *dswlSurface)
+{
+ // find dswlSurface's window
+ DSZone *zone = __getZone(dswlSurface);
+ if (zone)
+ {
+ zone->raiseWindow(dswlSurface);
+ }
+}
+
+void DSWindowManagerPrivate::lowerWindow(DSWaylandSurface *dswlSurface)
+{
+ // find dswlSurface's window
+ DSZone *zone = __getZone(dswlSurface);
+ if (zone)
+ {
+ zone->lowerWindow(dswlSurface);
+ }
+}
+
DSWindowManager::DSWindowManager(DSObject *parent)
: DS_INIT_PRIVATE_PTR(DSWindowManager)
{
priv->setWindowPosition(dsSurface, x, y);
}
+void DSWindowManager::activateWindow(DSWaylandSurface *dswlSurface)
+{
+ DS_GET_PRIV(DSWindowManager);
+ priv->activateWindow(dswlSurface);
+}
+
+void DSWindowManager::raiseWindow(DSWaylandSurface *dswlSurface)
+{
+ DS_GET_PRIV(DSWindowManager);
+ priv->raiseWindow(dswlSurface);
+}
+
+void DSWindowManager::lowerWindow(DSWaylandSurface *dswlSurface)
+{
+ DS_GET_PRIV(DSWindowManager);
+ priv->lowerWindow(dswlSurface);
+}
+
} // namespace display_server
void setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h);
void setWindowPosition(DSWaylandSurface *dsSurface, int x, int y);
+ void activateWindow(DSWaylandSurface *dswlSurface);
+ void raiseWindow(DSWaylandSurface *dswlSurface);
+ void lowerWindow(DSWaylandSurface *dswlSurface);
+
protected:
private:
void setWindowGeometry(DSWaylandSurface *dsSurface, int x, int y, unsigned int w, unsigned h);
void setWindowPosition(DSWaylandSurface *dsSurface, int x, int y);
+ void activateWindow(DSWaylandSurface *dswlSurface);
+ void raiseWindow(DSWaylandSurface *dswlSurface);
+ void lowerWindow(DSWaylandSurface *dswlSurface);
+
private:
DSZone *__getZone(DSWindow *window);
DSZone *__getZone(DSWaylandSurface *surface);
__size{0, 0},
__waylandCompositor(nullptr),
__wm(nullptr),
- __waylandShell(nullptr)
+ __eventLoop(nullptr),
+ __waylandShell(nullptr),
+ __stackChanged(false)
{
__waylandCompositor = DSWaylandCompositor::getInstance();
if (__waylandCompositor)
if (__wm)
__wm->registerZone(this);
+ __eventLoop = DSEventLoop::getInstance();
+ if (__eventLoop)
+ __eventLoop->registerCallbackIdleEnterer(this, std::bind(&DSZone::__onEventIdleEnterer, this, std::placeholders::_1));
+
+
__waylandShell = __waylandCompositor->getShell();
if (__waylandShell)
__waylandShell->registerCallbackShellSurfaceCreated(this, std::bind(&DSZone::__onShellSurfaceCreated, this, std::placeholders::_1));
{
if (__wm)
__wm->unregisterZone(this);
-
- DSWindowManager::releaseInstance();
- DSWaylandCompositor::releaseInstance();
+ if (__eventLoop)
+ DSEventLoop::releaseInstance();
+ if (__wm)
+ DSWindowManager::releaseInstance();
+ if (__waylandCompositor)
+ DSWaylandCompositor::releaseInstance();
}
void DSZone::setPosition(stPosition &position)
__windowCreatedSignal.emit(nullptr);
}
+void DSZone::__onEventIdleEnterer(void *data)
+{
+ if (__stackChanged)
+ {
+ DSLOG_DBG("DSZone", "Calculate Visibility...");
+
+ // calculate visibility?
+ __stackChanged = false;
+ }
+}
+
void DSZone::__onSurfaceCreated(std::shared_ptr<DSWaylandSurface> waylandSurface)
{
DSLOG_DBG("DSZone", "waylandSurface:(shared:%p, pure:%p)", waylandSurface, waylandSurface.get());
}
// for Test
-void DSZone::callCallbackWindowShellCreated()
+void DSZone::callCallbackWindowShellCreated(std::shared_ptr<DSWindowShell> winShell)
+{
+ __windowShellCreatedSignal.emit(winShell);
+}
+
+bool DSZone::testCreateWindow(std::shared_ptr<DSWaylandSurface> waylandSurface)
{
- __windowShellCreatedSignal.emit(nullptr);
+ std::shared_ptr<DSWindow> window = __createWindow(waylandSurface);
+ if (!window) return false;
+
+ return true;
}
std::list<std::shared_ptr<DSWindow>> DSZone::getWindowList()
return __windowShellList;
}
+void DSZone::__prependWindowList(std::shared_ptr<DSWindow> window)
+{
+ __windowList.remove(window);
+ __windowList.push_front(window);
+
+ __stackChanged = true;
+}
+
+void DSZone::__appendWindowList(std::shared_ptr<DSWindow> window)
+{
+ __windowList.remove(window);
+ __windowList.push_back(window);
+
+ __stackChanged = true;
+}
+
std::shared_ptr<DSWindow> DSZone::__findWindow(DSWaylandSurface *dswlSurface)
{
std::list<std::shared_ptr<DSWindow>> wList = getWindowList();
std::shared_ptr<DSWindow> DSZone::__createWindow(std::shared_ptr<DSWaylandSurface> waylandSurface)
{
std::shared_ptr<DSWindow> window = std::make_shared<DSWindow>(waylandSurface);
- __windowList.push_front(window);
+ __prependWindowList(window);
// emit a signal of the surface committed
__windowCreatedSignal.emit(window);
*/
}
+void DSZone::activateWindow(DSWaylandSurface *dswlSurface)
+{
+ if (!dswlSurface) return;
+
+ std::shared_ptr<DSWindow> window = __findWindow(dswlSurface);
+ __prependWindowList(window);
+
+ DSWindowShell *wShell = __findWindowShell(dswlSurface);
+ if (!wShell) return;
+
+ wShell->activate();
+}
+
+void DSZone::raiseWindow(DSWaylandSurface* dswlSurface)
+{
+ if (!dswlSurface) return;
+
+ std::shared_ptr<DSWindow> window = __findWindow(dswlSurface);
+ __prependWindowList(window);
+
+ DSWindowShell *wShell = __findWindowShell(dswlSurface);
+ if (!wShell) return;
+
+ wShell->raise();
+}
+
+void DSZone::lowerWindow(DSWaylandSurface* dswlSurface)
+{
+ if (!dswlSurface) return;
+
+ std::shared_ptr<DSWindow> window = __findWindow(dswlSurface);
+ __appendWindowList(window);
+
+ DSWindowShell *wShell = __findWindowShell(dswlSurface);
+ if (!wShell) return;
+
+ wShell->lower();
+}
+
} // namespace display_server
#include "DSWindowShell.h"
#include "DSSignal.h"
#include "DSStruct.h"
+#include "DSEventLoop.h"
namespace display_server
{
// emit functions for testing
void callCallbackWindowCreated();
- void callCallbackWindowShellCreated();
+ void callCallbackWindowShellCreated(std::shared_ptr<DSWindowShell> winShell);
+ // for test
+ bool testCreateWindow(std::shared_ptr<DSWaylandSurface> waylandSurface);
// for window property
bool setWindowTitle(DSWaylandSurface *dswSurface, const std::string &title);
bool setWindowGeometry(DSWaylandSurface *dswSurface, int x, int y, unsigned int w, unsigned h);
bool setWindowPosition(DSWaylandSurface *dswSurface, int x, int y);
+ void activateWindow(DSWaylandSurface *dswlSurface);
+ void raiseWindow(DSWaylandSurface* dswlSurface);
+ void lowerWindow(DSWaylandSurface* dswlSurface);
+
std::list<std::shared_ptr<DSWindow>> getWindowList();
std::list<std::shared_ptr<DSWindowShell>> getWindowShellList();
private:
+ void __onEventIdleEnterer(void *data);
+
void __onSurfaceCreated(std::shared_ptr<DSWaylandSurface> waylandSurface);
void __onSurfaceDestroy(std::shared_ptr<DSWaylandSurface> waylandSurface);
std::shared_ptr<DSWindowShell> __createWindowShell(std::shared_ptr<DSWindow> window);
void __destroyWindowShell(DSWindowShell* windowShell, DSWaylandSurface *surface);
+ void __prependWindowList(std::shared_ptr<DSWindow> window);
+ void __appendWindowList(std::shared_ptr<DSWindow> window);
+
std::shared_ptr<DSWindow> __findWindow(DSWaylandSurface *dswlSurface);
DSWindowShell* __findWindowShell(DSWaylandSurface *dswlSurface);
std::list<std::shared_ptr<DSWindowShell>> __windowShellList;
DSWaylandCompositor *__waylandCompositor;
DSWindowManager *__wm;
+ DSEventLoop *__eventLoop;
IDSWaylandShell *__waylandShell;
+ bool __stackChanged;
std::map<DSWaylandSurface*, DSWindowShell*> __windowShellMap;
#include "libds-tests.h"
#include "DSZone.h"
+#include "DSWaylandSurface.h"
+#include "DSWindow.h"
#include "DSPolicyArea.h"
#include "DSPolicyAreaPrivate.h"
__boolOnWindowShellCreated(false)
{
zone->registerCallbackWindowCreated(this, std::bind(&TestZone::onWindowCreated, this, std::placeholders::_1));
+ zone->registerCallbackWindowShellCreated(this, std::bind(&TestZone::onWindowShellCreated, this, std::placeholders::_1));
__zone = zone;
+
+ __countWindow = 0;
+
+ for (int i=0; i<5; i++)
+ myWindow[i] = nullptr;
}
~TestZone()
void onWindowCreated(std::shared_ptr<DSWindow> window) {
__boolOnWindowCreated = true;
+
+ myWindow[__countWindow] = window.get();
+ __countWindow++;
}
- void callOnWindowShellCreated() {
- __zone->callCallbackWindowShellCreated();
+ void callOnWindowShellCreated(std::shared_ptr<DSWindowShell> winShell) {
+ __zone->callCallbackWindowShellCreated(winShell);
}
bool getResultOnWindowShellCreated() {
return __boolOnWindowShellCreated;
}
- void onWindowShellCreated(std::shared_ptr<DSWindow> window) {
+ void onWindowShellCreated(std::shared_ptr<DSWindowShell> windowShell) {
__boolOnWindowShellCreated = true;
}
+ std::list<std::shared_ptr<DSWindow>> getWindowList() {
+ return __zone->getWindowList();
+ }
+
+ int getWindowCount() {
+ return __countWindow;
+ }
+
+public:
+ DSWindow* myWindow[5];
+
private:
bool __boolOnWindowCreated;
bool __boolOnWindowShellCreated;
std::shared_ptr<DSZone> __zone;
+ int __countWindow;
};
TEST_F(DSZoneTest, NewDSZone)
// before calling WindowShell created
EXPECT_FALSE(testZone->getResultOnWindowShellCreated());
- testZone->callOnWindowShellCreated();
+ testZone->callOnWindowShellCreated(nullptr);
// after calling WindowShell created
EXPECT_TRUE(testZone->getResultOnWindowShellCreated());
}
+
+TEST_F(DSZoneTest, stackChanged)
+{
+ int count;
+
+ auto zone = std::make_shared<DSZone>();
+ EXPECT_TRUE(zone != nullptr);
+
+ auto testZone = std::make_shared<TestZone>(zone);
+
+ EXPECT_TRUE(testZone != nullptr);
+
+ auto dswlSurface1 = std::make_shared<DSWaylandSurface>();
+ EXPECT_TRUE(zone->testCreateWindow(dswlSurface1));
+
+ auto dswlSurface2 = std::make_shared<DSWaylandSurface>();
+ EXPECT_TRUE(zone->testCreateWindow(dswlSurface2));
+
+ count = testZone->getWindowCount();
+ for (std::shared_ptr<DSWindow> w : zone->getWindowList())
+ {
+ EXPECT_TRUE(w.get() == testZone->myWindow[count-1]);
+ count--;
+ }
+
+ zone->raiseWindow(dswlSurface1.get());
+
+ count = 0;
+ for (std::shared_ptr<DSWindow> w : zone->getWindowList())
+ {
+ EXPECT_TRUE(w.get() == testZone->myWindow[count]);
+ count++;
+ }
+}
+