}
+bool DSWindowShell::setZone(DSZone *zone)
+{
+ DS_GET_PRIV(DSWindowShell);
+ return priv->setZone(zone);
+}
+
+DSZone *DSWindowShell::getZone(void)
+{
+ DS_GET_PRIV(DSWindowShell);
+ return priv->getZone();
+}
+
void DSWindowShell::setShellSurface(IDSWaylandShellSurface *shellSurface)
{
DS_GET_PRIV(DSWindowShell);
class DSWindow;
class DSWindowShellPrivate;
+class DSZone;
class DSWindowShell
{
void destroy(void);
+ bool setZone(DSZone *zone);
+ DSZone *getZone(void);
+
void setShellSurface(IDSWaylandShellSurface *zxdgSurface);
IDSWaylandShellSurface *getShellSurface(void);
* DEALINGS IN THE SOFTWARE.
*/
+#include "DSZone.h"
#include "DSWindowShell.h"
#include "DSWindowShellPrivate.h"
: __p_ptr(p_ptr),
__window(window),
__shellSurface(nullptr),
+ __zone(nullptr),
__x(0), __y(0),
__w(0), __h(0),
__reqX(0), __reqY(0),
else
set = false;
- __window->allowUserGeometry(set);
+ __handleUserGeometryHint(set);
}
}
+bool DSWindowShellPrivate::__handleUserGeometryHint(bool setUserGeometry)
+{
+ if (!__window) return false;
+
+ __window->allowUserGeometry(setUserGeometry);
+ if (setUserGeometry)
+ {
+ // reset windows geometry
+ __x = __y = __w = __h = 0;
+ __window->setPosition(__x, __y);
+ __window->setSize(__w, __h);
+ }
+ else
+ {
+ // apply zone's geometry
+ if (__zone)
+ {
+ stPosition zPos = __zone->getPosition();
+ stSize zSize = __zone->getSize();
+ __x = zPos.x;
+ __y = zPos.y;
+ __w = zSize.w;
+ __h = zSize.h;
+
+ __window->setPosition(__x, __y);
+ __window->setSize(__w, __h);
+ }
+ }
+
+ return true;
+}
+
bool DSWindowShellPrivate::create(DSWindowShell *pParent)
{
return true;
}
+bool DSWindowShellPrivate::setZone(DSZone *zone)
+{
+ if (__zone)
+ {
+ // unset information for old zone
+ }
+
+ __zone = zone;
+ if (__zone)
+ {
+ stPosition zPos = __zone->getPosition();
+ stSize zSize = __zone->getSize();
+
+ // check whether DSWindowShell's geometry has to change or not
+ if (__window)
+ {
+ if (!__window->isAllowUserGeometry())
+ {
+ __x = zPos.x;
+ __y = zPos.y;
+ __w = zSize.w;
+ __h = zSize.h;
+
+ __window->setPosition(__x, __y);
+ __window->setSize(__w, __h);
+ }
+ }
+ else
+ {
+ __x = zPos.x;
+ __y = zPos.y;
+ __w = zSize.w;
+ __h = zSize.h;
+ }
+ }
+
+ return true;
+}
+
+DSZone *DSWindowShellPrivate::getZone(void)
+{
+ return __zone;
+}
void DSWindowShellPrivate::setShellSurface(IDSWaylandShellSurface *shellSurface)
{
bool DSWindowShellPrivate::setPosition(int x, int y)
{
- __x = x;
- __y = y;
+ __reqX = x;
+ __reqY = y;
if (__window)
- __window->setPosition(__x, __y);
+ {
+ if (__window->isAllowUserGeometry())
+ {
+ __x = x;
+ __y = y;
+ __window->setPosition(__x, __y);
+ }
+ }
+ else
+ {
+ __x = x;
+ __y = y;
+ }
return true;
}
bool DSWindowShellPrivate::setSize(unsigned int w, unsigned int h)
{
- __w = w;
- __h = h;
+ __reqW = w;
+ __reqH = h;
if (__window)
- __window->setSize(__w, __h);
+ {
+ if (__window->isAllowUserGeometry())
+ {
+ __w = w;
+ __h = h;
+ __window->setSize(__w, __h);
+ }
+ }
+ else
+ {
+ __w = w;
+ __h = h;
+ }
return true;
}
bool DSWindowShellPrivate::setGeometry(int x, int y, unsigned int w, unsigned int h)
{
- __x = x;
- __y = y;
- __w = w;
- __h = h;
+ __reqX = x;
+ __reqY = y;
+ __reqW = w;
+ __reqH = h;
if (__window)
{
- __window->setPosition(__x, __y);
- __window->setSize(__w, __h);
+ if (__window->isAllowUserGeometry())
+ {
+ __x = x;
+ __y = y;
+ __w = w;
+ __h = h;
+ __window->setPosition(__x, __y);
+ __window->setSize(__w, __h);
+ }
+ }
+ else
+ {
+ __x = x;
+ __y = y;
+ __w = w;
+ __h = h;
}
return true;
void destroy(void);
+ bool setZone(DSZone *zone);
+ DSZone *getZone(void);
+
void setShellSurface(IDSWaylandShellSurface *shellSurface);
IDSWaylandShellSurface *getShellSurface(void);
struct stWindowAuxHint* __findAuxHint(int32_t id);
void __handleAuxHint(stWindowAuxHint *hint);
+ bool __handleUserGeometryHint(bool setUserGeometry);
private:
DSWindow *__window;
IDSWaylandShellSurface *__shellSurface;
- int __x, __y;
- unsigned int __w, __h;
- int __reqX, __reqY;
- unsigned int __reqW, __reqH;
+ DSZone *__zone;
+ int __x, __y; // real (applied) position
+ unsigned int __w, __h; // real (applied) size
+ int __reqX, __reqY; // requested position by client
+ unsigned int __reqW, __reqH; // requested size by client
DSWindowShell *__parent;
int __layer;
std::list<DSWindowShell*> __childList;
DSWindow *ptrWindow = window.get();
std::shared_ptr<DSWindowShell> shell = std::make_shared<DSWindowShell>(ptrWindow);
+ if (!shell) return nullptr;
+
+ shell->setZone(this);
+
__windowShellList.push_front(shell);
__windowShellMap.insert(std::make_pair(ptrWindow->surface(), shell.get()));
std::unique_ptr<DSWindowShell> shell = std::make_unique<DSWindowShell>(window.get());
EXPECT_TRUE(shell != nullptr);
- EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true);
+ EXPECT_TRUE(shell->setPosition(100, 150) == true);
+ pos = shell->getPosition();
+
+ EXPECT_TRUE(pos.x == 0);
+ EXPECT_TRUE(pos.y == 0);
+}
+
+TEST_F(DSWindowShellTest, getPosition_P2)
+{
+ stPosition pos;
+ auto window = std::make_shared<DSWindow>();
+ std::unique_ptr<DSWindowShell> shell = std::make_unique<DSWindowShell>(window.get());
+ EXPECT_TRUE(shell != nullptr);
+
+ // set user geometry
+ shell->addAuxHint(1, "wm.policy.win.user.geometry", "1");
+
EXPECT_TRUE(shell->setPosition(100, 150) == true);
pos = shell->getPosition();
std::unique_ptr<DSWindowShell> shell = std::make_unique<DSWindowShell>(window.get());
EXPECT_TRUE(shell != nullptr);
- EXPECT_TRUE(shell->create(0, 0, 720, 1280, nullptr) == true);
+ shell->setGeometry(100, 150, 480, 800);
+ geo = shell->getGeometry();
+
+ EXPECT_TRUE(geo.x == 0);
+ EXPECT_TRUE(geo.y == 0);
+ EXPECT_TRUE(geo.w == 0);
+ EXPECT_TRUE(geo.h == 0);
+}
+
+TEST_F(DSWindowShellTest, Geometry_P2)
+{
+ stGeometry geo;
+
+ auto window = std::make_shared<DSWindow>();
+ std::unique_ptr<DSWindowShell> shell = std::make_unique<DSWindowShell>(window.get());
+ EXPECT_TRUE(shell != nullptr);
+
+ // set user geometry
+ shell->addAuxHint(1, "wm.policy.win.user.geometry", "1");
shell->setGeometry(100, 150, 480, 800);
geo = shell->getGeometry();