summaryrefslogtreecommitdiff
path: root/plugins
diff options
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-12-21 14:29:09 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-12-21 14:29:09 +0800
commitf12f8513e9b6a467e71cb39d98c99bb0c6ede685 (patch)
tree55096fad17e7a80bde094274363a3839f92b761d /plugins
parent1c2c9c8c3973c56a3711390e71bb1523a108cf98 (diff)
Use nux::Geometry instead of CompSize and CompRect in the Unity::MT classes since we can't
link to those (bzr r1794.1.2)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/unity-mt-grab-handles/CMakeLists.txt2
-rw-r--r--plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp88
-rw-r--r--plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h73
3 files changed, 79 insertions, 84 deletions
diff --git a/plugins/unity-mt-grab-handles/CMakeLists.txt b/plugins/unity-mt-grab-handles/CMakeLists.txt
index a67d6b7f5..95874e929 100644
--- a/plugins/unity-mt-grab-handles/CMakeLists.txt
+++ b/plugins/unity-mt-grab-handles/CMakeLists.txt
@@ -2,4 +2,4 @@ find_package (Compiz REQUIRED)
include (CompizPlugin)
-compiz_plugin (unitymtgrabhandles PLUGINDEPS composite opengl CFLAGSADD -std=c++0x)
+compiz_plugin (unitymtgrabhandles PKGDEPS nux-1.0>=1.2.2 PLUGINDEPS composite opengl CFLAGSADD -std=c++0x)
diff --git a/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp b/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp
index dfc4b6369..615617788 100644
--- a/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp
+++ b/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.cpp
@@ -203,8 +203,8 @@ Unity::MT::GrabHandle::reposition(int x,
if (flags & PositionSet)
{
- mRect.setX(x);
- mRect.setY(y);
+ mRect.x = x;
+ mRect.y = y;
}
if (flags & PositionLock)
@@ -227,29 +227,28 @@ Unity::MT::GrabHandle::reposition(int x, int y, unsigned int flags) const
Unity::MT::TextureLayout
Unity::MT::GrabHandle::layout()
{
- return TextureLayout(mTexture, &mRect);
+ return TextureLayout(mTexture, mRect);
}
Unity::MT::GrabHandle::GrabHandle(GLTexture::List *texture,
- CompSize size,
+ unsigned int width,
+ unsigned int height,
const boost::shared_ptr <GrabHandleGroup> &owner,
- unsigned int id,
- Damager *damager) :
+ unsigned int id) :
mOwner(owner),
mTexture (texture),
mId(id),
- mRect (0, 0, size.width(), size.height()),
- mDamager (damager),
+ mRect (0, 0, width, height),
mImpl (NULL)
{
}
Unity::MT::GrabHandle::Ptr
-Unity::MT::GrabHandle::create (GLTexture::List *texture, CompSize size,
+Unity::MT::GrabHandle::create (GLTexture::List *texture, unsigned int width, unsigned int height,
const boost::shared_ptr <GrabHandleGroup> &owner,
- unsigned int id, Damager *damager)
+ unsigned int id)
{
- Unity::MT::GrabHandle::Ptr p (new Unity::MT::GrabHandle (texture, size, owner, id, damager));
+ Unity::MT::GrabHandle::Ptr p (new Unity::MT::GrabHandle (texture, width, height, owner, id));
p->mImpl = Unity::MT::GrabHandle::ImplFactory::Default ()->create (p);
return p;
@@ -339,7 +338,7 @@ Unity::MT::GrabHandleGroup::needsAnimate()
}
void
-Unity::MT::GrabHandleGroup::relayout(const CompRect& rect, bool hard)
+Unity::MT::GrabHandleGroup::relayout(const nux::Geometry& rect, bool hard)
{
/* Each grab handle at each vertex, eg:
*
@@ -364,10 +363,10 @@ Unity::MT::GrabHandleGroup::relayout(const CompRect& rect, bool hard)
for (unsigned int i = 0; i < NUM_HANDLES; i++)
{
Unity::MT::GrabHandle::Ptr & handle = mHandles.at(i);
- CompPoint p(rect.x() + rect.width() * pos[i][0] -
- handle->width() / 2,
- rect.y() + rect.height() * pos[i][1] -
- handle->height() / 2);
+ CompPoint p(rect.x + rect.width * pos[i][0] -
+ handle->width () / 2,
+ rect.y + rect.height * pos[i][1] -
+ handle->height () / 2);
handle->reposition (p.x (), p.y (), Unity::MT::PositionSet | (hard ? Unity::MT::PositionLock : 0));
}
@@ -418,8 +417,7 @@ UnityMTGrabHandlesWindow::requestMovement (int x,
}
Unity::MT::GrabHandleGroup::GrabHandleGroup(GrabHandleWindow *owner,
- std::vector <Unity::MT::TextureSize> &textures,
- Damager *damager) :
+ std::vector <Unity::MT::TextureSize> &textures) :
mState(State::NONE),
mOpacity(0.0f),
mMoreAnimate(false),
@@ -429,23 +427,25 @@ Unity::MT::GrabHandleGroup::GrabHandleGroup(GrabHandleWindow *owner,
Unity::MT::GrabHandleGroup::Ptr
Unity::MT::GrabHandleGroup::create (GrabHandleWindow *owner,
- std::vector<Unity::MT::TextureSize> &textures,
- Damager *damager)
+ std::vector<Unity::MT::TextureSize> &textures)
{
- Unity::MT::GrabHandleGroup::Ptr p = Unity::MT::GrabHandleGroup::Ptr (new Unity::MT::GrabHandleGroup (owner, textures, damager));
+ Unity::MT::GrabHandleGroup::Ptr p = Unity::MT::GrabHandleGroup::Ptr (new Unity::MT::GrabHandleGroup (owner, textures));
for (unsigned int i = 0; i < NUM_HANDLES; i++)
- p->mHandles.push_back(Unity::MT::GrabHandle::create (&textures.at(i).first,
- textures.at(i).second, p, (handlesMask.find (i))->second, damager));
+ p->mHandles.push_back(Unity::MT::GrabHandle::create (textures.at(i).first,
+ textures.at(i).second.width,
+ textures.at(i).second.height,
+ p,
+ handlesMask.find (i)->second));
return p;
}
Unity::MT::GrabHandleGroup::~GrabHandleGroup()
{
for (Unity::MT::GrabHandle::Ptr & handle : mHandles)
- handle->damage (CompRect (handle->x (),
- handle->y (),
- handle->width (),
- handle->height ()));
+ handle->damage (nux::Geometry (handle->x (),
+ handle->y (),
+ handle->width (),
+ handle->height ()));
}
void
@@ -748,10 +748,10 @@ UnityMTGrabHandlesScreen::donePaint()
{
handles->forEachHandle ([&](const Unity::MT::GrabHandle::Ptr &h)
{
- h->damage (CompRect (h->x (),
- h->y (),
- h->width (),
- h->height ()));
+ h->damage (nux::Geometry (h->x (),
+ h->y (),
+ h->width (),
+ h->height ()));
});
}
}
@@ -834,7 +834,7 @@ UnityMTGrabHandlesWindow::glDraw(const GLMatrix& transform,
{
/* We want to set the geometry of the handle to the window
* region */
- CompRegion reg = CompRegion(*layout.second);
+ CompRegion reg = CompRegion(layout.second.x, layout.second.y, layout.second.width, layout.second.height);
for(GLTexture * tex : *layout.first)
{
@@ -890,7 +890,7 @@ void
UnityMTGrabHandlesWindow::relayout(const CompRect& r, bool hard)
{
if (mHandles)
- mHandles->relayout(r, hard);
+ mHandles->relayout(nux::Geometry (r.x (), r.y (), r.width (), r.height ()), hard);
}
void
@@ -903,7 +903,8 @@ void
UnityMTGrabHandlesWindow::moveNotify(int dx, int dy, bool immediate)
{
if (mHandles)
- mHandles->relayout((const CompRect&) window->inputRect(), false);
+ mHandles->relayout(nux::Geometry (window->inputRect ().x (), window->inputRect ().y (),
+ window->inputRect ().width (), window->inputRect ().height ()), false);
window->moveNotify(dx, dy, immediate);
}
@@ -974,7 +975,7 @@ UnityMTGrabHandlesWindow::showHandles(bool use_timer)
if (!mHandles)
{
- mHandles = Unity::MT::GrabHandleGroup::create (this, us->textures (), us);
+ mHandles = Unity::MT::GrabHandleGroup::create (this, us->textures ());
us->addHandles(mHandles);
}
@@ -983,7 +984,10 @@ UnityMTGrabHandlesWindow::showHandles(bool use_timer)
unsigned int showingMask = Unity::MT::getLayoutForMask (window->state (), window->actions ());
activate();
mHandles->show(showingMask);
- mHandles->relayout(window->inputRect(), true);
+ mHandles->relayout(nux::Geometry (window->inputRect().x (),
+ window->inputRect().y (),
+ window->inputRect().width(),
+ window->inputRect().height()), true);
window->updateWindowOutputExtents();
cWindow->damageOutputExtents();
@@ -1132,11 +1136,15 @@ UnityMTGrabHandlesScreen::UnityMTGrabHandlesScreen(CompScreen* s) :
{
CompString fname = "handle-";
CompString pname("unitymtgrabhandles");
+ CompSize size;
fname = compPrintf("%s%i.png", fname.c_str(), i);
mHandleTextures.at(i).first =
- GLTexture::readImageToTexture(fname, pname,
- mHandleTextures.at(i).second);
+ new GLTexture::List (GLTexture::readImageToTexture(fname, pname,
+ size));
+
+ mHandleTextures.at (i).second.width = size.width ();
+ mHandleTextures.at (i).second.height = size.height ();
}
optionSetToggleHandlesKeyInitiate(boost::bind(&UnityMTGrabHandlesScreen::toggleHandles, this, _1, _2, _3));
@@ -1147,7 +1155,9 @@ UnityMTGrabHandlesScreen::UnityMTGrabHandlesScreen(CompScreen* s) :
UnityMTGrabHandlesScreen::~UnityMTGrabHandlesScreen()
{
mGrabHandles.clear ();
- mHandleTextures.clear();
+ for (auto it : mHandleTextures)
+ if (it.first)
+ delete it.first;
}
UnityMTGrabHandlesWindow::UnityMTGrabHandlesWindow(CompWindow* w) :
diff --git a/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h b/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h
index d77cce970..795039c9f 100644
--- a/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h
+++ b/plugins/unity-mt-grab-handles/src/unity-mt-grab-handles.h
@@ -16,7 +16,7 @@
* Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
*/
-
+#include <Nux/Nux.h>
#include <glib.h>
#include <core/core.h>
#include <composite/composite.h>
@@ -34,28 +34,17 @@ namespace Unity
{
namespace MT
{
-typedef std::pair <GLTexture::List, CompSize> TextureSize;
-typedef std::pair <GLTexture::List*, CompRect*> TextureLayout;
-
-class Damager
-{
-public:
-
- virtual void damage (const CompRegion &) = 0;
-};
+typedef std::pair <GLTexture::List*, nux::Geometry> TextureSize;
+typedef std::pair <GLTexture::List*, nux::Geometry> TextureLayout;
class DummyDamager
{
public:
- void damage (const CompRegion &reg)
+ void damage (const nux::Geometry &g)
{
- std::cout << "Damage rects: " << std::endl;
- for (const CompRect &r : reg.rects ())
- std::cout << "Rect: " << r.x () << " "
- << r.y () << " "
- << r.width () << " "
- << r.height () << std::endl;
+ std::cout << "Damage rects: " << std::endl;
+ std::cout << "x: " << g.x << " y: " << g.y << " width: " << g.width << " height: " << g.height << std::endl;
}
};
@@ -113,10 +102,10 @@ public:
typedef boost::shared_ptr <GrabHandle> Ptr;
static GrabHandle::Ptr create (GLTexture::List *texture,
- CompSize size,
+ unsigned int width,
+ unsigned int height,
const boost::shared_ptr <GrabHandleGroup> &owner,
- unsigned int id,
- Damager *damager);
+ unsigned int id);
~GrabHandle();
bool operator== (const GrabHandle &other) const
@@ -149,12 +138,12 @@ public:
TextureLayout layout();
unsigned int id () const { return mId; }
- unsigned int width () const { return mRect.width (); }
- unsigned int height () const { return mRect.height (); }
- int x () const { return mRect.x (); }
- int y () const { return mRect.y (); }
+ unsigned int width () const { return mRect.width; }
+ unsigned int height () const { return mRect.height; }
+ int x () const { return mRect.x; }
+ int y () const { return mRect.y; }
- void damage (const CompRegion &r) const { mDamager->damage (r); }
+ void damage (const nux::Geometry &g) const { mImpl->damage (g); }
public:
@@ -175,6 +164,8 @@ public:
virtual void lockPosition (int x,
int y,
unsigned int flags) = 0;
+
+ virtual void damage (const nux::Geometry &g) = 0;
};
class ImplFactory
@@ -201,17 +192,15 @@ public:
private:
GrabHandle(GLTexture::List *texture,
- CompSize size,
+ unsigned int width,
+ unsigned int height,
const boost::shared_ptr <GrabHandleGroup> &owner,
- unsigned int id,
- Damager *damager);
+ unsigned int id);
boost::weak_ptr <GrabHandleGroup> mOwner;
GLTexture::List *mTexture;
- CompSize mTexSize;
unsigned int mId;
- CompRect mRect;
- Damager *mDamager;
+ nux::Geometry mRect;
Impl *mImpl;
};
@@ -249,6 +238,12 @@ public:
int y,
unsigned int flags);
+ void damage (const nux::Geometry &g)
+ {
+ CompRegion r (g.x, g.y, g.width, g.height);
+ CompositeScreen::get (screen)->damageRegion (r);
+ }
+
private:
boost::weak_ptr <Unity::MT::GrabHandle> mGrabHandle;
@@ -277,11 +272,10 @@ public:
typedef boost::shared_ptr <GrabHandleGroup> Ptr;
static GrabHandleGroup::Ptr create (GrabHandleWindow *owner,
- std::vector<TextureSize> &textures,
- Damager *damager);
+ std::vector<TextureSize> &textures);
~GrabHandleGroup();
- void relayout(const CompRect&, bool);
+ void relayout(const nux::Geometry&, bool);
void restack();
bool visible();
@@ -305,8 +299,7 @@ public:
private:
GrabHandleGroup(GrabHandleWindow *owner,
- std::vector<TextureSize> &textures,
- Damager *damager);
+ std::vector<TextureSize> &textures);
enum class State
{
@@ -330,7 +323,6 @@ class UnityMTGrabHandlesScreen :
public ScreenInterface,
public CompositeScreenInterface,
public GLScreenInterface,
- public Unity::MT::Damager,
public UnitymtgrabhandlesOptions
{
public:
@@ -374,13 +366,6 @@ public:
return mHandleTextures;
}
-protected:
-
- void damage (const CompRegion &r)
- {
- CompositeScreen::get (screen)->damageRegion (r);
- }
-
private:
std::list <Unity::MT::GrabHandleGroup::Ptr> mGrabHandles;